Skip to content

Commit 22d3455

Browse files
committed
fix(listitem): remove size prop
1 parent 6a288a4 commit 22d3455

6 files changed

Lines changed: 65 additions & 139 deletions

File tree

src/components/Avatar/Avatar.styles.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,8 @@ export type GetAvatarStyles = (
5757

5858
const avatarScale: { [size in ControlSize]: number } = {
5959
large: 2,
60-
medium: 1,
61-
small: 0.75,
60+
medium: 1.5,
61+
small: 1,
6262
};
6363

6464
export const getAvatarStyles: GetAvatarStyles = (

src/components/KitchenSink/KitchenSink.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -611,7 +611,6 @@ export const KitchenSink = () => {
611611
}}
612612
title="Some label"
613613
description="Some description"
614-
size="large"
615614
/>
616615
</Playground>
617616

src/components/ListItem/ListItem.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@ For image, it composes `Avatar`, you can pass `avatarProps` provide more specifi
2121
}}
2222
title="Some label"
2323
description="Some description"
24-
size="large"
2524
/>
2625
</Playground>
2726

src/components/ListItem/ListItem.styles.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ export type GetListItemStyles = (
1818
theme: Theme,
1919
) => ListItemStyles;
2020

21-
export const getListItemStyles: GetListItemStyles = (
22-
{ size = 'medium', isDisabled },
23-
theme,
24-
) => {
21+
export const getListItemStyles: GetListItemStyles = ({ isDisabled }, theme) => {
2522
return {
2623
descriptionStyle: {},
2724
imageWrapperStyle: {
@@ -39,7 +36,7 @@ export const getListItemStyles: GetListItemStyles = (
3936
backgroundColor: theme.colors.background.content,
4037
borderBottomWidth: 1,
4138
borderColor: theme.colors.border.default,
42-
height: theme.controlHeights[size],
39+
height: theme.controlHeights.large,
4340
justifyContent: 'center',
4441
paddingLeft: 16,
4542
paddingRight: 8,

src/components/ListItem/ListItem.tsx

Lines changed: 11 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as React from 'react';
22
import { GestureResponderEvent, TouchableOpacity, View } from 'react-native';
33
import { DeepPartial } from 'ts-essentials';
44

5-
import { ControlSize, TextSize, useTheme } from '../../theme';
5+
import { useTheme } from '../../theme';
66
import { mergeStyles, ReplaceReturnType } from '../../utils/mergeStyles';
77
import { Avatar, AvatarProps } from '../Avatar';
88
import { Icon } from '../Icon';
@@ -14,18 +14,6 @@ import {
1414
} from './ListItem.styles';
1515

1616
export interface ListItemProps {
17-
/**
18-
* Size of the list item.
19-
* @default "medium"
20-
*/
21-
size?: ControlSize;
22-
23-
/**
24-
* When true, list item will not be able to be pressed.
25-
* @default false
26-
*/
27-
isDisabled?: boolean;
28-
2917
/**
3018
* Title of the list item
3119
*/
@@ -41,6 +29,12 @@ export interface ListItemProps {
4129
*/
4230
avatarProps?: AvatarProps;
4331

32+
/**
33+
* When true, list item will not be able to be pressed.
34+
* @default false
35+
*/
36+
isDisabled?: boolean;
37+
4438
/**
4539
* Icon replacing `Avatar` on the left hand-side
4640
*/
@@ -75,46 +69,13 @@ export interface ListItemProps {
7569
testID?: string;
7670
}
7771

78-
const iconSize: {
79-
[size in ControlSize]: number;
80-
} = {
81-
large: 32,
82-
medium: 24,
83-
small: 16,
84-
};
85-
86-
const avatarSize: {
87-
[size in ControlSize]: number;
88-
} = {
89-
large: 40,
90-
medium: 32,
91-
small: 24,
92-
};
93-
94-
const titleSize: {
95-
[size in ControlSize]: TextSize;
96-
} = {
97-
large: 'large',
98-
medium: 'medium',
99-
small: 'small',
100-
};
101-
102-
const descriptionSize: {
103-
[size in ControlSize]: TextSize;
104-
} = {
105-
large: 'medium',
106-
medium: 'small',
107-
small: 'xsmall',
108-
};
109-
11072
export const ListItem = (props: ListItemProps) => {
11173
const {
11274
avatarProps,
11375
getStyles,
11476
isDisabled = false,
11577
title,
11678
description,
117-
size = 'medium',
11879
onPress,
11980
rightIcon,
12081
leftIcon,
@@ -153,23 +114,19 @@ export const ListItem = (props: ListItemProps) => {
153114
<View style={leftWrapperStyle}>
154115
<View style={imageWrapperStyle}>
155116
{leftIcon || avatarProps ? (
156-
<Avatar size={avatarSize[size]} {...avatarProps} />
117+
<Avatar size="small" {...avatarProps} />
157118
) : null}
158119
</View>
159120
<View style={textWrapperStyle}>
160121
{title && (
161-
<Text
162-
getStyles={() => ({ textStyle: titleStyle })}
163-
size={titleSize[size]}
164-
weight="500"
165-
>
122+
<Text getStyles={() => ({ textStyle: titleStyle })} size="large">
166123
{title}
167124
</Text>
168125
)}
169126
{description && (
170127
<Text
171128
getStyles={() => ({ textStyle: descriptionStyle })}
172-
size={descriptionSize[size]}
129+
size="medium"
173130
color="muted"
174131
>
175132
{description}
@@ -180,11 +137,7 @@ export const ListItem = (props: ListItemProps) => {
180137
{rightIcon === null
181138
? null
182139
: rightIcon || (
183-
<Icon
184-
color="default"
185-
size={iconSize[size]}
186-
name="chevron-right"
187-
/>
140+
<Icon color="default" size={24} name="chevron-right" />
188141
)}
189142
</View>
190143
</TouchableOpacity>

0 commit comments

Comments
 (0)