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: syntax tokens #57

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft

feat: syntax tokens #57

wants to merge 11 commits into from

Conversation

bennypowers
Copy link
Member

@bennypowers bennypowers commented Jan 23, 2023

based on #55

closes #16

@netlify
Copy link

netlify bot commented Jan 23, 2023

Deploy Preview for red-hat-design-tokens ready!

Name Link
🔨 Latest commit 4fe57b0
🔍 Latest deploy log https://app.netlify.com/sites/red-hat-design-tokens/deploys/65ea1448f445800008841b6d
😎 Deploy Preview https://deploy-preview-57--red-hat-design-tokens.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@bennypowers bennypowers force-pushed the tokens/syntax branch 2 times, most recently from 539049f to 80c300a Compare January 26, 2023 08:52
@bennypowers
Copy link
Member Author

bennypowers commented Jan 26, 2023

OK @coreyvickery this is ready for you to tinker with.

To get set up, check out this branch

git checkout tokens/syntax

Then clean out your working directory (save any uncommitted changes, they may be deleted)

git clean -dfx

Next install dependencies

npm ci

Then start the 11ty dev server

npm start

Once that's ready, you can change the values in tokens/color/syntax.yaml and they will be reflected in the Syntax Highlighting section of the demo page. NB: the current values are basically randomly chosen, so have at 'em.

You can uncomment any of the commented tokens and add values to see how they will reflect on the page. You can add markdown fenced code blocks to tokens/color/syntax.md to see how other languages will look.

@marionnegp marionnegp self-assigned this Feb 3, 2023
@coreyvickery
Copy link
Collaborator

@marionnegp Tagging you to take over.

@marionnegp
Copy link
Contributor

@bennypowers, I've been trying to match up the Prism JS tokens with the XD mockups, and I'm wondering how Prism is matching tokens to pieces of the code. For example, in the screenshot below myValue isn't mapped to a token, but it seems like it should be. The keyword class is also being used for multiple parts of the typescript example.
Screenshot 2023-02-08 at 4 23 37 PM

Is there a way to change this (maybe using Prism's Custom Class plugin)? Would that be a lot to manage in the future?

@bennypowers
Copy link
Member Author

@marionnegp if i understood correctly, you mean we should customize prism's parser to highlight tokens that it doesn't already, or to highlight them differently. If we went that route, we'd have to then also require all our users to implement a custom version of prism's parser whenever using our tokens, in order to get consistent results, and I think that's prohibitively complex for a user that just wants to theme a syntax snippet.

we could try highlighting with highlight.js instead, which is also quite popular.

@marionnegp
Copy link
Contributor

@bennypowers, yeah, that level of complexity was what I was afraid of. I think we should try highlight.js instead. @coreyvickery had used the highlight.js demos as a guide and tweaked the color, so it should be easier to update token colors.

@changeset-bot
Copy link

changeset-bot bot commented Feb 22, 2023

⚠️ No Changeset found

Latest commit: 4fe57b0

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@marionnegp
Copy link
Contributor

@bennypowers, could you add highlight.js here instead of Prism.js? Does it cause any issues to use Prism in PFE and Highlight here?

@bennypowers
Copy link
Member Author

prism is the default in 11ty, but we can override that for the sake of the token pages, which I've done in the most recent commits.

This is getting at a deeper problem which is that we should prefer not to tie our token names to a given library. So let's say we got things worked out using highlight JS, and using their token names in our token names. What if we get a request for prism.js support? treesitter? vscode?

@bennypowers
Copy link
Member Author

bennypowers commented Mar 6, 2023

The current state of the PR encodes our color token names using highlightjs' syntax token names. The result is that the DP (as of 3c5a412) looks more-or-less like the XD, but this will be difficult to maintain and port to other syntax highlighting schemes like vscode, treesitter, or prism (which is the default highlighter for 11ty)

I think the way forward is:

  1. use treesitter token names to define our token names
  2. keep the logic of how to convert from treesitter token names to final output (e.g. prism.js theme, highlightjs theme, vscode theme json, etc) in the output generator files in lib/formats
  3. evaluate the results: if the designers find them to be too much of a compromise, establish a table of each exceptional case and how to express them in each format (prism, highlightjs, treesitter, vscode)

For reference, here are the highlight groups that nvim treesitter uses

@text.literal      Comment
@text.reference    Identifier
@text.title        Title
@text.uri          Underlined
@text.underline    Underlined
@text.todo         Todo
@comment           Comment
@punctuation       Delimiter
@constant          Constant
@constant.builtin  Special
@constant.macro    Define
@define            Define
@macro             Macro
@string            String
@string.escape     SpecialChar
@string.special    SpecialChar
@character         Character
@character.special SpecialChar
@number            Number
@boolean           Boolean
@float             Float
@function          Function
@function.builtin  Special
@function.macro    Macro
@parameter         Identifier
@method            Function
@field             Identifier
@property          Identifier
@constructor       Special
@conditional       Conditional
@repeat            Repeat
@label             Label
@operator          Operator
@keyword           Keyword
@exception         Exception
@variable          Identifier
@type              Type
@type.definition   Typedef
@storageclass      StorageClass
@structure         Structure
@namespace         Identifier
@include           Include
@preproc           PreProc
@debug             Debug
@tag               Tag

@bennypowers
Copy link
Member Author

leaving this here for future reference: https://dbanks.design/blog/vs-code-theme-with-style-dictionary/#Syntax-styles

@marionnegp
Copy link
Contributor

I used this syntax highlighting spreadsheet to match Tree-sitter tokens to what we have in this XD as best as I could. If I wasn't sure whether there was any code from the XD mockup that matched, I left a ? in the cell.

@bennypowers, I can try installing Tree-sitter and working to add these if that would be the next step.

@bennypowers
Copy link
Member Author

bennypowers commented Apr 16, 2023

@marionnegp I resolved the conflicts in this branch. b60bf62 looks nice! Build fails for good reasons: we need to realign syntax greys to the new grey tokens

@markcaron markcaron added the needs discovery Needs discovery label Sep 15, 2023
@coreyvickery
Copy link
Collaborator

Update on syntax highlighting colors posted here.

RedHat-UX/red-hat-design-system#1091

@markcaron markcaron modified the milestone: RHDS Tokens 2.0 Jan 12, 2024
commit f54e53e
Author: Marionne Patel <[email protected]>
Date:   Mon Feb 26 11:13:00 2024 -0500

    feat: update danger status tokens (#131)

    * feat: change value of --rh-color-status-danger-on-light

    * feat: add --rh-color-icon-status color tokens

    * fix: add `on-dark` for warning icon color

    * feat: add changeset

commit b64dd32
Author: Marionne Patel <[email protected]>
Date:   Mon Jan 15 09:31:06 2024 -0500

    feat: add status color tokens (#124)

    * feat: add status color tokens, fix a duplicated red orange value, change the max width of the copy button to show full token name, and change order of categories on Netlify page

    * feat: add descriptions

    * docs: add changeset

    * feat: group surface status colors with other surface tokens

    * fix: remove space

    * feat: change neutral status to default and note status to info

    * feat: remove caution status colors and add -status to border and surface status tokens

    * feat: update changeset

    ---------

    Co-authored-by: Benny Powers <[email protected]>

commit 9539e1d
Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Date:   Wed Dec 13 10:59:13 2023 +0200

    chore: prepare release (#125)

    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

commit 3c18e2c
Author: Benny Powers <[email protected]>
Date:   Wed Dec 13 10:18:26 2023 +0200

    fix: allow component token names

commit a5dfee5
Author: Marionne Patel <[email protected]>
Date:   Wed Dec 6 07:05:03 2023 -0500

    feat: create a new folder under assets to house breakpoint images (#120)

    Co-authored-by: Benny Powers - עם ישראל חי! <[email protected]>

commit b020c49
Author: Mark Caron <[email protected]>
Date:   Wed Dec 6 03:45:56 2023 -0500

    docs: update README.md (#122)

    Adding stylized alert/admonition for the NOTE

commit 4c64dfc
Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Date:   Mon Dec 4 12:58:55 2023 -0500

    chore: prepare release (#115)

    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

commit 9759846
Author: Benny Powers - עם ישראל חי! <[email protected]>
Date:   Mon Dec 4 16:59:42 2023 +0200

    docs: correct stylelint rule name (#121)

commit 41125df
Author: Marionne Patel <[email protected]>
Date:   Sun Dec 3 03:23:12 2023 -0500

    feat: update crayon colors with new brand colors (#119)

    * feat: update crayon colors with new brand colors

    * feat: update semantic token values with new crayon tokens

    * fix: fix typo in interactive tokens file, add code comments

    * feat: add changeset with crayon color updates

    * feat: add semantic token value changes to changeset

    * feat: update token names in stylelint README migration example

    * fix: remove empty keys

    * feat: replace crayon color tables with migration rules and list of tokens new to 2.0

    * feat: added use cases when applicable, fixed a blue migration rule, and updated a brand token values

    * docs: apply suggestions from code review

    * docs: update .changeset/add-new-brand-colors.md

    ---------

    Co-authored-by: Benny Powers - עם ישראל חי! <[email protected]>

commit c793fd8
Author: Benny Powers <[email protected]>
Date:   Thu Jun 8 19:14:14 2023 +0300

    feat(editor): make css var fallback values placeholders (#114)

    * feat(editor): make css var fallback values placeholders

    This lets users more easily choose between the fallback and non-fallback forms
    ```css
    padding: var(--rh-space-xs, 4px);
    margin: var(--rh-space-xs);
    ```

    * docs: add changeset

commit b059238
Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Date:   Thu May 25 10:56:22 2023 -0400

    chore: prepare release (#112)

    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

commit f820df6
Author: Steven Spriggs <[email protected]>
Date:   Thu May 25 10:54:24 2023 -0400

    fix: ensure cjs files are included in package (#111)

    * fix: ensure cjs files are included in package

    * chore: update changeset

    * chore: update changeset

commit fa73870
Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Date:   Wed May 24 11:06:04 2023 -0400

    chore: prepare release (#109)

    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

commit a777f24
Author: Michael Potter <[email protected]>
Date:   Wed May 24 11:03:58 2023 -0400

    fix: missing file exports (#108)

    * fix: made typescript compile a dep of style-dictionary

    * chore: added changeset

    * chore: changset

commit 1485cea
Author: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Date:   Tue May 23 13:30:26 2023 -0400

    chore: prepare release (#105)

    Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>

commit c80fea2
Author: Steven Spriggs <[email protected]>
Date:   Tue May 23 11:20:40 2023 -0400

    chore: missing script for types in release workflow (#104)

commit 0766863
Author: Steven Spriggs <[email protected]>
Date:   Thu May 18 13:21:25 2023 -0400

    feat: add meta data token export (#103)

    * feat: add meta data token export

    * chore: update comment

    * fix: export entire token object in meta entries

    * docs: update lib/formats/map.js

    * docs: update lib/formats/map.js

    ---------

    Co-authored-by: Benny Powers <[email protected]>

commit d35d8a2
Author: Ivana Rodriguez <[email protected]>
Date:   Mon Apr 24 09:33:30 2023 -0400

    fix: plugin filename should match release tag (#102)

    * fix: plugin filename should match release tag

    * fix: throw error if filename doesn't match

    * ci: break out package step and run after version bump
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs discovery Needs discovery
Projects
Status: Dev WIP 🔵
Status: In Progress 🟢
Status: In Progress 🟢
Development

Successfully merging this pull request may close these issues.

New Tokens: Code Color Scheme
4 participants