@tamagui/theme-base 1.46.1 → 1.47.0

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/index.js CHANGED
@@ -1,32 +1,5 @@
1
1
  "use strict";
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __hasOwnProp = Object.prototype.hasOwnProperty;
6
- var __copyProps = (to, from, except, desc) => {
7
- if (from && typeof from === "object" || typeof from === "function") {
8
- for (let key of __getOwnPropNames(from))
9
- if (!__hasOwnProp.call(to, key) && key !== except)
10
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
- }
12
- return to;
13
- };
14
- var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
15
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
16
- var src_exports = {};
17
- module.exports = __toCommonJS(src_exports);
18
- __reExport(src_exports, require("./themes"), module.exports);
19
- __reExport(src_exports, require("./tokens"), module.exports);
20
- __reExport(src_exports, require("@tamagui/colors"), module.exports);
21
- if (process.env.NODE_ENV === "development") {
22
- console.log(
23
- `Note: We've moved @tamagui/theme-base over to @tamagui/themes. They are much improved and easier to use. If you really want to keep this package, copy and paste the contents into your app as it will be removed eventually.`
24
- );
25
- }
26
- // Annotate the CommonJS export names for ESM import in node:
27
- 0 && (module.exports = {
28
- ...require("./themes"),
29
- ...require("./tokens"),
30
- ...require("@tamagui/colors")
31
- });
2
+ throw new Error(
3
+ `This package is deprecated and replaced with @tamagui/themes, please change`
4
+ );
32
5
  //# sourceMappingURL=index.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.tsx"],
4
- "mappings": ";;;;;;;;;;;;;;;AAAA;AAAA;AAAA,wBAAc,qBAAd;AACA,wBAAc,qBADd;AAEA,wBAAc,4BAFd;AAIA,IAAI,QAAQ,IAAI,aAAa,eAAe;AAE1C,UAAQ;AAAA,IACN;AAAA,EACF;AACF;",
4
+ "mappings": ";AAAA,MAAM,IAAI;AAAA,EACR;AACF;",
5
5
  "names": []
6
6
  }
package/dist/esm/index.js CHANGED
@@ -1,9 +1,4 @@
1
- export * from "./themes";
2
- export * from "./tokens";
3
- export * from "@tamagui/colors";
4
- if (process.env.NODE_ENV === "development") {
5
- console.log(
6
- `Note: We've moved @tamagui/theme-base over to @tamagui/themes. They are much improved and easier to use. If you really want to keep this package, copy and paste the contents into your app as it will be removed eventually.`
7
- );
8
- }
1
+ throw new Error(
2
+ `This package is deprecated and replaced with @tamagui/themes, please change`
3
+ );
9
4
  //# sourceMappingURL=index.js.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.tsx"],
4
- "mappings": "AAAA,cAAc;AACd,cAAc;AACd,cAAc;AAEd,IAAI,QAAQ,IAAI,aAAa,eAAe;AAE1C,UAAQ;AAAA,IACN;AAAA,EACF;AACF;",
4
+ "mappings": "AAAA,MAAM,IAAI;AAAA,EACR;AACF;",
5
5
  "names": []
6
6
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/theme-base",
3
- "version": "1.46.1",
3
+ "version": "1.47.0",
4
4
  "types": "./types/index.d.ts",
5
5
  "main": "dist/cjs",
6
6
  "module": "dist/esm",
@@ -26,13 +26,8 @@
26
26
  "require": "./dist/cjs/index.js"
27
27
  }
28
28
  },
29
- "dependencies": {
30
- "@tamagui/colors": "1.46.1",
31
- "@tamagui/core": "1.46.1",
32
- "@tamagui/create-themes": "1.46.1"
33
- },
34
29
  "devDependencies": {
35
- "@tamagui/build": "1.46.1"
30
+ "@tamagui/build": "1.47.0"
36
31
  },
37
32
  "publishConfig": {
38
33
  "access": "public"
package/src/index.tsx CHANGED
@@ -1,10 +1,3 @@
1
- export * from './themes'
2
- export * from './tokens'
3
- export * from '@tamagui/colors'
4
-
5
- if (process.env.NODE_ENV === 'development') {
6
- // rome-ignore lint/nursery/noConsoleLog: <explanation>
7
- console.log(
8
- `Note: We've moved @tamagui/theme-base over to @tamagui/themes. They are much improved and easier to use. If you really want to keep this package, copy and paste the contents into your app as it will be removed eventually.`
9
- )
10
- }
1
+ throw new Error(
2
+ `This package is deprecated and replaced with @tamagui/themes, please change`
3
+ )
package/types/index.d.ts CHANGED
@@ -1,4 +1 @@
1
- export * from './themes';
2
- export * from './tokens';
3
- export * from '@tamagui/colors';
4
1
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAA;AACxB,cAAc,UAAU,CAAA;AACxB,cAAc,iBAAiB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":""}
@@ -1,43 +0,0 @@
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
- const 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) =>
33
- parseInt(hexStr.repeat(2 / hexStr.length), 16)
34
-
35
- const getAlphaFloat = (a: any, alpha = 1) => {
36
- if (a !== undefined) {
37
- return a / 255
38
- }
39
- if (typeof alpha !== 'number' || alpha < 0 || alpha > 1) {
40
- return 1
41
- }
42
- return alpha
43
- }
package/src/themes.tsx DELETED
@@ -1,50 +0,0 @@
1
- import { GeneratedThemes, createThemes } from '@tamagui/create-themes'
2
-
3
- import { colorTokens } from './tokens'
4
-
5
- type LightColorSets = typeof colorTokens.light
6
-
7
- type ColorNames = keyof LightColorSets
8
- type ColorShades = keyof UnionToIntersection<LightColorSets[keyof LightColorSets]>
9
-
10
- export const themes: GeneratedThemes<ColorNames, ColorShades> = createThemes({
11
- activeColor: 'blue',
12
- light: [
13
- '#fff',
14
- '#f4f4f4',
15
- 'hsl(0, 0%, 99.0%)',
16
- 'hsl(0, 0%, 97.3%)',
17
- 'hsl(0, 0%, 95.1%)',
18
- 'hsl(0, 0%, 93.0%)',
19
- 'hsl(0, 0%, 90.9%)',
20
- 'hsl(0, 0%, 88.7%)',
21
- 'hsl(0, 0%, 85.8%)',
22
- 'hsl(0, 0%, 78.0%)',
23
- 'hsl(0, 0%, 56.1%)',
24
- 'hsl(0, 0%, 52.3%)',
25
- 'hsl(0, 0%, 43.5%)',
26
- 'hsl(0, 0%, 9.0%)',
27
- ],
28
- dark: [
29
- '#111111',
30
- '#151515',
31
- '#191919',
32
- '#232323',
33
- '#282828',
34
- '#323232',
35
- '#383838',
36
- '#424242',
37
- '#494949',
38
- '#545454',
39
- '#626262',
40
- '#a5a5a5',
41
- ],
42
- colorsLight: colorTokens.light,
43
- colorsDark: colorTokens.dark,
44
- })
45
-
46
- type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
47
- k: infer I
48
- ) => void
49
- ? I
50
- : never
package/src/tokens.tsx DELETED
@@ -1,194 +0,0 @@
1
- import {
2
- blue,
3
- blueDark,
4
- gray,
5
- grayDark,
6
- green,
7
- greenDark,
8
- orange,
9
- orangeDark,
10
- pink,
11
- pinkDark,
12
- purple,
13
- purpleDark,
14
- red,
15
- redDark,
16
- yellow,
17
- yellowDark,
18
- } from '@tamagui/colors'
19
- import { Variable, createTokens, createVariable } from '@tamagui/core'
20
-
21
- // should roughly map to button/input etc height at each level
22
- // fonts should match that height/lineHeight at each stop
23
- // so these are really non-linear on purpose
24
- // why?
25
- // - at sizes <1, used for fine grained things (borders, smallest paddingY)
26
- // - so smallest padY should be roughly 1-4px so it can join with lineHeight
27
- // - at sizes >=1, have to consider "pressability" (jumps up)
28
- // - after that it should go upwards somewhat naturally
29
- // - H1 / headings top out at 10 naturally, so after 10 we can go upwards faster
30
- // but also one more wrinkle...
31
- // space is used in conjunction with size
32
- // i'm setting space to generally just a fixed fraction of size (~1/3-2/3 still fine tuning)
33
- export const size = {
34
- $0: 0,
35
- '$0.25': 2,
36
- '$0.5': 4,
37
- '$0.75': 8,
38
- $1: 20,
39
- '$1.5': 24,
40
- $2: 28,
41
- '$2.5': 32,
42
- $3: 36,
43
- '$3.5': 40,
44
- $4: 44,
45
- $true: 44,
46
- '$4.5': 48,
47
- $5: 52,
48
- $6: 64,
49
- $7: 74,
50
- $8: 84,
51
- $9: 94,
52
- $10: 104,
53
- $11: 124,
54
- $12: 144,
55
- $13: 164,
56
- $14: 184,
57
- $15: 204,
58
- $16: 224,
59
- $17: 224,
60
- $18: 244,
61
- $19: 264,
62
- $20: 284,
63
- }
64
-
65
- type SizeKeysIn = keyof typeof size
66
- type Sizes = {
67
- [Key in SizeKeysIn extends `$${infer Key}` ? Key : SizeKeysIn]: number
68
- }
69
- type SizeKeys = `${keyof Sizes extends `${infer K}` ? K : never}`
70
-
71
- const spaces = Object.entries(size).map(([k, v]) => {
72
- return [k, sizeToSpace(v)] as const
73
- })
74
-
75
- // a bit odd but keeping backward compat for values >8 while fixing below
76
- function sizeToSpace(v: number) {
77
- if (v === 0) return 0
78
- if (v === 2) return 0.5
79
- if (v === 4) return 1
80
- if (v === 8) return 1.5
81
- if (v <= 16) return Math.round(v * 0.333)
82
- return Math.floor(v * 0.7 - 12)
83
- }
84
-
85
- const spacesNegative = spaces.slice(1).map(([k, v]) => [`-${k.slice(1)}`, -v])
86
-
87
- type SizeKeysWithNegatives =
88
- | Exclude<`-${SizeKeys extends `$${infer Key}` ? Key : SizeKeys}`, '-0'>
89
- | SizeKeys
90
-
91
- export const space: {
92
- [Key in SizeKeysWithNegatives]: Key extends keyof Sizes ? Sizes[Key] : number
93
- } = {
94
- ...Object.fromEntries(spaces),
95
- ...Object.fromEntries(spacesNegative),
96
- } as any
97
-
98
- export const zIndex = {
99
- 0: 0,
100
- 1: 100,
101
- 2: 200,
102
- 3: 300,
103
- 4: 400,
104
- 5: 500,
105
- }
106
-
107
- export const colorTokens = {
108
- light: {
109
- blue: blue,
110
- gray: gray,
111
- green: green,
112
- orange: orange,
113
- pink: pink,
114
- purple: purple,
115
- red: red,
116
- yellow: yellow,
117
- },
118
- dark: {
119
- blue: blueDark,
120
- gray: grayDark,
121
- green: greenDark,
122
- orange: orangeDark,
123
- pink: pinkDark,
124
- purple: purpleDark,
125
- red: redDark,
126
- yellow: yellowDark,
127
- },
128
- }
129
-
130
- export const darkColors = {
131
- ...colorTokens.dark.blue,
132
- ...colorTokens.dark.gray,
133
- ...colorTokens.dark.green,
134
- ...colorTokens.dark.orange,
135
- ...colorTokens.dark.pink,
136
- ...colorTokens.dark.purple,
137
- ...colorTokens.dark.red,
138
- ...colorTokens.dark.yellow,
139
- }
140
-
141
- export const lightColors = {
142
- ...colorTokens.light.blue,
143
- ...colorTokens.light.gray,
144
- ...colorTokens.light.green,
145
- ...colorTokens.light.orange,
146
- ...colorTokens.light.pink,
147
- ...colorTokens.light.purple,
148
- ...colorTokens.light.red,
149
- ...colorTokens.light.yellow,
150
- }
151
-
152
- export const color = {
153
- ...postfixObjKeys(lightColors, 'Light'),
154
- ...postfixObjKeys(darkColors, 'Dark'),
155
- }
156
-
157
- function postfixObjKeys<
158
- A extends { [key: string]: Variable<string> | string },
159
- B extends string
160
- >(
161
- obj: A,
162
- postfix: B
163
- ): {
164
- [Key in `${keyof A extends string ? keyof A : never}${B}`]: Variable<string> | string
165
- } {
166
- return Object.fromEntries(
167
- Object.entries(obj).map(([k, v]) => [`${k}${postfix}`, v])
168
- ) as any
169
- }
170
-
171
- export const radius = {
172
- 0: 0,
173
- 1: 3,
174
- 2: 5,
175
- 3: 7,
176
- 4: 9,
177
- true: 9,
178
- 5: 10,
179
- 6: 16,
180
- 7: 19,
181
- 8: 22,
182
- 9: 26,
183
- 10: 34,
184
- 11: 42,
185
- 12: 50,
186
- }
187
-
188
- export const tokens = createTokens({
189
- color,
190
- radius,
191
- zIndex,
192
- space,
193
- size,
194
- })
@@ -1,4 +0,0 @@
1
- import { Variable } from '@tamagui/core';
2
- export declare const hexToRGBA: (hex: string, alpha?: number) => string;
3
- export declare const setColorAlpha: (colorIn: string | Variable, alpha?: number) => string;
4
- //# sourceMappingURL=colorUtils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"colorUtils.d.ts","sourceRoot":"","sources":["../src/colorUtils.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAoB,MAAM,eAAe,CAAA;AAE1D,eAAO,MAAM,SAAS,QAAS,MAAM,2BAQpC,CAAA;AAED,eAAO,MAAM,aAAa,YAAa,MAAM,GAAG,QAAQ,2BAYvD,CAAA"}
package/types/themes.d.ts DELETED
@@ -1,9 +0,0 @@
1
- import { GeneratedThemes } from '@tamagui/create-themes';
2
- import { colorTokens } from './tokens';
3
- type LightColorSets = typeof colorTokens.light;
4
- type ColorNames = keyof LightColorSets;
5
- type ColorShades = keyof UnionToIntersection<LightColorSets[keyof LightColorSets]>;
6
- export declare const themes: GeneratedThemes<ColorNames, ColorShades>;
7
- type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (k: infer I) => void ? I : never;
8
- export {};
9
- //# sourceMappingURL=themes.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"themes.d.ts","sourceRoot":"","sources":["../src/themes.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAgB,MAAM,wBAAwB,CAAA;AAEtE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAEtC,KAAK,cAAc,GAAG,OAAO,WAAW,CAAC,KAAK,CAAA;AAE9C,KAAK,UAAU,GAAG,MAAM,cAAc,CAAA;AACtC,KAAK,WAAW,GAAG,MAAM,mBAAmB,CAAC,cAAc,CAAC,MAAM,cAAc,CAAC,CAAC,CAAA;AAElF,eAAO,MAAM,MAAM,EAAE,eAAe,CAAC,UAAU,EAAE,WAAW,CAkC1D,CAAA;AAEF,KAAK,mBAAmB,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,GAAG,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,GAAG,KAAK,CAAC,SAAS,CAC7E,CAAC,EAAE,MAAM,CAAC,KACP,IAAI,GACL,CAAC,GACD,KAAK,CAAA"}