Skip to content

Commit dbda1f9

Browse files
chore: added rest props for icons
1 parent f89048e commit dbda1f9

File tree

17 files changed

+66
-30
lines changed

17 files changed

+66
-30
lines changed
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import React, {useMemo} from 'react';
2+
3+
import {useTheme} from '../../theme/useTheme.hook';
4+
import {type IconProps} from '../../icons/icon-props';
5+
import {getColorStyles, styles} from './assist-chip.styles';
6+
import {BaseChip, type BaseChipProps} from '../base-chip/BaseChip.component';
7+
8+
export interface AssistChipProps<T extends IconProps> extends BaseChipProps {
9+
elevated?: boolean;
10+
LeadingIcon?: React.FC<T>;
11+
leadingIconProps?: T;
12+
}
13+
14+
export const AssistChip = <T extends IconProps>({
15+
elevated = false,
16+
LeadingIcon,
17+
leadingIconProps = {} as T,
18+
style,
19+
labelStyle,
20+
disabled = false,
21+
...props
22+
}: AssistChipProps<T>) => {
23+
const theme = useTheme();
24+
const colorStyles = useMemo(() => getColorStyles(elevated, disabled, theme), [disabled, elevated, theme]);
25+
26+
return (
27+
<BaseChip
28+
style={[elevated && !disabled ? styles.elevatedContainer : styles.outlinedContainer, colorStyles.container, style]}
29+
labelStyle={[colorStyles.label, labelStyle]}
30+
leadingIcon={LeadingIcon ? <LeadingIcon size={18} color={colorStyles.icon.color} {...leadingIconProps} /> : null}
31+
{...props}
32+
/>
33+
);
34+
};

src/chips/base-chip/BaseChip.component.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export const BaseChip: React.FC<BaseChipProps> = ({label, leadingIcon, trailingI
1616
const {labelLarge} = useTypography();
1717

1818
return (
19-
<TouchableOpacity style={[styles.container, style]} hitSlop={8} {...props}>
19+
<TouchableOpacity style={[styles.container, style]} hitSlop={8} {...props} disabled>
2020
{leadingIcon}
2121
<Text style={[[styles.label, labelLarge]]}>{label}</Text>
2222
{trailingIcon}

src/chips/input-chip/InputChip.component.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import {useTheme} from '../../theme/useTheme.hook';
77
import {type IconProps} from '../../icons/icon-props';
88
import {BaseChip, type BaseChipProps} from '../base-chip/BaseChip.component';
99

10-
interface InputChipProps<T extends IconProps> extends BaseChipProps {
10+
export interface InputChipProps<T extends IconProps> extends BaseChipProps {
1111
selected?: boolean;
1212
imageUrl?: string;
1313
LeadingIcon?: React.FC<T>;
@@ -22,6 +22,7 @@ export const InputChip = <T extends IconProps>({
2222
hasTrailingIcon = true,
2323
leadingIconProps = {} as T,
2424
style,
25+
labelStyle,
2526
...props
2627
}: InputChipProps<T>) => {
2728
const {surface, secondaryContainer, outline, primary} = useTheme();
@@ -48,7 +49,7 @@ export const InputChip = <T extends IconProps>({
4849
return (
4950
<BaseChip
5051
style={[dynamicStyles.container, imageUrl ? styles.chipWithAvatarContainer : [], style]}
51-
labelStyle={dynamicStyles.label}
52+
labelStyle={[dynamicStyles.label, labelStyle]}
5253
leadingIcon={LeadingIcon ? <LeadingIcon size={18} color={primary.background} {...leadingIconProps} /> : renderLeadingAvatar()}
5354
trailingIcon={hasTrailingIcon ? <CloseIcon size={18} color={onContainerColor} /> : null}
5455
{...props}

src/icons/account-circle-filled-icon/AccountCircleFilledIcon.component.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import type {IconProps} from '../icon-props';
77
const DEFAULT_SIZE = 24;
88
const DEFAULT_COLOR = '#000';
99

10-
export const AccountCircleFilledIcon = ({color = DEFAULT_COLOR, size = DEFAULT_SIZE}: IconProps) => (
11-
<Svg viewBox="0 0 24 24" width={size} height={size}>
10+
export const AccountCircleFilledIcon = ({color = DEFAULT_COLOR, size = DEFAULT_SIZE, ...props}: IconProps) => (
11+
<Svg viewBox="0 0 24 24" width={size} height={size} {...props}>
1212
<Path fill={color} d={path} />
1313
</Svg>
1414
);

src/icons/arrow-back-icon/ArrowBackIcon.component.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import type {IconProps} from '../icon-props';
77
const DEFAULT_SIZE = 24;
88
const DEFAULT_COLOR = '#000';
99

10-
export const ArrowBackIcon = ({color = DEFAULT_COLOR, size = DEFAULT_SIZE}: IconProps) => (
11-
<Svg viewBox="0 0 24 24" width={size} height={size}>
10+
export const ArrowBackIcon = ({color = DEFAULT_COLOR, size = DEFAULT_SIZE, ...props}: IconProps) => (
11+
<Svg viewBox="0 0 24 24" width={size} height={size} {...props}>
1212
<Path fill={color} d={path} />
1313
</Svg>
1414
);

src/icons/attach-file-icon/AttachFileIcon.component.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import type {IconProps} from '../icon-props';
77
const DEFAULT_SIZE = 24;
88
const DEFAULT_COLOR = '#000';
99

10-
export const AttachFileIcon: React.FC<IconProps> = ({color = DEFAULT_COLOR, size = DEFAULT_SIZE}) => (
11-
<Svg viewBox="0 0 24 24" width={size} height={size} fill={'none'}>
10+
export const AttachFileIcon: React.FC<IconProps> = ({color = DEFAULT_COLOR, size = DEFAULT_SIZE, ...props}) => (
11+
<Svg viewBox="0 0 24 24" width={size} height={size} fill={'none'} {...props}>
1212
<Path fill={color} d={path} />
1313
</Svg>
1414
);

src/icons/bookmark-border-icon/BookmarkBorderIcon.component.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import type {IconProps} from '../icon-props';
77
const DEFAULT_SIZE = 24;
88
const DEFAULT_COLOR = '#000';
99

10-
export const BookmarkBorderIcon = ({color = DEFAULT_COLOR, size = DEFAULT_SIZE}: IconProps) => (
11-
<Svg viewBox="0 0 24 24" width={size} height={size}>
10+
export const BookmarkBorderIcon = ({color = DEFAULT_COLOR, size = DEFAULT_SIZE, ...props}: IconProps) => (
11+
<Svg viewBox="0 0 24 24" width={size} height={size} {...props}>
1212
<Path fill={color} d={path} />
1313
</Svg>
1414
);

src/icons/check-small-icon/CheckSmallIcon.component.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import type {IconProps} from '../icon-props';
77
const DEFAULT_SIZE = 24;
88
const DEFAULT_COLOR = '#000';
99

10-
export const CheckSmallIcon: React.FC<IconProps> = ({color = DEFAULT_COLOR, size = DEFAULT_SIZE}) => (
11-
<Svg viewBox="0 0 24 24" width={size} height={size} fill={'none'}>
10+
export const CheckSmallIcon: React.FC<IconProps> = ({color = DEFAULT_COLOR, size = DEFAULT_SIZE, ...props}) => (
11+
<Svg viewBox="0 0 24 24" width={size} height={size} fill={'none'} {...props}>
1212
<Path fill={color} d={path} />
1313
</Svg>
1414
);

src/icons/close-icon/CloseIcon.component.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import type {IconProps} from '../icon-props';
77
const DEFAULT_SIZE = 24;
88
const DEFAULT_COLOR = '#000';
99

10-
export const CloseIcon: React.FC<IconProps> = ({color = DEFAULT_COLOR, size = DEFAULT_SIZE}) => (
11-
<Svg viewBox="0 0 24 24" width={size} height={size}>
10+
export const CloseIcon: React.FC<IconProps> = ({color = DEFAULT_COLOR, size = DEFAULT_SIZE, ...props}) => (
11+
<Svg viewBox="0 0 24 24" width={size} height={size} {...props}>
1212
<Path fill={color} d={path} />
1313
</Svg>
1414
);

src/icons/delete-icon/DeleteIcon.component.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ import type {IconProps} from '../icon-props';
77
const DEFAULT_SIZE = 24;
88
const DEFAULT_COLOR = '#000';
99

10-
export const DeleteIcon = ({color = DEFAULT_COLOR, size = DEFAULT_SIZE}: IconProps) => (
11-
<Svg viewBox="0 0 24 24" width={size} height={size}>
10+
export const DeleteIcon = ({color = DEFAULT_COLOR, size = DEFAULT_SIZE, ...props}: IconProps) => (
11+
<Svg viewBox="0 0 24 24" width={size} height={size} {...props}>
1212
<Path fill={color} d={path} />
1313
</Svg>
1414
);

0 commit comments

Comments
 (0)