Skip to content

Variants Clashing #6

@clintwood

Description

@clintwood

Awesome library - thanks!

I'm needing to define multiple colorVariants on core colors like in the example below. As can be seen they are a light and dark variants of core colors accent and primary. These are not to be confused with a light and dark themes - they are unrelated - they are variants on the core theme colors of each theme.

When I build this I get an error Error: Variant light already exists.

I would have expected these to not clash since they are scoped uniquely. I have had a look at the source and notice that class ColorVariant does not consider the scope as part of it's uniqueness, hence the clashes.

As a workaround for now I will move the variant colors into the colors(...) definitions.

const lightTheme = new Theme()
  .name('light')
  .default()
  .assignable()
  .colors({
    'on-accent': '#FFFFFF',
    'accent': '#CB116E',

    'on-primary': '#292929',
    'primary': '#FAFAFA',
  })
  .colorVariant('light', '#FF569C', 'accent')
  .colorVariant('dark', '#940043', 'accent')
  .colorVariant('light', '#FFFFFF', 'primary')
  .colorVariant('dark', '#C7C7C7', 'primary');

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions