Skip to content

Conversation

@ze-flo
Copy link
Contributor

@ze-flo ze-flo commented Jun 3, 2024

Description

This PR follows up on #1798 and generates a 12-step color scale using the very lightweight color2k library.

Detail

Garden's color palette were generated using Leonardo using the following offset-based contrast ratios.

const targetRatios = {
      100: 1.08,
      200: 1.2,
      300: 1.35,
      400: 2,
      500: 2.8,
      600: 3.3,
      700: 5,
      800: 10,
      900: 13,
      1000: 16,
      1100: 17.5,
      1200: 19.5
    };

generateColorScale generates a 200 color scale with Color2K and returns a color scale object. Each key is an offset value and the corresponding value is the color that best matches the target contrast ratio for that offset. 🎨

See demo.

Size improvement over chroma-js

BEFORE

Screen Shot 2024-04-25 at 8 49 42 AM

AFTER

Screenshot 2024-06-04 at 1 02 20 PM

Before (KB) After (KB) Diff
15.44 2.69 -82.57%

Checklist

  • 👌 design updates will be Garden Designer approved (add the designer as a reviewer)
  • 🌐 demo is up-to-date (npm start)
  • ⬅️ renders as expected with reversed (RTL) direction
  • 🤘 renders as expected with Bedrock CSS (?bedrock)
  • 💂‍♂️ includes new unit tests. Maintain existing coverage (always >= 96%)
  • ♿ tested for WCAG 2.1 AA accessibility compliance
  • 📝 tested in Chrome, Firefox, Safari, and Edge

@ze-flo ze-flo changed the base branch from main to next June 3, 2024 23:45
@coveralls
Copy link

Coverage Status

coverage: 96.046% (-0.04%) from 96.084%
when pulling c54a3b9 on ze-flo/custom-color-scale-gen
into cffdb06 on next.

@ze-flo ze-flo marked this pull request as ready for review June 4, 2024 23:21
@ze-flo ze-flo requested a review from a team as a code owner June 4, 2024 23:21
@geotrev
Copy link
Contributor

geotrev commented Jun 5, 2024

bundle size difference

pog

@ze-flo ze-flo merged commit 45281be into next Jun 6, 2024
@ze-flo ze-flo deleted the ze-flo/custom-color-scale-gen branch June 6, 2024 17:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

6 participants