marigold-ui / marigold

Design System based on react-aria and Tailwind CSS
https://marigold-ui.io
MIT License
101 stars 7 forks source link

Themes 1.0 #1923

Closed sebald closed 2 years ago

sebald commented 2 years ago

Description

We need to refactor our themes!

Requirements

Tasks

Theme Spec

const theme = {
  ...tokens,
  root: {},
  components: {
    Button: {
      base: {
        // styles that are applied every time
      },
      size: {
        small: {},
        medium: {},
        large: {},
      },
      variant: {
        primary: {},
        secondary: {},
      },
    },
    Checkbox: {
      base: {
        // Component consists of multiple parts
        container: {},
        icon: {},
        label: {},
      },
      size: {
        small: {
          container: {},
          icon: {},
          label: {},
        },
        medium: {
          container: {},
          icon: {},
          label: {},
        },
        large: {
          container: {},
          icon: {},
          label: {},
        },
      }
    },
  },
};

Context

Our themes became very large and hard to maintain, we need more structure!

Consequences

More to write, but maintainable 🥳

sebald commented 2 years ago

@ti10le we should gather "semantic colors" (error, info, warning, ...) and other value we want to support in createTheme. Do you want to make a list?

ti10le commented 2 years ago

@ti10le we should gather "semantic colors" (error, info, warning, ...) and other value we want to support in createTheme. Do you want to make a list?

Yes I can! But what other values do you mean? Do you mean some values we already have (space, sizes) or more values like from open-props: gradient, animation or s.e.?

sebald commented 2 years ago

@ti10le fonts for example, not sure if there are any others. but the colors are the most important ones, i guess.

ti10le commented 2 years ago

to extend createTheme():

colors: {
    text: ...,
    background: ...,
    primary: ...,
    secondary: ...,
    disabled: ...,
    error: ...,
    warning: ...,
    info: ...,
    success: ...,
    white: // ? like in docs theme,
    black: // ? like in docs theme,
}
fonts: {
    body: ...,
    heading: ...,
}

for the future maybe something like this:

// brand colors
    primaryLight: '$blue200', //  $blue600 on dark mode
    primary: '$blue500',
    primaryDark: '$blue600',
    primaryShadow: '$blue100', // $blue600 on dark mode

    secondaryLight: '$purple200', // $purple600 on dark mode
    secondary: '$purple500',
    secondaryDark: '$purple600',
    secondaryShadow: '$purple100', // $purple600 on dark mode

(https://nextui.org/docs/theme/default-theme)

sebald commented 2 years ago

@ti10le white, black can not be a single value, see @marigold/tokens. Needs hues. When is background used?

sebald commented 2 years ago

Change Proposal: Use regular CSS as much as possible, because recomputing the styles programmatically is expensive and could make apps slow.

ti10le commented 2 years ago

@ti10le white, black can not be a single value, see @marigold/tokens. Needs hues. When is background used?

I think background could be useful inside components eg dialog. But sure we could also remove it.

sebald commented 2 years ago

Closing. Will do createTheme updates past 1.0. See #2002