npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@iyio/at-dot-css

v0.7.0

Published

A fast and lightweight css-in-js library. The at-dot-css is a superset of css with a few simple additions to make it a little easier to scope component styles, work with variables and define responsive breakpoints.

Downloads

562

Readme

at-dot-css

A fast and lightweight css-in-js library. The at-dot-css is a superset of css with a few simple additions to make it a little easier to scope component styles, work with variables and define responsive breakpoints.

The syntax is designed to be vary simple to implement, only requiring a simple find and replace algorithm which keeps parsing times to a minimum. There is no nesting, functions or mixins, just good old css with a couple of extra goodies 🤓

Usage

AtDot styles are defined using the atDotCss function. The atDotCss function returns a ParseAtDotStyle object with functions that correspond to each of the @. selectors defined in the style. After the first call to a selector function the style is parsed and a new style sheet is inserted into the head of the document or added to a custom style sheet renderer.

at-dot-css example (note - css-in-js syntax highlighting is provided by the high-js vscode extension)

The css in the example above is converted to the css below.

.Example{
    display:flex;
    flex-direction:row;
    align-items:center;
    padding:1rem;
    border-radius:12px;
    border:1px solid var(--Example-color);
    gap:1rem;
}

.Example-header{
    margin:0;
}

.Example-button{
    border:none;
    background-color:#ccc;
    padding:1rem;
    border-radius:12px;
}
.Example-button.active{
    background-color:var(--Example-color);
}

@media(max-width:768px){
    .Example{
        flex-direction:column;
        align-items:flex-start;
    }
}

Using with NextJs

When using at-dot-css in a NextJS project and rending server side or at build time styles are added to a style queue that is then rendered using the NextJsStyleSheets component from the @iyio/nextjs-common package. Using the NextJsStyleSheets component allows css generated by at-dot-css to be included in the css bundles generated by NextJs.

Installation

npm install @iyio/at-dot-css

Configuration

There is no configuration 🥹, no extra build steps, no messing with webpack. Just install the package and start using it 🥳

The Syntax

All the code examples below assume the name of the current style is "Example".

Root Selector

@.root - The root selector is replaced with the current style name.

/* at-dot */
@.root{
    padding:1rem;
}

/* converted css*/
.Example{
    padding:1rem;
}

Named Selector

@.{selector-name} - Named selectors are prefixed with the name of the current style.

/* at-dot */
@.title{
    margin:1rem 0;
}

/* converted css*/
.Example-title{
    margin:1rem 0;
}

Variables

@@{variable-name} - Variable names are prefixed with the current style name and wrapped in a var function call.

/* at-dot */
.some-name{
    color:@@color;
    width:calc( 100% - @@extraMargin )
}

/* converted css*/
.some-name{
    color:var(--Example-color);
    width:calc( 100% - var(--Example-extraMargin) )
}

(note - when using vars in calculations a space after the var name is required for typescript intellisense to function correctly)

Breakpoint Media Queries

@{break-point} - Breakpoint media queries allow you to quickly define media queries for standard breakpoints.

/* at-dot */
@tabletSmDown{
    .my-component{
        flex-direction:column;
    }
}
@tabletSmUp{
    .my-title{
        font-size:2rem;
    }
}

/* converted css*/
@media(max-width:768px){
    .my-component{
        flex-direction:column;
    }
}
@media(min-width:577px){
    .my-title{
        font-size:2rem;
    }
}

Breakpoints:

  • @mobileSmUp - Small mobile breakpoint and up - (all breakpoints)
  • @mobileUp - Mobile breakpoint and up
  • @tabletSmUp - Small tablet breakpoint and up
  • @tabletUp - Tablet breakpoint and up
  • @desktopSmUp - Small desktop breakpoint and up
  • @desktopUp - Desktop breakpoint and up
  • @mobileSmDown - Small mobile breakpoint and down
  • @mobileDown - Mobile breakpoint and down
  • @tabletSmDown - Small tablet breakpoint and down
  • @tabletDown - Tablet breakpoint and down
  • @desktopSmDown - Small desktop breakpoint and down
  • @desktopDown - Desktop breakpoint and down - (all breakpoints)

Syntax Highlighting

Syntax highlighting is provided using the high-js vscode extension

Type Safety

When using at-dot-css with TypeScript you get full type safety and intellisense.

intellisense