Skip to content

Commit 96a042c

Browse files
committed
feat: add theme.shapes and cornersToStyle
1 parent f998dff commit 96a042c

27 files changed

Lines changed: 117 additions & 46 deletions

File tree

example/src/Examples/TextInputExample.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -672,7 +672,7 @@ const TextInputExample = () => {
672672
<TextInput
673673
mode="outlined"
674674
theme={{
675-
roundness: 25,
675+
shapes: { corner: { extraSmall: 25 } },
676676
}}
677677
label="Outlined text input with custom roundness"
678678
/>
@@ -681,7 +681,7 @@ const TextInputExample = () => {
681681
<TextInput
682682
mode="outlined"
683683
label="Outlined text input without roundness"
684-
theme={{ roundness: 0 }}
684+
theme={{ shapes: { corner: { extraSmall: 0 } } }}
685685
/>
686686
</View>
687687
<View style={styles.inputContainerStyle}>

src/components/Button/Button.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,7 +210,7 @@ const Button = (
210210
},
211211
[mode]
212212
);
213-
const { roundness, animation } = theme;
213+
const { animation } = theme;
214214
const uppercase = uppercaseProp ?? false;
215215
const isWeb = Platform.OS === 'web';
216216

@@ -271,7 +271,7 @@ const Button = (
271271
(style) => style.startsWith('border') && style.endsWith('Radius')
272272
);
273273

274-
const borderRadius = 5 * roundness;
274+
const borderRadius = theme.shapes.corner.largeIncreased;
275275
const iconSize = 18;
276276

277277
const {

src/components/Card/Card.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,7 @@ const Card = (
181181
const { current: elevationDarkAdaptive } = React.useRef<Animated.Value>(
182182
new Animated.Value(cardElevation)
183183
);
184-
const { animation, dark, mode, roundness } = theme;
184+
const { animation, dark, mode } = theme;
185185

186186
const prevDarkRef = React.useRef<boolean>(dark);
187187
React.useEffect(() => {
@@ -267,7 +267,7 @@ const Card = (
267267
);
268268

269269
const borderRadiusCombinedStyles = {
270-
borderRadius: 3 * roundness,
270+
borderRadius: theme.shapes.corner.medium,
271271
...borderRadiusStyles,
272272
};
273273

src/components/Card/utils.tsx

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,15 @@ export const getCardCoverStyle = ({
2626
index?: number;
2727
total?: number;
2828
}) => {
29-
const { roundness } = theme;
30-
3129
if (Object.keys(borderRadiusStyles).length > 0) {
3230
return {
33-
borderRadius: 3 * roundness,
31+
borderRadius: theme.shapes.corner.medium,
3432
...borderRadiusStyles,
3533
};
3634
}
3735

3836
return {
39-
borderRadius: 3 * roundness,
37+
borderRadius: theme.shapes.corner.medium,
4038
};
4139
};
4240

src/components/Chip/Chip.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,6 @@ const Chip = ({
205205
...rest
206206
}: Props) => {
207207
const theme = useInternalTheme(themeOverrides);
208-
const { roundness } = theme;
209208
const isWeb = Platform.OS === 'web';
210209

211210
const { current: elevation } = React.useRef<Animated.Value>(
@@ -244,7 +243,7 @@ const Chip = ({
244243
});
245244

246245
const opacity = 0.38;
247-
const defaultBorderRadius = roundness * 2;
246+
const defaultBorderRadius = theme.shapes.corner.small;
248247
const iconSize = 18;
249248

250249
const {

src/components/Dialog/Dialog.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,7 @@ const Dialog = ({
105105
}: Props) => {
106106
const { right, left } = useSafeAreaInsets();
107107
const theme = useInternalTheme(themeOverrides);
108-
const { roundness } = theme as Theme;
109-
const borderRadius = 7 * roundness;
108+
const borderRadius = (theme as Theme).shapes.corner.extraLarge;
110109

111110
const backgroundColor = theme.colors.surfaceContainerHigh;
112111

src/components/Drawer/DrawerItem.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,14 @@ const DrawerItem = ({
100100
...rest
101101
}: Props) => {
102102
const theme = useInternalTheme(themeOverrides);
103-
const { roundness } = theme;
104103

105104
const backgroundColor = active ? theme.colors.secondaryContainer : undefined;
106105
const contentColor = active
107106
? theme.colors.onSecondaryContainer
108107
: theme.colors.onSurfaceVariant;
109108

110109
const labelMargin = icon ? 12 : 0;
111-
const borderRadius = 7 * roundness;
110+
const borderRadius = theme.shapes.corner.extraLarge;
112111
const font = theme.fonts.labelLarge;
113112

114113
return (

src/components/FAB/utils.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -284,10 +284,10 @@ const v3LargeSize = {
284284
width: 96,
285285
};
286286

287-
const getCustomFabSize = (customSize: number, roundness: number) => ({
287+
const getCustomFabSize = (customSize: number) => ({
288288
height: customSize,
289289
width: customSize,
290-
borderRadius: roundness === 0 ? 0 : customSize / roundness,
290+
borderRadius: customSize / 4,
291291
});
292292

293293
export const getFabStyle = ({
@@ -299,17 +299,15 @@ export const getFabStyle = ({
299299
size: 'small' | 'medium' | 'large';
300300
theme: InternalTheme;
301301
}) => {
302-
const { roundness } = theme;
303-
304-
if (customSize) return getCustomFabSize(customSize, roundness);
302+
if (customSize) return getCustomFabSize(customSize);
305303

306304
switch (size) {
307305
case 'small':
308-
return { ...v3SmallSize, borderRadius: 3 * roundness };
306+
return { ...v3SmallSize, borderRadius: theme.shapes.corner.medium };
309307
case 'medium':
310-
return { ...v3MediumSize, borderRadius: 4 * roundness };
308+
return { ...v3MediumSize, borderRadius: theme.shapes.corner.large };
311309
case 'large':
312-
return { ...v3LargeSize, borderRadius: 7 * roundness };
310+
return { ...v3LargeSize, borderRadius: theme.shapes.corner.extraLarge };
313311
}
314312
};
315313

src/components/Menu/Menu.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ const Menu = ({
622622
}),
623623
},
624624
],
625-
borderRadius: theme.roundness,
625+
borderRadius: theme.shapes.corner.extraSmall,
626626
...(scrollableMenuHeight ? { height: scrollableMenuHeight } : {}),
627627
};
628628

src/components/Searchbar.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import IconButton from './IconButton/IconButton';
2020
import MaterialCommunityIcon from './MaterialCommunityIcon';
2121
import Surface from './Surface';
2222
import { useInternalTheme } from '../core/theming';
23+
import { cornerNone } from '../theme/tokens/sys/shape';
2324
import type { Theme, ThemeProp } from '../types';
2425
import { forwardRef } from '../utils/forwardRef';
2526

@@ -213,7 +214,7 @@ const Searchbar = forwardRef<TextInputHandles, Props>(
213214
onClearIconPress?.(e);
214215
};
215216

216-
const { roundness, dark } = theme;
217+
const { dark } = theme;
217218

218219
const placeholderTextColor = theme.colors.onSurface;
219220
const textColor = theme.colors.onSurfaceVariant;
@@ -237,10 +238,12 @@ const Searchbar = forwardRef<TextInputHandles, Props>(
237238
return (
238239
<Surface
239240
style={[
240-
{ borderRadius: roundness },
241+
{ borderRadius: theme.shapes.corner.extraSmall },
241242
{
242243
backgroundColor: theme.colors.surfaceContainerHigh,
243-
borderRadius: roundness * (isBarMode ? 7 : 0),
244+
borderRadius: isBarMode
245+
? theme.shapes.corner.extraLarge
246+
: cornerNone,
244247
},
245248
styles.container,
246249
style,

0 commit comments

Comments
 (0)