Giter VIP home page Giter VIP logo

Comments (6)

robinweser avatar robinweser commented on June 19, 2024 1

Hey @chrisrzhou,

Thanks for the bug report!
This is indeed a valid bug, since renderStatic (as long as used with objects) should process style with plugins.
Nested styles are another issue and will be handled in a separate PR, see #863


Firstly, thank you so much for this wonderful + delightful + beautiful library ❤️. I'm amazed at how much Fela can do with so little, and I am very close to wiring up something exciting that is only made possible with Fela!

That sounds amazing! Mind sharing what you're up to? Maybe I can help out or answer some questions :)
Feel free to contact me via Twitter (@robinweser) or E-Mail ([email protected]) and I can share my phone number to connect over a proper messenger.

from fela.

robinweser avatar robinweser commented on June 19, 2024 1

@chrisrzhou This took quite some time, but I finally managed to look into it: #894

Would this solve your issues? We need to manually pass these props when using renderStatic as the renderer is not aware of any props or theme. The staticStyle from useFela solves that since it has access to all context.

from fela.

chrisrzhou avatar chrisrzhou commented on June 19, 2024

On searching issues, I think this maybe related: #465

If the goal of renderStatic is to basically apply simple static styles (objects or template strings) without rule processing, then I think the current behavior is probably as-expected, and this would be more of a feature request.

If this feature is supported, the most immediate use case specific to fela-plugin-theme-value plugin is you can now define static/global styles with theme variables without having to manually maintain it. The general use case is that renderStatic will formally use the Fela rule "langage" and APIs, which leads to a better developer experience when using the renderStatic method.

Thanks and would love to hear if this is a bug vs feature!

from fela.

chrisrzhou avatar chrisrzhou commented on June 19, 2024

Quick update, I have an (almost complete) workaround for my problem:

const renderStatic = (renderer, style, selector, props) => {
  const staticStyle = renderer.plugins.reduce((_acc, plugin) => {
    return plugin(style, null, null, props);
  }, style);
  renderer.renderStatic(staticStyle, selector);
};

const renderer = createFelaRenderer({ enhancers, plugins });
const props = { theme }; // add any additional props that plugins depend on.
renderStatic(renderer, style, element, props);

EDIT: While the above applies most plugins and resolved my issue with fela-plugin-theme-value, I'm hitting a wall with nested/pseudo/media-queries which I can't get to work (I suspect this is an internal implementation on how Fela resolves nested pseudo/media-queries) e.g.

const ulStyleObject = {
  // primitive
  color: 'red', // works
  marginLeft: 40,  // works
  // theme-value, responsive-value
  padding: 'l', // NOW WORKS!
  backgroundColor: ['palette.red1', 'yellow'], // responsive still doesn't work
  // nested
  '> li': {
    paddingLeft: 100,  // nesting doesn't work
   ':hover': {
      color: 'pink', // nesting/pseudo doesn't work
    }
  },
}

Feel free to close the issue if this is something that fela is unlikely to support in the near future, but do let me know if renderStatic will be fully plugin-aware in the future!

from fela.

chrisrzhou avatar chrisrzhou commented on June 19, 2024

Thanks for confirming it's a bug and I'll contact you soon in the next week or so after I've fleshed things out a bit more. tl;dr, it's proof that Fela is the minimal primitive for building UI/design systems with delightful DX (but you know that already :P).

from fela.

chrisrzhou avatar chrisrzhou commented on June 19, 2024

A quick question/request while piggybacking on this issue:

Are there plans for an API method that can capture transformation of styles modified by plugins? Currently renderer.renderRule only returns the evaluated class name.

This would be huge in the debugging DX, and I can also see this being valuable for consumers who want to use Fela purely as a rules-processing engine, grabbing the data of the evaluated styles for custom use.

from fela.

Related Issues (20)

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.