diff --git a/src/alf/themes.ts b/src/alf/themes.ts index 1ae9610c7f..f5af08e567 100644 --- a/src/alf/themes.ts +++ b/src/alf/themes.ts @@ -25,13 +25,13 @@ export const light = { palette: lightPalette, atoms: { text: { - color: tokens.color.gray_950, + color: tokens.color.gray_1000, }, text_contrast_700: { - color: tokens.color.gray_600, + color: tokens.color.gray_700, }, text_contrast_500: { - color: tokens.color.gray_400, + color: tokens.color.gray_500, }, text_inverted: { color: tokens.color.white, @@ -40,19 +40,25 @@ export const light = { backgroundColor: tokens.color.white, }, bg_contrast_100: { - backgroundColor: tokens.color.gray_50, - }, - bg_contrast_200: { backgroundColor: tokens.color.gray_100, }, - bg_contrast_300: { + bg_contrast_200: { backgroundColor: tokens.color.gray_200, }, + bg_contrast_300: { + backgroundColor: tokens.color.gray_300, + }, + bg_positive: { + backgroundColor: tokens.color.green_500, + }, + bg_negative: { + backgroundColor: tokens.color.red_400, + }, border: { - borderColor: tokens.color.gray_100, + borderColor: tokens.color.gray_200, }, border_contrast_500: { - borderColor: tokens.color.gray_400, + borderColor: tokens.color.gray_500, }, }, } @@ -70,10 +76,10 @@ export const dark: Theme = { color: tokens.color.gray_500, }, text_inverted: { - color: tokens.color.gray_950, + color: tokens.color.gray_1000, }, bg: { - backgroundColor: tokens.color.gray_950, + backgroundColor: tokens.color.gray_1000, }, bg_contrast_100: { backgroundColor: tokens.color.gray_900, @@ -84,6 +90,12 @@ export const dark: Theme = { bg_contrast_300: { backgroundColor: tokens.color.gray_700, }, + bg_positive: { + backgroundColor: tokens.color.green_400, + }, + bg_negative: { + backgroundColor: tokens.color.red_400, + }, border: { borderColor: tokens.color.gray_800, }, diff --git a/src/alf/tokens.ts b/src/alf/tokens.ts index 124378b88d..159a7213cd 100644 --- a/src/alf/tokens.ts +++ b/src/alf/tokens.ts @@ -4,19 +4,19 @@ const GRAYSCALE_SATURATION = 22 export const color = { white: '#FFFFFF', - gray_50: `hsl(${BLUE_HUE}, ${GRAYSCALE_SATURATION}%, 95%)`, - gray_100: `hsl(${BLUE_HUE}, ${GRAYSCALE_SATURATION}%, 90%)`, - gray_200: `hsl(${BLUE_HUE}, ${GRAYSCALE_SATURATION}%, 80%)`, - gray_300: `hsl(${BLUE_HUE}, ${GRAYSCALE_SATURATION}%, 70%)`, - gray_400: `hsl(${BLUE_HUE}, ${GRAYSCALE_SATURATION}%, 60%)`, - gray_500: `hsl(${BLUE_HUE}, ${GRAYSCALE_SATURATION}%, 50%)`, - gray_600: `hsl(${BLUE_HUE}, ${GRAYSCALE_SATURATION}%, 40%)`, - gray_700: `hsl(${BLUE_HUE}, ${GRAYSCALE_SATURATION}%, 30%)`, - gray_800: `hsl(${BLUE_HUE}, ${GRAYSCALE_SATURATION}%, 20%)`, - gray_900: `hsl(${BLUE_HUE}, ${GRAYSCALE_SATURATION}%, 10%)`, - gray_950: `hsl(${BLUE_HUE}, ${GRAYSCALE_SATURATION}%, 5%)`, + gray_0: `hsl(${BLUE_HUE}, ${GRAYSCALE_SATURATION}%, 100%)`, + gray_100: `hsl(${BLUE_HUE}, ${GRAYSCALE_SATURATION}%, 95%)`, + gray_200: `hsl(${BLUE_HUE}, ${GRAYSCALE_SATURATION}%, 85%)`, + gray_300: `hsl(${BLUE_HUE}, ${GRAYSCALE_SATURATION}%, 75%)`, + gray_400: `hsl(${BLUE_HUE}, ${GRAYSCALE_SATURATION}%, 65%)`, + gray_500: `hsl(${BLUE_HUE}, ${GRAYSCALE_SATURATION}%, 55%)`, + gray_600: `hsl(${BLUE_HUE}, ${GRAYSCALE_SATURATION}%, 45%)`, + gray_700: `hsl(${BLUE_HUE}, ${GRAYSCALE_SATURATION}%, 35%)`, + gray_800: `hsl(${BLUE_HUE}, ${GRAYSCALE_SATURATION}%, 25%)`, + gray_900: `hsl(${BLUE_HUE}, ${GRAYSCALE_SATURATION}%, 15%)`, + gray_1000: `hsl(${BLUE_HUE}, ${GRAYSCALE_SATURATION}%, 5%)`, - blue_50: `hsl(${BLUE_HUE}, 99%, 98%)`, + blue_0: `hsl(${BLUE_HUE}, 99%, 100%)`, blue_100: `hsl(${BLUE_HUE}, 99%, 93%)`, blue_200: `hsl(${BLUE_HUE}, 99%, 83%)`, blue_300: `hsl(${BLUE_HUE}, 99%, 73%)`, @@ -26,31 +26,31 @@ export const color = { blue_700: `hsl(${BLUE_HUE}, 99%, 33%)`, blue_800: `hsl(${BLUE_HUE}, 99%, 23%)`, blue_900: `hsl(${BLUE_HUE}, 99%, 13%)`, - blue_950: `hsl(${BLUE_HUE}, 99%, 8%)`, + blue_1000: `hsl(${BLUE_HUE}, 99%, 8%)`, - green_50: `hsl(130, 60%, 95%)`, - green_100: `hsl(130, 60%, 90%)`, - green_200: `hsl(130, 60%, 80%)`, - green_300: `hsl(130, 60%, 70%)`, - green_400: `hsl(130, 60%, 60%)`, - green_500: `hsl(130, 60%, 50%)`, - green_600: `hsl(130, 60%, 40%)`, - green_700: `hsl(130, 60%, 30%)`, - green_800: `hsl(130, 60%, 20%)`, - green_900: `hsl(130, 60%, 10%)`, - green_950: `hsl(130, 60%, 5%)`, + green_0: `hsl(130, 60%, 100%)`, + green_100: `hsl(130, 60%, 95%)`, + green_200: `hsl(130, 60%, 85%)`, + green_300: `hsl(130, 60%, 75%)`, + green_400: `hsl(130, 60%, 65%)`, + green_500: `hsl(130, 60%, 55%)`, + green_600: `hsl(130, 60%, 45%)`, + green_700: `hsl(130, 60%, 35%)`, + green_800: `hsl(130, 60%, 25%)`, + green_900: `hsl(130, 60%, 15%)`, + green_1000: `hsl(130, 60%, 5%)`, - red_50: `hsl(349, 96%, 95%)`, - red_100: `hsl(349, 96%, 90%)`, - red_200: `hsl(349, 96%, 80%)`, - red_300: `hsl(349, 96%, 70%)`, - red_400: `hsl(349, 96%, 60%)`, - red_500: `hsl(349, 96%, 50%)`, - red_600: `hsl(349, 96%, 40%)`, - red_700: `hsl(349, 96%, 30%)`, - red_800: `hsl(349, 96%, 20%)`, - red_900: `hsl(349, 96%, 10%)`, - red_950: `hsl(349, 96%, 5%)`, + red_0: `hsl(349, 96%, 100%)`, + red_100: `hsl(349, 96%, 95%)`, + red_200: `hsl(349, 96%, 85%)`, + red_300: `hsl(349, 96%, 75%)`, + red_400: `hsl(349, 96%, 65%)`, + red_500: `hsl(349, 96%, 55%)`, + red_600: `hsl(349, 96%, 45%)`, + red_700: `hsl(349, 96%, 35%)`, + red_800: `hsl(349, 96%, 25%)`, + red_900: `hsl(349, 96%, 15%)`, + red_1000: `hsl(349, 96%, 5%)`, } export const space = { diff --git a/src/view/com/Button.tsx b/src/view/com/Button.tsx index 974fb64837..d1f70d4aeb 100644 --- a/src/view/com/Button.tsx +++ b/src/view/com/Button.tsx @@ -1,7 +1,7 @@ import React from 'react' import {Pressable, Text, PressableProps, TextProps} from 'react-native' import * as tokens from '#/alf/tokens' -import {useTheme, atoms} from '#/alf' +import {atoms} from '#/alf' export type ButtonType = | 'primary' @@ -34,18 +34,23 @@ export type ButtonProps = Omit & export type ButtonTextProps = TextProps & VariantProps export function Button({children, style, type, size, ...rest}: ButtonProps) { - const t = useTheme() const {baseStyles, hoverStyles} = React.useMemo(() => { const baseStyles = [] const hoverStyles = [] switch (type) { case 'primary': - baseStyles.push(t.atoms.backgroundColor.primary) + baseStyles.push({ + backgroundColor: tokens.color.blue_500, + }) break case 'secondary': - baseStyles.push(t.atoms.backgroundColor.l2) - hoverStyles.push(t.atoms.backgroundColor.l1) + baseStyles.push({ + backgroundColor: tokens.color.gray_200, + }) + hoverStyles.push({ + backgroundColor: tokens.color.gray_100, + }) break default: } @@ -53,18 +58,18 @@ export function Button({children, style, type, size, ...rest}: ButtonProps) { switch (size) { case 'large': baseStyles.push( - atoms.padding.py.m, - atoms.padding.px.xl, - atoms.radius.m, - atoms.flex.gap.s, + atoms.py_md, + atoms.px_xl, + atoms.rounded_md, + atoms.gap_sm, ) break case 'small': baseStyles.push( - atoms.padding.py.s, - atoms.padding.px.m, - atoms.radius.s, - atoms.flex.gap.xs, + atoms.py_sm, + atoms.px_md, + atoms.rounded_sm, + atoms.gap_xs, ) break default: @@ -74,7 +79,7 @@ export function Button({children, style, type, size, ...rest}: ButtonProps) { baseStyles, hoverStyles, } - }, [type, size, t]) + }, [type, size]) const [state, setState] = React.useState({ pressed: false, @@ -123,8 +128,8 @@ export function Button({children, style, type, size, ...rest}: ButtonProps) { [ - atoms.flex.row, - atoms.flex.alignCenter, + atoms.flex_row, + atoms.align_center, ...baseStyles, ...(state.hovered ? hoverStyles : []), typeof style === 'function' ? style(state) : style, @@ -155,7 +160,6 @@ export function ButtonText({ size, ...rest }: ButtonTextProps) { - const t = useTheme() const textStyles = React.useMemo(() => { const base = [] @@ -164,31 +168,33 @@ export function ButtonText({ base.push({color: tokens.color.white}) break case 'secondary': - base.push(t.atoms.color.l5) + base.push({ + color: tokens.color.gray_700, + }) break default: } switch (size) { case 'small': - base.push(atoms.font.s, {paddingBottom: 1}) + base.push(atoms.text_sm, {paddingBottom: 1}) break case 'large': - base.push(atoms.font.m, {paddingBottom: 1}) + base.push(atoms.text_md, {paddingBottom: 1}) break default: } return base - }, [type, size, t]) + }, [type, size]) return ( diff --git a/src/view/com/Typography.tsx b/src/view/com/Typography.tsx index ffb35e3cd4..6579c2e511 100644 --- a/src/view/com/Typography.tsx +++ b/src/view/com/Typography.tsx @@ -4,7 +4,7 @@ import {useTheme, atoms, web} from '#/alf' export function Text({style, ...rest}: TextProps) { const t = useTheme() - return + return } export function H1({style, ...rest}: TextProps) { @@ -18,7 +18,7 @@ export function H1({style, ...rest}: TextProps) { ) } @@ -34,7 +34,7 @@ export function H2({style, ...rest}: TextProps) { ) } @@ -50,7 +50,7 @@ export function H3({style, ...rest}: TextProps) { ) } @@ -66,7 +66,7 @@ export function H4({style, ...rest}: TextProps) { ) } @@ -82,7 +82,7 @@ export function H5({style, ...rest}: TextProps) { ) } @@ -98,7 +98,7 @@ export function H6({style, ...rest}: TextProps) { ) } diff --git a/src/view/screens/DebugNew.tsx b/src/view/screens/DebugNew.tsx index 99548435ca..0b7c5f03bc 100644 --- a/src/view/screens/DebugNew.tsx +++ b/src/view/screens/DebugNew.tsx @@ -4,6 +4,7 @@ import {CenteredView, ScrollView} from '#/view/com/util/Views' import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome' import {useSetColorMode} from '#/state/shell' +import * as tokens from '#/alf/tokens' import {atoms as a, useTheme, useBreakpoints, ThemeProvider as Alf} from '#/alf' import {Button, ButtonText} from '#/view/com/Button' import {Text, H1, H2, H3, H4, H5, H6} from '#/view/com/Typography' @@ -59,13 +60,83 @@ function ThemedSection() { const t = useTheme() return ( - -

- Colors (this theme is always light) + +

theme.atoms.text

+ +

+ theme.atoms.text_contrast_700

+ +

+ theme.atoms.text_contrast_500 +

+ + - - + + theme.bg + + + theme.bg_contrast_100 + + + + + theme.bg_contrast_200 + + + theme.bg_contrast_300 + + + + + theme.bg_positive + + + theme.bg_negative + ) @@ -80,54 +151,29 @@ export function DebugScreen() { - - - -

Colors

- - - - - - -

Spacing

- - - - xxs (2px) - - - - - - -

Typography

- - -

Heading 1

-

Heading 2

-

Heading 3

-

Heading 4

-
Heading 5
-
Heading 6
- - H1 Size Text - H2 Size Text - H3 Size Text - H4 Size Text - H5 Size Text - H6 Size Text - Very Small Size Text -
-
- + + + + +

Heading 1

+

Heading 2

+

Heading 3

+

Heading 4

+
Heading 5
+
Heading 6
+ + atoms.text_xxl + atoms.text_xl + atoms.text_lg + atoms.text_md + atoms.text_sm + atoms.text_xs + atoms.text_xxs -

Buttons

-
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

Spacing

+ + + + xxs (2px) + + + + + xs (4px) + + + + + sm (8px) + + + + + md (12px) + + + + + lg (18px) + + + + + xl (24px) + + + + + xxl (32px) + + + + + +