Skip to content

Conversation

@cchaos
Copy link
Contributor

@cchaos cchaos commented May 8, 2022

Theming ideas

Can prop values be generated through the global theme layer?
This is all conjecture since I don't know if the provider can be used this way.

Example: Buttons

Amsterdam theme:

export const BUTTON_COLORS = ‘primary’ | ‘success’;
export const useEuiButtonColorCSS = () => {
  const euiTheme = useEuiTheme();
  return {
    primary: `
      background-color: ${euiButtonColor('primary', euiTheme)};
    `,
    success: `
      background-color: ${euiButtonColor('success', euiTheme)};
    `,
  }
}

Somehow the EuiThemeProvider should expect certain component prop type options like

EuiButtonProps[‘color’]: EuiThemeProvider.theme.button.colors

Then the button component would pull the available prop's map and related styling via the provider:

export type ButtonColor = EuiThemeProvider.theme.button.colors;
export const EuiButton: FunctionComponent<Props> = ({
  color,
)} => {
  const style = [useEuiButtonColorCSS[color]];
}
export const EuiBottomBar = forwardRef<HTMLElement, EuiBottomBarProps>(
  (props, ref) => {
    const BottomBar = _EuiBottomBar;
    return (
      <EuiThemeProvider colorMode={'dark'}>
        <BottomBar ref={ref} {...props} />
      </EuiThemeProvider>
    );
  }
);

Screen Shot 2022-05-08 at 18 09 13 PM

This screenshots show how the docs is still looping through manual list of previously available colors, but only 3 of which are available in this theme.


The nice thing about this approach, is it will separate basic / functional styles from purely visual ones. Perhaps open up a way to make those basic / functional styles static.

@cchaos cchaos added the skip-changelog Use on PRs to skip changelog requirement (Don't delete - used for automation) label May 8, 2022
@github-actions
Copy link

github-actions bot commented Aug 7, 2022

👋 Hey there. This PR hasn't had any activity for 90 days. We'll automatically close it if that trend continues for another week. If you feel this issue is still valid and needs attention please let us know with a comment.

@github-actions github-actions bot added the stale-pr (Don't delete - used for automation) label Aug 7, 2022
@github-actions
Copy link

❌ We're automatically closing this PR due to lack of activity. Please comment if you feel this was done in error.

@github-actions github-actions bot added the stale-pr-closed (Don't delete - used for automation) label Aug 14, 2022
@github-actions github-actions bot closed this Aug 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip-changelog Use on PRs to skip changelog requirement (Don't delete - used for automation) stale-pr (Don't delete - used for automation) stale-pr-closed (Don't delete - used for automation)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant