Skip to content

Commit

Permalink
Display undefined value (#10)
Browse files Browse the repository at this point in the history
* Display undefined string if value is undefined

* Remove unnecessary block
tomoya authored May 4, 2020

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 564386b commit f00a4bb
Showing 3 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion example/src/Box/Box.stories.tsx
Original file line number Diff line number Diff line change
@@ -9,7 +9,7 @@ export default {
pattern: {
bg: ['white', 'blue', 'red', 'yellow'],
width: [1, '50%', 256],
p: [1, 2, 3],
p: [undefined, 2, 3],
},
},
},
8 changes: 6 additions & 2 deletions src/__snapshots__/index.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -246,7 +246,9 @@ Array [
<styled.span>
<span
className="sc-AxirZ HanLJ"
/>
>
undefined
</span>
</styled.span>
</div>
</styled.div>
@@ -478,7 +480,9 @@ Array [
<styled.span>
<span
className="sc-AxirZ HanLJ"
/>
>
undefined
</span>
</styled.span>
</div>
</styled.div>
14 changes: 6 additions & 8 deletions src/components/Matrix/Matrix.tsx
Original file line number Diff line number Diff line change
@@ -27,15 +27,13 @@ export const Matrix: React.FC<MatrixProps> = ({ component, propsPattern, origina
width={3 / 10}
>
<Box bg="#eeeeee" p={2} width={128}>
{Object.entries(props).map(([key, value]) => {
return (
<Box key={key}>
<Box mb={2}>
<Text fontWeight="bold">{key}</Text>: <Text>{value}</Text>
</Box>
{Object.entries(props).map(([key, value]) => (
<Box key={key}>
<Box mb={2}>
<Text fontWeight="bold">{key}</Text>: <Text>{value ?? 'undefined'}</Text>
</Box>
);
})}
</Box>
))}
</Box>
<Box m={2} overflow="hidden">
<Component {...originalProps} {...props} />

0 comments on commit f00a4bb

Please sign in to comment.