Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: fixed Chip "shadow" and height issue #4461

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions src/components/Chip/Chip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,7 @@ const Chip = ({
<Surface
style={[
styles.container,
isV3 &&
(isOutlined ? styles.md3OutlineContainer : styles.md3FlatContainer),
isV3 && styles.md3Container,
!theme.isV3 && {
elevation: elevationStyle,
},
Expand Down Expand Up @@ -439,12 +438,9 @@ const styles = StyleSheet.create({
borderStyle: 'solid',
flexDirection: Platform.select({ default: 'column', web: 'row' }),
},
md3OutlineContainer: {
md3Container: {
borderWidth: 1,
},
md3FlatContainer: {
borderWidth: 0,
},
content: {
flexDirection: 'row',
alignItems: 'center',
Expand Down
5 changes: 5 additions & 0 deletions src/components/Chip/helpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ const getBorderColor = ({
const isSelectedColor = selectedColor !== undefined;

if (theme.isV3) {
if (!isOutlined) {
// If the Chip mode is "flat", set border color to transparent
return 'transparent';
}

if (disabled) {
return color(theme.colors.onSurfaceVariant).alpha(0.12).rgb().string();
}
Expand Down
9 changes: 3 additions & 6 deletions src/components/__tests__/Chip.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -669,10 +669,7 @@ describe('getChipColor - border color', () => {
isOutlined: false,
})
).toMatchObject({
borderColor: color(getTheme().colors.onSurfaceVariant)
.alpha(0.12)
.rgb()
.string(),
borderColor: 'transparent',
});
});

Expand All @@ -684,7 +681,7 @@ describe('getChipColor - border color', () => {
isOutlined: false,
})
).toMatchObject({
borderColor: color('purple').alpha(0.29).rgb().string(),
borderColor: 'transparent',
});
});

Expand All @@ -695,7 +692,7 @@ describe('getChipColor - border color', () => {
isOutlined: false,
})
).toMatchObject({
borderColor: getTheme().colors.outline,
borderColor: 'transparent',
});
});

Expand Down
20 changes: 10 additions & 10 deletions src/components/__tests__/__snapshots__/Chip.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ exports[`renders chip with close button 1`] = `
style={
{
"backgroundColor": "rgba(232, 222, 248, 1)",
"borderColor": "rgba(121, 116, 126, 1)",
"borderColor": "transparent",
"borderRadius": 8,
"borderStyle": "solid",
"borderWidth": 0,
"borderWidth": 1,
"flex": undefined,
"flexDirection": "column",
"shadowColor": "#000",
Expand Down Expand Up @@ -332,10 +332,10 @@ exports[`renders chip with custom close button 1`] = `
style={
{
"backgroundColor": "rgba(232, 222, 248, 1)",
"borderColor": "rgba(121, 116, 126, 1)",
"borderColor": "transparent",
"borderRadius": 8,
"borderStyle": "solid",
"borderWidth": 0,
"borderWidth": 1,
"flex": undefined,
"flexDirection": "column",
"shadowColor": "#000",
Expand Down Expand Up @@ -641,10 +641,10 @@ exports[`renders chip with icon 1`] = `
style={
{
"backgroundColor": "rgba(232, 222, 248, 1)",
"borderColor": "rgba(121, 116, 126, 1)",
"borderColor": "transparent",
"borderRadius": 8,
"borderStyle": "solid",
"borderWidth": 0,
"borderWidth": 1,
"flex": undefined,
"flexDirection": "column",
"shadowColor": "#000",
Expand Down Expand Up @@ -850,10 +850,10 @@ exports[`renders chip with onPress 1`] = `
style={
{
"backgroundColor": "rgba(232, 222, 248, 1)",
"borderColor": "rgba(121, 116, 126, 1)",
"borderColor": "transparent",
"borderRadius": 8,
"borderStyle": "solid",
"borderWidth": 0,
"borderWidth": 1,
"flex": undefined,
"flexDirection": "column",
"shadowColor": "#000",
Expand Down Expand Up @@ -1164,10 +1164,10 @@ exports[`renders selected chip 1`] = `
style={
{
"backgroundColor": "rgb(232, 222, 248)",
"borderColor": "rgba(121, 116, 126, 1)",
"borderColor": "transparent",
"borderRadius": 8,
"borderStyle": "solid",
"borderWidth": 0,
"borderWidth": 1,
"flex": undefined,
"flexDirection": "column",
"shadowColor": "#000",
Expand Down
4 changes: 2 additions & 2 deletions src/components/__tests__/__snapshots__/ListItem.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,10 @@ exports[`renders list item with custom description 1`] = `
style={
{
"backgroundColor": "rgba(232, 222, 248, 1)",
"borderColor": "rgba(121, 116, 126, 1)",
"borderColor": "transparent",
"borderRadius": 8,
"borderStyle": "solid",
"borderWidth": 0,
"borderWidth": 1,
"flex": undefined,
"flexDirection": "column",
"shadowColor": "#000",
Expand Down
Loading