Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

Commit

Permalink
Ambiance: check typeof elevation to allow for 0 value
Browse files Browse the repository at this point in the history
  • Loading branch information
arnemolland committed Feb 20, 2022
1 parent c5587cf commit f15316b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
14 changes: 13 additions & 1 deletion src/lib/providers/AmbianceProvider.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,19 @@ export const Sample = () => {
<AmbientBox>
<AmbientBox>
<AmbientBox>
<AmbientBox></AmbientBox>
<AmbientBox>
<Ambiance elevation={0}>
<AmbianceContext.Consumer>
{(ambiance) => {
return (
<ColorBox color={ambiance.color}>
<p>Elevation (forced): {ambiance.elevation}</p>
</ColorBox>
)
}}
</AmbianceContext.Consumer>
</Ambiance>
</AmbientBox>
</AmbientBox>
</AmbientBox>
</AmbientBox>
Expand Down
4 changes: 2 additions & 2 deletions src/lib/providers/AmbianceProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ const Ambiance: React.FC<AmbianceProviderProps> = ({
const parent = React.useContext(AmbianceContext)
const theme = useTheme()

if (!parent && !elevation) {
if (!parent && typeof elevation === 'undefined') {
elevation = 0
} else if (!elevation) {
} else if (typeof elevation === 'undefined') {
elevation = parent.elevation + 1
}

Expand Down

0 comments on commit f15316b

Please sign in to comment.