Skip to content
This repository was archived by the owner on Feb 18, 2022. It is now read-only.
This repository was archived by the owner on Feb 18, 2022. It is now read-only.

Runtime support #32

Closed
Closed

Description

@ebryn

Have you thought at all about how we might be able to support custom properties being modified at runtime? That would get us closer to a higher fidelity transpilation/polyfill.

Activity

  1. MoOx commented on Apr 30, 2015

    @MoOx
    Contributor

    I think transpilation is not directly related to a polyfill.

    Doing a polyfill can be done by two ways:

    • use postcss on the front with this plugin and some specific added code to compute thing on runtime
    • make a lighter polyfill that still need to parse stylesheets.

    In all situations, this doesn't seems to be directly related to the code of this plugin.

  2. ebryn commented on May 1, 2015

    @ebryn
    Author

    I know it's not totally on topic, but I wanted to start a discussion about possible runtime support because I've personally heard it used as an argument for not using custom properties yet. It appears the Polymer team is exploring a runtime based solution themselves: https://github.com/Polymer/polymer/blob/0.8-preview/PRIMER.md#custom-css-properties

  3. MoOx commented on May 1, 2015

    @MoOx
    Contributor

    it used as an argument for not using custom properties yet

    We are using custom properties syntax only. That what people should understand.

    That said if they have a nice polyfill that would be cool.

  4. kevinSuttle commented on Aug 3, 2016

    @kevinSuttle

    Check out this thread @MoOx

    segmentio/myth#10 (comment)

  5. MoOx commented on Aug 3, 2016

    @MoOx
    Contributor

    So what? This plugin is a fork for rework-vars, so I am aware of the entire discussion around this. I am leaving this issue open for people looking for option, but as said before, we can't handle this in postcss.

  6. kevinSuttle commented on Aug 3, 2016

    @kevinSuttle

    Is it at least possible to read the var values inside of something like React?

  7. MoOx commented on Aug 3, 2016

    @MoOx
    Contributor

    For that you should do the opposite: use the "variables" option to define your variables via javascript (so easily accessible in any js context).

  8. kevinSuttle commented on Aug 3, 2016

    @kevinSuttle

    So, in that case do you need to import your webpack config to a JS context, or can you make a file with a default export that = the object that contains the values and just require() it in both the JS context and webpack config?

  9. MoOx commented on Aug 3, 2016

    @MoOx
    Contributor

    I think you just answered yourself with your last option ;)

  10. kevinSuttle commented on Aug 3, 2016

    @kevinSuttle

    Haha. Indeed.

    // Colors.js
    const colorConstants = {
      PrimaryThemeColor: '#3acfb6',
      SecondaryThemeColor: '#16a78f',
    }
    
    module.exports = colorConstants;
    // webpack.config.js
    // ...
    const colorConstants = require('./src/Themes/Colors');
    // ...
        customProperties({
              preserve: true,
              variables: colorConstants,
              appendVariables: true,
         }),
  11. kevinSuttle commented on Sep 16, 2016

    @kevinSuttle
  12. luwes commented on Jul 13, 2017

    @luwes

    I got a basic solution for this issue.
    https://github.com/luwes/postcss-custom-properties-map

    It's a PostCSS plugin to generate a JS lookup map with rules that have declarations with custom CSS props. The idea is to only include this map if native custom CSS props are not supported. Then we loop through those rules, find the matching ones in sheet.cssRules and change the props with the actual values. Looping through the sheets cssRules is probably the most expensive and could be optimized I think. Maybe by having a separate stylesheet for only custom css properties or putting the props at the top or bottom of your sheet and having a break rule...

  13. luwes commented on Aug 5, 2017

    @luwes
  14. MoOx commented on Aug 6, 2017

    @MoOx
    Contributor

    Some people like to play with fire.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions