@coinbase/cdp-react 0.0.30 → 0.0.32

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.
@@ -21,6 +21,8 @@ const e = {
21
21
  // background
22
22
  alternate: { value: e.gray100 },
23
23
  // alternate background
24
+ contrast: { value: "{colors.fg.default}" },
25
+ // contrast background, used to mix with other backgrounds to create relative colors (i.e. for hover / pressed states)
24
26
  overlay: { value: "{colors.bg.alternate}", modify: { type: "alpha", value: 0.33 } },
25
27
  // overlay background
26
28
  skeleton: { value: "{colors.fg.default}", modify: { type: "alpha", value: 0.1 } },
@@ -60,7 +62,7 @@ const e = {
60
62
  negative: { value: "{colors.fg.negative}" }
61
63
  // negative line color
62
64
  }
63
- }, a = {
65
+ }, o = {
64
66
  page: {
65
67
  bg: {
66
68
  default: { value: "{colors.bg.default}" }
@@ -77,7 +79,14 @@ const e = {
77
79
  primary: {
78
80
  bg: {
79
81
  default: { value: "{colors.bg.primary}" },
80
- hover: { value: "{colors.bg.primary}", modify: { type: "alpha", value: "0.9" } }
82
+ hover: {
83
+ value: "{colors.bg.primary}",
84
+ modify: { type: "mix", value: [["{colors.bg.contrast}", "15%"]] }
85
+ },
86
+ pressed: {
87
+ value: "{colors.bg.primary}",
88
+ modify: { type: "mix", value: [["{colors.bg.contrast}", "30%"]] }
89
+ }
81
90
  },
82
91
  border: {
83
92
  focus: { value: "{colors.line.primary}" }
@@ -92,7 +101,11 @@ const e = {
92
101
  default: { value: "{colors.bg.secondary}" },
93
102
  hover: {
94
103
  value: "{colors.bg.secondary}",
95
- modify: { type: "alpha", value: "0.9" }
104
+ modify: { type: "mix", value: [["{colors.bg.contrast}", "10%"]] }
105
+ },
106
+ pressed: {
107
+ value: "{colors.bg.secondary}",
108
+ modify: { type: "mix", value: [["{colors.bg.contrast}", "20%"]] }
96
109
  }
97
110
  },
98
111
  border: {
@@ -108,13 +121,27 @@ const e = {
108
121
  primary: {
109
122
  text: {
110
123
  default: { value: "{colors.fg.primary}" },
111
- hover: { value: "{colors.fg.primary}", modify: { type: "alpha", value: "0.9" } }
124
+ hover: {
125
+ value: "{colors.fg.primary}",
126
+ modify: { type: "mix", value: [["{colors.bg.contrast}", "15%"]] }
127
+ },
128
+ pressed: {
129
+ value: "{colors.fg.primary}",
130
+ modify: { type: "mix", value: [["{colors.bg.contrast}", "30%"]] }
131
+ }
112
132
  }
113
133
  },
114
134
  secondary: {
115
135
  text: {
116
136
  default: { value: "{colors.fg.default}" },
117
- hover: { value: "{colors.fg.default}", modify: { type: "alpha", value: "0.9" } }
137
+ hover: {
138
+ value: "{colors.fg.default}",
139
+ modify: { type: "mix", value: [["{colors.bg.contrast}", "10%"]] }
140
+ },
141
+ pressed: {
142
+ value: "{colors.fg.default}",
143
+ modify: { type: "mix", value: [["{colors.bg.contrast}", "20%"]] }
144
+ }
118
145
  }
119
146
  }
120
147
  },
@@ -150,7 +177,15 @@ const e = {
150
177
  },
151
178
  trigger: {
152
179
  bg: {
153
- default: { value: "{colors.bg.default}" }
180
+ default: { value: "{colors.bg.default}" },
181
+ hover: {
182
+ value: "{colors.bg.default}",
183
+ modify: { type: "mix", value: [["{colors.bg.contrast}", "5%"]] }
184
+ },
185
+ pressed: {
186
+ value: "{colors.bg.default}",
187
+ modify: { type: "mix", value: [["{colors.bg.contrast}", "7%"]] }
188
+ }
154
189
  },
155
190
  border: {
156
191
  default: { value: "{colors.line.default}" },
@@ -184,7 +219,10 @@ const e = {
184
219
  item: {
185
220
  bg: {
186
221
  default: { value: "{colors.bg.default}" },
187
- highlight: { value: "{colors.bg.secondary}" }
222
+ highlight: {
223
+ value: "{colors.bg.default}",
224
+ modify: { type: "mix", value: [["{colors.bg.contrast}", "10%"]] }
225
+ }
188
226
  },
189
227
  text: {
190
228
  default: { value: "{colors.fg.default}" },
@@ -206,30 +244,30 @@ const e = {
206
244
  default: { value: "{colors.fg.default}" }
207
245
  }
208
246
  }
209
- }, o = {
247
+ }, a = {
210
248
  ...l,
211
- ...a
249
+ ...o
212
250
  }, r = {
213
251
  family: {
214
252
  mono: {
215
253
  value: '"DM Mono", monospace'
216
254
  },
217
255
  sans: {
218
- value: '"DM Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"'
256
+ value: '"Rethink Sans", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol"'
219
257
  }
220
258
  },
221
259
  size: {
222
260
  base: { value: 16 }
223
261
  }
224
- }, u = {
225
- colors: o,
262
+ }, t = {
263
+ colors: a,
226
264
  font: r
227
265
  };
228
266
  export {
229
- o as colors,
267
+ a as colors,
230
268
  e as colorsBase,
231
- a as colorsComponents,
269
+ o as colorsComponents,
232
270
  l as colorsSemantic,
233
271
  r as font,
234
- u as tokens
272
+ t as tokens
235
273
  };
@@ -11,6 +11,12 @@ export type TokenValue = {
11
11
  modify?: {
12
12
  type: "alpha";
13
13
  value: number | string;
14
+ } | {
15
+ type: "hsl";
16
+ value: [number, number, number];
17
+ } | {
18
+ type: "mix";
19
+ value: ReadonlyArray<string | readonly [string, string]>;
14
20
  };
15
21
  };
16
22
  export type NestedTokenObject = {
@@ -1,27 +1,44 @@
1
- function f(e) {
2
- return typeof e == "object" && e !== null && "value" in e && (typeof e.value == "string" || typeof e.value == "number");
1
+ function a(t) {
2
+ return typeof t == "object" && t !== null && "value" in t && (typeof t.value == "string" || typeof t.value == "number");
3
3
  }
4
- function p(e, t = "cdp-web") {
5
- const n = {};
6
- function o(u, s) {
7
- for (const l in u)
8
- if (Object.prototype.hasOwnProperty.call(u, l)) {
9
- const c = [...s, l], r = u[l];
10
- if (f(r)) {
11
- const i = c.join("-");
12
- n[i] = a(r, t);
13
- } else typeof r == "object" && r !== null && o(r, c);
4
+ function p(t, e = "cdp-web") {
5
+ const o = {};
6
+ function n(r, c) {
7
+ for (const s in r)
8
+ if (Object.prototype.hasOwnProperty.call(r, s)) {
9
+ const f = [...c, s], i = r[s];
10
+ if (a(i)) {
11
+ const u = f.join("-");
12
+ o[u] = y(i, e);
13
+ } else typeof i == "object" && i !== null && n(i, f);
14
14
  }
15
15
  }
16
- return o(e, []), n;
16
+ return n(t, []), o;
17
17
  }
18
- const a = (e, t) => {
19
- if (typeof e.value == "number")
20
- return `${e.value}px`;
21
- const n = e.value.startsWith("{") && e.value.endsWith("}") ? `var(--${t ? `${t}-` : ""}${e.value.slice(1, -1).replace(/\./g, "-")})` : e.value;
22
- return e.modify?.type === "alpha" ? `color(from ${n} srgb r g b / ${e.modify.value ?? 1})` : n;
23
- }, y = (e) => Object.entries(e).reduce((t, [n, o]) => (t[`--cdp-web-${n}`] = o, t), {});
18
+ const l = (t, e) => t.startsWith("{") && t.endsWith("}") ? `var(--${e ? `${e}-` : ""}${t.slice(1, -1).replace(/\./g, "-")})` : t, y = (t, e) => {
19
+ if (typeof t.value == "number")
20
+ return `${t.value}px`;
21
+ const o = l(t.value, e);
22
+ if (t.modify?.type === "alpha")
23
+ return `color(from ${o} srgb r g b / ${t.modify.value ?? 1})`;
24
+ if (t.modify?.type === "hsl") {
25
+ const [n, r, c] = t.modify.value;
26
+ return `hsl(from ${o} calc(h * ${n}) calc(s * ${r}) calc(l * ${c}))`;
27
+ }
28
+ if (t.modify?.type === "mix") {
29
+ let n = o;
30
+ return t.modify.value.forEach((r) => {
31
+ if (typeof r == "string")
32
+ n += `, ${l(r, e)}`;
33
+ else {
34
+ const [c, s] = r;
35
+ n += `, ${l(c, e)} ${s}`;
36
+ }
37
+ }), `color-mix(in oklab, ${n})`;
38
+ }
39
+ return o;
40
+ }, m = (t) => Object.entries(t).reduce((e, [o, n]) => (e[`--cdp-web-${o}`] = n, e), {});
24
41
  export {
25
42
  p as flattenTokensObject,
26
- y as themeToCssVariables
43
+ m as themeToCssVariables
27
44
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coinbase/cdp-react",
3
- "version": "0.0.30",
3
+ "version": "0.0.32",
4
4
  "type": "module",
5
5
  "dependencies": {
6
6
  "@internationalized/number": "3.6.4",
@@ -14,8 +14,8 @@
14
14
  },
15
15
  "peerDependencies": {
16
16
  "react": ">=18.2.0",
17
- "@coinbase/cdp-core": "^0.0.30",
18
- "@coinbase/cdp-hooks": "^0.0.30"
17
+ "@coinbase/cdp-core": "^0.0.32",
18
+ "@coinbase/cdp-hooks": "^0.0.32"
19
19
  },
20
20
  "devDependencies": {
21
21
  "@size-limit/preset-big-lib": "^11.2.0",
@@ -45,8 +45,8 @@
45
45
  "vite": "^7.0.4",
46
46
  "vite-plugin-dts": "^4.5.4",
47
47
  "vite-plugin-lib-inject-css": "^2.2.2",
48
- "@coinbase/cdp-core": "^0.0.30",
49
- "@coinbase/cdp-hooks": "^0.0.30"
48
+ "@coinbase/cdp-core": "^0.0.32",
49
+ "@coinbase/cdp-hooks": "^0.0.32"
50
50
  },
51
51
  "size-limit": [
52
52
  {