Code Monkey home page Code Monkey logo

css-variable's Introduction

css-variable

npm e2e test npm bundle size npm type definitions NPM

Tiny ( ~0.3 kb ) treeshakable library to define CSS custom properties (variables) in JS.
Compatible with 👩‍🎤 Emotion / 💅 StyledComponents / Linaria and similar CSS-in-JS solutions.

Install

npm i css-variable

Docs

http://css-variable.js.org

License

Licensed under MIT
Crafted with <3 @jantimon

Special thanks to @4alpine for donating the package name.

css-variable's People

Contributors

jantimon avatar martindisch avatar jaggli avatar mad-kat avatar christinaheidt avatar jigsawye avatar karlhorky avatar tyderion avatar

Stargazers

Manuel Reich avatar Vitaly Chernov avatar Olivier Tassinari avatar Islam avatar Huy Giang avatar Roman Zhernosek avatar Jan R. Biasi avatar  avatar Eko tristiyadi avatar Makoto Tateno avatar Usman Yunusov avatar  avatar Julian Bravard avatar Eduardo Sigrist Ciciliato avatar Marco Aurélio avatar  avatar Junho Yeo avatar Hector Romo avatar Erik avatar Austin avatar Kai Hao avatar Schalk Burger avatar ✅ Daniel Danielecki avatar Danny Fritz avatar Inchill avatar Andris Sīlis avatar Andrei Luca avatar Tenvi avatar ryanwang avatar Diego Enjamio avatar Marco Roth avatar 余凡 avatar Zhongxiang Wang avatar  avatar  avatar vlad avatar 五柳 avatar Rustam Giliaziev avatar  avatar Ryan Murphy avatar Vinson Chuong avatar Andrew Chou avatar Thomas Marrec avatar ziofat avatar asidpulse avatar mrisho avatar Saul Palomino Ramos avatar Daniel Almaguer avatar Sandalots avatar HsunPei Wang avatar  avatar  avatar Matt Hamlin avatar jiahao li avatar Alexander Plavinski avatar Jimmy / Erozak avatar  avatar Papi Peppers avatar Duc-Thien Bui avatar Wendao avatar André Neves avatar Alucard avatar Naveen MC avatar Santhosh Veer avatar C. T. Lin avatar Matteu avatar dai avatar  avatar Matt avatar Siddharth Kshetrapal avatar Marcos Moreira avatar Patrick Smith avatar Mike Darche avatar Marc Agbanchenou avatar Daniel Jorge avatar Akinn Rosa avatar ptruser avatar  avatar George avatar Konstantin Krivlenia avatar Schmidt avatar Simon Mollweide avatar Michael Dougall avatar Joel Willi avatar Erdem avatar Haegul Pyun avatar  avatar Silvio Boesch avatar Remo Vetere avatar

Watchers

 avatar James Cloos avatar  avatar  avatar  avatar martin avatar  avatar

css-variable's Issues

Please add better docs and examples

As a css-in-js newbie, i have really no idea how to use this lib when i read only the website.

After study the code and the examples it got clearer. But big waste of time, if everybody has to do that.

You should add a sentence for which benefit this lib is absolute needed and superior to other solutions.
E.g. why should i use this and not the things inlcuded in styled-components like theming?
smaller virtual DOM updates for a newbie like me, how, what perfomance gain could i expect?

Example from Webpage:
What are tokens?
Why i need and define tokens?
Confusing example "Create themeable CSS Snipptes": What is gradientStartColor variable? is it mistyped startColor?

Describe the api:
Which parameters has createVar?
How to access them? with .val, with .toStyle(...)?
createGlobalTheme with scope without scope "", difference?

Unify Babel & SWC

After the latest commits to this project I'm really hooked to improve it further.

One aspect that I noticed that bugs me is that when you switch from Babel to SWC or vice versa, there will be changes for the names of the variables (with and without displayNames).

I have a branch that changes the tests so that the interoperability is checked and I started with changing the babel plugin logic (to be the same as in SWC), because I think the visual names in SWC are much better.

I wanted to ask if this direction is generally a good idea or do you see issues?

createVars

declaring multiple vars at once is quite repetitive right now e.g.:

const a = createVar()
const b = createVar()
const c = createVar()

maybe we could create a new helper createVars which would allow to use the spread operator to declare multiple vars at the same time:

export function* createVars<TValue = string> () { while(1) { yield createVar<TValue>() }}
const [a,b,c] = createVars();

Linaria - TypeScript problem

Hey there,

Using Linaria and the code below:

import { css } from '@linaria/core';
import { createVar } from 'css-variable';

const myColor = createVar({ value: 'rebeccapurple' });

export const foo = css`
	background-color: ${myColor};
`;

I get the following error message:

Argument of type 'CSSVariable' is not assignable to parameter of type 'string | number | CSSProperties | StyledMeta'.
Type 'CSSVariable' is not assignable to type 'CSSProperties'.
Index signature for type 'string' is missing in type 'CSSVariable'.

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.