Coder Social home page Coder Social logo

Advantages

  • There is no need to learn the syntax of preprocessors like less/sass/postcss, as you can achieve the same or even more functionality directly using JavaScript.
  • CSS encapsulation makes it easy to extend and override styles.
  • Better performance, as it transforms the CSS object at build time.
  • Boost your development with @collie-ui/css or tailwindcss(incoming).
  • Excellent DX with typescript type hints.
  • Supports server-side rendering with nextjs.
  • Supports CSS breakpoint array syntax.
  • Supports theme customization and CSS property customization, simplifying CSS development.
  • Low learning curve - in 99% of cases, you only need to use the styled function.
  • have a best integration with react, webpack, rollup, vite, nextjs.

Example

import { absYCenter } from "@collie-ui/css";
import { makeStyled } from "@colliejs/react";
import { collieConfig } from "../collie.config";
export const styled = makeStyled(collieConfig);

export const StyledButton = styled("button", {
  w: 100,
  h: 40,
  _hover: {
    opacity: 0.8,
    background: "$primary",
    borderRadius: 10,
    color: "white",
  },
  _after: {
    h: "100%",
    w: [10, 4],
    background: "red",
    ...absYCenter({ right: 0 }),//obj=eval('Function') => css(obj)=>cssText. cssObject/styledObject
  },

  variants: {
    size: {
      full: {
        w: "100%",
      },
      big: {
        w: 80,
      },
      md: {
        w: 40,
      },
      sm: {
        w: 20,
      },
      dynamic: x => ({
        //any size you want
        w: x,
      }),
    },
    shape: {
      round: {
        borderRadius: 9999,
      },
      rect: {
        borderRadius: 0,
      },
    },
    status: {
      disabled: {
        true: {
          cursor: "not-allowed",
          background: "$gray200",
        },
      },
    },
  },

  compoundVariants: { 
    type:{
      title:{
        size: "big",
        shape: ?"round":'',
        css: {
          background: "$gray200",
        },
      },

      subTitle:{
        size: "md",
        shape: "rect",
        css: {
          background: "$gray200",
        },
    }
  }

  [
    {
      size: "big",
      shape: "round",
      css: {
        background: "$gray200",
      },
    },
  ],
  defaultVariants: {
    shape: "rect",
  },
});

How to use

const App = (props)=> {
  return <Button shape="round" disabled={props.disabled} css={{background:'red'}}>Login<Button/>
}

Get started

completed demo

know more about examples,

  git clone https://github.com/colliejs/examples && cd examples && pnpm install && pnpm dev

How does it work

  • transform the styled object to css text at build time

Big thanks

  • stitches - a css-in-js library with multi-variant support

colliejs's Projects

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.