Skip to content

Theemo / @theemo/style-dictionary / makeConstrainedFilter

Function: makeConstrainedFilter()

ts
function makeConstrainedFilter(constraints): (token) => any

Creates a function to filter tokens on the given constraints.

Parameters

ParameterTypeDescription
constraintsPartial<FeatureConstraints & ScopeConstraint>the constraints

Returns

Function

a filter function

Parameters

ParameterType
tokenTransformedToken

Returns

any

Example

Use as filter property in style dictionary config.

js
const { makeConstrainedFilter } = require('@theemo/style-dictionary');

module.exports = {
  platforms: {
    '[your-platforn]': {
      filter: makeConstrainedFilter({
        features: {
          'color-scheme': 'dark'
        }
      })
    }
  }
}

Source

filters/make-constrained-filter.ts:32