Skip to content

Commit e52d0cb

Browse files
authored
Update Redux Toolkit (#3129)
1 parent 50dfd81 commit e52d0cb

34 files changed

Lines changed: 172 additions & 146 deletions

apps/zui/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
"@brimdata/zed-node": "workspace:*",
4343
"@js-joda/core": "^3.2.0",
4444
"@monaco-editor/react": "^4.5.1",
45-
"@reduxjs/toolkit": "^1.9.3",
45+
"@reduxjs/toolkit": "^2.2.5",
4646
"@swc/cli": "^0.1.55",
4747
"@swc/core": "^1.2.144",
4848
"@swc/jest": "^0.2.17",

apps/zui/src/app/routes/app-wrapper/main-area.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const BG = styled.main`
1818
margin: 10px;
1919
margin-top: 0;
2020
border-radius: 6px;
21-
box-shadow: var(--shadow-s);
21+
box-shadow: var(--shadow-m);
2222
border: 1px solid var(--border-color);
2323
2424
@media (prefers-color-scheme: light) {

apps/zui/src/components/icon-button.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,13 @@ const BG = styled.button`
3333
&:hover:not(:disabled) {
3434
background: var(--emphasis-bg);
3535
svg {
36-
transform: scale(1.1);
36+
transform: scale(1.03);
3737
}
3838
}
3939
4040
&:active:not(:disabled) {
41-
background: var(--emphasis-bg-more);
42-
svg {
43-
transform: scale(1.05);
44-
}
41+
background: var(--emphasis-bg);
42+
transform: scale(0.99);
4543
}
4644
4745
&.icon-label {

apps/zui/src/components/icon/icon-names.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export type IconMapping = {[name: string]: MingCuteIconName}
55
export type IconName = keyof typeof iconNames | keyof typeof customIconNames
66

77
export const iconNames = {
8+
session: "layout_top",
89
chevron_down: "down",
910
chevron_left: "left",
1011
chevron_right: "right",

apps/zui/src/core/state/create-crud-slice.ts

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99

1010
export function createCrudSlice<T>(opts: {
1111
name: string
12-
adapter: EntityAdapter<T>
12+
adapter: EntityAdapter<T, string>
1313
}) {
1414
const {name, adapter} = opts
1515

@@ -21,41 +21,50 @@ export function createCrudSlice<T>(opts: {
2121

2222
return createSlice({
2323
name,
24-
initialState: {ids: [], entities: {}} as EntityState<T>,
24+
initialState: {ids: [], entities: {}} as EntityState<T, string>,
2525
reducers: {
2626
sync: (state, action: PayloadAction<T[]>) => {
27-
adapter.setAll(state as EntityState<T>, action.payload)
27+
adapter.setAll(state as EntityState<T, string>, action.payload)
2828
},
2929
create: (state, action: PayloadAction<T | T[]>) => {
3030
if (Array.isArray(action.payload)) {
31-
adapter.addMany(state as EntityState<T>, action.payload)
31+
adapter.addMany(state as EntityState<T, string>, action.payload)
3232
} else {
33-
adapter.addOne(state as EntityState<T>, action.payload)
33+
adapter.addOne(state as EntityState<T, string>, action.payload)
3434
}
3535
},
36-
update: (state, action: PayloadAction<Update<T> | Update<T>[]>) => {
36+
update: (
37+
state,
38+
action: PayloadAction<Update<T, string> | Update<T, string>[]>
39+
) => {
3740
if (Array.isArray(action.payload)) {
38-
adapter.updateMany(state as EntityState<T>, action.payload)
41+
adapter.updateMany(state as EntityState<T, string>, action.payload)
3942
} else {
40-
adapter.updateOne(state as EntityState<T>, action.payload)
43+
adapter.updateOne(state as EntityState<T, string>, action.payload)
4144
}
4245
},
4346
upsert: (state, action: PayloadAction<T | T[]>) => {
4447
if (Array.isArray(action.payload)) {
45-
adapter.upsertMany(state as EntityState<T>, action.payload)
48+
adapter.upsertMany(state as EntityState<T, string>, action.payload)
4649
} else {
47-
adapter.upsertOne(state as EntityState<T>, action.payload)
50+
adapter.upsertOne(state as EntityState<T, string>, action.payload)
4851
}
4952
},
5053
delete: (state, action: PayloadAction<string | string[] | T | T[]>) => {
5154
if (Array.isArray(action.payload)) {
52-
adapter.removeMany(state as EntityState<T>, action.payload.map(getId))
55+
adapter.removeMany(
56+
state as EntityState<T, string>,
57+
action.payload.map(getId) as any
58+
)
5359
} else {
54-
adapter.removeOne(state as EntityState<T>, getId(action.payload))
60+
adapter.removeOne(
61+
state as EntityState<T, string>,
62+
getId(action.payload) as any
63+
)
5564
}
5665
},
5766
deleteAll: (state) => {
58-
adapter.removeAll(state as EntityState<T>)
67+
adapter.removeAll(state as EntityState<T, string>)
5968
},
6069
},
6170
})

apps/zui/src/css/_utilities.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,3 +259,9 @@
259259
.debug-blue {
260260
outline: 1px dashed blue;
261261
}
262+
263+
.truncate {
264+
white-space: nowrap;
265+
overflow: hidden;
266+
text-overflow: ellipsis;
267+
}

apps/zui/src/css/blocks/_section-tabs.scss

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,23 @@
55
border-top: 2px solid transparent;
66
border-bottom: 2px solid transparent;
77
color: var(--fg-color-less);
8+
transition: all var(--hover-duration);
89

910
&[aria-pressed="true"] {
1011
opacity: 1;
1112
color: var(--text-active);
1213
border-bottom: 2px solid var(--primary-color);
1314
}
1415

15-
&:hover {
16+
&:hover,
17+
&:active {
1618
background: var(--emphasis-bg-less);
1719
}
1820

21+
&:active {
22+
transform: scale(0.985);
23+
}
24+
1925
span {
2026
padding: 0 var(--half-gutter);
2127
display: block;
Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,3 @@
11
.box {
22
padding: var(--gutter-space);
33
}
4-
5-
.gutter {
6-
padding-inline: var(--gutter-space);
7-
}
8-
9-
.gutter-block {
10-
padding-block: var(--gutter-space);
11-
}
12-
13-
.half-gutter {
14-
--gutter-space: var(--half-gutter);
15-
}
16-
17-
.gutter-inline-end {
18-
padding-inline-end: var(--gutter);
19-
}

apps/zui/src/css/compositions/_flex-center.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,13 @@
33
align-items: center;
44
justify-content: center;
55
}
6+
7+
.center-y {
8+
display: flex;
9+
align-items: center;
10+
}
11+
12+
.center-x {
13+
display: flex;
14+
justify-content: center;
15+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
.gutter {
2+
padding-inline: var(--gutter-space);
3+
}
4+
5+
.gutter-block {
6+
padding-block: var(--gutter-space);
7+
}
8+
9+
.half-gutter {
10+
--gutter-space: var(--half-gutter);
11+
}
12+
13+
.gutter-inline-end {
14+
padding-inline-end: var(--gutter);
15+
}

0 commit comments

Comments
 (0)