Skip to content

Commit

Permalink
[@mantine/styles] Fix incorrect theme.spacing calculation when it is …
Browse files Browse the repository at this point in the history
…override with 0 values (#1832)
  • Loading branch information
rtivital committed Aug 13, 2022
1 parent 882aebb commit 3709d09
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
42 changes: 42 additions & 0 deletions src/mantine-core/src/Table/Table.story.tsx
@@ -0,0 +1,42 @@
import React from 'react';
import { MantineProvider } from '@mantine/styles';
import { Table } from './Table';

export default { title: 'Table' };

const elements = [
{ position: 6, mass: 12.011, symbol: 'C', name: 'Carbon' },
{ position: 7, mass: 14.007, symbol: 'N', name: 'Nitrogen' },
{ position: 39, mass: 88.906, symbol: 'Y', name: 'Yttrium' },
{ position: 56, mass: 137.33, symbol: 'Ba', name: 'Barium' },
{ position: 58, mass: 140.12, symbol: 'Ce', name: 'Cerium' },
];

export function Usage() {
const rows = elements.map((element) => (
<tr key={element.name}>
<td>{element.position}</td>
<td>{element.name}</td>
<td>{element.symbol}</td>
<td>{element.mass}</td>
</tr>
));

return (
<MantineProvider inherit theme={{ spacing: { xs: 0, sm: 2, md: 4, lg: 8, xl: 12 } }}>
<div style={{ padding: 40 }}>
<Table verticalSpacing="xl" horizontalSpacing="xs" fontSize="xl" striped>
<thead>
<tr>
<th>Element position</th>
<th>Element name</th>
<th>Symbol</th>
<th>Atomic mass</th>
</tr>
</thead>
<tbody>{rows}</tbody>
</Table>
</div>
</MantineProvider>
);
}
4 changes: 3 additions & 1 deletion src/mantine-styles/src/theme/functions/fns/size/size.ts
Expand Up @@ -8,5 +8,7 @@ export function size(props: GetSize) {
return props.size;
}

return props.sizes[props.size] || props.size || props.sizes.md;
const computedSize = props.sizes[props.size];

return computedSize !== undefined ? computedSize : props.size || props.sizes.md;
}

0 comments on commit 3709d09

Please sign in to comment.