Skip to content
This repository has been archived by the owner on Nov 26, 2024. It is now read-only.

Adding themes to token architecture #148

Merged
merged 2 commits into from
Jun 16, 2022

Conversation

georgewrmarshall
Copy link
Collaborator

@georgewrmarshall georgewrmarshall commented May 20, 2022

Description

Updating the CSS-in-JS architecture to include themes so we can change the theme object at the top level without worrying about constructing theme specific styles further down the tree e.g combining color with shadow.

  • Theme specific tokens live in the src/js/themes/ directory and import global tokens from src/js
  • lightTheme and darkTheme objects are exported and will contain all design tokens color, typography etc.
lightTheme: {
    colors: {
        // light theme colors
    },
    typography: {
        // global typography but could be themed
    },
    // ...rest of the design tokens
}

This could be how the new theme tokens could work

import { lightTheme, darkTheme } from '@metamask/design-tokens';

<Provider theme={theme === 'default' ? lightTheme : darkTheme}  />

const createStyles = (theme: any) =>
	StyleSheet.create({
		info: {
			backgroundColor: theme.colors.info.muted,
			borderColor: theme.colors.info.default,
			fontSize: theme.typography.sBodyMD.fontSize,
			fontWeight: theme.typography.sBodyMD.fontWeight,
		},
		warning: {
			backgroundColor: theme.colors.warning.muted,
			borderColor: theme.colors.warning.default,
			fontSize: theme.typography.sBodyMD.fontSize,
			fontWeight: theme.typography.sBodyMD.fontWeight,
		},
		error: {
			backgroundColor: theme.colors.error.muted,
			borderColor: theme.colors.error.default,
			fontSize: theme.typography.sBodyMD.fontSize,
			fontWeight: theme.typography.sBodyMD.fontWeight,
		},
	});

const { theme } = useAppThemeFromContext() || mockTheme;
	const styles = createStyles(theme);

To do

  • Update docs once we have consensus on structure

@georgewrmarshall georgewrmarshall requested a review from Cal-L May 20, 2022 21:06
@georgewrmarshall georgewrmarshall self-assigned this May 20, 2022
@metamaskbot
Copy link
Collaborator

Builds ready [aaad3a5]

@metamaskbot
Copy link
Collaborator

Builds ready [cc51e47]

@georgewrmarshall georgewrmarshall added the code Issue related to code work label May 20, 2022
@georgewrmarshall georgewrmarshall force-pushed the update/141/css-in-js-architecture branch from cc51e47 to b2dc8d1 Compare June 6, 2022 23:01
@georgewrmarshall georgewrmarshall marked this pull request as ready for review June 6, 2022 23:02
@georgewrmarshall georgewrmarshall requested a review from a team as a code owner June 6, 2022 23:02
@georgewrmarshall georgewrmarshall force-pushed the update/141/css-in-js-architecture branch from b2dc8d1 to 8963807 Compare June 6, 2022 23:02
@metamaskbot
Copy link
Collaborator

Builds ready [8963807]

@georgewrmarshall georgewrmarshall force-pushed the update/141/css-in-js-architecture branch from 8963807 to 0a298ce Compare June 6, 2022 23:20
@metamaskbot
Copy link
Collaborator

Builds ready [0a298ce]

@metamaskbot
Copy link
Collaborator

Builds ready [2f6aa8a]

Copy link
Collaborator

@Cal-L Cal-L left a comment

Choose a reason for hiding this comment

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

LGTM

@georgewrmarshall georgewrmarshall merged commit 1e2d6d2 into main Jun 16, 2022
@georgewrmarshall georgewrmarshall deleted the update/141/css-in-js-architecture branch June 16, 2022 20:24
@georgewrmarshall
Copy link
Collaborator Author

Closes #141

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
code Issue related to code work
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants