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

super-jss

v1.0.47

Published

A powerful library for responsive CSS styles in Angular applications.

Downloads

253

Readme

Super JSS Library

Super JSS is a dynamic CSS library designed for Angular applications, making styling with JavaScript objects a breeze. It's all about giving developers the power to create responsive designs effortlessly. With Super JSS, you're not just writing styles; you're crafting a responsive experience with the simplicity of JavaScript. It's fast, it's light, and it's built to supercharge your Angular apps with a flair of elegance and ease.

🌟 Features

  • Dynamic Styling: Craft styles using JavaScript objects.
  • shorthand styles: Simplify your styles and values with shorthand properties.
  • Responsive Design: Adapt styles for various device breakpoints.
  • Theming: Switch between different themes seamlessly.
  • Typography: Enhanced support for HTML tags from H1 to H6, P, and span.

🚀 Getting Started

Prerequisites

  • An existing Angular project.
  • Node.js and npm.

Installation

npm i super-jss

Integration

Import the SjDirective in your standalone component and apply the [sj] directive to the element you want to style. The directive accepts a single object or an array of objects. The object keys are the CSS properties, and the values are the responsive CSS values. The directive will automatically apply the styles to the element.

Basic usage

It uses all keys from CSS Properties and CSS Values from MDN. This elements used as a js object empower the programmer to add dynamic values easily

import {SjDirective} from "super-jss";
@Component({
  standalone: true,
  selector: 'app-demo',
  template: `
     <div [sj]="{backgroundColor: '#aa5645', padding: '10px'}">
        Welcome to Super JSS!
      </div>    
  `
})
export class DemoComponent {}

Responsive handling

The responsive values are defined within a css property using the following format: {xs: 'value', sm: 'value', md: 'value', lg: 'value', xl: 'value'}.

import {SjDirective} from "super-jss";
@Component({
  standalone: true,
  selector: 'app-demo',
  template: `
    <div [sj]="{backgroundColor: '#aa5645', padding: {xs: '4px', sm: '6px', md: '8px', lg: '12px', xl:'18px', xxl: '24px'}">
        Welcome to Super JSS!
      </div>  
  `
})
export class DemoComponent {}

Shorthand properties

properties for css key elements or values are intuitive and very handy for fast development. when using values, they are converted by 10px. This unit may be changed if desired

import {SjDirective} from "super-jss";
@Component({
  standalone: true,
  selector: 'app-demo',
  template: `
    <div [sj]="{d: 'flex', fxDir: {xs: 'row', md: 'column'}} fxJustify: 'center'}">
      <div [sj]="{bg: '#aa5645', px:{xs: 2, md: 4}, py: {xs: 1, md: 3}}">
        Welcome to Super JSS!
      </div>
    </div>    
  `
})
export class DemoComponent {}

Using palette

The palette is a set of colors that can be used in the application. each color is defined by 4 shades. Example: primary.main, primary.light, primary.dark, primary.contrast.

The options in the palette are primary, secondary, tertiary, success, info, warning, error, dark, neutral, light

import {SjDirective} from "super-jss";
@Component({
  standalone: true,
  selector: 'app-demo',
  template: `
    <div [sj]="{ bg: 'primary', p: 2}">
      <div [sj]="{bg: 'secondary', px:{xs: 2, md: 4}, py: {xs: 1, md: 3}}">
        <h1 [sj]="{c: 'secondary.light'}">Welcome to Super JSS!</h1>
      </div>
    </div>    
  `
})
export class DemoComponent {}

typography

The typography is defined by the following keys: h1, h2, h3, h4, h5, h6, p, span. Each key applies the corresponding style to the element. The styles are defined in the theme.

import {SjDirective} from "super-jss";
@Component({
  standalone: true,
  selector: 'app-demo',
  template: `
    <h1 [sj]>Welcome to Super JSS!</h1>
  `
})
export class DemoComponent {}

Using SjStyle as array

This may give a lot of power to the programmer to create dynamic styles. The array of styles is merged in order, so the last style will override the previous ones.

import {SjDirective} from "super-jss";
@Component({
  standalone: true,
  selector: 'app-demo',
  template: `
    <div [sj]="[sjDemoClass, sjDemoBorder]">
      Welcome to Super JSS!
    </div>
  `
})
export class DemoComponent {
  sjDemoClass = {
    d: 'flex',
    fxDir: 'column',
    fxAItems: 'center',
    fxJustify: 'center',
    p: {xs: '4px', md: '8px'},
    bg: '#aa5645'
  };

  sjDemoBorder = {
    border: {xs: '1px solid black', md: '2px solid black'}
  };
}

Update a theme item, such as palette, typography or breakpoints.

import {SjDirective} from "super-jss";
@Component({
  standalone: true,
  selector: 'app-demo',
  template: `
    <div (click)="updateTheme()" [sj]="{bg: 'primary', p: 2}">
      <div  [sj]="{bg: 'secondary', px:{xs: 2, md: 4}, py: {xs: 1, md: 3}}">
        <h1 [sj]="{c: 'secondary.light'}">Welcome to Super JSS!</h1>
      </div>
    </div>    
  `
})
export class HeaderComponent {

  constructor(private th:SjThemeService) {
  }

  updateTheme() {
      this.th.setPalette({
        primary: {
          main: '#aa5645',
          light: '#aaa6a5',
          dark: '#aa0605',
          contrast: '#ffffff',
        },
        secondary: {
          main: this.th.colors().yellow[500],
          light: this.th.colors().yellow[200],
          dark: this.th.colors().yellow[700],
          contrast: this.th.colors().purple[700],
        }
      });
      
      this.th.setBreakpoints({
        sm: 630,
        md: 900,
      });
      
      this.th.setTypography({
        default: { fontFamily: 'Courier New'},
        H1: { fontSize: '2rem', fontWeight: 'bold'},
      });
  }
}

📖 Documentation

Dive deep into Super JSS's capabilities:

(below is the original documentation, it will be updated soon)

🎨 Demos

📖 Articles

💖 Support

If you find Super JSS useful, consider supporting its development:

📬 Contact

For inquiries, feedback, or issues, reach out at [email protected].