Skip to content

Commit accaf63

Browse files
committed
fix(*): fix checkbox size and style refactorings
1 parent 9165581 commit accaf63

14 files changed

Lines changed: 160 additions & 188 deletions

File tree

src/components/Badge/Badge.styles.ts

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,16 @@
11
import { TextStyle, ViewStyle } from 'react-native';
22

3-
import { FillColor, Fills, Theme } from '../../theme/ThemeInterface';
3+
import {
4+
ControlSize,
5+
FillColor,
6+
Fills,
7+
Theme,
8+
} from '../../theme/ThemeInterface';
49
import { Shape, shapeMapping } from '../Box';
510

6-
export interface BadgeSizes {
7-
small: ViewStyle;
8-
medium: ViewStyle;
9-
large: ViewStyle;
10-
}
11-
12-
export type BadgeSize = keyof BadgeSizes;
13-
1411
export interface BadgeVariables {
1512
fills: Fills;
16-
sizes: BadgeSizes;
13+
sizes: { [size in ControlSize]: ViewStyle };
1714
}
1815
export const getBadgeVariables = (theme: Theme): BadgeVariables => {
1916
return {
@@ -43,7 +40,7 @@ export const getBadgeVariables = (theme: Theme): BadgeVariables => {
4340

4441
export interface BadgeStylesProps {
4542
shape: Shape;
46-
size: BadgeSize;
43+
size: ControlSize;
4744
color: FillColor;
4845
isSolid: boolean;
4946
}

src/components/Badge/Badge.tsx

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,16 @@ import { View } from 'react-native';
33
import { DeepPartial } from 'ts-essentials';
44

55
import { useTheme } from '../../theme';
6-
import { FillColor } from '../../theme/ThemeInterface';
6+
import { ControlSize, FillColor } from '../../theme/ThemeInterface';
77
import { mergeStyles, ReplaceReturnType } from '../../utils/mergeStyles';
88
import { Shape } from '../Box';
99
import { Text } from '../Typography';
10-
import {
11-
BadgeSize,
12-
BadgeStyles,
13-
GetBadgeStyles,
14-
getBadgeStyles,
15-
} from './Badge.styles';
10+
import { BadgeStyles, GetBadgeStyles, getBadgeStyles } from './Badge.styles';
1611

1712
export interface BadgeProps {
1813
children: React.ReactNode;
1914
color?: FillColor;
20-
size?: BadgeSize;
15+
size?: ControlSize;
2116
shape?: Shape;
2217
isSolid?: boolean;
2318
getStyles?: ReplaceReturnType<GetBadgeStyles, DeepPartial<BadgeStyles>>;

src/components/Checkbox/Checkbox.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import { Checkbox } from '.';
2020
isDisabled={false}
2121
isInteractive={true}
2222
onChange={toggle}
23-
size="small"
23+
size="medium"
2424
getStyles={(props, theme) => ({
2525
checkboxStyle: {},
2626
checkboxFocusBackgroundColor: '',

src/components/Checkbox/Checkbox.styles.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const getCheckboxStyles: GetCheckboxStyles = (
4444
{ isChecked, isDisabled, shape, hasLabel, labelPosition, checkColor, size },
4545
theme,
4646
) => {
47-
const sizeValue = theme.controlHeights[size];
47+
const sizeValue = theme.controlHeights[size] - 16;
4848

4949
return {
5050
checkboxFocusBackgroundColor: isChecked

src/components/Checkbox/Checkbox.tsx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export const Checkbox = (props: CheckboxProps) => {
4444
onChange = () => null,
4545
shape = 'square',
4646
labelPosition = 'right',
47-
size = 'small',
47+
size = 'medium',
4848
label,
4949
checkColor,
5050
getStyles,
@@ -92,15 +92,19 @@ export const Checkbox = (props: CheckboxProps) => {
9292
>
9393
<View style={outerWrapperStyle}>
9494
{labelPosition === 'left' && (
95-
<Text getStyles={() => ({ textStyle })}>{label}</Text>
95+
<Text size={size} getStyles={() => ({ textStyle })}>
96+
{label}
97+
</Text>
9698
)}
9799

98100
<View style={checkboxStyle}>
99101
{isChecked ? <Icon name="check" size={20} color={iconColor} /> : null}
100102
</View>
101103

102104
{labelPosition === 'right' && (
103-
<Text getStyles={() => ({ textStyle })}>{label}</Text>
105+
<Text size={size} getStyles={() => ({ textStyle })}>
106+
{label}
107+
</Text>
104108
)}
105109
</View>
106110
</TouchableHighlight>

src/components/Grid/Container.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,20 @@ import { DeepPartial } from 'ts-essentials';
44

55
import { useTheme } from '../../theme';
66
import { mergeStyles, ReplaceReturnType } from '../../utils/mergeStyles';
7-
import { GetProgressStyles, ProgressStyles } from '../Progress/Progress.styles';
8-
import { getContainerStyles } from './Container.styles';
7+
import {
8+
ContainerStyles,
9+
GetContainerStyles,
10+
getContainerStyles,
11+
} from './Container.styles';
912
import { LayoutContext } from './LayoutContext';
1013

1114
export interface ContainerProps {
1215
children: React.ReactNode;
1316
maxWidth?: number;
14-
getStyles?: ReplaceReturnType<GetProgressStyles, DeepPartial<ProgressStyles>>;
17+
getStyles?: ReplaceReturnType<
18+
GetContainerStyles,
19+
DeepPartial<ContainerStyles>
20+
>;
1521
}
1622

1723
/**

src/components/Progress/Progress.styles.ts

Lines changed: 0 additions & 74 deletions
This file was deleted.

src/components/Progress/index.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/components/Progress/Progress.mdx renamed to src/components/ProgressBar/ProgressBar.mdx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
---
2-
name: Progress
2+
name: ProgressBar
33
menu: Components
44
---
55

66
import { Counter as CounterContainer } from 'react-powerplug';
77
import { Playground, Props } from 'docz';
8-
import { Progress } from './Progress';
8+
import { ProgressBar } from '.';
99
import { Box } from '../Box';
1010
import { Button } from '../Button';
1111
import { Counter } from '../Counter';
1212

13-
# Progress
13+
# ProgressBar
1414

1515
### Usage
1616

1717
<Playground>
1818
<CounterContainer initial={0}>
1919
{({ count, incBy, decBy }) => (
2020
<Box>
21-
<Progress
21+
<ProgressBar
2222
percent={count}
2323
size="large"
2424
getStyles={(props, theme) => ({
@@ -40,4 +40,4 @@ import { Counter } from '../Counter';
4040

4141
### Props
4242

43-
<Props of={Progress} />
43+
<Props of={ProgressBar} />
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import { ViewStyle } from 'react-native';
2+
3+
import { ControlSize, Theme } from '../../theme/ThemeInterface';
4+
5+
export interface ProgressBarVariables {
6+
container: ViewStyle;
7+
progress: ViewStyle;
8+
}
9+
10+
export interface ProgressBarStylesProps {
11+
size: ControlSize;
12+
}
13+
14+
export type GetProgressBarStyles = (
15+
progressStylesProps: ProgressBarStylesProps,
16+
theme: Theme,
17+
) => ProgressBarStyles;
18+
19+
export interface ProgressBarStyles {
20+
progressStyle: ViewStyle;
21+
containerStyle: ViewStyle;
22+
}
23+
24+
export const getProgressBarStyles: GetProgressBarStyles = ({ size }, theme) => {
25+
const height = theme.controlHeights[size] - 16;
26+
27+
return {
28+
containerStyle: {
29+
backgroundColor: theme.colors.background.greyDefault,
30+
borderRadius: 999,
31+
height,
32+
overflow: 'hidden',
33+
},
34+
progressStyle: {
35+
backgroundColor: theme.colors.background.primaryDefault,
36+
borderRadius: 999,
37+
height: '100%',
38+
},
39+
};
40+
};

0 commit comments

Comments
 (0)