Skip to content
Merged
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
9 changes: 4 additions & 5 deletions src/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,11 +148,11 @@ const Button = ({
...rest
}: Props) => {
const { current: elevation } = React.useRef<Animated.Value>(
new Animated.Value(mode === 'contained' ? 2 : 0)
new Animated.Value(disabled || mode !== 'contained' ? 0 : 2)
);
React.useEffect(() => {
elevation.setValue(mode === 'contained' ? 2 : 0);
}, [mode, elevation]);
elevation.setValue(disabled || mode !== 'contained' ? 0 : 2);
}, [mode, elevation, disabled]);

const handlePressIn = () => {
if (mode === 'contained') {
Expand Down Expand Up @@ -252,7 +252,6 @@ const Button = ({
StyleSheet.flatten(labelStyle) || {};

const textStyle = { color: textColor, ...font };
const elevationRes = disabled || mode !== 'contained' ? 0 : elevation;
const iconStyle =
StyleSheet.flatten(contentStyle)?.flexDirection === 'row-reverse'
? styles.iconReverse
Expand All @@ -264,7 +263,7 @@ const Button = ({
style={[
styles.button,
compact && styles.compact,
{ elevation: elevationRes } as ViewStyle,
{ elevation },
buttonStyle,
style,
]}
Expand Down
28 changes: 28 additions & 0 deletions src/components/__tests__/__snapshots__/Banner.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@ exports[`render visible banner, with custom theme 1`] = `
"elevation": 0,
"margin": 4,
"minWidth": "auto",
"shadowColor": "#000000",
"shadowOffset": Object {
"height": 0,
"width": 0,
},
"shadowOpacity": 0,
"shadowRadius": 0,
}
}
>
Expand Down Expand Up @@ -397,6 +404,13 @@ exports[`renders visible banner, with action buttons and with image 1`] = `
"elevation": 0,
"margin": 4,
"minWidth": "auto",
"shadowColor": "#000000",
"shadowOffset": Object {
"height": 0,
"width": 0,
},
"shadowOpacity": 0,
"shadowRadius": 0,
}
}
>
Expand Down Expand Up @@ -589,6 +603,13 @@ exports[`renders visible banner, with action buttons and without image 1`] = `
"elevation": 0,
"margin": 4,
"minWidth": "auto",
"shadowColor": "#000000",
"shadowOffset": Object {
"height": 0,
"width": 0,
},
"shadowOpacity": 0,
"shadowRadius": 0,
}
}
>
Expand Down Expand Up @@ -687,6 +708,13 @@ exports[`renders visible banner, with action buttons and without image 1`] = `
"elevation": 0,
"margin": 4,
"minWidth": "auto",
"shadowColor": "#000000",
"shadowOffset": Object {
"height": 0,
"width": 0,
},
"shadowOpacity": 0,
"shadowRadius": 0,
}
}
>
Expand Down
77 changes: 77 additions & 0 deletions src/components/__tests__/__snapshots__/Button.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ exports[`renders button with an accessibility hint 1`] = `
"borderWidth": 0,
"elevation": 0,
"minWidth": 64,
"shadowColor": "#000000",
"shadowOffset": Object {
"height": 0,
"width": 0,
},
"shadowOpacity": 0,
"shadowRadius": 0,
}
}
>
Expand Down Expand Up @@ -110,6 +117,13 @@ exports[`renders button with an accessibility label 1`] = `
"borderWidth": 0,
"elevation": 0,
"minWidth": 64,
"shadowColor": "#000000",
"shadowOffset": Object {
"height": 0,
"width": 0,
},
"shadowOpacity": 0,
"shadowRadius": 0,
}
}
>
Expand Down Expand Up @@ -209,6 +223,13 @@ exports[`renders button with color 1`] = `
"borderWidth": 0,
"elevation": 0,
"minWidth": 64,
"shadowColor": "#000000",
"shadowOffset": Object {
"height": 0,
"width": 0,
},
"shadowOpacity": 0,
"shadowRadius": 0,
}
}
>
Expand Down Expand Up @@ -307,6 +328,13 @@ exports[`renders button with custom testID 1`] = `
"borderWidth": 0,
"elevation": 0,
"minWidth": 64,
"shadowColor": "#000000",
"shadowOffset": Object {
"height": 0,
"width": 0,
},
"shadowOpacity": 0,
"shadowRadius": 0,
}
}
>
Expand Down Expand Up @@ -406,6 +434,13 @@ exports[`renders button with icon 1`] = `
"borderWidth": 0,
"elevation": 0,
"minWidth": 64,
"shadowColor": "#000000",
"shadowOffset": Object {
"height": 0,
"width": 0,
},
"shadowOpacity": 0,
"shadowRadius": 0,
}
}
>
Expand Down Expand Up @@ -532,6 +567,13 @@ exports[`renders button with icon in reverse order 1`] = `
"borderWidth": 0,
"elevation": 0,
"minWidth": 64,
"shadowColor": "#000000",
"shadowOffset": Object {
"height": 0,
"width": 0,
},
"shadowOpacity": 0,
"shadowRadius": 0,
}
}
>
Expand Down Expand Up @@ -765,6 +807,13 @@ exports[`renders disabled button 1`] = `
"borderWidth": 0,
"elevation": 0,
"minWidth": 64,
"shadowColor": "#000000",
"shadowOffset": Object {
"height": 0,
"width": 0,
},
"shadowOpacity": 0,
"shadowRadius": 0,
}
}
>
Expand Down Expand Up @@ -863,6 +912,13 @@ exports[`renders loading button 1`] = `
"borderWidth": 0,
"elevation": 0,
"minWidth": 64,
"shadowColor": "#000000",
"shadowOffset": Object {
"height": 0,
"width": 0,
},
"shadowOpacity": 0,
"shadowRadius": 0,
}
}
>
Expand Down Expand Up @@ -1151,6 +1207,13 @@ exports[`renders outlined button with mode 1`] = `
"borderWidth": 0.5,
"elevation": 0,
"minWidth": 64,
"shadowColor": "#000000",
"shadowOffset": Object {
"height": 0,
"width": 0,
},
"shadowOpacity": 0,
"shadowRadius": 0,
}
}
>
Expand Down Expand Up @@ -1249,6 +1312,13 @@ exports[`renders text button by default 1`] = `
"borderWidth": 0,
"elevation": 0,
"minWidth": 64,
"shadowColor": "#000000",
"shadowOffset": Object {
"height": 0,
"width": 0,
},
"shadowOpacity": 0,
"shadowRadius": 0,
}
}
>
Expand Down Expand Up @@ -1347,6 +1417,13 @@ exports[`renders text button with mode 1`] = `
"borderWidth": 0,
"elevation": 0,
"minWidth": 64,
"shadowColor": "#000000",
"shadowOffset": Object {
"height": 0,
"width": 0,
},
"shadowOpacity": 0,
"shadowRadius": 0,
}
}
>
Expand Down
7 changes: 7 additions & 0 deletions src/components/__tests__/__snapshots__/DataTable.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -968,6 +968,13 @@ exports[`renders data table pagination with options select 1`] = `
"elevation": 0,
"marginRight": 16,
"minWidth": 64,
"shadowColor": "#000000",
"shadowOffset": Object {
"height": 0,
"width": 0,
},
"shadowOpacity": 0,
"shadowRadius": 0,
"textAlign": "center",
}
}
Expand Down
21 changes: 21 additions & 0 deletions src/components/__tests__/__snapshots__/Menu.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ exports[`renders menu with content styles 1`] = `
"borderWidth": 0.5,
"elevation": 0,
"minWidth": 64,
"shadowColor": "#000000",
"shadowOffset": Object {
"height": 0,
"width": 0,
},
"shadowOpacity": 0,
"shadowRadius": 0,
}
}
>
Expand Down Expand Up @@ -116,6 +123,13 @@ exports[`renders not visible menu 1`] = `
"borderWidth": 0.5,
"elevation": 0,
"minWidth": 64,
"shadowColor": "#000000",
"shadowOffset": Object {
"height": 0,
"width": 0,
},
"shadowOpacity": 0,
"shadowRadius": 0,
}
}
>
Expand Down Expand Up @@ -218,6 +232,13 @@ exports[`renders visible menu 1`] = `
"borderWidth": 0.5,
"elevation": 0,
"minWidth": 64,
"shadowColor": "#000000",
"shadowOffset": Object {
"height": 0,
"width": 0,
},
"shadowOpacity": 0,
"shadowRadius": 0,
}
}
>
Expand Down
7 changes: 7 additions & 0 deletions src/components/__tests__/__snapshots__/Snackbar.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ exports[`renders snackbar with action button 1`] = `
"marginHorizontal": 8,
"marginVertical": 6,
"minWidth": "auto",
"shadowColor": "#000000",
"shadowOffset": Object {
"height": 0,
"width": 0,
},
"shadowOpacity": 0,
"shadowRadius": 0,
}
}
>
Expand Down