♻️(frontend) replace hardcoded colors with contextual tokens#1858
♻️(frontend) replace hardcoded colors with contextual tokens#1858dtinth wants to merge 1 commit intosuitenumerique:mainfrom
Conversation
There was a problem hiding this comment.
Thank you for your contribution.
Indeed, it is is linked to this issue: suitenumerique/cunningham#369
I can see some noticeable differences between the modified editor (left) and the original one (right), could we find a color in the palette closer to what we have ?
|
@AntoLC Thank you very much for the PR review. Currently, Docs hardcoded main text color to: & .bn-editor {
color: var(--c--globals--colors--gray-700);
}In Cunningham's design tokens, these are the colors available: neutral: {
primary: "ref(globals.colors.gray-850)",
secondary: "ref(globals.colors.gray-600)",
tertiary: "ref(globals.colors.gray-550)",
"on-neutral": "ref(globals.colors.gray-050)",
},So we have two choices:
I looked into Figma, but it seems that “Création des palettes de couleurs en Dark mode” has not been implemented yet. That's why the color choices are limited. In this PR I opted to choose the darker one, because it leads to better contrast (for accessibility). This may need more discussion with Docs designer or Cunningham team on what is the best way forward. An alternative is to use color mixing e.g. & .bn-editor {
color: color-mix(
in srgb,
var(--c--contextuals--content--semantic--neutral--primary) 40%,
var(--c--contextuals--content--semantic--neutral--secondary)
);
}That is, 40% of primary and 60% of secondary. This approximates the global |
26d632a to
068f9f9
Compare
Replaced hardcoded global color tokens (gray-000, gray-100, gray-600, white, gainsboro) with Cunningham contextual tokens to enable proper dark mode support. Components updated: - LeftPanel: background colors - DropButton: popover background - DropdownMenu: menu item background - DocEditor: editor container background - DocEditor styles: BlockNote CSS variables, inline code, links - TableContent: panel and heading backgrounds This allows the UI to automatically adapt between light and dark themes. Signed-off-by: dtinth-ampere-devbox <dtinth@spacet.me> Signed-off-by: dtinth on MBP M1 <dtinth@spacet.me>
068f9f9 to
05cb24b
Compare
|
@AntoLC Hello again, I have updated the color of the main text to this now: color: color-mix(
in srgb,
var(--c--contextuals--content--semantic--neutral--primary) 39%,
var(--c--contextuals--content--semantic--neutral--secondary)
);I created a brute-forcer to determine the best percentage that results in the closest color. 39% of
I believe this will make the PR a strictly forward progress, as IMO, using |
There was a problem hiding this comment.
I can still see to big diff with what we have:

I think we should wait about overriding the mantime tokens, if you revert the styles.tsx part, I am keen that we merge what you made though.
You can still override the mantime tokens (or other part) on your own instance if you want, here some examples on how to do:
#771
https://antolc.github.io/docs-customized/docs-custom/public/custom-style.css
https://github.com/suitenumerique/docs/blob/main/docs/customization.md#runtime-theming-
Dark theme is on the roadmap, I will try to increase the priority.
Purpose
Many parts of the editor are hardcoded to use global colors (which do not respond to dark/light modes) instead of contextual colors (which are ready to use with dark theme). This makes it hard to create dark theme for it.
This PR replaces hardcoded global color tokens with Cunningham contextual tokens throughout the frontend, enabling automatic adaptation between light and dark themes.
Related issue:
Proposal
Colors changed
gray-000surface--primarygray-000gray-800whitesurface--primarygray-000gray-800gray-000surface--primarygray-000gray-800whitesurface--primarygray-000gray-800gray-700neutral--primary+61% of
neutral--secondarygray-700gray-050+61% of
gray-100gainsboropalette--gray--tertiarygray-150gray-850gray-600neutral--secondarygray-600gray-100gray-000surface--primarygray-000gray-800gray-100neutral--secondarygray-100gray-700#cfcfcfborder--semantic--neutral--tertiarygray-150gray-700#efefefborder--surface--primarygray-100gray-750External contributions
Thank you for your contribution! 🎉
Please ensure the following items are checked before submitting your pull request:
git commit --signoff(DCO compliance)git commit -S)<gitmoji>(type) title description## [Unreleased]section (if noticeable change)