@tamagui/theme-base 1.0.1-beta.59 → 1.0.1-beta.60
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/themes.js +6 -6
- package/dist/cjs/themes.js.map +1 -1
- package/dist/esm/themes.js +6 -6
- package/dist/esm/themes.js.map +1 -1
- package/dist/jsx/themes.js +6 -6
- package/package.json +5 -4
- package/src/colorUtils.tsx +42 -0
- package/src/index.tsx +3 -0
- package/src/themes.tsx +379 -0
- package/src/tokens.tsx +195 -0
package/dist/cjs/themes.js
CHANGED
|
@@ -195,14 +195,14 @@ const themeColors = {
|
|
|
195
195
|
};
|
|
196
196
|
const lightThemes = createThemesFrom("light", themeCreator, {
|
|
197
197
|
backgrounds: themeColors.light,
|
|
198
|
-
backgroundStrong: "#
|
|
198
|
+
backgroundStrong: "#f2f2f2",
|
|
199
199
|
borderColors: themeColors.light.slice(2),
|
|
200
200
|
isLight: true
|
|
201
201
|
});
|
|
202
202
|
const darkThemes = createThemesFrom("dark", themeCreator, {
|
|
203
203
|
backgrounds: themeColors.dark,
|
|
204
204
|
colors: themeColors.light.slice(2),
|
|
205
|
-
backgroundStrong: "#
|
|
205
|
+
backgroundStrong: "#000",
|
|
206
206
|
isBase: true,
|
|
207
207
|
isLight: false,
|
|
208
208
|
shift: 1,
|
|
@@ -217,8 +217,8 @@ const baseThemes = __spreadProps(__spreadValues(__spreadProps(__spreadValues({},
|
|
|
217
217
|
light_active: makeActiveTheme(lightThemes.light),
|
|
218
218
|
light_Card: lightThemes.light,
|
|
219
219
|
light_Button: lightThemes.light,
|
|
220
|
-
light_SliderTrack: lightThemes.
|
|
221
|
-
light_SliderTrackActive: lightThemes.
|
|
220
|
+
light_SliderTrack: lightThemes.light_alt2,
|
|
221
|
+
light_SliderTrackActive: lightThemes.light_alt3,
|
|
222
222
|
light_Switch: lightThemes.light,
|
|
223
223
|
light_SwitchThumb: lightThemes.light_alt1,
|
|
224
224
|
light_DrawerFrame: lightThemes.light_alt1
|
|
@@ -226,9 +226,9 @@ const baseThemes = __spreadProps(__spreadValues(__spreadProps(__spreadValues({},
|
|
|
226
226
|
dark,
|
|
227
227
|
dark_active: makeActiveTheme(darkThemes.dark),
|
|
228
228
|
dark_Card: darkThemes.dark,
|
|
229
|
-
dark_DrawerFrame: darkThemes.
|
|
229
|
+
dark_DrawerFrame: darkThemes.dark_alt2,
|
|
230
230
|
dark_SliderTrack: darkThemes.dark_darker,
|
|
231
|
-
dark_SliderTrackActive: darkThemes.
|
|
231
|
+
dark_SliderTrackActive: darkThemes.dark_alt3,
|
|
232
232
|
dark_Switch: darkThemes.dark_darker,
|
|
233
233
|
dark_SwitchThumb: darkThemes.dark_alt1,
|
|
234
234
|
dark_Button: darkThemes.dark_alt1
|
package/dist/cjs/themes.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/themes.tsx"],
|
|
4
|
-
"sourcesContent": ["import { Variable, createTheme, createVariable, getVariableValue } from '@tamagui/core'\n\nimport { setColorAlpha } from './colorUtils'\nimport { darkColors, lightColors, tokens } from './tokens'\n\nconst { color } = tokens\n\n// spaghetti ahead\n\ntype ThemeCreatorProps = {\n shift?: number\n backgrounds: (string | Variable)[]\n backgroundStrong?: string | Variable\n borderColors?: (string | Variable)[]\n colors?: (string | Variable)[]\n offsets?: {\n color?: number[] | null\n background?: number[] | null\n borderColor?: number[] | null\n }\n isLight?: boolean\n isBase?: boolean\n}\n\n// helpers\n\nconst alternates = [1, 2, 3, 4] as const\nconst alts = [1, 2, 3] as const\ntype AltKeys = 1 | 2 | 3\ntype AltName<Name extends string, Keys extends string | number> = `${Name}_alt${Keys}`\ntype ThemeCreator<A = any> = (str: number, props: ThemeCreatorProps) => A\n\nfunction createThemesFrom<Name extends string, GetTheme extends ThemeCreator = ThemeCreator>(\n name: Name,\n getTheme: GetTheme,\n props: ThemeCreatorProps\n): {\n [key in `${Name}_alt${AltKeys}` | `${Name}` | `${Name}_darker`]: GetTheme extends ThemeCreator<\n infer Theme\n >\n ? Theme\n : never\n} {\n const { shift = 0 } = props\n const theme = getTheme(0 + shift, props)\n let themeEntries: any[] = [[name, theme]]\n\n // generate alternates (for use in other themes), but keep just alts\n const altThemes: any[] = alternates.map((alt) => [\n `${name}_alt${alt}`,\n getTheme(alt + (props.isLight ? 0 : 0) + shift, props),\n ])\n const altThemes2: any[] = alternates.map((alt) => [\n `${name}_alt${alt}`,\n getTheme(alt + shift, props),\n ])\n const altButtonThemes: any[] = alternates.map((_, i) => {\n const [bName, bTheme] = [altThemes2[i][0], (altThemes2[i + 1] || altThemes2[i])[1]]\n return [`${bName}_Button` as any, bTheme]\n })\n // add these after alts since we rely on positioning\n const darkerTheme = getTheme(Math.max(0, shift + (props.isLight ? 1 : -1)), props)\n const activeTheme = makeActiveTheme(theme)\n\n // TODO can be de-duped\n const inverted = altThemes.map(([_name, theme]) => {\n return {\n ...theme,\n background: theme.color,\n backgroundHover: theme.colorHover,\n backgroundFocus: theme.colorFocus,\n backgroundPress: theme.colorPress,\n color: theme.background,\n colorHover: theme.backgroundHover,\n colorFocus: theme.backgroundFocus,\n colorPress: theme.backgroundPress,\n }\n })\n\n themeEntries = [\n ...themeEntries,\n // keep just alts\n ...altThemes.slice(0, alts.length),\n ...altButtonThemes.slice(0, alts.length),\n [`${name}_Button`, altThemes2[1][1]],\n [`${name}_DrawerFrame`, altThemes2[1][1]],\n [`${name}_SliderTrack`, altThemes[1][1]],\n [`${name}_SliderTrackActive`, altThemes[3][1]],\n [`${name}_SliderThumb`, inverted[2]],\n [`${name}_Progress`, altThemes[2][1]],\n [`${name}_ProgressIndicator`, inverted[2]],\n [`${name}_Switch`, altThemes[0][1]],\n [`${name}_SwitchThumb`, inverted[2]],\n [`${name}_TooltipArrow`, altThemes[1][1]],\n [`${name}_TooltipContent`, altThemes[1][1]],\n [`${name}_darker`, darkerTheme],\n [`${name}_active`, activeTheme],\n ]\n const themes = Object.fromEntries(themeEntries)\n // if (props.isLight) {\n // console.log('themes', themes)\n // }\n return themes as any\n}\n\nconst themeCreator = (\n str = 1,\n {\n backgrounds,\n isLight = true,\n isBase = false,\n colors = [...backgrounds].reverse(),\n borderColors = isLight ? colors : backgrounds,\n backgroundStrong,\n offsets: offsetsProp,\n }: ThemeCreatorProps\n) => {\n const offsets = {\n borderColor: offsetsProp?.borderColor ?? offsetsProp?.background ?? [0, 0, 0, 0],\n background: offsetsProp?.background ?? [0, 0, 0, 0],\n color: offsetsProp?.color ?? [0, 0, 0, 0],\n }\n const darkColors = isLight ? colors : backgrounds\n const lighterDir = isLight ? -1 : 1\n const darkerDir = -lighterDir\n const strongerDir = isLight ? darkerDir : lighterDir\n const softerDir = -strongerDir\n const get = (arr: any[], index: number, name = 'background') => {\n return arr[Math.max(0, Math.min(index + (offsets[name][str] || 0), arr.length - 1))]\n }\n\n const colorTranslucent = setColorAlpha(getVariableValue(get(colors, 0 + str, 'color')), 0.5)\n\n let theme = {\n background: get(backgrounds, str),\n backgroundStrong: backgroundStrong || get(backgrounds, str + strongerDir * 2),\n backgroundSoft: get(backgrounds, str + softerDir * 2),\n backgroundHover: get(backgrounds, str + lighterDir),\n backgroundPress: get(backgrounds, str + darkerDir),\n backgroundFocus: get(backgrounds, str + darkerDir * 2),\n backgroundTransparent: color.grayA1Light,\n color: get(colors, 0 + str, 'color'),\n colorHover: get(colors, 1 + str, 'color'),\n colorPress: get(colors, 2 + str, 'color'),\n colorFocus: get(colors, 3 + str, 'color'),\n colorTranslucent,\n colorMid: (isLight ? colors : backgrounds)[Math.floor(colors.length / 2)],\n shadowColor: isLight ? color.grayA2Light : color.grayA8Light,\n shadowColorHover: darkColors[!isLight ? 1 : 8],\n shadowColorPress: darkColors[!isLight ? 1 : 8],\n shadowColorFocus: darkColors[!isLight ? 1 : 8],\n borderColor: null as any as string | Variable,\n borderColorHover: null as any as string | Variable,\n borderColorPress: null as any as string | Variable,\n borderColorFocus: null as any as string | Variable,\n }\n\n if (isBase) {\n Object.assign(theme, {\n borderColor: isLight\n ? get(colors, 8 - str, 'borderColor')\n : get(backgrounds, 2 + str, 'borderColor'),\n borderColorHover: isLight\n ? get(colors, 6 - str, 'borderColor')\n : get(backgrounds, 3 + str, 'borderColor'),\n borderColorPress: isLight\n ? get(colors, 5 - str, 'borderColor')\n : get(backgrounds, 1 + str, 'borderColor'),\n borderColorFocus: isLight\n ? get(colors, 4 - str, 'borderColor')\n : get(backgrounds, 3 + str, 'borderColor'),\n })\n } else {\n Object.assign(theme, {\n borderColor: get(borderColors, 1 + strongerDir, 'borderColor'),\n borderColorHover: get(borderColors, 2 + strongerDir, 'borderColor'),\n borderColorPress: get(borderColors, 3 + strongerDir, 'borderColor'),\n borderColorFocus: get(borderColors, 4 + strongerDir, 'borderColor'),\n })\n }\n\n return theme\n}\n\nconst themeColors = {\n light: [\n '#fff',\n '#f4f4f4',\n color.gray1Light,\n color.gray2Light,\n color.gray3Light,\n color.gray4Light,\n color.gray5Light,\n color.gray6Light,\n color.gray7Light,\n color.gray8Light,\n color.gray9Light,\n color.gray10Light,\n color.gray11Light,\n color.gray12Light,\n ],\n dark: [\n '#111111',\n '#151515',\n '#191919',\n '#232323',\n '#282828',\n '#323232',\n '#383838',\n '#424242',\n '#494949',\n '#545454',\n '#626262',\n '#777777',\n ],\n}\n\nconst lightThemes = createThemesFrom('light', themeCreator, {\n backgrounds: themeColors.light,\n // isBase: true,\n backgroundStrong: '#fafafa',\n borderColors: themeColors.light.slice(2),\n isLight: true,\n})\n\nconst darkThemes = createThemesFrom('dark', themeCreator, {\n backgrounds: themeColors.dark,\n colors: themeColors.light.slice(2),\n backgroundStrong: '#111',\n isBase: true,\n isLight: false,\n shift: 1,\n offsets: {\n color: [0, 4, 5, 5, 5, 5],\n },\n})\n\nconst light = createTheme({\n ...lightColors,\n ...lightThemes.light,\n})\n\nconst dark = createTheme({\n ...darkColors,\n ...darkThemes.dark,\n})\n\ntype ThemeBase = {\n [Key in keyof typeof dark]: string\n}\n\nconst baseThemes = {\n // light\n ...lightThemes,\n light,\n light_active: makeActiveTheme(lightThemes.light),\n light_Card: lightThemes.light,\n light_Button: lightThemes.light,\n light_SliderTrack: lightThemes.light_alt1,\n light_SliderTrackActive: lightThemes.light_alt2,\n light_Switch: lightThemes.light,\n light_SwitchThumb: lightThemes.light_alt1,\n light_DrawerFrame: lightThemes.light_alt1,\n\n // dark\n ...darkThemes,\n dark,\n dark_active: makeActiveTheme(darkThemes.dark),\n dark_Card: darkThemes.dark,\n dark_DrawerFrame: darkThemes.dark_alt1,\n dark_SliderTrack: darkThemes.dark_darker,\n dark_SliderTrackActive: darkThemes.dark_alt1,\n dark_Switch: darkThemes.dark_darker,\n dark_SwitchThumb: darkThemes.dark_alt1,\n dark_Button: darkThemes.dark_alt1,\n}\n\nfunction makeActiveTheme(theme: any) {\n const res = { ...theme }\n res.backgroundHover = res.background\n res.colorHover = res.color\n res.backgroundPress = res.background\n res.colorPress = res.color\n return res\n}\n\nconst darkEntries = Object.entries(dark)\nconst lightEntries = Object.entries(light)\nfunction findColors(prefix: string, dark = false): ThemeBase {\n return Object.fromEntries(\n (dark ? darkEntries : lightEntries).filter(([k]) => k.startsWith(prefix))\n ) as any\n}\n\nexport const colorSchemes = [\n { name: 'blue', colors: findColors('blue'), darkColors: findColors('blue', true) },\n { name: 'gray', colors: findColors('gray'), darkColors: findColors('gray', true) },\n { name: 'green', colors: findColors('green'), darkColors: findColors('green', true) },\n { name: 'orange', colors: findColors('orange'), darkColors: findColors('orange', true) },\n { name: 'pink', colors: findColors('pink'), darkColors: findColors('pink', true) },\n { name: 'purple', colors: findColors('purple'), darkColors: findColors('purple', true) },\n { name: 'red', colors: findColors('red'), darkColors: findColors('red', true) },\n { name: 'yellow', colors: findColors('yellow'), darkColors: findColors('yellow', true) },\n { name: 'teal', colors: findColors('teal'), darkColors: findColors('teal', true) },\n] as const\n\nexport type ColorNames = typeof colorSchemes[number]['name']\n\n// nice and flat\nexport const colorNames: ColorNames[] = [\n 'blue',\n 'gray',\n 'green',\n 'orange',\n 'pink',\n 'purple',\n 'red',\n 'yellow',\n 'teal',\n]\n\ntype ColorThemeNames =\n | ColorNames\n | AltName<`light_${ColorNames}`, AltKeys>\n | AltName<`dark_${ColorNames}`, AltKeys>\n\nconst colorThemeEntries = colorSchemes.flatMap(({ name, colors, darkColors }) => {\n const [altLightThemes, altDarkThemes] = [\n { colors: darkColors, backgrounds: colors },\n { colors, backgrounds: darkColors },\n ].map((props, i) => {\n const isLight = i === 0\n const colorsBase = Object.values(props.colors).slice(2)\n const [backgrounds, colors] = [\n Object.values(props.backgrounds),\n isLight ? colorsBase : [colorsBase[0], '#ccc', ...colorsBase.slice(1)],\n ] as const\n\n const scheme = isLight ? 'light' : 'dark'\n const shift = isLight ? 0 : 1\n\n // if (!isLight) {\n // const [_, h, sp, lp] = backgrounds[0].match(/hsl\\(([0-9\\.]+), ([0-9\\.]+)\\%, ([0-9\\.]+)\\%\\)/)!\n // backgrounds.unshift(`hsl(${h}, ${sp}%, ${parseFloat(lp) / 2}%)`)\n // }\n\n const themeWithAlts = createThemesFrom(name, themeCreator, {\n colors,\n backgrounds,\n borderColors: backgrounds,\n isLight,\n shift,\n isBase: false,\n offsets: {\n background: isLight ? [2, 2, 2, 2, 2, 2] : null,\n borderColor: isLight ? [2, 2, 2, 3, 2] : null,\n color: isLight ? [0, 0, -1, -2, -3, -3, -4] : [-1, -1, -1, -1, -1, -1],\n },\n })\n\n return Object.entries(themeWithAlts).map(([k, v]) => [`${scheme}_${k}`, v])\n })\n return [...altLightThemes, ...altDarkThemes]\n})\n\ntype MyThemeBase = typeof baseThemes['light_alt1']\n\nconst colorThemes: {\n [key in ColorThemeNames]: MyThemeBase\n} = Object.fromEntries(colorThemeEntries) as any\n\nconst allThemes = {\n ...baseThemes,\n ...colorThemes,\n} as const\n\nexport const themes: {\n [key in keyof typeof allThemes]: typeof baseThemes['light']\n} = allThemes as any\n"],
|
|
4
|
+
"sourcesContent": ["import { Variable, createTheme, createVariable, getVariableValue } from '@tamagui/core'\n\nimport { setColorAlpha } from './colorUtils'\nimport { darkColors, lightColors, tokens } from './tokens'\n\nconst { color } = tokens\n\n// spaghetti ahead\n\ntype ThemeCreatorProps = {\n shift?: number\n backgrounds: (string | Variable)[]\n backgroundStrong?: string | Variable\n borderColors?: (string | Variable)[]\n colors?: (string | Variable)[]\n offsets?: {\n color?: number[] | null\n background?: number[] | null\n borderColor?: number[] | null\n }\n isLight?: boolean\n isBase?: boolean\n}\n\n// helpers\n\nconst alternates = [1, 2, 3, 4] as const\nconst alts = [1, 2, 3] as const\ntype AltKeys = 1 | 2 | 3\ntype AltName<Name extends string, Keys extends string | number> = `${Name}_alt${Keys}`\ntype ThemeCreator<A = any> = (str: number, props: ThemeCreatorProps) => A\n\nfunction createThemesFrom<Name extends string, GetTheme extends ThemeCreator = ThemeCreator>(\n name: Name,\n getTheme: GetTheme,\n props: ThemeCreatorProps\n): {\n [key in `${Name}_alt${AltKeys}` | `${Name}` | `${Name}_darker`]: GetTheme extends ThemeCreator<\n infer Theme\n >\n ? Theme\n : never\n} {\n const { shift = 0 } = props\n const theme = getTheme(0 + shift, props)\n let themeEntries: any[] = [[name, theme]]\n\n // generate alternates (for use in other themes), but keep just alts\n const altThemes: any[] = alternates.map((alt) => [\n `${name}_alt${alt}`,\n getTheme(alt + (props.isLight ? 0 : 0) + shift, props),\n ])\n const altThemes2: any[] = alternates.map((alt) => [\n `${name}_alt${alt}`,\n getTheme(alt + shift, props),\n ])\n const altButtonThemes: any[] = alternates.map((_, i) => {\n const [bName, bTheme] = [altThemes2[i][0], (altThemes2[i + 1] || altThemes2[i])[1]]\n return [`${bName}_Button` as any, bTheme]\n })\n // add these after alts since we rely on positioning\n const darkerTheme = getTheme(Math.max(0, shift + (props.isLight ? 1 : -1)), props)\n const activeTheme = makeActiveTheme(theme)\n\n // TODO can be de-duped\n const inverted = altThemes.map(([_name, theme]) => {\n return {\n ...theme,\n background: theme.color,\n backgroundHover: theme.colorHover,\n backgroundFocus: theme.colorFocus,\n backgroundPress: theme.colorPress,\n color: theme.background,\n colorHover: theme.backgroundHover,\n colorFocus: theme.backgroundFocus,\n colorPress: theme.backgroundPress,\n }\n })\n\n themeEntries = [\n ...themeEntries,\n // keep just alts\n ...altThemes.slice(0, alts.length),\n ...altButtonThemes.slice(0, alts.length),\n [`${name}_Button`, altThemes2[1][1]],\n [`${name}_DrawerFrame`, altThemes2[1][1]],\n [`${name}_SliderTrack`, altThemes[1][1]],\n [`${name}_SliderTrackActive`, altThemes[3][1]],\n [`${name}_SliderThumb`, inverted[2]],\n [`${name}_Progress`, altThemes[2][1]],\n [`${name}_ProgressIndicator`, inverted[2]],\n [`${name}_Switch`, altThemes[0][1]],\n [`${name}_SwitchThumb`, inverted[2]],\n [`${name}_TooltipArrow`, altThemes[1][1]],\n [`${name}_TooltipContent`, altThemes[1][1]],\n [`${name}_darker`, darkerTheme],\n [`${name}_active`, activeTheme],\n ]\n const themes = Object.fromEntries(themeEntries)\n // if (props.isLight) {\n // console.log('themes', themes)\n // }\n return themes as any\n}\n\nconst themeCreator = (\n str = 1,\n {\n backgrounds,\n isLight = true,\n isBase = false,\n colors = [...backgrounds].reverse(),\n borderColors = isLight ? colors : backgrounds,\n backgroundStrong,\n offsets: offsetsProp,\n }: ThemeCreatorProps\n) => {\n const offsets = {\n borderColor: offsetsProp?.borderColor ?? offsetsProp?.background ?? [0, 0, 0, 0],\n background: offsetsProp?.background ?? [0, 0, 0, 0],\n color: offsetsProp?.color ?? [0, 0, 0, 0],\n }\n const darkColors = isLight ? colors : backgrounds\n const lighterDir = isLight ? -1 : 1\n const darkerDir = -lighterDir\n const strongerDir = isLight ? darkerDir : lighterDir\n const softerDir = -strongerDir\n const get = (arr: any[], index: number, name = 'background') => {\n return arr[Math.max(0, Math.min(index + (offsets[name][str] || 0), arr.length - 1))]\n }\n\n const colorTranslucent = setColorAlpha(getVariableValue(get(colors, 0 + str, 'color')), 0.5)\n\n let theme = {\n background: get(backgrounds, str),\n backgroundStrong: backgroundStrong || get(backgrounds, str + strongerDir * 2),\n backgroundSoft: get(backgrounds, str + softerDir * 2),\n backgroundHover: get(backgrounds, str + lighterDir),\n backgroundPress: get(backgrounds, str + darkerDir),\n backgroundFocus: get(backgrounds, str + darkerDir * 2),\n backgroundTransparent: color.grayA1Light,\n color: get(colors, 0 + str, 'color'),\n colorHover: get(colors, 1 + str, 'color'),\n colorPress: get(colors, 2 + str, 'color'),\n colorFocus: get(colors, 3 + str, 'color'),\n colorTranslucent,\n colorMid: (isLight ? colors : backgrounds)[Math.floor(colors.length / 2)],\n shadowColor: isLight ? color.grayA2Light : color.grayA8Light,\n shadowColorHover: darkColors[!isLight ? 1 : 8],\n shadowColorPress: darkColors[!isLight ? 1 : 8],\n shadowColorFocus: darkColors[!isLight ? 1 : 8],\n borderColor: null as any as string | Variable,\n borderColorHover: null as any as string | Variable,\n borderColorPress: null as any as string | Variable,\n borderColorFocus: null as any as string | Variable,\n }\n\n if (isBase) {\n Object.assign(theme, {\n borderColor: isLight\n ? get(colors, 8 - str, 'borderColor')\n : get(backgrounds, 2 + str, 'borderColor'),\n borderColorHover: isLight\n ? get(colors, 6 - str, 'borderColor')\n : get(backgrounds, 3 + str, 'borderColor'),\n borderColorPress: isLight\n ? get(colors, 5 - str, 'borderColor')\n : get(backgrounds, 1 + str, 'borderColor'),\n borderColorFocus: isLight\n ? get(colors, 4 - str, 'borderColor')\n : get(backgrounds, 3 + str, 'borderColor'),\n })\n } else {\n Object.assign(theme, {\n borderColor: get(borderColors, 1 + strongerDir, 'borderColor'),\n borderColorHover: get(borderColors, 2 + strongerDir, 'borderColor'),\n borderColorPress: get(borderColors, 3 + strongerDir, 'borderColor'),\n borderColorFocus: get(borderColors, 4 + strongerDir, 'borderColor'),\n })\n }\n\n return theme\n}\n\nconst themeColors = {\n light: [\n '#fff',\n '#f4f4f4',\n color.gray1Light,\n color.gray2Light,\n color.gray3Light,\n color.gray4Light,\n color.gray5Light,\n color.gray6Light,\n color.gray7Light,\n color.gray8Light,\n color.gray9Light,\n color.gray10Light,\n color.gray11Light,\n color.gray12Light,\n ],\n dark: [\n '#111111',\n '#151515',\n '#191919',\n '#232323',\n '#282828',\n '#323232',\n '#383838',\n '#424242',\n '#494949',\n '#545454',\n '#626262',\n '#777777',\n ],\n}\n\nconst lightThemes = createThemesFrom('light', themeCreator, {\n backgrounds: themeColors.light,\n // isBase: true,\n backgroundStrong: '#f2f2f2', // matches iOS\n borderColors: themeColors.light.slice(2),\n isLight: true,\n})\n\nconst darkThemes = createThemesFrom('dark', themeCreator, {\n backgrounds: themeColors.dark,\n colors: themeColors.light.slice(2),\n backgroundStrong: '#000',\n isBase: true,\n isLight: false,\n shift: 1,\n offsets: {\n color: [0, 4, 5, 5, 5, 5],\n },\n})\n\nconst light = createTheme({\n ...lightColors,\n ...lightThemes.light,\n})\n\nconst dark = createTheme({\n ...darkColors,\n ...darkThemes.dark,\n})\n\ntype ThemeBase = {\n [Key in keyof typeof dark]: string\n}\n\nconst baseThemes = {\n // light\n ...lightThemes,\n light,\n light_active: makeActiveTheme(lightThemes.light),\n light_Card: lightThemes.light,\n light_Button: lightThemes.light,\n light_SliderTrack: lightThemes.light_alt2,\n light_SliderTrackActive: lightThemes.light_alt3,\n light_Switch: lightThemes.light,\n light_SwitchThumb: lightThemes.light_alt1,\n light_DrawerFrame: lightThemes.light_alt1,\n\n // dark\n ...darkThemes,\n dark,\n dark_active: makeActiveTheme(darkThemes.dark),\n dark_Card: darkThemes.dark,\n dark_DrawerFrame: darkThemes.dark_alt2,\n dark_SliderTrack: darkThemes.dark_darker,\n dark_SliderTrackActive: darkThemes.dark_alt3,\n dark_Switch: darkThemes.dark_darker,\n dark_SwitchThumb: darkThemes.dark_alt1,\n dark_Button: darkThemes.dark_alt1,\n}\n\nfunction makeActiveTheme(theme: any) {\n const res = { ...theme }\n res.backgroundHover = res.background\n res.colorHover = res.color\n res.backgroundPress = res.background\n res.colorPress = res.color\n return res\n}\n\nconst darkEntries = Object.entries(dark)\nconst lightEntries = Object.entries(light)\nfunction findColors(prefix: string, dark = false): ThemeBase {\n return Object.fromEntries(\n (dark ? darkEntries : lightEntries).filter(([k]) => k.startsWith(prefix))\n ) as any\n}\n\nexport const colorSchemes = [\n { name: 'blue', colors: findColors('blue'), darkColors: findColors('blue', true) },\n { name: 'gray', colors: findColors('gray'), darkColors: findColors('gray', true) },\n { name: 'green', colors: findColors('green'), darkColors: findColors('green', true) },\n { name: 'orange', colors: findColors('orange'), darkColors: findColors('orange', true) },\n { name: 'pink', colors: findColors('pink'), darkColors: findColors('pink', true) },\n { name: 'purple', colors: findColors('purple'), darkColors: findColors('purple', true) },\n { name: 'red', colors: findColors('red'), darkColors: findColors('red', true) },\n { name: 'yellow', colors: findColors('yellow'), darkColors: findColors('yellow', true) },\n { name: 'teal', colors: findColors('teal'), darkColors: findColors('teal', true) },\n] as const\n\nexport type ColorNames = typeof colorSchemes[number]['name']\n\n// nice and flat\nexport const colorNames: ColorNames[] = [\n 'blue',\n 'gray',\n 'green',\n 'orange',\n 'pink',\n 'purple',\n 'red',\n 'yellow',\n 'teal',\n]\n\ntype ColorThemeNames =\n | ColorNames\n | AltName<`light_${ColorNames}`, AltKeys>\n | AltName<`dark_${ColorNames}`, AltKeys>\n\nconst colorThemeEntries = colorSchemes.flatMap(({ name, colors, darkColors }) => {\n const [altLightThemes, altDarkThemes] = [\n { colors: darkColors, backgrounds: colors },\n { colors, backgrounds: darkColors },\n ].map((props, i) => {\n const isLight = i === 0\n const colorsBase = Object.values(props.colors).slice(2)\n const [backgrounds, colors] = [\n Object.values(props.backgrounds),\n isLight ? colorsBase : [colorsBase[0], '#ccc', ...colorsBase.slice(1)],\n ] as const\n\n const scheme = isLight ? 'light' : 'dark'\n const shift = isLight ? 0 : 1\n\n // if (!isLight) {\n // const [_, h, sp, lp] = backgrounds[0].match(/hsl\\(([0-9\\.]+), ([0-9\\.]+)\\%, ([0-9\\.]+)\\%\\)/)!\n // backgrounds.unshift(`hsl(${h}, ${sp}%, ${parseFloat(lp) / 2}%)`)\n // }\n\n const themeWithAlts = createThemesFrom(name, themeCreator, {\n colors,\n backgrounds,\n borderColors: backgrounds,\n isLight,\n shift,\n isBase: false,\n offsets: {\n background: isLight ? [2, 2, 2, 2, 2, 2] : null,\n borderColor: isLight ? [2, 2, 2, 3, 2] : null,\n color: isLight ? [0, 0, -1, -2, -3, -3, -4] : [-1, -1, -1, -1, -1, -1],\n },\n })\n\n return Object.entries(themeWithAlts).map(([k, v]) => [`${scheme}_${k}`, v])\n })\n return [...altLightThemes, ...altDarkThemes]\n})\n\ntype MyThemeBase = typeof baseThemes['light_alt1']\n\nconst colorThemes: {\n [key in ColorThemeNames]: MyThemeBase\n} = Object.fromEntries(colorThemeEntries) as any\n\nconst allThemes = {\n ...baseThemes,\n ...colorThemes,\n} as const\n\nexport const themes: {\n [key in keyof typeof allThemes]: typeof baseThemes['light']\n} = allThemes as any\n"],
|
|
5
5
|
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAwE;AAExE,wBAA8B;AAC9B,oBAAgD;AAEhD,MAAM,EAAE,UAAU;AAqBlB,MAAM,aAAa,CAAC,GAAG,GAAG,GAAG,CAAC;AAC9B,MAAM,OAAO,CAAC,GAAG,GAAG,CAAC;AAKrB,0BACE,MACA,UACA,OAOA;AACA,QAAM,EAAE,QAAQ,MAAM;AACtB,QAAM,QAAQ,SAAS,IAAI,OAAO,KAAK;AACvC,MAAI,eAAsB,CAAC,CAAC,MAAM,KAAK,CAAC;AAGxC,QAAM,YAAmB,WAAW,IAAI,CAAC,QAAQ;AAAA,IAC/C,GAAG,WAAW;AAAA,IACd,SAAS,MAAO,OAAM,UAAU,IAAI,KAAK,OAAO,KAAK;AAAA,EACvD,CAAC;AACD,QAAM,aAAoB,WAAW,IAAI,CAAC,QAAQ;AAAA,IA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AAQ;AAAA,MACR,SAAS;AAAA,QACP,YAAY,UAAU,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC,IAAI;AAAA,QAC3C,aAAa,UAAU,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,IAAI;AAAA,QACzC,OAAO,UAAU,CAAC,GAAG,GAAG,IAAI,IAAI,IAAI,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,IAAI,IAAI,IAAI,EAAE;AAAA,MACvE;AAAA,IACF,CAAC;AAED,WAAO,OAAO,QAAQ,aAAa,EAAE,IAAI,CAAC,CAAC,GAAG,OAAO,CAAC,GAAG,UAAU,KAAK,CAAC,CAAC;AAAA,EAC5E,CAAC;AACD,SAAO,CAAC,GAAG,gBAAgB,GAAG,aAAa;AAC7C,CAAC;AAID,MAAM,cAEF,OAAO,YAAY,iBAAiB;AAExC,MAAM,YAAY,kCACb,aACA;AAGE,MAAM,SAET;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/esm/themes.js
CHANGED
|
@@ -157,14 +157,14 @@ const themeColors = {
|
|
|
157
157
|
};
|
|
158
158
|
const lightThemes = createThemesFrom("light", themeCreator, {
|
|
159
159
|
backgrounds: themeColors.light,
|
|
160
|
-
backgroundStrong: "#
|
|
160
|
+
backgroundStrong: "#f2f2f2",
|
|
161
161
|
borderColors: themeColors.light.slice(2),
|
|
162
162
|
isLight: true
|
|
163
163
|
});
|
|
164
164
|
const darkThemes = createThemesFrom("dark", themeCreator, {
|
|
165
165
|
backgrounds: themeColors.dark,
|
|
166
166
|
colors: themeColors.light.slice(2),
|
|
167
|
-
backgroundStrong: "#
|
|
167
|
+
backgroundStrong: "#000",
|
|
168
168
|
isBase: true,
|
|
169
169
|
isLight: false,
|
|
170
170
|
shift: 1,
|
|
@@ -186,8 +186,8 @@ const baseThemes = {
|
|
|
186
186
|
light_active: makeActiveTheme(lightThemes.light),
|
|
187
187
|
light_Card: lightThemes.light,
|
|
188
188
|
light_Button: lightThemes.light,
|
|
189
|
-
light_SliderTrack: lightThemes.
|
|
190
|
-
light_SliderTrackActive: lightThemes.
|
|
189
|
+
light_SliderTrack: lightThemes.light_alt2,
|
|
190
|
+
light_SliderTrackActive: lightThemes.light_alt3,
|
|
191
191
|
light_Switch: lightThemes.light,
|
|
192
192
|
light_SwitchThumb: lightThemes.light_alt1,
|
|
193
193
|
light_DrawerFrame: lightThemes.light_alt1,
|
|
@@ -195,9 +195,9 @@ const baseThemes = {
|
|
|
195
195
|
dark,
|
|
196
196
|
dark_active: makeActiveTheme(darkThemes.dark),
|
|
197
197
|
dark_Card: darkThemes.dark,
|
|
198
|
-
dark_DrawerFrame: darkThemes.
|
|
198
|
+
dark_DrawerFrame: darkThemes.dark_alt2,
|
|
199
199
|
dark_SliderTrack: darkThemes.dark_darker,
|
|
200
|
-
dark_SliderTrackActive: darkThemes.
|
|
200
|
+
dark_SliderTrackActive: darkThemes.dark_alt3,
|
|
201
201
|
dark_Switch: darkThemes.dark_darker,
|
|
202
202
|
dark_SwitchThumb: darkThemes.dark_alt1,
|
|
203
203
|
dark_Button: darkThemes.dark_alt1
|
package/dist/esm/themes.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/themes.tsx"],
|
|
4
|
-
"sourcesContent": ["import { Variable, createTheme, createVariable, getVariableValue } from '@tamagui/core'\n\nimport { setColorAlpha } from './colorUtils'\nimport { darkColors, lightColors, tokens } from './tokens'\n\nconst { color } = tokens\n\n// spaghetti ahead\n\ntype ThemeCreatorProps = {\n shift?: number\n backgrounds: (string | Variable)[]\n backgroundStrong?: string | Variable\n borderColors?: (string | Variable)[]\n colors?: (string | Variable)[]\n offsets?: {\n color?: number[] | null\n background?: number[] | null\n borderColor?: number[] | null\n }\n isLight?: boolean\n isBase?: boolean\n}\n\n// helpers\n\nconst alternates = [1, 2, 3, 4] as const\nconst alts = [1, 2, 3] as const\ntype AltKeys = 1 | 2 | 3\ntype AltName<Name extends string, Keys extends string | number> = `${Name}_alt${Keys}`\ntype ThemeCreator<A = any> = (str: number, props: ThemeCreatorProps) => A\n\nfunction createThemesFrom<Name extends string, GetTheme extends ThemeCreator = ThemeCreator>(\n name: Name,\n getTheme: GetTheme,\n props: ThemeCreatorProps\n): {\n [key in `${Name}_alt${AltKeys}` | `${Name}` | `${Name}_darker`]: GetTheme extends ThemeCreator<\n infer Theme\n >\n ? Theme\n : never\n} {\n const { shift = 0 } = props\n const theme = getTheme(0 + shift, props)\n let themeEntries: any[] = [[name, theme]]\n\n // generate alternates (for use in other themes), but keep just alts\n const altThemes: any[] = alternates.map((alt) => [\n `${name}_alt${alt}`,\n getTheme(alt + (props.isLight ? 0 : 0) + shift, props),\n ])\n const altThemes2: any[] = alternates.map((alt) => [\n `${name}_alt${alt}`,\n getTheme(alt + shift, props),\n ])\n const altButtonThemes: any[] = alternates.map((_, i) => {\n const [bName, bTheme] = [altThemes2[i][0], (altThemes2[i + 1] || altThemes2[i])[1]]\n return [`${bName}_Button` as any, bTheme]\n })\n // add these after alts since we rely on positioning\n const darkerTheme = getTheme(Math.max(0, shift + (props.isLight ? 1 : -1)), props)\n const activeTheme = makeActiveTheme(theme)\n\n // TODO can be de-duped\n const inverted = altThemes.map(([_name, theme]) => {\n return {\n ...theme,\n background: theme.color,\n backgroundHover: theme.colorHover,\n backgroundFocus: theme.colorFocus,\n backgroundPress: theme.colorPress,\n color: theme.background,\n colorHover: theme.backgroundHover,\n colorFocus: theme.backgroundFocus,\n colorPress: theme.backgroundPress,\n }\n })\n\n themeEntries = [\n ...themeEntries,\n // keep just alts\n ...altThemes.slice(0, alts.length),\n ...altButtonThemes.slice(0, alts.length),\n [`${name}_Button`, altThemes2[1][1]],\n [`${name}_DrawerFrame`, altThemes2[1][1]],\n [`${name}_SliderTrack`, altThemes[1][1]],\n [`${name}_SliderTrackActive`, altThemes[3][1]],\n [`${name}_SliderThumb`, inverted[2]],\n [`${name}_Progress`, altThemes[2][1]],\n [`${name}_ProgressIndicator`, inverted[2]],\n [`${name}_Switch`, altThemes[0][1]],\n [`${name}_SwitchThumb`, inverted[2]],\n [`${name}_TooltipArrow`, altThemes[1][1]],\n [`${name}_TooltipContent`, altThemes[1][1]],\n [`${name}_darker`, darkerTheme],\n [`${name}_active`, activeTheme],\n ]\n const themes = Object.fromEntries(themeEntries)\n // if (props.isLight) {\n // console.log('themes', themes)\n // }\n return themes as any\n}\n\nconst themeCreator = (\n str = 1,\n {\n backgrounds,\n isLight = true,\n isBase = false,\n colors = [...backgrounds].reverse(),\n borderColors = isLight ? colors : backgrounds,\n backgroundStrong,\n offsets: offsetsProp,\n }: ThemeCreatorProps\n) => {\n const offsets = {\n borderColor: offsetsProp?.borderColor ?? offsetsProp?.background ?? [0, 0, 0, 0],\n background: offsetsProp?.background ?? [0, 0, 0, 0],\n color: offsetsProp?.color ?? [0, 0, 0, 0],\n }\n const darkColors = isLight ? colors : backgrounds\n const lighterDir = isLight ? -1 : 1\n const darkerDir = -lighterDir\n const strongerDir = isLight ? darkerDir : lighterDir\n const softerDir = -strongerDir\n const get = (arr: any[], index: number, name = 'background') => {\n return arr[Math.max(0, Math.min(index + (offsets[name][str] || 0), arr.length - 1))]\n }\n\n const colorTranslucent = setColorAlpha(getVariableValue(get(colors, 0 + str, 'color')), 0.5)\n\n let theme = {\n background: get(backgrounds, str),\n backgroundStrong: backgroundStrong || get(backgrounds, str + strongerDir * 2),\n backgroundSoft: get(backgrounds, str + softerDir * 2),\n backgroundHover: get(backgrounds, str + lighterDir),\n backgroundPress: get(backgrounds, str + darkerDir),\n backgroundFocus: get(backgrounds, str + darkerDir * 2),\n backgroundTransparent: color.grayA1Light,\n color: get(colors, 0 + str, 'color'),\n colorHover: get(colors, 1 + str, 'color'),\n colorPress: get(colors, 2 + str, 'color'),\n colorFocus: get(colors, 3 + str, 'color'),\n colorTranslucent,\n colorMid: (isLight ? colors : backgrounds)[Math.floor(colors.length / 2)],\n shadowColor: isLight ? color.grayA2Light : color.grayA8Light,\n shadowColorHover: darkColors[!isLight ? 1 : 8],\n shadowColorPress: darkColors[!isLight ? 1 : 8],\n shadowColorFocus: darkColors[!isLight ? 1 : 8],\n borderColor: null as any as string | Variable,\n borderColorHover: null as any as string | Variable,\n borderColorPress: null as any as string | Variable,\n borderColorFocus: null as any as string | Variable,\n }\n\n if (isBase) {\n Object.assign(theme, {\n borderColor: isLight\n ? get(colors, 8 - str, 'borderColor')\n : get(backgrounds, 2 + str, 'borderColor'),\n borderColorHover: isLight\n ? get(colors, 6 - str, 'borderColor')\n : get(backgrounds, 3 + str, 'borderColor'),\n borderColorPress: isLight\n ? get(colors, 5 - str, 'borderColor')\n : get(backgrounds, 1 + str, 'borderColor'),\n borderColorFocus: isLight\n ? get(colors, 4 - str, 'borderColor')\n : get(backgrounds, 3 + str, 'borderColor'),\n })\n } else {\n Object.assign(theme, {\n borderColor: get(borderColors, 1 + strongerDir, 'borderColor'),\n borderColorHover: get(borderColors, 2 + strongerDir, 'borderColor'),\n borderColorPress: get(borderColors, 3 + strongerDir, 'borderColor'),\n borderColorFocus: get(borderColors, 4 + strongerDir, 'borderColor'),\n })\n }\n\n return theme\n}\n\nconst themeColors = {\n light: [\n '#fff',\n '#f4f4f4',\n color.gray1Light,\n color.gray2Light,\n color.gray3Light,\n color.gray4Light,\n color.gray5Light,\n color.gray6Light,\n color.gray7Light,\n color.gray8Light,\n color.gray9Light,\n color.gray10Light,\n color.gray11Light,\n color.gray12Light,\n ],\n dark: [\n '#111111',\n '#151515',\n '#191919',\n '#232323',\n '#282828',\n '#323232',\n '#383838',\n '#424242',\n '#494949',\n '#545454',\n '#626262',\n '#777777',\n ],\n}\n\nconst lightThemes = createThemesFrom('light', themeCreator, {\n backgrounds: themeColors.light,\n // isBase: true,\n backgroundStrong: '#fafafa',\n borderColors: themeColors.light.slice(2),\n isLight: true,\n})\n\nconst darkThemes = createThemesFrom('dark', themeCreator, {\n backgrounds: themeColors.dark,\n colors: themeColors.light.slice(2),\n backgroundStrong: '#111',\n isBase: true,\n isLight: false,\n shift: 1,\n offsets: {\n color: [0, 4, 5, 5, 5, 5],\n },\n})\n\nconst light = createTheme({\n ...lightColors,\n ...lightThemes.light,\n})\n\nconst dark = createTheme({\n ...darkColors,\n ...darkThemes.dark,\n})\n\ntype ThemeBase = {\n [Key in keyof typeof dark]: string\n}\n\nconst baseThemes = {\n // light\n ...lightThemes,\n light,\n light_active: makeActiveTheme(lightThemes.light),\n light_Card: lightThemes.light,\n light_Button: lightThemes.light,\n light_SliderTrack: lightThemes.light_alt1,\n light_SliderTrackActive: lightThemes.light_alt2,\n light_Switch: lightThemes.light,\n light_SwitchThumb: lightThemes.light_alt1,\n light_DrawerFrame: lightThemes.light_alt1,\n\n // dark\n ...darkThemes,\n dark,\n dark_active: makeActiveTheme(darkThemes.dark),\n dark_Card: darkThemes.dark,\n dark_DrawerFrame: darkThemes.dark_alt1,\n dark_SliderTrack: darkThemes.dark_darker,\n dark_SliderTrackActive: darkThemes.dark_alt1,\n dark_Switch: darkThemes.dark_darker,\n dark_SwitchThumb: darkThemes.dark_alt1,\n dark_Button: darkThemes.dark_alt1,\n}\n\nfunction makeActiveTheme(theme: any) {\n const res = { ...theme }\n res.backgroundHover = res.background\n res.colorHover = res.color\n res.backgroundPress = res.background\n res.colorPress = res.color\n return res\n}\n\nconst darkEntries = Object.entries(dark)\nconst lightEntries = Object.entries(light)\nfunction findColors(prefix: string, dark = false): ThemeBase {\n return Object.fromEntries(\n (dark ? darkEntries : lightEntries).filter(([k]) => k.startsWith(prefix))\n ) as any\n}\n\nexport const colorSchemes = [\n { name: 'blue', colors: findColors('blue'), darkColors: findColors('blue', true) },\n { name: 'gray', colors: findColors('gray'), darkColors: findColors('gray', true) },\n { name: 'green', colors: findColors('green'), darkColors: findColors('green', true) },\n { name: 'orange', colors: findColors('orange'), darkColors: findColors('orange', true) },\n { name: 'pink', colors: findColors('pink'), darkColors: findColors('pink', true) },\n { name: 'purple', colors: findColors('purple'), darkColors: findColors('purple', true) },\n { name: 'red', colors: findColors('red'), darkColors: findColors('red', true) },\n { name: 'yellow', colors: findColors('yellow'), darkColors: findColors('yellow', true) },\n { name: 'teal', colors: findColors('teal'), darkColors: findColors('teal', true) },\n] as const\n\nexport type ColorNames = typeof colorSchemes[number]['name']\n\n// nice and flat\nexport const colorNames: ColorNames[] = [\n 'blue',\n 'gray',\n 'green',\n 'orange',\n 'pink',\n 'purple',\n 'red',\n 'yellow',\n 'teal',\n]\n\ntype ColorThemeNames =\n | ColorNames\n | AltName<`light_${ColorNames}`, AltKeys>\n | AltName<`dark_${ColorNames}`, AltKeys>\n\nconst colorThemeEntries = colorSchemes.flatMap(({ name, colors, darkColors }) => {\n const [altLightThemes, altDarkThemes] = [\n { colors: darkColors, backgrounds: colors },\n { colors, backgrounds: darkColors },\n ].map((props, i) => {\n const isLight = i === 0\n const colorsBase = Object.values(props.colors).slice(2)\n const [backgrounds, colors] = [\n Object.values(props.backgrounds),\n isLight ? colorsBase : [colorsBase[0], '#ccc', ...colorsBase.slice(1)],\n ] as const\n\n const scheme = isLight ? 'light' : 'dark'\n const shift = isLight ? 0 : 1\n\n // if (!isLight) {\n // const [_, h, sp, lp] = backgrounds[0].match(/hsl\\(([0-9\\.]+), ([0-9\\.]+)\\%, ([0-9\\.]+)\\%\\)/)!\n // backgrounds.unshift(`hsl(${h}, ${sp}%, ${parseFloat(lp) / 2}%)`)\n // }\n\n const themeWithAlts = createThemesFrom(name, themeCreator, {\n colors,\n backgrounds,\n borderColors: backgrounds,\n isLight,\n shift,\n isBase: false,\n offsets: {\n background: isLight ? [2, 2, 2, 2, 2, 2] : null,\n borderColor: isLight ? [2, 2, 2, 3, 2] : null,\n color: isLight ? [0, 0, -1, -2, -3, -3, -4] : [-1, -1, -1, -1, -1, -1],\n },\n })\n\n return Object.entries(themeWithAlts).map(([k, v]) => [`${scheme}_${k}`, v])\n })\n return [...altLightThemes, ...altDarkThemes]\n})\n\ntype MyThemeBase = typeof baseThemes['light_alt1']\n\nconst colorThemes: {\n [key in ColorThemeNames]: MyThemeBase\n} = Object.fromEntries(colorThemeEntries) as any\n\nconst allThemes = {\n ...baseThemes,\n ...colorThemes,\n} as const\n\nexport const themes: {\n [key in keyof typeof allThemes]: typeof baseThemes['light']\n} = allThemes as any\n"],
|
|
4
|
+
"sourcesContent": ["import { Variable, createTheme, createVariable, getVariableValue } from '@tamagui/core'\n\nimport { setColorAlpha } from './colorUtils'\nimport { darkColors, lightColors, tokens } from './tokens'\n\nconst { color } = tokens\n\n// spaghetti ahead\n\ntype ThemeCreatorProps = {\n shift?: number\n backgrounds: (string | Variable)[]\n backgroundStrong?: string | Variable\n borderColors?: (string | Variable)[]\n colors?: (string | Variable)[]\n offsets?: {\n color?: number[] | null\n background?: number[] | null\n borderColor?: number[] | null\n }\n isLight?: boolean\n isBase?: boolean\n}\n\n// helpers\n\nconst alternates = [1, 2, 3, 4] as const\nconst alts = [1, 2, 3] as const\ntype AltKeys = 1 | 2 | 3\ntype AltName<Name extends string, Keys extends string | number> = `${Name}_alt${Keys}`\ntype ThemeCreator<A = any> = (str: number, props: ThemeCreatorProps) => A\n\nfunction createThemesFrom<Name extends string, GetTheme extends ThemeCreator = ThemeCreator>(\n name: Name,\n getTheme: GetTheme,\n props: ThemeCreatorProps\n): {\n [key in `${Name}_alt${AltKeys}` | `${Name}` | `${Name}_darker`]: GetTheme extends ThemeCreator<\n infer Theme\n >\n ? Theme\n : never\n} {\n const { shift = 0 } = props\n const theme = getTheme(0 + shift, props)\n let themeEntries: any[] = [[name, theme]]\n\n // generate alternates (for use in other themes), but keep just alts\n const altThemes: any[] = alternates.map((alt) => [\n `${name}_alt${alt}`,\n getTheme(alt + (props.isLight ? 0 : 0) + shift, props),\n ])\n const altThemes2: any[] = alternates.map((alt) => [\n `${name}_alt${alt}`,\n getTheme(alt + shift, props),\n ])\n const altButtonThemes: any[] = alternates.map((_, i) => {\n const [bName, bTheme] = [altThemes2[i][0], (altThemes2[i + 1] || altThemes2[i])[1]]\n return [`${bName}_Button` as any, bTheme]\n })\n // add these after alts since we rely on positioning\n const darkerTheme = getTheme(Math.max(0, shift + (props.isLight ? 1 : -1)), props)\n const activeTheme = makeActiveTheme(theme)\n\n // TODO can be de-duped\n const inverted = altThemes.map(([_name, theme]) => {\n return {\n ...theme,\n background: theme.color,\n backgroundHover: theme.colorHover,\n backgroundFocus: theme.colorFocus,\n backgroundPress: theme.colorPress,\n color: theme.background,\n colorHover: theme.backgroundHover,\n colorFocus: theme.backgroundFocus,\n colorPress: theme.backgroundPress,\n }\n })\n\n themeEntries = [\n ...themeEntries,\n // keep just alts\n ...altThemes.slice(0, alts.length),\n ...altButtonThemes.slice(0, alts.length),\n [`${name}_Button`, altThemes2[1][1]],\n [`${name}_DrawerFrame`, altThemes2[1][1]],\n [`${name}_SliderTrack`, altThemes[1][1]],\n [`${name}_SliderTrackActive`, altThemes[3][1]],\n [`${name}_SliderThumb`, inverted[2]],\n [`${name}_Progress`, altThemes[2][1]],\n [`${name}_ProgressIndicator`, inverted[2]],\n [`${name}_Switch`, altThemes[0][1]],\n [`${name}_SwitchThumb`, inverted[2]],\n [`${name}_TooltipArrow`, altThemes[1][1]],\n [`${name}_TooltipContent`, altThemes[1][1]],\n [`${name}_darker`, darkerTheme],\n [`${name}_active`, activeTheme],\n ]\n const themes = Object.fromEntries(themeEntries)\n // if (props.isLight) {\n // console.log('themes', themes)\n // }\n return themes as any\n}\n\nconst themeCreator = (\n str = 1,\n {\n backgrounds,\n isLight = true,\n isBase = false,\n colors = [...backgrounds].reverse(),\n borderColors = isLight ? colors : backgrounds,\n backgroundStrong,\n offsets: offsetsProp,\n }: ThemeCreatorProps\n) => {\n const offsets = {\n borderColor: offsetsProp?.borderColor ?? offsetsProp?.background ?? [0, 0, 0, 0],\n background: offsetsProp?.background ?? [0, 0, 0, 0],\n color: offsetsProp?.color ?? [0, 0, 0, 0],\n }\n const darkColors = isLight ? colors : backgrounds\n const lighterDir = isLight ? -1 : 1\n const darkerDir = -lighterDir\n const strongerDir = isLight ? darkerDir : lighterDir\n const softerDir = -strongerDir\n const get = (arr: any[], index: number, name = 'background') => {\n return arr[Math.max(0, Math.min(index + (offsets[name][str] || 0), arr.length - 1))]\n }\n\n const colorTranslucent = setColorAlpha(getVariableValue(get(colors, 0 + str, 'color')), 0.5)\n\n let theme = {\n background: get(backgrounds, str),\n backgroundStrong: backgroundStrong || get(backgrounds, str + strongerDir * 2),\n backgroundSoft: get(backgrounds, str + softerDir * 2),\n backgroundHover: get(backgrounds, str + lighterDir),\n backgroundPress: get(backgrounds, str + darkerDir),\n backgroundFocus: get(backgrounds, str + darkerDir * 2),\n backgroundTransparent: color.grayA1Light,\n color: get(colors, 0 + str, 'color'),\n colorHover: get(colors, 1 + str, 'color'),\n colorPress: get(colors, 2 + str, 'color'),\n colorFocus: get(colors, 3 + str, 'color'),\n colorTranslucent,\n colorMid: (isLight ? colors : backgrounds)[Math.floor(colors.length / 2)],\n shadowColor: isLight ? color.grayA2Light : color.grayA8Light,\n shadowColorHover: darkColors[!isLight ? 1 : 8],\n shadowColorPress: darkColors[!isLight ? 1 : 8],\n shadowColorFocus: darkColors[!isLight ? 1 : 8],\n borderColor: null as any as string | Variable,\n borderColorHover: null as any as string | Variable,\n borderColorPress: null as any as string | Variable,\n borderColorFocus: null as any as string | Variable,\n }\n\n if (isBase) {\n Object.assign(theme, {\n borderColor: isLight\n ? get(colors, 8 - str, 'borderColor')\n : get(backgrounds, 2 + str, 'borderColor'),\n borderColorHover: isLight\n ? get(colors, 6 - str, 'borderColor')\n : get(backgrounds, 3 + str, 'borderColor'),\n borderColorPress: isLight\n ? get(colors, 5 - str, 'borderColor')\n : get(backgrounds, 1 + str, 'borderColor'),\n borderColorFocus: isLight\n ? get(colors, 4 - str, 'borderColor')\n : get(backgrounds, 3 + str, 'borderColor'),\n })\n } else {\n Object.assign(theme, {\n borderColor: get(borderColors, 1 + strongerDir, 'borderColor'),\n borderColorHover: get(borderColors, 2 + strongerDir, 'borderColor'),\n borderColorPress: get(borderColors, 3 + strongerDir, 'borderColor'),\n borderColorFocus: get(borderColors, 4 + strongerDir, 'borderColor'),\n })\n }\n\n return theme\n}\n\nconst themeColors = {\n light: [\n '#fff',\n '#f4f4f4',\n color.gray1Light,\n color.gray2Light,\n color.gray3Light,\n color.gray4Light,\n color.gray5Light,\n color.gray6Light,\n color.gray7Light,\n color.gray8Light,\n color.gray9Light,\n color.gray10Light,\n color.gray11Light,\n color.gray12Light,\n ],\n dark: [\n '#111111',\n '#151515',\n '#191919',\n '#232323',\n '#282828',\n '#323232',\n '#383838',\n '#424242',\n '#494949',\n '#545454',\n '#626262',\n '#777777',\n ],\n}\n\nconst lightThemes = createThemesFrom('light', themeCreator, {\n backgrounds: themeColors.light,\n // isBase: true,\n backgroundStrong: '#f2f2f2', // matches iOS\n borderColors: themeColors.light.slice(2),\n isLight: true,\n})\n\nconst darkThemes = createThemesFrom('dark', themeCreator, {\n backgrounds: themeColors.dark,\n colors: themeColors.light.slice(2),\n backgroundStrong: '#000',\n isBase: true,\n isLight: false,\n shift: 1,\n offsets: {\n color: [0, 4, 5, 5, 5, 5],\n },\n})\n\nconst light = createTheme({\n ...lightColors,\n ...lightThemes.light,\n})\n\nconst dark = createTheme({\n ...darkColors,\n ...darkThemes.dark,\n})\n\ntype ThemeBase = {\n [Key in keyof typeof dark]: string\n}\n\nconst baseThemes = {\n // light\n ...lightThemes,\n light,\n light_active: makeActiveTheme(lightThemes.light),\n light_Card: lightThemes.light,\n light_Button: lightThemes.light,\n light_SliderTrack: lightThemes.light_alt2,\n light_SliderTrackActive: lightThemes.light_alt3,\n light_Switch: lightThemes.light,\n light_SwitchThumb: lightThemes.light_alt1,\n light_DrawerFrame: lightThemes.light_alt1,\n\n // dark\n ...darkThemes,\n dark,\n dark_active: makeActiveTheme(darkThemes.dark),\n dark_Card: darkThemes.dark,\n dark_DrawerFrame: darkThemes.dark_alt2,\n dark_SliderTrack: darkThemes.dark_darker,\n dark_SliderTrackActive: darkThemes.dark_alt3,\n dark_Switch: darkThemes.dark_darker,\n dark_SwitchThumb: darkThemes.dark_alt1,\n dark_Button: darkThemes.dark_alt1,\n}\n\nfunction makeActiveTheme(theme: any) {\n const res = { ...theme }\n res.backgroundHover = res.background\n res.colorHover = res.color\n res.backgroundPress = res.background\n res.colorPress = res.color\n return res\n}\n\nconst darkEntries = Object.entries(dark)\nconst lightEntries = Object.entries(light)\nfunction findColors(prefix: string, dark = false): ThemeBase {\n return Object.fromEntries(\n (dark ? darkEntries : lightEntries).filter(([k]) => k.startsWith(prefix))\n ) as any\n}\n\nexport const colorSchemes = [\n { name: 'blue', colors: findColors('blue'), darkColors: findColors('blue', true) },\n { name: 'gray', colors: findColors('gray'), darkColors: findColors('gray', true) },\n { name: 'green', colors: findColors('green'), darkColors: findColors('green', true) },\n { name: 'orange', colors: findColors('orange'), darkColors: findColors('orange', true) },\n { name: 'pink', colors: findColors('pink'), darkColors: findColors('pink', true) },\n { name: 'purple', colors: findColors('purple'), darkColors: findColors('purple', true) },\n { name: 'red', colors: findColors('red'), darkColors: findColors('red', true) },\n { name: 'yellow', colors: findColors('yellow'), darkColors: findColors('yellow', true) },\n { name: 'teal', colors: findColors('teal'), darkColors: findColors('teal', true) },\n] as const\n\nexport type ColorNames = typeof colorSchemes[number]['name']\n\n// nice and flat\nexport const colorNames: ColorNames[] = [\n 'blue',\n 'gray',\n 'green',\n 'orange',\n 'pink',\n 'purple',\n 'red',\n 'yellow',\n 'teal',\n]\n\ntype ColorThemeNames =\n | ColorNames\n | AltName<`light_${ColorNames}`, AltKeys>\n | AltName<`dark_${ColorNames}`, AltKeys>\n\nconst colorThemeEntries = colorSchemes.flatMap(({ name, colors, darkColors }) => {\n const [altLightThemes, altDarkThemes] = [\n { colors: darkColors, backgrounds: colors },\n { colors, backgrounds: darkColors },\n ].map((props, i) => {\n const isLight = i === 0\n const colorsBase = Object.values(props.colors).slice(2)\n const [backgrounds, colors] = [\n Object.values(props.backgrounds),\n isLight ? colorsBase : [colorsBase[0], '#ccc', ...colorsBase.slice(1)],\n ] as const\n\n const scheme = isLight ? 'light' : 'dark'\n const shift = isLight ? 0 : 1\n\n // if (!isLight) {\n // const [_, h, sp, lp] = backgrounds[0].match(/hsl\\(([0-9\\.]+), ([0-9\\.]+)\\%, ([0-9\\.]+)\\%\\)/)!\n // backgrounds.unshift(`hsl(${h}, ${sp}%, ${parseFloat(lp) / 2}%)`)\n // }\n\n const themeWithAlts = createThemesFrom(name, themeCreator, {\n colors,\n backgrounds,\n borderColors: backgrounds,\n isLight,\n shift,\n isBase: false,\n offsets: {\n background: isLight ? [2, 2, 2, 2, 2, 2] : null,\n borderColor: isLight ? [2, 2, 2, 3, 2] : null,\n color: isLight ? [0, 0, -1, -2, -3, -3, -4] : [-1, -1, -1, -1, -1, -1],\n },\n })\n\n return Object.entries(themeWithAlts).map(([k, v]) => [`${scheme}_${k}`, v])\n })\n return [...altLightThemes, ...altDarkThemes]\n})\n\ntype MyThemeBase = typeof baseThemes['light_alt1']\n\nconst colorThemes: {\n [key in ColorThemeNames]: MyThemeBase\n} = Object.fromEntries(colorThemeEntries) as any\n\nconst allThemes = {\n ...baseThemes,\n ...colorThemes,\n} as const\n\nexport const themes: {\n [key in keyof typeof allThemes]: typeof baseThemes['light']\n} = allThemes as any\n"],
|
|
5
5
|
"mappings": ";;AAAA;AAEA;AACA;AAEA,MAAM,EAAE,UAAU;AAqBlB,MAAM,aAAa,CAAC,GAAG,GAAG,GAAG,CAAC;AAC9B,MAAM,OAAO,CAAC,GAAG,GAAG,CAAC;AAKrB,0BACE,MACA,UACA,OAOA;AACA,QAAM,EAAE,QAAQ,MAAM;AACtB,QAAM,QAAQ,SAAS,IAAI,OAAO,KAAK;AACvC,MAAI,eAAsB,CAAC,CAAC,MAAM,KAAK,CAAC;AAGxC,QAAM,YAAmB,WAAW,IAAI,CAAC,QAAQ;AAAA,IAC/C,GAAG,WAAW;AAAA,IACd,SAAS,MAAO,OAAM,UAAU,IAAI,KAAK,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C;AAAA,IACvE;AAEA,UAAM,SAAS,UAAU,UAAU;AACnC,UAAM,QAAQ,UAAU,IAAI;AAO5B,UAAM,gBAAgB,iBAAiB,MAAM,cAAc;AAAA,MACzD;AAAA,MACA;AAAA,MACA,cAAc;AAAA,MACd;AAAA,MACA;AAAA,MACA,QAAQ;AAAA,MACR,SAAS;AAAA,QACP,YAAY,UAAU,CAAC,GAAG,GAAG,GAAG,GAAG,GAAG,CAAC,IAAI;AAAA,QAC3C,aAAa,UAAU,CAAC,GAAG,GAAG,GAAG,GAAG,CAAC,IAAI;AAAA,QACzC,OAAO,UAAU,CAAC,GAAG,GAAG,IAAI,IAAI,IAAI,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,IAAI,IAAI,IAAI,EAAE;AAAA,MACvE;AAAA,IACF,CAAC;AAED,WAAO,OAAO,QAAQ,aAAa,EAAE,IAAI,CAAC,CAAC,GAAG,OAAO,CAAC,GAAG,UAAU,KAAK,CAAC,CAAC;AAAA,EAC5E,CAAC;AACD,SAAO,CAAC,GAAG,gBAAgB,GAAG,aAAa;AAC7C,CAAC;AAID,MAAM,cAEF,OAAO,YAAY,iBAAiB;AAExC,MAAM,YAAY;AAAA,EAChB,GAAG;AAAA,EACH,GAAG;AACL;AAEO,MAAM,SAET;",
|
|
6
6
|
"names": []
|
|
7
7
|
}
|
package/dist/jsx/themes.js
CHANGED
|
@@ -157,14 +157,14 @@ const themeColors = {
|
|
|
157
157
|
};
|
|
158
158
|
const lightThemes = createThemesFrom("light", themeCreator, {
|
|
159
159
|
backgrounds: themeColors.light,
|
|
160
|
-
backgroundStrong: "#
|
|
160
|
+
backgroundStrong: "#f2f2f2",
|
|
161
161
|
borderColors: themeColors.light.slice(2),
|
|
162
162
|
isLight: true
|
|
163
163
|
});
|
|
164
164
|
const darkThemes = createThemesFrom("dark", themeCreator, {
|
|
165
165
|
backgrounds: themeColors.dark,
|
|
166
166
|
colors: themeColors.light.slice(2),
|
|
167
|
-
backgroundStrong: "#
|
|
167
|
+
backgroundStrong: "#000",
|
|
168
168
|
isBase: true,
|
|
169
169
|
isLight: false,
|
|
170
170
|
shift: 1,
|
|
@@ -186,8 +186,8 @@ const baseThemes = {
|
|
|
186
186
|
light_active: makeActiveTheme(lightThemes.light),
|
|
187
187
|
light_Card: lightThemes.light,
|
|
188
188
|
light_Button: lightThemes.light,
|
|
189
|
-
light_SliderTrack: lightThemes.
|
|
190
|
-
light_SliderTrackActive: lightThemes.
|
|
189
|
+
light_SliderTrack: lightThemes.light_alt2,
|
|
190
|
+
light_SliderTrackActive: lightThemes.light_alt3,
|
|
191
191
|
light_Switch: lightThemes.light,
|
|
192
192
|
light_SwitchThumb: lightThemes.light_alt1,
|
|
193
193
|
light_DrawerFrame: lightThemes.light_alt1,
|
|
@@ -195,9 +195,9 @@ const baseThemes = {
|
|
|
195
195
|
dark,
|
|
196
196
|
dark_active: makeActiveTheme(darkThemes.dark),
|
|
197
197
|
dark_Card: darkThemes.dark,
|
|
198
|
-
dark_DrawerFrame: darkThemes.
|
|
198
|
+
dark_DrawerFrame: darkThemes.dark_alt2,
|
|
199
199
|
dark_SliderTrack: darkThemes.dark_darker,
|
|
200
|
-
dark_SliderTrackActive: darkThemes.
|
|
200
|
+
dark_SliderTrackActive: darkThemes.dark_alt3,
|
|
201
201
|
dark_Switch: darkThemes.dark_darker,
|
|
202
202
|
dark_SwitchThumb: darkThemes.dark_alt1,
|
|
203
203
|
dark_Button: darkThemes.dark_alt1
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/theme-base",
|
|
3
|
-
"version": "1.0.1-beta.
|
|
3
|
+
"version": "1.0.1-beta.60",
|
|
4
4
|
"types": "./types/index.d.ts",
|
|
5
5
|
"main": "dist/cjs",
|
|
6
6
|
"module": "dist/esm",
|
|
7
7
|
"module:jsx": "dist/jsx",
|
|
8
8
|
"files": [
|
|
9
|
+
"src",
|
|
9
10
|
"types",
|
|
10
11
|
"dist"
|
|
11
12
|
],
|
|
@@ -16,11 +17,11 @@
|
|
|
16
17
|
"clean:build": "tamagui-build clean:build"
|
|
17
18
|
},
|
|
18
19
|
"dependencies": {
|
|
19
|
-
"@tamagui/colors": "^1.0.1-beta.
|
|
20
|
-
"@tamagui/core": "^1.0.1-beta.
|
|
20
|
+
"@tamagui/colors": "^1.0.1-beta.60",
|
|
21
|
+
"@tamagui/core": "^1.0.1-beta.60"
|
|
21
22
|
},
|
|
22
23
|
"devDependencies": {
|
|
23
|
-
"@tamagui/build": "^1.0.1-beta.
|
|
24
|
+
"@tamagui/build": "^1.0.1-beta.60"
|
|
24
25
|
},
|
|
25
26
|
"publishConfig": {
|
|
26
27
|
"access": "public"
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { Variable, getVariableValue } from '@tamagui/core'
|
|
2
|
+
|
|
3
|
+
export const hexToRGBA = (hex: string, alpha = 1) => {
|
|
4
|
+
if (!isValidHex(hex)) {
|
|
5
|
+
throw new Error('Invalid HEX')
|
|
6
|
+
}
|
|
7
|
+
const chunkSize = Math.floor((hex.length - 1) / 3)
|
|
8
|
+
const hexArr = getChunksFromString(hex.slice(1), chunkSize)
|
|
9
|
+
const [r, g, b, a] = hexArr?.map(convertHexUnitTo256) ?? []
|
|
10
|
+
return `rgba(${r}, ${g}, ${b}, ${getAlphaFloat(a, alpha)})`
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const setColorAlpha = (colorIn: string | Variable, alpha = 1) => {
|
|
14
|
+
let color = `${getVariableValue(colorIn)}`
|
|
15
|
+
if (color.startsWith('hsl(')) {
|
|
16
|
+
return color.replace('hsl', 'hsla').replace(')', `, ${alpha})`)
|
|
17
|
+
}
|
|
18
|
+
if (color.startsWith('#')) {
|
|
19
|
+
return hexToRGBA(color, alpha)
|
|
20
|
+
}
|
|
21
|
+
if (color.startsWith('rgb(')) {
|
|
22
|
+
return color.replace('rgb', 'rgba').replace(')', `, ${alpha})`)
|
|
23
|
+
}
|
|
24
|
+
return color
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const isValidHex = (hex: string) => /^#([A-Fa-f0-9]{3,4}){1,2}$/.test(hex)
|
|
28
|
+
|
|
29
|
+
const getChunksFromString = (st: string, chunkSize = 0) =>
|
|
30
|
+
st.match(new RegExp(`.{${chunkSize}}`, 'g'))
|
|
31
|
+
|
|
32
|
+
const convertHexUnitTo256 = (hexStr: string) => parseInt(hexStr.repeat(2 / hexStr.length), 16)
|
|
33
|
+
|
|
34
|
+
const getAlphaFloat = (a: any, alpha = 1) => {
|
|
35
|
+
if (a !== undefined) {
|
|
36
|
+
return a / 255
|
|
37
|
+
}
|
|
38
|
+
if (typeof alpha != 'number' || alpha < 0 || alpha > 1) {
|
|
39
|
+
return 1
|
|
40
|
+
}
|
|
41
|
+
return alpha
|
|
42
|
+
}
|
package/src/index.tsx
ADDED
package/src/themes.tsx
ADDED
|
@@ -0,0 +1,379 @@
|
|
|
1
|
+
import { Variable, createTheme, createVariable, getVariableValue } from '@tamagui/core'
|
|
2
|
+
|
|
3
|
+
import { setColorAlpha } from './colorUtils'
|
|
4
|
+
import { darkColors, lightColors, tokens } from './tokens'
|
|
5
|
+
|
|
6
|
+
const { color } = tokens
|
|
7
|
+
|
|
8
|
+
// spaghetti ahead
|
|
9
|
+
|
|
10
|
+
type ThemeCreatorProps = {
|
|
11
|
+
shift?: number
|
|
12
|
+
backgrounds: (string | Variable)[]
|
|
13
|
+
backgroundStrong?: string | Variable
|
|
14
|
+
borderColors?: (string | Variable)[]
|
|
15
|
+
colors?: (string | Variable)[]
|
|
16
|
+
offsets?: {
|
|
17
|
+
color?: number[] | null
|
|
18
|
+
background?: number[] | null
|
|
19
|
+
borderColor?: number[] | null
|
|
20
|
+
}
|
|
21
|
+
isLight?: boolean
|
|
22
|
+
isBase?: boolean
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// helpers
|
|
26
|
+
|
|
27
|
+
const alternates = [1, 2, 3, 4] as const
|
|
28
|
+
const alts = [1, 2, 3] as const
|
|
29
|
+
type AltKeys = 1 | 2 | 3
|
|
30
|
+
type AltName<Name extends string, Keys extends string | number> = `${Name}_alt${Keys}`
|
|
31
|
+
type ThemeCreator<A = any> = (str: number, props: ThemeCreatorProps) => A
|
|
32
|
+
|
|
33
|
+
function createThemesFrom<Name extends string, GetTheme extends ThemeCreator = ThemeCreator>(
|
|
34
|
+
name: Name,
|
|
35
|
+
getTheme: GetTheme,
|
|
36
|
+
props: ThemeCreatorProps
|
|
37
|
+
): {
|
|
38
|
+
[key in `${Name}_alt${AltKeys}` | `${Name}` | `${Name}_darker`]: GetTheme extends ThemeCreator<
|
|
39
|
+
infer Theme
|
|
40
|
+
>
|
|
41
|
+
? Theme
|
|
42
|
+
: never
|
|
43
|
+
} {
|
|
44
|
+
const { shift = 0 } = props
|
|
45
|
+
const theme = getTheme(0 + shift, props)
|
|
46
|
+
let themeEntries: any[] = [[name, theme]]
|
|
47
|
+
|
|
48
|
+
// generate alternates (for use in other themes), but keep just alts
|
|
49
|
+
const altThemes: any[] = alternates.map((alt) => [
|
|
50
|
+
`${name}_alt${alt}`,
|
|
51
|
+
getTheme(alt + (props.isLight ? 0 : 0) + shift, props),
|
|
52
|
+
])
|
|
53
|
+
const altThemes2: any[] = alternates.map((alt) => [
|
|
54
|
+
`${name}_alt${alt}`,
|
|
55
|
+
getTheme(alt + shift, props),
|
|
56
|
+
])
|
|
57
|
+
const altButtonThemes: any[] = alternates.map((_, i) => {
|
|
58
|
+
const [bName, bTheme] = [altThemes2[i][0], (altThemes2[i + 1] || altThemes2[i])[1]]
|
|
59
|
+
return [`${bName}_Button` as any, bTheme]
|
|
60
|
+
})
|
|
61
|
+
// add these after alts since we rely on positioning
|
|
62
|
+
const darkerTheme = getTheme(Math.max(0, shift + (props.isLight ? 1 : -1)), props)
|
|
63
|
+
const activeTheme = makeActiveTheme(theme)
|
|
64
|
+
|
|
65
|
+
// TODO can be de-duped
|
|
66
|
+
const inverted = altThemes.map(([_name, theme]) => {
|
|
67
|
+
return {
|
|
68
|
+
...theme,
|
|
69
|
+
background: theme.color,
|
|
70
|
+
backgroundHover: theme.colorHover,
|
|
71
|
+
backgroundFocus: theme.colorFocus,
|
|
72
|
+
backgroundPress: theme.colorPress,
|
|
73
|
+
color: theme.background,
|
|
74
|
+
colorHover: theme.backgroundHover,
|
|
75
|
+
colorFocus: theme.backgroundFocus,
|
|
76
|
+
colorPress: theme.backgroundPress,
|
|
77
|
+
}
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
themeEntries = [
|
|
81
|
+
...themeEntries,
|
|
82
|
+
// keep just alts
|
|
83
|
+
...altThemes.slice(0, alts.length),
|
|
84
|
+
...altButtonThemes.slice(0, alts.length),
|
|
85
|
+
[`${name}_Button`, altThemes2[1][1]],
|
|
86
|
+
[`${name}_DrawerFrame`, altThemes2[1][1]],
|
|
87
|
+
[`${name}_SliderTrack`, altThemes[1][1]],
|
|
88
|
+
[`${name}_SliderTrackActive`, altThemes[3][1]],
|
|
89
|
+
[`${name}_SliderThumb`, inverted[2]],
|
|
90
|
+
[`${name}_Progress`, altThemes[2][1]],
|
|
91
|
+
[`${name}_ProgressIndicator`, inverted[2]],
|
|
92
|
+
[`${name}_Switch`, altThemes[0][1]],
|
|
93
|
+
[`${name}_SwitchThumb`, inverted[2]],
|
|
94
|
+
[`${name}_TooltipArrow`, altThemes[1][1]],
|
|
95
|
+
[`${name}_TooltipContent`, altThemes[1][1]],
|
|
96
|
+
[`${name}_darker`, darkerTheme],
|
|
97
|
+
[`${name}_active`, activeTheme],
|
|
98
|
+
]
|
|
99
|
+
const themes = Object.fromEntries(themeEntries)
|
|
100
|
+
// if (props.isLight) {
|
|
101
|
+
// console.log('themes', themes)
|
|
102
|
+
// }
|
|
103
|
+
return themes as any
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
const themeCreator = (
|
|
107
|
+
str = 1,
|
|
108
|
+
{
|
|
109
|
+
backgrounds,
|
|
110
|
+
isLight = true,
|
|
111
|
+
isBase = false,
|
|
112
|
+
colors = [...backgrounds].reverse(),
|
|
113
|
+
borderColors = isLight ? colors : backgrounds,
|
|
114
|
+
backgroundStrong,
|
|
115
|
+
offsets: offsetsProp,
|
|
116
|
+
}: ThemeCreatorProps
|
|
117
|
+
) => {
|
|
118
|
+
const offsets = {
|
|
119
|
+
borderColor: offsetsProp?.borderColor ?? offsetsProp?.background ?? [0, 0, 0, 0],
|
|
120
|
+
background: offsetsProp?.background ?? [0, 0, 0, 0],
|
|
121
|
+
color: offsetsProp?.color ?? [0, 0, 0, 0],
|
|
122
|
+
}
|
|
123
|
+
const darkColors = isLight ? colors : backgrounds
|
|
124
|
+
const lighterDir = isLight ? -1 : 1
|
|
125
|
+
const darkerDir = -lighterDir
|
|
126
|
+
const strongerDir = isLight ? darkerDir : lighterDir
|
|
127
|
+
const softerDir = -strongerDir
|
|
128
|
+
const get = (arr: any[], index: number, name = 'background') => {
|
|
129
|
+
return arr[Math.max(0, Math.min(index + (offsets[name][str] || 0), arr.length - 1))]
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const colorTranslucent = setColorAlpha(getVariableValue(get(colors, 0 + str, 'color')), 0.5)
|
|
133
|
+
|
|
134
|
+
let theme = {
|
|
135
|
+
background: get(backgrounds, str),
|
|
136
|
+
backgroundStrong: backgroundStrong || get(backgrounds, str + strongerDir * 2),
|
|
137
|
+
backgroundSoft: get(backgrounds, str + softerDir * 2),
|
|
138
|
+
backgroundHover: get(backgrounds, str + lighterDir),
|
|
139
|
+
backgroundPress: get(backgrounds, str + darkerDir),
|
|
140
|
+
backgroundFocus: get(backgrounds, str + darkerDir * 2),
|
|
141
|
+
backgroundTransparent: color.grayA1Light,
|
|
142
|
+
color: get(colors, 0 + str, 'color'),
|
|
143
|
+
colorHover: get(colors, 1 + str, 'color'),
|
|
144
|
+
colorPress: get(colors, 2 + str, 'color'),
|
|
145
|
+
colorFocus: get(colors, 3 + str, 'color'),
|
|
146
|
+
colorTranslucent,
|
|
147
|
+
colorMid: (isLight ? colors : backgrounds)[Math.floor(colors.length / 2)],
|
|
148
|
+
shadowColor: isLight ? color.grayA2Light : color.grayA8Light,
|
|
149
|
+
shadowColorHover: darkColors[!isLight ? 1 : 8],
|
|
150
|
+
shadowColorPress: darkColors[!isLight ? 1 : 8],
|
|
151
|
+
shadowColorFocus: darkColors[!isLight ? 1 : 8],
|
|
152
|
+
borderColor: null as any as string | Variable,
|
|
153
|
+
borderColorHover: null as any as string | Variable,
|
|
154
|
+
borderColorPress: null as any as string | Variable,
|
|
155
|
+
borderColorFocus: null as any as string | Variable,
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (isBase) {
|
|
159
|
+
Object.assign(theme, {
|
|
160
|
+
borderColor: isLight
|
|
161
|
+
? get(colors, 8 - str, 'borderColor')
|
|
162
|
+
: get(backgrounds, 2 + str, 'borderColor'),
|
|
163
|
+
borderColorHover: isLight
|
|
164
|
+
? get(colors, 6 - str, 'borderColor')
|
|
165
|
+
: get(backgrounds, 3 + str, 'borderColor'),
|
|
166
|
+
borderColorPress: isLight
|
|
167
|
+
? get(colors, 5 - str, 'borderColor')
|
|
168
|
+
: get(backgrounds, 1 + str, 'borderColor'),
|
|
169
|
+
borderColorFocus: isLight
|
|
170
|
+
? get(colors, 4 - str, 'borderColor')
|
|
171
|
+
: get(backgrounds, 3 + str, 'borderColor'),
|
|
172
|
+
})
|
|
173
|
+
} else {
|
|
174
|
+
Object.assign(theme, {
|
|
175
|
+
borderColor: get(borderColors, 1 + strongerDir, 'borderColor'),
|
|
176
|
+
borderColorHover: get(borderColors, 2 + strongerDir, 'borderColor'),
|
|
177
|
+
borderColorPress: get(borderColors, 3 + strongerDir, 'borderColor'),
|
|
178
|
+
borderColorFocus: get(borderColors, 4 + strongerDir, 'borderColor'),
|
|
179
|
+
})
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return theme
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
const themeColors = {
|
|
186
|
+
light: [
|
|
187
|
+
'#fff',
|
|
188
|
+
'#f4f4f4',
|
|
189
|
+
color.gray1Light,
|
|
190
|
+
color.gray2Light,
|
|
191
|
+
color.gray3Light,
|
|
192
|
+
color.gray4Light,
|
|
193
|
+
color.gray5Light,
|
|
194
|
+
color.gray6Light,
|
|
195
|
+
color.gray7Light,
|
|
196
|
+
color.gray8Light,
|
|
197
|
+
color.gray9Light,
|
|
198
|
+
color.gray10Light,
|
|
199
|
+
color.gray11Light,
|
|
200
|
+
color.gray12Light,
|
|
201
|
+
],
|
|
202
|
+
dark: [
|
|
203
|
+
'#111111',
|
|
204
|
+
'#151515',
|
|
205
|
+
'#191919',
|
|
206
|
+
'#232323',
|
|
207
|
+
'#282828',
|
|
208
|
+
'#323232',
|
|
209
|
+
'#383838',
|
|
210
|
+
'#424242',
|
|
211
|
+
'#494949',
|
|
212
|
+
'#545454',
|
|
213
|
+
'#626262',
|
|
214
|
+
'#777777',
|
|
215
|
+
],
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
const lightThemes = createThemesFrom('light', themeCreator, {
|
|
219
|
+
backgrounds: themeColors.light,
|
|
220
|
+
// isBase: true,
|
|
221
|
+
backgroundStrong: '#f2f2f2', // matches iOS
|
|
222
|
+
borderColors: themeColors.light.slice(2),
|
|
223
|
+
isLight: true,
|
|
224
|
+
})
|
|
225
|
+
|
|
226
|
+
const darkThemes = createThemesFrom('dark', themeCreator, {
|
|
227
|
+
backgrounds: themeColors.dark,
|
|
228
|
+
colors: themeColors.light.slice(2),
|
|
229
|
+
backgroundStrong: '#000',
|
|
230
|
+
isBase: true,
|
|
231
|
+
isLight: false,
|
|
232
|
+
shift: 1,
|
|
233
|
+
offsets: {
|
|
234
|
+
color: [0, 4, 5, 5, 5, 5],
|
|
235
|
+
},
|
|
236
|
+
})
|
|
237
|
+
|
|
238
|
+
const light = createTheme({
|
|
239
|
+
...lightColors,
|
|
240
|
+
...lightThemes.light,
|
|
241
|
+
})
|
|
242
|
+
|
|
243
|
+
const dark = createTheme({
|
|
244
|
+
...darkColors,
|
|
245
|
+
...darkThemes.dark,
|
|
246
|
+
})
|
|
247
|
+
|
|
248
|
+
type ThemeBase = {
|
|
249
|
+
[Key in keyof typeof dark]: string
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
const baseThemes = {
|
|
253
|
+
// light
|
|
254
|
+
...lightThemes,
|
|
255
|
+
light,
|
|
256
|
+
light_active: makeActiveTheme(lightThemes.light),
|
|
257
|
+
light_Card: lightThemes.light,
|
|
258
|
+
light_Button: lightThemes.light,
|
|
259
|
+
light_SliderTrack: lightThemes.light_alt2,
|
|
260
|
+
light_SliderTrackActive: lightThemes.light_alt3,
|
|
261
|
+
light_Switch: lightThemes.light,
|
|
262
|
+
light_SwitchThumb: lightThemes.light_alt1,
|
|
263
|
+
light_DrawerFrame: lightThemes.light_alt1,
|
|
264
|
+
|
|
265
|
+
// dark
|
|
266
|
+
...darkThemes,
|
|
267
|
+
dark,
|
|
268
|
+
dark_active: makeActiveTheme(darkThemes.dark),
|
|
269
|
+
dark_Card: darkThemes.dark,
|
|
270
|
+
dark_DrawerFrame: darkThemes.dark_alt2,
|
|
271
|
+
dark_SliderTrack: darkThemes.dark_darker,
|
|
272
|
+
dark_SliderTrackActive: darkThemes.dark_alt3,
|
|
273
|
+
dark_Switch: darkThemes.dark_darker,
|
|
274
|
+
dark_SwitchThumb: darkThemes.dark_alt1,
|
|
275
|
+
dark_Button: darkThemes.dark_alt1,
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
function makeActiveTheme(theme: any) {
|
|
279
|
+
const res = { ...theme }
|
|
280
|
+
res.backgroundHover = res.background
|
|
281
|
+
res.colorHover = res.color
|
|
282
|
+
res.backgroundPress = res.background
|
|
283
|
+
res.colorPress = res.color
|
|
284
|
+
return res
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
const darkEntries = Object.entries(dark)
|
|
288
|
+
const lightEntries = Object.entries(light)
|
|
289
|
+
function findColors(prefix: string, dark = false): ThemeBase {
|
|
290
|
+
return Object.fromEntries(
|
|
291
|
+
(dark ? darkEntries : lightEntries).filter(([k]) => k.startsWith(prefix))
|
|
292
|
+
) as any
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
export const colorSchemes = [
|
|
296
|
+
{ name: 'blue', colors: findColors('blue'), darkColors: findColors('blue', true) },
|
|
297
|
+
{ name: 'gray', colors: findColors('gray'), darkColors: findColors('gray', true) },
|
|
298
|
+
{ name: 'green', colors: findColors('green'), darkColors: findColors('green', true) },
|
|
299
|
+
{ name: 'orange', colors: findColors('orange'), darkColors: findColors('orange', true) },
|
|
300
|
+
{ name: 'pink', colors: findColors('pink'), darkColors: findColors('pink', true) },
|
|
301
|
+
{ name: 'purple', colors: findColors('purple'), darkColors: findColors('purple', true) },
|
|
302
|
+
{ name: 'red', colors: findColors('red'), darkColors: findColors('red', true) },
|
|
303
|
+
{ name: 'yellow', colors: findColors('yellow'), darkColors: findColors('yellow', true) },
|
|
304
|
+
{ name: 'teal', colors: findColors('teal'), darkColors: findColors('teal', true) },
|
|
305
|
+
] as const
|
|
306
|
+
|
|
307
|
+
export type ColorNames = typeof colorSchemes[number]['name']
|
|
308
|
+
|
|
309
|
+
// nice and flat
|
|
310
|
+
export const colorNames: ColorNames[] = [
|
|
311
|
+
'blue',
|
|
312
|
+
'gray',
|
|
313
|
+
'green',
|
|
314
|
+
'orange',
|
|
315
|
+
'pink',
|
|
316
|
+
'purple',
|
|
317
|
+
'red',
|
|
318
|
+
'yellow',
|
|
319
|
+
'teal',
|
|
320
|
+
]
|
|
321
|
+
|
|
322
|
+
type ColorThemeNames =
|
|
323
|
+
| ColorNames
|
|
324
|
+
| AltName<`light_${ColorNames}`, AltKeys>
|
|
325
|
+
| AltName<`dark_${ColorNames}`, AltKeys>
|
|
326
|
+
|
|
327
|
+
const colorThemeEntries = colorSchemes.flatMap(({ name, colors, darkColors }) => {
|
|
328
|
+
const [altLightThemes, altDarkThemes] = [
|
|
329
|
+
{ colors: darkColors, backgrounds: colors },
|
|
330
|
+
{ colors, backgrounds: darkColors },
|
|
331
|
+
].map((props, i) => {
|
|
332
|
+
const isLight = i === 0
|
|
333
|
+
const colorsBase = Object.values(props.colors).slice(2)
|
|
334
|
+
const [backgrounds, colors] = [
|
|
335
|
+
Object.values(props.backgrounds),
|
|
336
|
+
isLight ? colorsBase : [colorsBase[0], '#ccc', ...colorsBase.slice(1)],
|
|
337
|
+
] as const
|
|
338
|
+
|
|
339
|
+
const scheme = isLight ? 'light' : 'dark'
|
|
340
|
+
const shift = isLight ? 0 : 1
|
|
341
|
+
|
|
342
|
+
// if (!isLight) {
|
|
343
|
+
// const [_, h, sp, lp] = backgrounds[0].match(/hsl\(([0-9\.]+), ([0-9\.]+)\%, ([0-9\.]+)\%\)/)!
|
|
344
|
+
// backgrounds.unshift(`hsl(${h}, ${sp}%, ${parseFloat(lp) / 2}%)`)
|
|
345
|
+
// }
|
|
346
|
+
|
|
347
|
+
const themeWithAlts = createThemesFrom(name, themeCreator, {
|
|
348
|
+
colors,
|
|
349
|
+
backgrounds,
|
|
350
|
+
borderColors: backgrounds,
|
|
351
|
+
isLight,
|
|
352
|
+
shift,
|
|
353
|
+
isBase: false,
|
|
354
|
+
offsets: {
|
|
355
|
+
background: isLight ? [2, 2, 2, 2, 2, 2] : null,
|
|
356
|
+
borderColor: isLight ? [2, 2, 2, 3, 2] : null,
|
|
357
|
+
color: isLight ? [0, 0, -1, -2, -3, -3, -4] : [-1, -1, -1, -1, -1, -1],
|
|
358
|
+
},
|
|
359
|
+
})
|
|
360
|
+
|
|
361
|
+
return Object.entries(themeWithAlts).map(([k, v]) => [`${scheme}_${k}`, v])
|
|
362
|
+
})
|
|
363
|
+
return [...altLightThemes, ...altDarkThemes]
|
|
364
|
+
})
|
|
365
|
+
|
|
366
|
+
type MyThemeBase = typeof baseThemes['light_alt1']
|
|
367
|
+
|
|
368
|
+
const colorThemes: {
|
|
369
|
+
[key in ColorThemeNames]: MyThemeBase
|
|
370
|
+
} = Object.fromEntries(colorThemeEntries) as any
|
|
371
|
+
|
|
372
|
+
const allThemes = {
|
|
373
|
+
...baseThemes,
|
|
374
|
+
...colorThemes,
|
|
375
|
+
} as const
|
|
376
|
+
|
|
377
|
+
export const themes: {
|
|
378
|
+
[key in keyof typeof allThemes]: typeof baseThemes['light']
|
|
379
|
+
} = allThemes as any
|
package/src/tokens.tsx
ADDED
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import {
|
|
2
|
+
blue,
|
|
3
|
+
blueDark,
|
|
4
|
+
gray,
|
|
5
|
+
grayA,
|
|
6
|
+
grayDark,
|
|
7
|
+
grayDarkA,
|
|
8
|
+
green,
|
|
9
|
+
greenDark,
|
|
10
|
+
orange,
|
|
11
|
+
orangeDark,
|
|
12
|
+
pink,
|
|
13
|
+
pinkDark,
|
|
14
|
+
purple,
|
|
15
|
+
purpleDark,
|
|
16
|
+
red,
|
|
17
|
+
redDark,
|
|
18
|
+
teal,
|
|
19
|
+
tealDark,
|
|
20
|
+
violet,
|
|
21
|
+
violetDark,
|
|
22
|
+
yellow,
|
|
23
|
+
yellowDark,
|
|
24
|
+
} from '@tamagui/colors'
|
|
25
|
+
import { Variable, createTokens, createVariables } from '@tamagui/core'
|
|
26
|
+
|
|
27
|
+
// should roughly map to button/input etc height at each level
|
|
28
|
+
// fonts should match that height/lineHeight at each stop
|
|
29
|
+
// so these are really non-linear on purpose
|
|
30
|
+
// why?
|
|
31
|
+
// - at sizes <1, used for fine grained things (borders, smallest paddingY)
|
|
32
|
+
// - so smallest padY should be roughly 1-4px so it can join with lineHeight
|
|
33
|
+
// - at sizes >=1, have to consider "pressability" (jumps up)
|
|
34
|
+
// - after that it should go upwards somewhat naturally
|
|
35
|
+
// - H1 / headings top out at 10 naturally, so after 10 we can go upwards faster
|
|
36
|
+
// but also one more wrinkle...
|
|
37
|
+
// space is used in conjunction with size
|
|
38
|
+
// i'm setting space to generally just a fixed fraction of size (~1/3-2/3 still fine tuning)
|
|
39
|
+
const size = {
|
|
40
|
+
0: 0,
|
|
41
|
+
0.25: 2,
|
|
42
|
+
0.5: 4,
|
|
43
|
+
0.75: 8,
|
|
44
|
+
1: 20,
|
|
45
|
+
1.5: 24,
|
|
46
|
+
2: 28,
|
|
47
|
+
2.5: 32,
|
|
48
|
+
3: 36,
|
|
49
|
+
3.5: 40,
|
|
50
|
+
4: 44,
|
|
51
|
+
true: 44,
|
|
52
|
+
4.5: 48,
|
|
53
|
+
5: 52,
|
|
54
|
+
5.5: 59,
|
|
55
|
+
6: 64,
|
|
56
|
+
6.5: 69,
|
|
57
|
+
7: 74,
|
|
58
|
+
7.6: 79,
|
|
59
|
+
8: 84,
|
|
60
|
+
8.5: 89,
|
|
61
|
+
9: 94,
|
|
62
|
+
9.5: 99,
|
|
63
|
+
10: 104,
|
|
64
|
+
11: 124,
|
|
65
|
+
12: 144,
|
|
66
|
+
13: 164,
|
|
67
|
+
14: 184,
|
|
68
|
+
15: 204,
|
|
69
|
+
16: 224,
|
|
70
|
+
17: 224,
|
|
71
|
+
18: 244,
|
|
72
|
+
19: 264,
|
|
73
|
+
20: 284,
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
type Sizes = typeof size
|
|
77
|
+
type SizeKeys = `${keyof Sizes}`
|
|
78
|
+
|
|
79
|
+
const spaces = Object.entries(size).map(([k, v]) => [
|
|
80
|
+
k,
|
|
81
|
+
Math.max(0, v <= 16 ? Math.round(v * 0.333) : Math.floor(v * 0.7 - 12)),
|
|
82
|
+
])
|
|
83
|
+
|
|
84
|
+
const spacesNegative = spaces.map(([k, v]) => [`-${k}`, -v])
|
|
85
|
+
|
|
86
|
+
const space: {
|
|
87
|
+
[Key in `-${SizeKeys}` | SizeKeys]: Key extends keyof Sizes ? Sizes[Key] : number
|
|
88
|
+
} = {
|
|
89
|
+
...Object.fromEntries(spaces),
|
|
90
|
+
...Object.fromEntries(spacesNegative),
|
|
91
|
+
} as any
|
|
92
|
+
|
|
93
|
+
const zIndex = {
|
|
94
|
+
0: 0,
|
|
95
|
+
1: 100,
|
|
96
|
+
2: 200,
|
|
97
|
+
3: 300,
|
|
98
|
+
4: 400,
|
|
99
|
+
5: 500,
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
const colorTokens = {
|
|
103
|
+
light: {
|
|
104
|
+
blue: blue,
|
|
105
|
+
gray: gray,
|
|
106
|
+
grayA: grayA,
|
|
107
|
+
green: green,
|
|
108
|
+
orange: orange,
|
|
109
|
+
pink: pink,
|
|
110
|
+
purple: purple,
|
|
111
|
+
red: red,
|
|
112
|
+
violet: violet,
|
|
113
|
+
yellow: yellow,
|
|
114
|
+
teal: teal,
|
|
115
|
+
},
|
|
116
|
+
dark: {
|
|
117
|
+
blue: blueDark,
|
|
118
|
+
gray: grayDark,
|
|
119
|
+
grayA: grayDarkA,
|
|
120
|
+
green: greenDark,
|
|
121
|
+
orange: orangeDark,
|
|
122
|
+
pink: pinkDark,
|
|
123
|
+
purple: purpleDark,
|
|
124
|
+
red: redDark,
|
|
125
|
+
violet: violetDark,
|
|
126
|
+
yellow: yellowDark,
|
|
127
|
+
teal: tealDark,
|
|
128
|
+
},
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export const darkColors = {
|
|
132
|
+
...colorTokens.dark.blue,
|
|
133
|
+
...colorTokens.dark.gray,
|
|
134
|
+
...colorTokens.dark.grayA,
|
|
135
|
+
...colorTokens.dark.green,
|
|
136
|
+
...colorTokens.dark.orange,
|
|
137
|
+
...colorTokens.dark.pink,
|
|
138
|
+
...colorTokens.dark.purple,
|
|
139
|
+
...colorTokens.dark.red,
|
|
140
|
+
...colorTokens.dark.violet,
|
|
141
|
+
...colorTokens.dark.yellow,
|
|
142
|
+
...colorTokens.dark.teal,
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
export const lightColors = {
|
|
146
|
+
...colorTokens.light.blue,
|
|
147
|
+
...colorTokens.light.gray,
|
|
148
|
+
...colorTokens.light.grayA,
|
|
149
|
+
...colorTokens.light.green,
|
|
150
|
+
...colorTokens.light.orange,
|
|
151
|
+
...colorTokens.light.pink,
|
|
152
|
+
...colorTokens.light.purple,
|
|
153
|
+
...colorTokens.light.red,
|
|
154
|
+
...colorTokens.light.violet,
|
|
155
|
+
...colorTokens.light.yellow,
|
|
156
|
+
...colorTokens.light.teal,
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
const allColors = {
|
|
160
|
+
...postfixObjKeys(lightColors, 'Light'),
|
|
161
|
+
...postfixObjKeys(darkColors, 'Dark'),
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
function postfixObjKeys<A extends { [key: string]: Variable<string> | string }, B extends string>(
|
|
165
|
+
obj: A,
|
|
166
|
+
postfix: B
|
|
167
|
+
): {
|
|
168
|
+
[Key in `${keyof A extends string ? keyof A : never}${B}`]: Variable<string> | string
|
|
169
|
+
} {
|
|
170
|
+
return Object.fromEntries(Object.entries(obj).map(([k, v]) => [`${k}${postfix}`, v])) as any
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
const radius = {
|
|
174
|
+
0: 0,
|
|
175
|
+
1: 3,
|
|
176
|
+
2: 5,
|
|
177
|
+
3: 7,
|
|
178
|
+
4: 9,
|
|
179
|
+
5: 10,
|
|
180
|
+
6: 16,
|
|
181
|
+
7: 19,
|
|
182
|
+
8: 22,
|
|
183
|
+
9: 26,
|
|
184
|
+
10: 34,
|
|
185
|
+
11: 42,
|
|
186
|
+
12: 50,
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
export const tokens = createTokens({
|
|
190
|
+
color: allColors,
|
|
191
|
+
radius,
|
|
192
|
+
zIndex,
|
|
193
|
+
space,
|
|
194
|
+
size,
|
|
195
|
+
})
|