feat(pie-token-map): CACT-4721 add pie-token-map package#2715
feat(pie-token-map): CACT-4721 add pie-token-map package#2715matthewhardern wants to merge 6 commits intomainfrom
Conversation
🦋 Changeset detectedLatest commit: 54b5093 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
5d7d5b3 to
e295f49
Compare
jamieomaguire
left a comment
There was a problem hiding this comment.
Please can you deliver the follow-up work as a part of this ticket?
The readme content should be mandatory for this change at a minimum
Yep will do 👍 |
ceb2bad to
c04b651
Compare
ashleynolan
left a comment
There was a problem hiding this comment.
Couple of comments from me.
Would be interested to see the use case for this too (in terms of the application once it's published). I'm guessing it's for enabling better styling in JS hooks (CSS-inJS style), but I'd be wary of overusing it where CSS classes can be used to apply the styles instead, as it'll be less performant due to using JS.
It's purpose is solely to allow the use of styling text in marketing content on the JET+ hub, it enables marketing to say for example do underline on this word, and it then be applied across all 3 platforms identically without them having to write content for 3 platforms separately. It has no other intended use case beyond this. The way styles are applied obviously differ per platform and therefore we needed a cross platform way of doing it, android went first as they already had a library, web is copying their approach. |
Adds a new tool package providing programmatic lookup of PIE design tokens by name, returning CSS variable references. Supports color, typography, radius, spacing, elevation, gradient, motion, breakpoint, and z-index categories. Includes platform-agnostic color aliases for Android PIE token map parity.
- Filter out platform-specific (android-*, ios-*) color tokens that have no corresponding CSS custom properties in pie-css - Add comment explaining motion tokens use global source (no alias exists) - Narrow package.json files glob and add repository.directory field - Fix deprecated vite-plugin-dts outputDir option to outDir
Remove Environment Variables and License sections per review feedback.
4b69072 to
8565ce2
Compare
Summary
Adds a new
@justeattakeaway/pie-token-mappackage underpackages/tools/that provides programmatic lookup of PIE design tokens by name, returning CSS variable references (var(--dt-*)).Why this package?
Currently, consumers who need to reference design tokens programmatically (e.g. in JS/TS logic, SSR, or cross-platform tooling) have no typed, structured way to do so. They must hard-code CSS variable strings. This package:
as constarrays with extracted union types for every token category, giving compile-time autocomplete and validation@justeat/pie-design-tokens/dist/tokens.jsonand generates typed maps, ensuring the package stays in sync with upstream token changesIntended use case
Its purpose is solely to allow the use of styling text in marketing content on the JET+ hub. It enables marketing to say, for example, "underline this word", and have it applied across all 3 platforms identically — without them having to write content for 3 platforms separately. It has no other intended use case beyond this.
The way styles are applied obviously differs per platform, so we needed a cross-platform way of doing it. Android went first as they already had a library; web is copying their approach.
What's included
getColor(),getTypography(),getRadius(), etc.hasToken(category, name)- validation helper for checking token existencetokenMapconvenience object - aggregates all getters and raw mapstokensVersion- tracks the upstream@justeat/pie-design-tokensversioncontainer-base,container-neutral, etc. to theirweb-container-*CSS vars for Android parityfamily,weight,size/sizeWide/sizeNarrow,lineHeight,fontStyle,textDecoration, andparagraphproperties where applicableDesign decisions
@justeat/pie-design-tokensis a devDependency used only at build/generate timescripts/generate-token-map.tsreadstokens.jsondirectly, so adding new tokens upstream requires only a regenerate, not manual code changespie-css/css/input.cssrather thantokens.json, so the list is maintained explicitly in the generator"type": "module", Vite library build withformats: ['es'])Package structure
Test plan
var(--dt-*)refs)tokens.jsonis present in the generated mapsweb-*prefixed CSS varshasToken()tested across all categories for known and unknown namestokenMapconvenience object exposes all getters, raw maps, and versiontokensVersionmatches@justeat/pie-design-tokenspackage versionFollow-up work