Skip to content

Commit e8de3f8

Browse files
authored
chore: Update spectrum tokens (#7736)
* chore: update spectrum tokens * fix chromatic stories label ordering * fix remaining stories * fix flaky story * update remaining instance of tokens * Revert chromatic changes and mergeProps order * fix lint * stabilize colorswatchpicker again
1 parent fb3b865 commit e8de3f8

File tree

5 files changed

+57
-19
lines changed

5 files changed

+57
-19
lines changed

packages/@react-aria/utils/src/mergeProps.ts

+9-9
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type PropsArg = Props | null | undefined;
2323
// taken from: https://stackoverflow.com/questions/51603250/typescript-3-parameter-list-intersection-type/51604379#51604379
2424
type TupleTypes<T> = { [P in keyof T]: T[P] } extends { [key: number]: infer V } ? NullToObject<V> : never;
2525
type NullToObject<T> = T extends (null | undefined) ? {} : T;
26-
26+
2727
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
2828

2929
/**
@@ -34,10 +34,10 @@ type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends (
3434
* @param args - Multiple sets of props to merge together.
3535
*/
3636
export function mergeProps<T extends PropsArg[]>(...args: T): UnionToIntersection<TupleTypes<T>> {
37-
// Start with a base clone of the last argument. This is a lot faster than starting
37+
// Start with a base clone of the first argument. This is a lot faster than starting
3838
// with an empty object and adding properties as we go.
39-
let result: Props = {...args[args.length - 1]};
40-
for (let i = args.length - 2; i >= 0; i--) {
39+
let result: Props = {...args[0]};
40+
for (let i = 1; i < args.length; i++) {
4141
let props = args[i];
4242
for (let key in props) {
4343
let a = result[key];
@@ -53,20 +53,20 @@ export function mergeProps<T extends PropsArg[]>(...args: T): UnionToIntersectio
5353
key.charCodeAt(2) >= /* 'A' */ 65 &&
5454
key.charCodeAt(2) <= /* 'Z' */ 90
5555
) {
56-
result[key] = chain(b, a);
56+
result[key] = chain(a, b);
5757

5858
// Merge classnames, sometimes classNames are empty string which eval to false, so we just need to do a type check
5959
} else if (
6060
(key === 'className' || key === 'UNSAFE_className') &&
6161
typeof a === 'string' &&
6262
typeof b === 'string'
6363
) {
64-
result[key] = clsx(b, a);
64+
result[key] = clsx(a, b);
6565
} else if (key === 'id' && a && b) {
66-
result.id = mergeIds(b, a);
66+
result.id = mergeIds(a, b);
6767
// Override others
68-
} else if (a === undefined) {
69-
result[key] = b;
68+
} else {
69+
result[key] = b !== undefined ? b : a;
7070
}
7171
}
7272
}

packages/@react-spectrum/s2/chromatic/ColorSwatchPicker.stories.tsx

+40-2
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,12 @@
1010
* governing permissions and limitations under the License.
1111
*/
1212

13+
import {ColorSwatch} from '../src/ColorSwatch';
1314
import {ColorSwatchPicker} from '../src/ColorSwatchPicker';
14-
import {Example, ManySwatches} from '../stories/ColorSwatchPicker.stories';
15+
import {Example} from '../stories/ColorSwatchPicker.stories';
1516
import type {Meta} from '@storybook/react';
17+
import {style} from '../style' with {type: 'macro'};
18+
1619

1720
const meta: Meta<typeof ColorSwatchPicker> = {
1821
component: ColorSwatchPicker,
@@ -24,4 +27,39 @@ const meta: Meta<typeof ColorSwatchPicker> = {
2427

2528
export default meta;
2629

27-
export {Example, ManySwatches};
30+
export {Example};
31+
32+
let colors = [
33+
'#b3e5c2',
34+
'#71fa78',
35+
'#51a358',
36+
'#0346d4',
37+
'#6f975c',
38+
'#d1239a',
39+
'#70f72d',
40+
'#36f556',
41+
'#470a97',
42+
'#1c0aa4',
43+
'#3500c0',
44+
'#dcd549',
45+
'#bfb405',
46+
'#710ac9',
47+
'#342c8f',
48+
'#858af4',
49+
'#133c2b',
50+
'#14dbac',
51+
'#41696c',
52+
'#f28686',
53+
'#58f9a5',
54+
'#ff8553',
55+
'#7cf5c3',
56+
'#bb6b41'
57+
];
58+
59+
export const ManySwatches = (args: any) => (
60+
<ColorSwatchPicker {...args} styles={style({maxWidth: 192})}>
61+
{colors.map((color) => {
62+
return <ColorSwatch key={color} color={color} />;
63+
})}
64+
</ColorSwatchPicker>
65+
);

packages/@react-spectrum/s2/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@
120120
"postpack": "git checkout -- package.json"
121121
},
122122
"devDependencies": {
123-
"@adobe/spectrum-tokens": "^13.0.0-beta.53",
123+
"@adobe/spectrum-tokens": "^13.0.0-beta.56",
124124
"@parcel/macros": "^2.13.0",
125125
"@react-aria/test-utils": "1.0.0-alpha.3",
126126
"@testing-library/dom": "^10.1.0",

packages/dev/parcel-transformer-s2-icon/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"parcel": "^2.0.0"
77
},
88
"dependencies": {
9-
"@adobe/spectrum-tokens": "^13.0.0-beta.53",
9+
"@adobe/spectrum-tokens": "^13.0.0-beta.56",
1010
"@parcel/plugin": "^2.0.0",
1111
"@svgr/core": "^8.1.0",
1212
"@svgr/plugin-jsx": "^8.1.0",

yarn.lock

+6-6
Original file line numberDiff line numberDiff line change
@@ -145,10 +145,10 @@ __metadata:
145145
languageName: unknown
146146
linkType: soft
147147

148-
"@adobe/spectrum-tokens@npm:^13.0.0-beta.53":
149-
version: 13.0.0-beta.53
150-
resolution: "@adobe/spectrum-tokens@npm:13.0.0-beta.53"
151-
checksum: 10c0/e9968e211aec06cb6af1fbc29712cafa79f0b971b4c22882c6a65f14ea8fb23afe2c81f8bbfd377bbde4332cb1dbdc873e6a32a2cc6e3933592eb5724a6ce471
148+
"@adobe/spectrum-tokens@npm:^13.0.0-beta.56":
149+
version: 13.0.0-beta.56
150+
resolution: "@adobe/spectrum-tokens@npm:13.0.0-beta.56"
151+
checksum: 10c0/473a7e3cfb9317862584045b31c16e67122512f310c490c8cb9e11c1d200bbd78f79885e970e16034b375c19f2a27da27397a4ba3ee0cec1a8424a34582a85ad
152152
languageName: node
153153
linkType: hard
154154

@@ -7775,7 +7775,7 @@ __metadata:
77757775
version: 0.0.0-use.local
77767776
resolution: "@react-spectrum/parcel-transformer-s2-icon@workspace:packages/dev/parcel-transformer-s2-icon"
77777777
dependencies:
7778-
"@adobe/spectrum-tokens": "npm:^13.0.0-beta.53"
7778+
"@adobe/spectrum-tokens": "npm:^13.0.0-beta.56"
77797779
"@parcel/plugin": "npm:^2.0.0"
77807780
"@svgr/core": "npm:^8.1.0"
77817781
"@svgr/plugin-jsx": "npm:^8.1.0"
@@ -7894,7 +7894,7 @@ __metadata:
78947894
version: 0.0.0-use.local
78957895
resolution: "@react-spectrum/s2@workspace:packages/@react-spectrum/s2"
78967896
dependencies:
7897-
"@adobe/spectrum-tokens": "npm:^13.0.0-beta.53"
7897+
"@adobe/spectrum-tokens": "npm:^13.0.0-beta.56"
78987898
"@parcel/macros": "npm:^2.13.0"
78997899
"@react-aria/collections": "npm:3.0.0-alpha.7"
79007900
"@react-aria/focus": "npm:^3.19.1"

0 commit comments

Comments
 (0)