Skip to content

Commit 221faa2

Browse files
committed
fix: code review findings
1 parent 7f63048 commit 221faa2

17 files changed

Lines changed: 36 additions & 124 deletions

File tree

src/components/Card/CardTitle.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export type Props = React.ComponentPropsWithRef<typeof View> & {
4040
*
4141
* Body: `bodyLarge`, `bodyMedium`, `bodySmall`
4242
*/
43-
titleVariant?: keyof typeof TypescaleKey;
43+
titleVariant?: TypescaleKey;
4444
/**
4545
* Text for the subtitle. Note that this will only accept a string or `<Text>`-based node.
4646
*/
@@ -69,7 +69,7 @@ export type Props = React.ComponentPropsWithRef<typeof View> & {
6969
*
7070
* Body: `bodyLarge`, `bodyMedium`, `bodySmall`
7171
*/
72-
subtitleVariant?: keyof typeof TypescaleKey;
72+
subtitleVariant?: TypescaleKey;
7373
/**
7474
* Callback which returns a React element to display on the left side.
7575
*/

src/components/Checkbox/CheckboxItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ export type Props = {
8686
*
8787
* Body: `bodyLarge`, `bodyMedium`, `bodySmall`
8888
*/
89-
labelVariant?: keyof typeof TypescaleKey;
89+
labelVariant?: TypescaleKey;
9090
/**
9191
* @optional
9292
*/

src/components/Menu/Menu.tsx

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ import { useSafeAreaInsets } from 'react-native-safe-area-context';
2424
import MenuItem from './MenuItem';
2525
import { useInternalTheme } from '../../core/theming';
2626
import type { Elevation, Theme, ThemeProp } from '../../types';
27-
import { ElevationLevels } from '../../types';
2827
import { addEventListener } from '../../utils/addEventListener';
2928
import { BackHandler } from '../../utils/BackHandler/BackHandler';
3029
import Portal from '../Portal/Portal';
@@ -105,9 +104,14 @@ const EASING = Easing.bezier(0.4, 0, 0.2, 1);
105104
const WINDOW_LAYOUT = Dimensions.get('window');
106105

107106
const DEFAULT_ELEVATION: Elevation = 2;
108-
export const ELEVATION_LEVELS_MAP = Object.values(
109-
ElevationLevels
110-
) as ElevationLevels[];
107+
export const ELEVATION_LEVELS_MAP = [
108+
'level0',
109+
'level1',
110+
'level2',
111+
'level3',
112+
'level4',
113+
'level5',
114+
] as const;
111115

112116
const DEFAULT_MODE = 'elevated';
113117

src/components/RadioButton/RadioButtonItem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export type Props = {
8888
*
8989
* Body: `bodyLarge`, `bodyMedium`, `bodySmall`
9090
*/
91-
labelVariant?: keyof typeof TypescaleKey;
91+
labelVariant?: TypescaleKey;
9292
/**
9393
* Specifies the largest possible scale a label font can reach.
9494
*/

src/components/Typography/types.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ import type { TypescaleKey } from '../../types';
22

33
export type VariantProp<T> =
44
| (T extends string ? (string extends T ? never : T) : never)
5-
| keyof typeof TypescaleKey;
5+
| TypescaleKey;

src/components/__tests__/__snapshots__/ListSection.test.tsx.snap

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -188,16 +188,6 @@ exports[`renders list section with custom title style 1`] = `
188188
},
189189
},
190190
"roundness": 4,
191-
"state": {
192-
"opacity": {
193-
"disabled": 0.38,
194-
"dragged": 0.16,
195-
"enabled": 1,
196-
"focused": 0.1,
197-
"hovered": 0.08,
198-
"pressed": 0.1,
199-
},
200-
},
201191
}
202192
}
203193
>
@@ -740,16 +730,6 @@ exports[`renders list section with subheader 1`] = `
740730
},
741731
},
742732
"roundness": 4,
743-
"state": {
744-
"opacity": {
745-
"disabled": 0.38,
746-
"dragged": 0.16,
747-
"enabled": 1,
748-
"focused": 0.1,
749-
"hovered": 0.08,
750-
"pressed": 0.1,
751-
},
752-
},
753733
}
754734
}
755735
>
@@ -1290,16 +1270,6 @@ exports[`renders list section without subheader 1`] = `
12901270
},
12911271
},
12921272
"roundness": 4,
1293-
"state": {
1294-
"opacity": {
1295-
"disabled": 0.38,
1296-
"dragged": 0.16,
1297-
"enabled": 1,
1298-
"focused": 0.1,
1299-
"hovered": 0.08,
1300-
"pressed": 0.1,
1301-
},
1302-
},
13031273
}
13041274
}
13051275
>

src/deprecated.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@
1111
import { DarkTheme } from './theme/schemes/DarkTheme';
1212
import { LightTheme } from './theme/schemes/LightTheme';
1313
import { Palette } from './theme/tokens';
14-
import { TypescaleKey } from './types';
15-
import type { Theme, Elevation } from './types';
14+
import type { Theme, Elevation, TypescaleKey } from './types';
1615

1716
/**
1817
* @deprecated Use `LightTheme` instead. Will be removed in a future version.
@@ -32,8 +31,6 @@ export const MD3Colors = Palette;
3231
/**
3332
* @deprecated Use `TypescaleKey` instead. Will be removed in a future version.
3433
*/
35-
export const MD3TypescaleKey = TypescaleKey;
36-
// eslint-disable-next-line no-redeclare
3734
export type MD3TypescaleKey = TypescaleKey;
3835

3936
/**

src/theme/fonts.tsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,8 @@ import { typescale } from './tokens';
22
import type { TypescaleStyle, Typescale, TypescaleKey } from './types';
33

44
type FontsConfig =
5-
| {
6-
[key in TypescaleKey]: Partial<TypescaleStyle>;
7-
}
8-
| {
9-
[key: string]: TypescaleStyle;
10-
}
5+
| Record<TypescaleKey, Partial<TypescaleStyle>>
6+
| Record<string, TypescaleStyle>
117
| Partial<TypescaleStyle>;
128

139
function configureFontsConfig(

src/theme/schemes/DarkTheme.tsx

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
import { baseTheme } from './base';
22
import { tokens } from '../tokens';
33
import { buildScheme } from '../tokens/sys/color/roles';
4-
import { defaultState } from '../tokens/sys/state';
54
import type { Theme } from '../types';
65

76
export const DarkTheme: Theme = {
87
...baseTheme,
98
dark: true,
109
mode: 'adaptive',
1110
colors: buildScheme(tokens.md.ref.palette, tokens.md.ref, { mode: 'dark' }),
12-
state: defaultState,
1311
};

src/theme/schemes/DynamicTheme.android.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import { Platform, PlatformColor } from 'react-native';
22

33
import { DarkTheme } from './DarkTheme';
44
import { LightTheme } from './LightTheme';
5-
import { defaultState } from '../tokens/sys/state';
65
import type { Theme } from '../types';
76

87
const isApi34 = (Platform.Version as number) >= 34;
@@ -495,11 +494,9 @@ const darkColors = {
495494
export const DynamicLightTheme: Theme = {
496495
...LightTheme,
497496
colors: { ...LightTheme.colors, ...lightColors },
498-
state: defaultState,
499497
};
500498

501499
export const DynamicDarkTheme: Theme = {
502500
...DarkTheme,
503501
colors: { ...DarkTheme.colors, ...darkColors },
504-
state: defaultState,
505502
};

0 commit comments

Comments
 (0)