Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add js platform formats to calcite-design-tokens #8044

Merged
merged 9 commits into from
Oct 24, 2023

Conversation

alisonailea
Copy link
Contributor

@alisonailea alisonailea commented Oct 23, 2023

Related Issue: #7986

Summary

Adds two new platforms and four formats to design-token exports.

JS platform

The "js" platform creates a javascript object of the design-tokens and a typescript types declaration file representing that object. This format is necessary for documentation.

Examples

export default {
  core: {
    breakpoint: {
      width: {
        xxs: {
          value: "320px",
          type: "sizing",
          description: "Small handheld devices and mini-windows",
          filePath: "src/core.json",
          isSource: true,
          original: {
            value: "320px",
            type: "sizing",
            description: "Small handheld devices and mini-windows",
          },
          name: "xxs",
          attributes: {},
          path: ["core", "breakpoint", "width", "xxs"],
        },
      xs: {
declare const root: RootObject
export default root
interface RootObject {
  core: Core;
  semantic: Semantic;
}
interface Core {
  font: Font20;
  border: Border7;
  opacity: Opacity2;
  color: Color;
  sizing: Sizing;
  spacing: Sizing;
  breakpoint: Breakpoint;
  'z-index': Zindex;
}

ES6 platform

The "es6" platform provides the design tokens as tree-shakable javascript named exports.

Examples

export const CoreSpacing27 = "256px";
export const CoreSpacing28 = "288px";
export const CoreSpacingNone = "0px";
export const CoreBreakpointWidthXxs = "320px";
export const CoreBreakpointWidthXs = "476px";
export const CoreBreakpointWidthSm = "768px";
export const CoreBreakpointWidthMd = "1152px";
export const CoreBreakpointWidthLg = "1440px";
export const CoreSpacing27 : string;
export const CoreSpacing28 : string;
export const CoreSpacingNone : string;
export const CoreBreakpointWidthXxs : string;
export const CoreBreakpointWidthXs : string;
export const CoreBreakpointWidthSm : string;
export const CoreBreakpointWidthMd : string;
export const CoreBreakpointWidthLg : string;

@github-actions github-actions bot added the enhancement Issues tied to a new feature or request. label Oct 23, 2023
@alisonailea alisonailea added skip visual snapshots Pull requests that do not need visual regression testing. low risk Issues with low risk for consideration in low risk milestones labels Oct 23, 2023
Copy link
Member

@jcfranco jcfranco left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Had a couple of questions, but this LGTM! 🚀🕹️


Do we have any control over the generated interfaces? The numbered interfaces/types are unexpected, IMO.

interface Core {
  font: Font20;
  border: Border7;
  opacity: Opacity2;
  color: Color;
  sizing: Sizing;
  spacing: Sizing;
  breakpoint: Breakpoint;
  'z-index': Zindex;
}

Not a deal breaker as these aren't exported.

"./css/calcite/dark": "./dist/css/calcite-dark.css",
"./css/calcite/light": "./dist/css/calcite-light.css",
"./css/headless": "./dist/css/calcite-headless.css",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we keep ./css/headless for backwards compatibility?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yep! sorry I pulled from my November release branch.


type FormatOptions = { dictionary: Dictionary; file: File };

export function jsModule({ dictionary, file }: FormatOptions): string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nitpick: for readability, could these be named formatJs/formatTs (or similar)?

@alisonailea
Copy link
Contributor Author

alisonailea commented Oct 24, 2023

Do we have any control over the generated interfaces?

@jcfranco Technically yes. This was the default type shape generated by json-to-ts. However that seemed like a lot more work for a first pass and like you said, it's not exported.

@alisonailea alisonailea merged commit 0e1fefb into main Oct 24, 2023
11 checks passed
@alisonailea alisonailea deleted the astump/7986-js-token-platform-export branch October 24, 2023 21:20
benelan pushed a commit that referenced this pull request Oct 30, 2023
🤖 I have created a release *beep* *boop*
---


<details><summary>@esri/calcite-design-tokens: 1.1.0</summary>

##
[1.1.0](https://github.com/Esri/calcite-design-system/compare/@esri/calcite-design-tokens@1.0.0...@esri/calcite-design-tokens@1.1.0)
(2023-10-30)


### Features

* Add icon tokens
([#8008](#8008))
([3623df1](3623df1))
* Add js platform formats to calcite-design-tokens
([#8044](#8044))
([0e1fefb](0e1fefb))
* Add xxs breakpoint to tokens
([#7992](#7992))
([05512b6](05512b6))
* Reorganize breakpoints
([#7994](#7994))
([c64a059](c64a059))
</details>

<details><summary>@esri/calcite-components: 1.10.0</summary>

##
[1.10.0](https://github.com/Esri/calcite-design-system/compare/@esri/calcite-components@1.9.2...@esri/calcite-components@1.10.0)
(2023-10-30)


### Features

* **block:** Ensure chevron is always displayed
([#8014](#8014))
([95fecb2](95fecb2))
* **navigation-logo:** Adds `icon` and `iconFlipRtl` properties
([#8054](#8054))
([049056d](049056d))
* **stepper,stepper-item:** Adds support for built-in translations
([#8002](#8002))
([bb91624](bb91624))


### Bug Fixes

* **button, fab, inline-editable, split-button:** Prevent redundant
opacity when button is both loading and disabled
([#8015](#8015))
([3a1d3fd](3a1d3fd))
* **combobox:** Clear custom input value on blur
([#8070](#8070))
([327ff06](327ff06))
* **combobox:** Ensure icon scales are consistent
([#8075](#8075))
([babba3b](babba3b))
* **filter:** Corrects the accessible label
([#8069](#8069))
([c203084](c203084))
* Floating components will now get an initial position even if they are
not opened
([#8001](#8001))
([78b680d](78b680d))
* **icon:** Use pixel sizes for icons
([#8009](#8009))
([49085d5](49085d5))
* **input-date-picker, input-time-picker:** Adjust chevron scale
accordingly
([#8012](#8012))
([f894f80](f894f80))
* **input-time-zone:** Fix city translations
([#8058](#8058))
([7df7e1f](7df7e1f))
* **list-item:** Restore tabbability when an item's disabled prop is
toggled
([#8042](#8042))
([c970603](c970603))
* **pagination:** Prevents console error when page-size is set to zero
([#8017](#8017))
([d09d485](d09d485))
* **segmented-control-item:** Fix text color contrast
([#8036](#8036))
([ede8c43](ede8c43))
* **stepper:** Selects next enabled stepper-item when first one is
disabled
([#8004](#8004))
([e0ed54e](e0ed54e))


### Dependencies

* The following workspace dependencies were updated
  * devDependencies
    * @esri/calcite-design-tokens bumped from ^1.1.0-next.3 to ^1.1.0
</details>

<details><summary>@esri/calcite-components-react: 1.10.0</summary>

##
[1.10.0](https://github.com/Esri/calcite-design-system/compare/@esri/calcite-components-react@1.9.2...@esri/calcite-components-react@1.10.0)
(2023-10-30)


### Miscellaneous Chores

* **@esri/calcite-components-react:** Synchronize undefined versions


### Dependencies

* The following workspace dependencies were updated
  * dependencies
    * @esri/calcite-components bumped from ^1.10.0-next.11 to ^1.10.0
</details>

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

---------

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Issues tied to a new feature or request. low risk Issues with low risk for consideration in low risk milestones skip visual snapshots Pull requests that do not need visual regression testing.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants