Royal-Navy / design-system

Build web applications that meet the Royal Navy service standards
https://storybook.design-system.navy.digital.mod.uk
Apache License 2.0
104 stars 32 forks source link

Export selector functions directly in @royalnavy/design-tokens #3797

Closed jpveooys closed 4 weeks ago

jpveooys commented 1 month ago

Description

Currently to use the selectors in the Design Tokens library you have to import selectors and destructure it:

import { selectors } from '@royalnavy/design-tokens'

const { color } = selectors

I don't know the background to why it was done in this way, but it'd be helpful in general for it to be a bit more ergonomic to use the tokens.

One change towards that would be to make it possible to import the selector functions directly:

import { color } from '@royalnavy/design-tokens'

(Having to destructure selectors is a bit tedious, and also stops IDEs from being able to suggest missing imports.)

m7kvqbe1 commented 1 month ago

Sounds good - I don't think that much thought went into it at the time from a DX perspective as they'd not yet been used.

We'll continue to expose the selectors object to preserve backwards compatibility.