Giter VIP home page Giter VIP logo

zaftig's Issues

automatic prefixing for pseudo selectors (and values)

For example ::placeholder is not supported in Edge and causes a syntax error (flems).

Would be nice if we handled this automatically, and replaced with prefixed versions automatically like we do with css properties.

This might be the time to look into prefixing special css values as well.

name change?

The name zaftig was chosen initially because it was fairly unique, and justified the use of z but it's not particularly meaningful to what it does, and a bit hard to type (based on some reports).

Currently considering:

  • zafty

"theming" implementation

First of all, what I mean by "theming" is:

  1. being able to define variables which influence the style
  2. allow components to be notified (for e.g. re-rendering) when those variables change
  3. when the active theme's variable change, this effect is propagated automatically to all the interested parties

So going by that concept, by reading the README, I've understood this library does not offer a theming solution.

I've tried to implement it in React

Interesting files

constants.ts

defines the variables for the theme [1st item].

theme.ts

useThemeVariable subscribes to themeChangedCallbacks [2nd item]; due to the fact that it's a hook leveraging useState, the 3rd item is also satisfied.

Button.tsx

Due to useThemeVariable, this components re-renders everytime the theme changes.

What motivated me to do this, initially, was wondering how I'd use Sass' helper functions (darken, lighten, saturate, etc) outside of SCSS files, since that's not directly available with CSS-in-JS. I later found there's the color package for that, so you'd just need to post-process the variable's value after every theme change.


If you feel interested in bringing similar ideas into the library somehow, let me know! And thank you for this project.

Select where the style sheet goes

Useful for shadow dom or iframes.

Off topic: is generation of inline styles just for file size or are there other performance benefits?

improve documentation

Would be nice to have a section detailing the different coding styles possible with zaftig.

  • classic: most styles go inline inside view, directly on the element the style is for
  • defining single top level class outside of component and assigning to root element, use nested styles / classes to define styles beyond that
  • etc

handle `@import`

Currently zaftig doesn't support @import statements, would it make sense to do so? They only work if they're declared as the first rules in the stylesheet.

So would they only work in z.global? I feel like it probably doesn't make sense to implement, since links work fine, and there's less uncertainty about how they can be included..
Including an external stylesheet kind of goes against CSS in JS anyway...

https://developer.mozilla.org/en-US/docs/Web/CSS/@import

remove parser options setting

Not particularly useful, hurts compatibility with helper libraries, and adds a bit of bloat to the code base (pretty minimal though).

better error handling

Currently (particularly in prod mode) if one rule has a css syntax error in it the whole style will fail to generate and nothing will be applied, also the syntax error in unclear, because we spit out the whole style string instead of just the rule that failed.

Would be nice to add a try catch to insertRule to log which specific rules failed, and prevent the whole style from failing just because of that one rule.

helpers vs. inlinining the CSS directly into the templated string?

when I was using this library for the first time, I thought the z.helper API was neat

however, can't the same be done by interpolating expressions directly into the string?

e.g., instead of

z.helper({
  bo: 'border'
})

z`
  bo 4 solid red
`

do

z`
  ${bo(4, 'solid', 'red')}
`

collateral benefit: also results in straightforward type-checking if you're using e.g. TypeScript

this could also be z.style in the "post-processing" phase for effects which depend on updated values (after a hook has triggered an update, for instance)


Is there some advantage I'm failing to see in there? My current impression is that those custom functions are more flexible and also would help in reducing the API.

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.