Skip to content

Conversation

lukasjhan
Copy link
Member

@lukasjhan lukasjhan commented Mar 16, 2025

It closes #115

Summary by Sourcery

Updates the color system to use design tokens and introduces a color theme mode. This change replaces the previous color definitions with a new structure that supports light and high-contrast modes. It also removes the Color type and getTextColorClassname function.

Enhancements:

  • Refactor the color system to use design tokens and support light and high-contrast modes.
  • Remove the Color type and getTextColorClassname function.
  • Update components to remove color props.

Signed-off-by: Lukas.J.Han <[email protected]>
Signed-off-by: Lukas.J.Han <[email protected]>
@lukasjhan lukasjhan self-assigned this Mar 16, 2025
Copy link

sourcery-ai bot commented Mar 16, 2025

Reviewer's Guide by Sourcery

This pull request introduces a new color system that supports light and high-contrast themes. It replaces the existing color definitions with a new structure in packages/core/lib/colors/color.ts, updates the tailwindcss plugin to use CSS variables, and modifies the color story to include a theme selection. It also removes color properties from components and adds a theme context provider.

Updated class diagram for ColorThemeMode and colors

classDiagram
  class ColorThemeMode {
    <<enumeration>>
    light
    high-contrast
  }

  class colors {
    'primary-5': ColorValues
    'primary-10': ColorValues
    'primary-20': ColorValues
    'primary-30': ColorValues
    'primary-40': ColorValues
    'primary-50': ColorValues
    'primary-60': ColorValues
    'primary-70': ColorValues
    'primary-80': ColorValues
    'primary-90': ColorValues
    'primary-95': ColorValues
    'secondary-5': ColorValues
    'secondary-10': ColorValues
    'secondary-20': ColorValues
    'secondary-30': ColorValues
    'secondary-40': ColorValues
    'secondary-50': ColorValues
    'secondary-60': ColorValues
    'secondary-70': ColorValues
    'secondary-80': ColorValues
    'secondary-90': ColorValues
    'secondary-95': ColorValues
    'gray-0': ColorValues
    'gray-5': ColorValues
    'gray-10': ColorValues
    'gray-20': ColorValues
    'gray-30': ColorValues
    'gray-40': ColorValues
    'gray-50': ColorValues
    'gray-60': ColorValues
    'gray-70': ColorValues
    'gray-80': ColorValues
    'gray-90': ColorValues
    'gray-95': ColorValues
    'gray-100': ColorValues
    'alpha-black100': ColorValues
    'alpha-black75': ColorValues
    'alpha-black50': ColorValues
    'alpha-black25': ColorValues
    'alpha-black10': ColorValues
    'alpha-black0': ColorValues
    'alpha-white100': ColorValues
    'alpha-white75': ColorValues
    'alpha-white50': ColorValues
    'alpha-white25': ColorValues
    'alpha-white10': ColorValues
    'alpha-white0': ColorValues
    'danger-5': ColorValues
    'danger-10': ColorValues
    'danger-20': ColorValues
    'danger-30': ColorValues
    'danger-40': ColorValues
    'danger-50': ColorValues
    'danger-60': ColorValues
    'danger-70': ColorValues
    'danger-80': ColorValues
    'danger-90': ColorValues
    'danger-95': ColorValues
    'information-5': ColorValues
    'information-10': ColorValues
    'information-20': ColorValues
    'information-30': ColorValues
    'information-40': ColorValues
    'information-50': ColorValues
    'information-60': ColorValues
    'information-70': ColorValues
    'information-80': ColorValues
    'information-90': ColorValues
    'information-95': ColorValues
    'warning-5': ColorValues
    'warning-10': ColorValues
    'warning-20': ColorValues
    'warning-30': ColorValues
    'warning-40': ColorValues
    'warning-50': ColorValues
    'warning-60': ColorValues
    'warning-70': ColorValues
    'warning-80': ColorValues
    'warning-90': ColorValues
    'warning-95': ColorValues
    'success-5': ColorValues
    'success-10': ColorValues
    'success-20': ColorValues
    'success-30': ColorValues
    'success-40': ColorValues
    'success-50': ColorValues
    'success-60': ColorValues
    'success-70': ColorValues
    'success-80': ColorValues
    'success-90': ColorValues
    'success-95': ColorValues
    'point-5': ColorValues
    'point-10': ColorValues
    'point-20': ColorValues
    'point-30': ColorValues
    'point-40': ColorValues
    'point-50': ColorValues
    'point-60': ColorValues
    'point-70': ColorValues
    'point-80': ColorValues
    'point-90': ColorValues
    'point-95': ColorValues
    'graphic-10': ColorValues
    'graphic-30': ColorValues
    'graphic-50': ColorValues
    'graphic-70': ColorValues
    'graphic-90': ColorValues
  }

  class ColorValues {
    light: string
    high-contrast: string
  }

  colors ..> ColorValues : has
  ColorValues ..> ColorThemeMode : uses
Loading

File-Level Changes

Change Details Files
Replaced the existing color definitions with a new structure that supports multiple theme modes ('light' and 'high-contrast').
  • Introduced ColorThemeMode type to represent available theme modes.
  • Updated colors object to include color values for both 'light' and 'high-contrast' modes.
  • Added getColor helper function to retrieve color values based on the selected theme mode.
  • Added getThemeColors helper function to retrieve all colors for a specified mode.
packages/core/lib/colors/color.ts
Updated the tailwindcss plugin to use CSS variables for colors and removed the theme extension.
  • Removed the theme.extend.colors configuration.
  • Added CSS variables to the :root selector for each color.
  • Added CSS variables to the [data-theme="high-contrast"] selector for the high-contrast theme.
  • Removed screen size configurations.
packages/tailwindcss-plugin/krds-plugin.js
Updated the color story to use the new color structure and include a theme selection.
  • Modified ColorSwatch component to receive a mode prop.
  • Modified ColorGroup component to receive a mode prop.
  • Added a theme selection dropdown to switch between 'light' and 'high-contrast' modes.
  • Updated the color mapping to use the new color structure.
stories/core/color.stories.tsx
Removed color properties from components.
  • Removed color properties from Spinner component.
  • Removed color properties from Label component.
  • Removed color properties from Link component.
  • Removed color properties from Body component.
  • Removed color properties from Detail component.
  • Removed color properties from Display component.
  • Removed color properties from Heading component.
  • Removed color properties from Title component.
packages/core/lib/components/Spinner.tsx
packages/core/lib/components/Label.tsx
packages/core/lib/components/Link.tsx
packages/core/lib/components/Body.tsx
packages/core/lib/components/Detail.tsx
packages/core/lib/components/Display.tsx
packages/core/lib/components/Heading.tsx
packages/core/lib/components/Title.tsx
Added a theme context provider.
  • Added ThemeMode type.
  • Added DesignToken type.
  • Added ContextProps type.
  • Added ContextProvider component.
  • Added useContext hook.
packages/core/lib/provider.tsx

Assessment against linked issues

Issue Objective Addressed Explanation
#115 Update the color definitions in the application.
#115 Implement light and high-contrast color modes.
#115 Integrate the new color definitions into the Tailwind CSS plugin.

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!
  • Generate a plan of action for an issue: Comment @sourcery-ai plan on
    an issue to generate a plan of action for it.

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey @lukasjhan - I've reviewed your changes - here's some feedback:

Overall Comments:

  • Consider generating the tailwind config from the color definitions to ensure consistency.
  • The color palette in packages/core/lib/colors/color.ts is very comprehensive; ensure that it will be actively maintained and kept up-to-date.
Here's what I looked at during the review
  • 🟢 General issues: all looks good
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Signed-off-by: Lukas.J.Han <[email protected]>
@lukasjhan lukasjhan merged commit 891d500 into KRDS-community:main Mar 16, 2025
4 checks passed
@lukasjhan lukasjhan deleted the feat/color1.0 branch March 16, 2025 06:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

컬러 업데이트

1 participant