excss is a small, simple, zero-runtime CSS-in-JS library with just two APIs.

Related tags

Command-line excss
Overview

excss

excss is a small, simple, zero-runtime CSS-in-JS library with just two APIs.

; }; export function Component(props: Props) { const [rotate] = useState(0); const [isDisabled] = useState(false); return (
); }">
import { css, ex, FILE_ID } from "excss";
import type { Ex } from "excss";
import { useState } from "react";

const button = ex({
  color: {
    red: css`
      color: red;
    `,
    green: css`
      color: green;
    `,
    blue: css`
      color: blue;
    `,
  },
});

type Props = {
  buttonStyle: Ex<typeof button>;
};

export function Component(props: Props) {
  const [rotate] = useState(0);
  const [isDisabled] = useState(false);
  return (
    <div
      style={{ [`--${FILE_ID}-rotate`]: `${rotate}deg` }}
      className={ex.join(
        css`
          transform: rotate(var(--#{$FILE_ID}-rotate));
          $animation-spin: unique();
          animation: $animation_spin 0.5s;

          @keyframes #{$animation-spin} {
            from {
              transform: rotate(0);
            }
            to {
              transform: rotate(360deg);
            }
          }
        `,
        css`
          color: $primary;
          gap: $space_sm;
        `,
        !isDisabled &&
          css`
            @include mediaQuery(sm) {
              background-color: black;
            }

            @media screen and (max-width: $sm) {
              background-color: black;
            }

            &:hover {
              background-color: green;
            }
          `,
      )}
    >
      <button className={button(props.buttonStyle)}>Button</button>
    </div>
  );
}

Setups

Install excss.

npm i excss pnpm i excss yarn add excss

Setting up the compiler based on the bundler.

// next.config.mjs
import createExcss from "excss/next";

const withExcss = createExcss();

/** @type {import('next').NextConfig} */
const nextConfig = {};

export default withExcss(nextConfig);
// vite.config.ts
import Excss from "excss/vite";
import { defineConfig } from "vite";

export default defineConfig({
  plugins: [Excss()],
});
// webpack.config.mjs
import ExcssPlugin from "excss/webpack";
import MiniCssExtractPlugin from "mini-css-extract-plugin";

export default {
  // webpack options
  module: {
    rules: [
      {
        test: /\.css$/,
        use: [MiniCssExtractPlugin.loader, "css-loader"],
      },
    ],
  },
  plugins: [new ExcssPlugin(), new MiniCssExtractPlugin()],
};

excss.config.ts

// excss.config.ts
import { defineConfig, variants } from "excss/config";

export default defineConfig({
  include: /\.(ts|tsx)$/,
  helper: `
    ${variants({
      primary: "red",
    })}
  `,
});
Comments
  • feat: support for excss.config.ts

    feat: support for excss.config.ts

    In this PR, we are relocating the excess configuration settings from vite.config.ts and other similar files to a newly created excss.config.ts. This step is crucial as we gear up for the creation of a future VSCode extension, where the extension needs the ability to read the configuration seamlessly. Additionally, this modification will streamline the process of switching between bundlers whenever necessary, making it more efficient.

    vite.config.ts

    In the updated configuration, we have simplified the excss plugin initialization in vite.config.ts. Similar changes are also implemented in Next.js and webpack.

    import Excss from "excss/vite";
    import { defineConfig } from "vite";
    
    export default defineConfig({
      plugins: [
    +    Excss(),
    -    Excss({
    -      inject: ``,
    -    }),
      ],
    });
    

    excss.config.ts

    A new file excss.config.ts has been introduced to house the excess configuration settings, which includes the inject option.

    +import { defineConfig } from "excss/config";
    +
    +export default defineConfig({
    +  inject: ``,
    +});
    
    opened by taishinaritomi 1
  • feat: change export method for plugins from named export to default export

    feat: change export method for plugins from named export to default export

    ⚠️ BREAKING CHANGE !!

    Before

    import { Excss } from "excss/vite";
    import { ExcssPlugin } from "excss/webpack";
    import { createExcss } from "excss/next";
    

    After

    import Excss from "excss/vite";
    import ExcssPlugin from "excss/webpack";
    import createExcss from "excss/next";
    
    opened by taishinaritomi 1
  • feat: integrated variants field into inject field

    feat: integrated variants field into inject field

    ⚠️ BREAKING CHANGE !!

    Unified variants and inject fields for clearer positioning.

    Before

    // options
    {
      variants: {
        red: "#ff0000",
      },
      inject: `
        $breakpoints: (
          400: "screen and (max-width: 400px)",
          800: "screen and (max-width: 800px)",
          1000: "screen and (max-width: 1000px)",
        ) !default;
    
        @mixin mq($breakpoint) {
          @media #{map-get($breakpoints, $breakpoint)} {
              @content;
          }
        }
      `,
    }
    

    After

    import { variants } from "excss/config";
    
    // options
    {
      inject: `
        ${variants({
          red: "#ff0000",
        })}
        $breakpoints: (
          400: "screen and (max-width: 400px)",
          800: "screen and (max-width: 800px)",
          1000: "screen and (max-width: 1000px)",
        ) !default;
    
        @mixin mq($breakpoint) {
          @media #{map-get($breakpoints, $breakpoint)} {
              @content;
          }
        }
      `,
    }
    
    opened by taishinaritomi 1
  • chore(changesets): 🦋 publish packages

    chore(changesets): 🦋 publish packages

    This PR was opened by the Changesets release GitHub action. When you're ready to do a release, you can merge this and the packages will be published to npm automatically. If you're not ready to do a release yet, that's fine, whenever you add more changesets to main, this PR will be updated.

    Releases

    @excss/[email protected]

    Minor Changes

    • #48 c7b6aa6 Thanks @taishinaritomi! - refactor: rename inject to helper

      // excss.config.ts
      import { defineConfig } from "excss/config";
      
      export default defineConfig({
      -  inject: ``,
      +  helper: ``,
      });
      
    • #32 6955f23 Thanks @taishinaritomi! - feat: integrated variants field into inject field

      +import { variants } from "excss/config";
      
      {
      - variants: {
      -   red: "#ff0000",
      - },
        helper: `
      +   ${variants({
      +     red: "#ff0000",
      +   })}
          $breakpoints: (
            400: "screen and (max-width: 400px)",
            800: "screen and (max-width: 800px)",
            1000: "screen and (max-width: 1000px)",
          ) !default;
      
          @mixin mq($breakpoint) {
            @media #{map-get($breakpoints, $breakpoint)} {
                @content;
            }
          }
        `,
      }
      

    Patch Changes

    [email protected]

    Minor Changes

    • #48 c7b6aa6 Thanks @taishinaritomi! - refactor: rename inject to helper

      // excss.config.ts
      import { defineConfig } from "excss/config";
      
      export default defineConfig({
      -  inject: ``,
      +  helper: ``,
      });
      
    • #35 8953f56 Thanks @taishinaritomi! - feat: support for excss.config.ts

      vite.config.ts

      In the updated configuration, we have simplified the excss plugin initialization in vite.config.ts. Similar changes are also implemented in Next.js and webpack.

      import Excss from "excss/vite";
      import { defineConfig } from "vite";
      
      export default defineConfig({
        plugins: [
      +    Excss(),
      -    Excss({
      -      inject: ``,
      -    }),
        ],
      });
      

      excss.config.ts

      A new file excss.config.ts has been introduced to house the excess configuration settings, which includes the inject option.

      +import { defineConfig } from "excss/config";
      +
      +export default defineConfig({
      +  helper: ``,
      +});
      
    • #40 5e03c41 Thanks @taishinaritomi! - refactor: webpack plugin

    • #32 6955f23 Thanks @taishinaritomi! - feat: integrated variants field into inject field

      +import { variants } from "excss/config";
      
      {
      - variants: {
      -   red: "#ff0000",
      - },
        helper: `
      +   ${variants({
      +     red: "#ff0000",
      +   })}
          $breakpoints: (
            400: "screen and (max-width: 400px)",
            800: "screen and (max-width: 800px)",
            1000: "screen and (max-width: 1000px)",
          ) !default;
      
          @mixin mq($breakpoint) {
            @media #{map-get($breakpoints, $breakpoint)} {
                @content;
            }
          }
        `,
      }
      
    • #33 9d49dc8 Thanks @taishinaritomi! - feat: change export method for plugins from named export to default export

      -import { Excss } from "excss/vite";
      +import Excss from "excss/vite";
      
      -import { ExcssPlugin } from "excss/webpack";
      +import ExcssPlugin from "excss/webpack";
      
      -import { createExcss } from "excss/next";
      +import createExcss from "excss/next";
      

    Patch Changes

    opened by github-actions[bot] 1
  • feat: change in hash generation method for FILE_ID

    feat: change in hash generation method for FILE_ID

    Due to the build environment, the hash value was changing. To address this issue, I've changed it to use the relative_path instead of the absolute_path. Additionally, to ensure uniqueness, I've appended the packageName to the hash.

    Before

    FILE_ID = hash(absolute_path)

    After

    FILE_ID = hash(package_name + relative_path)

    opened by taishinaritomi 1
Owner
Taishi Naritomi
Taishi Naritomi
A minimal browser with a super simple rendering engine for HTML and CSS, using Rust.

minimal-browser A minimal browser with a super simple rendering engine for HTML and CSS, using Rust. Credit: https://github.com/mbrubeck and https://l

Federico Baldini 3 Jan 15, 2023
zman is a CLI year (time) progress that small, fast, and just one single binary.

zman zman is a CLI year (time) progress that small, fast, and just one single binary. Features Show year progress Show month, and week progress Show r

azzamsa 17 Dec 21, 2022
Tools - The Rome Toolchain. A linter, compiler, bundler, and more for JavaScript, TypeScript, HTML, Markdown, and CSS.

Rome is currently being rewritten in Rust. Read more about it in our latest blog post. The documentation below is out of date and available for poster

Rome 22k Jan 3, 2023
A Faster(⚡) formatter, linter, bundler, and more for JavaScript, TypeScript, JSON, HTML, Markdown, and CSS Lapce Plugin

Lapce Plugin for Rome Lapce-rome is a Lapce plugin for rome, The Rome is faster ⚡ , A formatter, linter, compiler, bundler, and more for JavaScript, T

xiaoxin 7 Dec 16, 2022
Configurable, smart and fast CSS/SCSS/Sass/Less formatter.

?? Malva Malva is a configurable, smart and fast CSS/SCSS/Sass/Less formatter. Why? Configurable Malva is configurable. It provides several configurat

Pig Fang 20 Oct 27, 2023
Crates.io library that provides high-level APIs for obtaining information on various entertainment media such as books, movies, comic books, anime, manga, and so on.

Crates.io library that provides high-level APIs for obtaining information on various entertainment media such as books, movies, comic books, anime, manga, and so on.

consumet-rs 5 Aug 13, 2023
Rust library for integrating local LLMs (with llama.cpp) and external LLM APIs.

Table of Contents About The Project Getting Started Roadmap Contributing License Contact A rust interface for the OpenAI API and Llama.cpp ./server AP

Shelby Jenkins 4 Dec 18, 2023
Shared k-mer content between two genomes

skc skc is a simple tool for finding shared k-mer content between two genomes. Installation Prebuilt binary curl -sSL skc.mbh.sh | sh # or with wget w

Michael Hall 16 Jun 26, 2023
A simple CLI I made while practicing rust to easily make QR codes with just one command, all in your terminal.

Welcome to rust-qrcode-cli ?? A CLI I made while practicing rust to easily make QR codes with just one command, all in your terminal. Install git clon

Dhravya Shah 2 Mar 2, 2022
A super simple prompt for Fish shell, just shows git info and Vi mode.

vifi is a portmandeau of 'Vi' and 'Fish', because it's a prompt for Fish shell, primarily focused around showing proper indicators when using Vi key bindings.

Mat Jones 1 Sep 15, 2022
🐎 Just a simple cross-platform neofetch for all the bronies out there.

⚠️ (WIP) This project is not ready for any serious use right now. A cross-platform command-line interface (CLI) tool written in Rust to display system

Jakub 4 Dec 15, 2022
Just a simple object renderer, written in under 500 lines using Rust.

All cargoes that the project runs are: bitflags: a crate for defining bitflag types cfg-if: a small macro crate for defining cfg-based - conditional c

null 3 May 4, 2023
Prototype for a CLI/Libary designed for interacting with NASA Open APIs with Rust.

Overview Voyager is a swiss army knife library for the NASA Open APIs. It is designed to bundle all the NASA APIs into a single package. Voyager can b

Ethan Gallucci 4 Aug 14, 2022
Fork of the Official Python3 API connector for Bybit's HTTP (bybit) and WebSockets APIs to rust

Fork of pybit python libary in Rust For the rust lovers and creators for bybit exchange version 5 Official Python3 API connector for Bybit's HTTP and

Omambia Dauglous 4 Aug 29, 2023
REC2 (Rusty External Command and Control) is client and server tool allowing auditor to execute command from VirusTotal and Mastodon APIs written in Rust. 🦀

Information: REC2 is an old personal project (early 2023) that I didn't continue development on. It's part of a list of projects that helped me to lea

Quentin Texier (g0h4n) 104 Oct 7, 2023
A safe and idiomatic wrapper over shared memory APIs in rust with proper cleanups.

shmem-bind A safe and idiomatic wrapper over shared memory APIs in rust with proper cleanups. Quick start: check the message-passing example for bette

ArshiA Akhavan 3 Apr 6, 2024
Rust library to convert RGB 24-bit colors into ANSI 256 (8-bit) color codes with zero dependencies and at compile-time.

rgb2ansi256 rgb2ansi256 is a small Rust library to convert RGB 24-bit colors into ANSI 256 (8-bit) color codes with zero dependencies and const fn. Th

Linda_pp 7 Nov 17, 2022
A lightweight, zero-dependency struct diffing library which allows changed fields to be collected and applied

structdiff A lightweight, zero-dependency struct diffing library which allows changed fields to be collected and applied. Derive Difference on a struc

null 7 Dec 25, 2022
Pure rust library for reading / writing DNG files providing access to the raw data in a zero-copy friendly way.

DNG-rs   A pure rust library for reading / writing DNG files providing access to the raw data in a zero-copy friendly way. Also containing code for re

apertus° - open source cinema 4 Dec 1, 2022