Skip to content

Commit 2543402

Browse files
committed
fix: button size typing
1 parent 9b2e44b commit 2543402

File tree

5 files changed

+34
-13
lines changed

5 files changed

+34
-13
lines changed

example/storybook/stories/components/Wrapper.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,11 @@ const myTheme = extendTheme({
6969
};
7070
},
7171
},
72+
sizes: {
73+
'my-size': {
74+
padding: 2,
75+
},
76+
},
7277
},
7378

7479
Checkbox: {
@@ -138,8 +143,9 @@ export function RenderTestButton() {
138143
const [state, setState] = React.useState(1);
139144
return (
140145
<Box style={{ position: 'absolute', top: 10, left: 20 }} m={2} bg="red.100">
141-
<Input m={2} />
146+
<Input m={2} size="my-size" />
142147
<Button
148+
size=""
143149
variant={'myNewButton'}
144150
// title={state.toString()}
145151
onPress={() => setState(state + 1)}

src/components/primitives/Button/types.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import type { InterfacePressableProps } from '../Pressable/types';
2727
// type buttonVariant = VariantTypeTest<'Button'>;
2828
// Todo: Create underscore Props section on docs.
2929
// _hover?: IButtonProps;
30+
3031
export interface InterfaceButtonProps
3132
extends InterfacePressableProps<IButtonProps> {
3233
/**
@@ -62,13 +63,7 @@ export interface InterfaceButtonProps
6263
/**
6364
* The size of the button.
6465
*/
65-
size?:
66-
| 'xs'
67-
| 'sm'
68-
| 'md'
69-
| 'lg'
70-
| (string & {})
71-
| ThemeComponentSizeType<'Button'>;
66+
size?: ThemeComponentSizeType<'Button'>;
7267
// size?: SizeType;
7368
/**
7469
* The start icon element to use in the button.
@@ -186,6 +181,9 @@ export type IButtonComponentType = ((
186181

187182
export type IButtonProps = InterfaceButtonProps & CustomProps<'Button'>;
188183

184+
// const a: IButtonProps = {
185+
// size:'' ;
186+
// }
189187
// type myProps = CustomProps<'Input'>;
190188
// export type IInputProps = InterfaceInputProps & CustomProps<'Input'>;
191189

src/components/primitives/Input/types.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
import type { TextInputProps } from 'react-native';
22
import type { StyledProps } from '../../../theme/types';
3-
import type { CombinedSizeType, PlatformProps, VariantType } from '../../types';
3+
import type {
4+
PlatformProps,
5+
ThemeComponentSizeType,
6+
VariantType,
7+
} from '../../types';
48
import type { InterfaceBoxProps } from '../Box';
59
import type { ResponsiveValue } from '../../../components/types';
610
import type { ISizes } from '../../../theme/base/sizes';
@@ -36,7 +40,7 @@ export interface InterfaceInputProps
3640
* The size of the input.
3741
* @default 'md'
3842
*/
39-
size?: CombinedSizeType<'Input'>; // ResponsiveValue<ISizes | (string & {}) | number>;
43+
size?: ThemeComponentSizeType<'Input'>; // ResponsiveValue<ISizes | (string & {}) | number>;
4044
/**
4145
* This will set aria-required="true" on web when passed in formcontrol.
4246
*/

src/components/types/utils.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ export type SizeType = ResponsiveValue<
2121
export type ThemeComponentSizeType<
2222
Component extends keyof ITheme['components']
2323
> = 'sizes' extends keyof ITheme['components'][Component]
24-
? ResponsiveValue<
25-
keyof ITheme['components'][Component]['sizes'] | (string & {})
26-
>
24+
? keyof ITheme['components'][Component]['sizes'] | (string & {})
2725
: never;
2826

2927
export type CombinedSizeType<Component extends keyof ITheme['components']> =

yarn.lock

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2337,6 +2337,21 @@
23372337
"@react-aria/utils" "^3.6.0"
23382338
"@react-native-aria/utils" "^0.2.6"
23392339

2340+
"@react-native-aria/[email protected]":
2341+
version "0.2.4-alpha.3"
2342+
resolved "https://registry.yarnpkg.com/@react-native-aria/listbox/-/listbox-0.2.4-alpha.3.tgz#1a8df0de6c932c8143ea73e43713a5d37070203c"
2343+
integrity sha512-e/y+Wdoyy/PbpFj4DVYDYMsKI+uUqnZ/0yLByqHQvzs8Ys8o69CQkyEYzHhxvFT5lCLegkLbuQN2cJd8bYNQsA==
2344+
dependencies:
2345+
"@react-aria/interactions" "^3.3.2"
2346+
"@react-aria/label" "^3.1.1"
2347+
"@react-aria/listbox" "^3.2.4"
2348+
"@react-aria/selection" "^3.3.2"
2349+
"@react-aria/utils" "^3.6.0"
2350+
"@react-native-aria/interactions" "^0.2.2"
2351+
"@react-native-aria/utils" "^0.2.6"
2352+
"@react-types/listbox" "^3.1.1"
2353+
"@react-types/shared" "^3.4.0"
2354+
23402355
"@react-native-aria/[email protected]":
23412356
version "0.3.3-rc.0"
23422357
resolved "https://registry.yarnpkg.com/@react-native-aria/overlays/-/overlays-0.3.3-rc.0.tgz#9041ddd6f151e6edb50c971d29920c458aa41459"

0 commit comments

Comments
 (0)