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

@lucas-labs/lui-micro

v3.1.4

Published

🎨 lui-micro › A lightweight scss library for building themed UIs 🤏

Downloads

7

Readme

📄 Documentation

📦 Install

Download with NPM/PNPM/YARN:

  • pnpm i @lucas-labs/lui-micro
  • npm i @lucas-labs/lui-micro
  • yarn add @lucas-labs/lui-micro

Then import it in your .scss file:

@use '~@lucas-labs/lui-micro' as lui;
@include lui.init();

⚙️ Options

The lui.init mixin can receive several params:

  • $theme: default theme configuration map
  • $breakpoints : media-breakpoints for breakpoint utilities.
  • $options: map with options for the library. It can have the following keys:
    • reboot: boolean. If true, the reboot will be applied. Default: true.
    • basic: boolean. If true, the basic styles will be applied. Default: true.
    • theme: boolean. If true, the theme will be applied. Default: true.
    • merge-theme-with-prebuilt: boolean. If true, the theme will be merged with the default theme. If you choose not to merge it, you will need to provide all the necesary variables. Default: true.
    • color-utilities: boolean. If true, color utilities will be created. Default: false.
    • typography-utilities: boolean. If true, typography utilities will be created. Default: false.
    • fg-var-name: string. Indicates the name of the variable that will be used in the theme config to set the foreground color. Default: text
    • bg-var-name: string. Indicates the name of the variable that will be used in the theme config to set the background color. Default: background

💡 All parameters are optional! (defaults will be used)

🎨 Theme / Customization

You can create any number of themes, but one of them needs to be the default theme. Normally, the default theame is created when calling lui.init.

Breakpoints

To set the breakpoints, you need to pass a map to the $breakpoints parameter in the lui.init mixin:

@use '~@lucas-labs/lui-micro' as lui;
@include lui.init(
    // this is also the default breakpoint map, 
    // so if you don't pass anything, this will be used
    $breakpoints: (
        xs: 0px,
        sm: 576px,
        md: 768px,
        lg: 992px,
        xl: 1200px,
    )
);

Setting default theme

You can set a default theme by passing a map object as a parameter to the lui.init mixin or by using the theme creation utility.

  • Using init mixin example:
@use '~@lucas-labs/lui-micro' as lui;
@include lui.init(
    $theme: (
        colors: (
            ...
        ),
        variables: (
            ...
        ),
        typography: (
            ...
        ),
    )
);

💡 You can see an example of a more complete theme config here.

  • Using theme-creation utility:
@use '~@lucas-labs/lui-micro' as lui;
@use '~@lucas-labs/lui-micro/theme' as theme;

@include lui.init();
@include theme.create-theme(
    $theme: (
        ...
        colors: (
            background: ...,
            text: ...,
            primary: ...,

            // nested maps are allowed (also allowed for variables)
            grouped: (
                a-nested-color: #fff,
                even-more-nested: (
                    ...
                ),
            )
            ...
        ),
        ...
    )
    $as-default: true // set as-default as true, so lui defaults to this theme
                      // this theme will be also used as a base for when you 
                      // create a new theme
);

Setting default theme

By using the create-theme utility you can also create themes as non-default themes. This means you'll be able to change between themes at runtime. This is possible because themes are made only of css variables.

@use '~@lucas-labs/lui-micro' as lui;
@use '~@lucas-labs/lui-micro/core' as core;

// setting a deault theme called "light"
@include lui.init(
    $theme: (
        name: "light",
        ...
    )
);

// creating another theme called "dark" that will not be default
@include core.create-theme(
    $theme: (
        name: "dark"
        ...
    )
    // don't pass $as-default here, or pass it as "false"
);

Now to change themes at runtime, you'll need to set an argument in your tag:

<html theme="dark"> 
...
</html>

To change it back to de default, either you set the theme attribute to its name, or remove the theme attribute from the html tag (it will default to the default theme):

<html theme="light"> 
...
</html>

Mixins

Vars and colors

The library includes some mixins that can be used to access the theme variables and colors

@use '@lucas-labs/lui-micro/color';
@use '@lucas-labs/lui-micro/var';

.my-div {
    background-color: color.get('primary'); // background-color: var(--c-primary);
    color: color.get('primary', 'rgb'); // color: var(--c-primary-rgb);

    // it works with nested colors too
    // provided you defined your nested theme-color as 
    // colors: (
    //     my: (
    //         nested: (
    //             color: #000,
    //         )    
    //     )
    // )
    border-color: color.get('my/nested/color'); // border-color: var(--c-my_nested_color);

    // get a theme variable
    border-radius: var.get('font-family'); // border-radius: var(--v-font-family);
    
    // as with colors, it works with nested variables too
    // provided you defined your nested variable as
    // variables: (
    //     my: (
    //         nested: (
    //             variable: 10px,
    //         )
    //     )
    // )
    border-radius: var.get('my/nested/variable'); // border-radius: var(--v-my_nested_variable);
}

Breakpoints

The library includes several mixins to help you create responsive layouts and styles.

@use '@lucas-labs/lui-micro/bp';

// @use '@lucas-labs/lui-micro/bp' with (
//     $breakpoints: ( sm: 576px, ... )
// );

.my-div {
    // create a breakpoint
    @include bp.up('sm') {
        // styles for sm and up
    }

    @include bp.down('sm') {
        // styles for sm and down
    }

    @include bp.only('sm') {
        // styles for sm only
    }

    @include bp.between('sm', 'md') {
        // styles for sm and md
    }

    @include bp.not('sm') {
        // styles for everything but sm
    }

}

Typographies

The library includes a mixin to get typography styles from the theme.

@use '@lucas-labs/lui-micro/typo';

.my-div {
    @include typo.typography('heading/h7');
}