Skip to content

Theemo / @theemo/style-dictionary / makeConstrainedFilter

Function: makeConstrainedFilter()

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

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

boolean

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'
        }
      })
    }
  }
}

Defined in

filters/make-constrained-filter.ts:32