Coder Social home page Coder Social logo

Comments (3)

lukasoppermann avatar lukasoppermann commented on September 21, 2024

Hey @rganko happy to accept a PR to deal with spaces. But I think it should be already working the way it does now, or do you experience a bug?

For the modes, the way you suggest is pretty uncommon. What we currently do is also not great. The best option would be to export one file per mode, but I am not sure if this is technically possible.

Mode should not be in the token name at all, as this breaks a lot of the magic of tokens, but for this we need multiple files e.g. dark.json and light.json with the same token (but different values) inside, e.g. tokens.bg (no mode reference.)

from design-tokens.

katywatkins avatar katywatkins commented on September 21, 2024

I'd love to better understand why one particular mode is included in the referenced name rather that removing it entirely. For a user with multiple modes for component tokens, won't there only ever be one mode with correct references? While the rest would always be wrong?

I'm running into something very similar to the problem mentioned above, except my primitive and component token collections both have a matching set of modes and there's still only one mode ever included in the referenced primitive names. I was also was hoping for the proposed output @rganko provided, but removing the mode from the name entirely seems like it would be almost equally helpful. Is the current functionality, where 'mode 2' (whichever Figma mode is listed last) is included in referenced token names regardless of their mode, the intended functionality for the foreseeable future? (Assuming there aren't significant changes made in how Figma does things.)

I'm fine writing some extra code to work around some of this, I was assuming I'd have to be using the JSON structure to make some of this work (top level as collections, second level as modes) - but also having to strip out one particular mode name from all referenced primitives feels awfully bad to me. I'm trying to figure out if my structure is fundamentally incompatible with this plugin and standard use cases, or if we're just in a temporary weird spot because variables are relatively new and things are likely to keep changing.

from design-tokens.

rganko avatar rganko commented on September 21, 2024

To be clear we are on the same page here let's compere JSON structure we've got.
Based on today's results from figma using Design Tokens plugin.

Note: For single mode every thing works great (thank you for your work).

In case of having another mode (light, dark), json structure seams to consider only last one from all of the modes that are available. See json below - token's path only considers dark mode.
Screenshot 2023-11-18 at 21 31 38

  "primitives": {
    "light": {
      "white-01": {
        "type": "color",
        "value": "#ffffffff",
        "blendMode": "normal"
      }
    },
    "dark": {
      "white-01": {
        "type": "color",
        "value": "#000000ff",
        "blendMode": "normal"
      }
    }
  },
  "tokens": {
    "header-bg": {
      "type": "color",
      "value": "{primitives.dark.white-01}"
    }
  }
}

It might look broken since there is no easy way to get primitives.light.white-01. The fact that only last one of used aliases are considered seems to be not that obvious.

And now the questions:

  1. Based on given results, can you please confirm if the result is correct (mainly primitives.dark.white-01) ?
  2. Is this plugin supposed to work only for single modes?
  3. @lukasoppermann you've mentioned creating two files for each mode separately. Is there (or will be) a possibility to choose which mode should be used while exporting?

from design-tokens.

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.