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: allow themes to use any srgb color for definitions #1756

Merged
merged 13 commits into from
Jan 31, 2024

Conversation

dsmmcken
Copy link
Contributor

@dsmmcken dsmmcken commented Jan 30, 2024

Themes were previously limited to HSL raw value colors such that transparency could be created using HSLA. This made theme creation somewhat annoying and limiting. This change adopts color-mix (requires chrome 111, firefox 113 -- both older than 6 months) to create any necessary transparency.

  • replaces hsl raw values with hex (allows skipping color normalization)
  • replace hsla usage with color-mix
  • fix miss-named legend-color
  • created utils that use color-mix for easier specification
  • move utils.scss to be auto-imported with custom.scss
  • re-wrote color normilzation and resolving to resolve color-mix based colors
  • changed iris grid theme context to not accept a paritial

Style changes:

  • style console input to match other inputs, add hover state to border
  • fix input border hover color to use correct variable
  • darken water color in dark theme maps]
  • adjust disabled button color in light theme]
  • fix selection background and selection hover color to be more subtle. (No idea why I made it so opaque, it used to be 0.09 pre-spectrum)

BREAKING CHANGE:

  • IrisGridThemeContext no longer accepts a paritial theme. By guaranteeing the provider is a full theme we can resolve the CSS variables and normailze the colors only once per theme load globally, rather than having to do it once per grid.
  • Themes must be defined using valid srgb CSS colors, and not hsl raw component values

Themes were previously limited to HSL raw value colors such that transparency could be created using HSLA. This made theme creation somewhat annoying and limiting. This change adopts color-mix (requires chrome 111, firefox 113 -- both older than 6 months) to create any necessary transparency.

- replaces hsl raw values with hex (allows skipping color normalization)
- replace hsla usage with color-mix
- fix miss-named legend-color
- created utils that use color-mix for easier specification
- move utils.scss to be auto-imported with custom.scss
- re-wrote color normilzation and resolving to resolve color-mix based colors
- changed iris grid theme context to not accept a paritial

Breaking change: IrisGridThemeContext no longer accepts a paritial theme. By  guaranteeing the provider is a full theme we can resolve the CSS variables and normailze the colors only once per theme load globally, rather than having to do it once per grid.
): T {
const perfStart = performance.now();

// Add a temporary div to attach temp css variables to
const tmpPropEl = document.createElement('div');
targetElement.appendChild(tmpPropEl);

const varExpressions = [...extractDistinctCssVariableExpressions(record)];
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this still able to resolve strings containing multiple expressions?
var(--bbb1) var(--bbb2)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes.

const el = document.createElement('div');
el.style.setProperty("--a", "#aaa");
el.style.setProperty("--b", "#bbb");
el.style.setProperty("--c", "var(--a) var(--b)");
document.body.appendChild(el);
window.getComputedStyle(el).getPropertyValue("--c");

// '#aaa #bbb'

Copy link

codecov bot commented Jan 31, 2024

Codecov Report

Attention: 5 lines in your changes are missing coverage. Please review.

Comparison is base (cfbbe74) 46.03% compared to head (0d68128) 46.06%.
Report is 1 commits behind head on main.

❗ Current head 0d68128 differs from pull request most recent head 87cad52. Consider uploading reports for the commit 87cad52 to get more accurate results

Files Patch % Lines
packages/code-studio/src/styleguide/colorUtils.ts 0.00% 4 Missing ⚠️
packages/iris-grid/src/IrisGrid.tsx 66.66% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1756      +/-   ##
==========================================
+ Coverage   46.03%   46.06%   +0.03%     
==========================================
  Files         626      626              
  Lines       37576    37593      +17     
  Branches     9447     9458      +11     
==========================================
+ Hits        17298    17318      +20     
+ Misses      20223    20220       -3     
  Partials       55       55              
Flag Coverage Δ
unit 46.06% <90.56%> (+0.03%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Contributor

@bmingles bmingles left a comment

Choose a reason for hiding this comment

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

Changes look good. Verified that local build + preview is working as well

@dsmmcken dsmmcken merged commit b047fa3 into main Jan 31, 2024
4 checks passed
@dsmmcken dsmmcken deleted the dmckenzie_color-mix branch January 31, 2024 21:57
@github-actions github-actions bot locked and limited conversation to collaborators Jan 31, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants