question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is it possible to create a custom transform which contains a group of properties/values?

See original GitHub issue

A common need with a lot of projects is the ability to define groups of styles together and then applying them later on.

Take Google’s Polymer project for example.

--paper-font-display1: {
  @apply --paper-font-common-base;
  font-size: 34px;
  font-weight: 400;
  letter-spacing: -.01em;
  line-height: 40px;
}

This can then be applied to any class, or even a utility class which can be reused.

While using the concept of design tokens I’ve noticed that it would be very useful to store groups of styles like as design tokens (or design mixins if you wish).

In my mind, there would be several parts needed to make this work.

  1. A syntax which allows you to define groups of values/properties in Style Dictionary
  2. A transform/format that exports the group of values in a specific way
  3. A way of applying those group of styles in the relevant platform

My background is in web development so I know the last two steps would be relatively easy because there are a lot of pre-processors available. I’m not that familiar with iOS and Android.

What are your thoughts? I’m interested in anyone’s thoughts on what the pros and cons of this might be.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:18 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
dbanksdesigncommented, Apr 8, 2019

For your point 2, dictionary.properties should be have references resolved and tokens transformed at this point. You should probably be referencing {size.font.base.value} to get it resolved properly. The reason is the resolution is “dumb” in that it simply copies whatever it finds at that object path and resolutions happen after transforms take place.

For excluding the groups what you could do is create 2 style dictionaries in a node file:

const StyleDictionary = require('style-dictionary');

StyleDictionary.extend({
  source: ['properties/**/*.json', 'components/**/*.json'],
  // ...
}).buildAllPlatforms();

StyleDictionary.extend({
  source: ['properties/**/*.json']
  // ...
}).buildAllPlatforms();

Or you could define a filter to filter out the component group stuff and use it on the files you don’t want it.

1reaction
dbanksdesigncommented, Aug 30, 2019

Hey @limitlessloop wanted to see if you needed any more help with this issue or if we can close it. We also have a discussion issue #268 about token organization and how to handle it properly moving forward. Thanks!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Transformation Custom Properties - SQL Server Integration ...
Some properties of transformations can be set by using property ... The Aggregate transformation has both custom properties and the ...
Read more >
CSS Properties and Values API Level 1 - W3C
A custom property can become a registered custom property , making it act more like a UA-defined property: giving it a syntax that's...
Read more >
CSS Logical Properties and Values - MDN Web Docs
CSS Logical Properties and Values is a module of CSS introducing logical properties and values that provide the ability to control layout ...
Read more >
C#: How to convert a list of objects to a list of a single property ...
Can I get a single properties values from a List<object>? -1 · Converting an Object List to a String List · -2 ·...
Read more >
A Complete Guide to Custom Properties | CSS-Tricks
Custom properties can make code easier to maintain because you can ... Say we have a custom property set pretty “high up” (on...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found