Skip to content

Commit

Permalink
fix(spacing): dont mutate sizes
Browse files Browse the repository at this point in the history
  • Loading branch information
raff-r committed Jul 2, 2020
1 parent 80b34ca commit 5332fe4
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 9 deletions.
10 changes: 3 additions & 7 deletions src/components/styles/Spacing.ts
@@ -1,13 +1,11 @@
import { css } from 'styled-components';
import { spacing as sizes, grid } from '../../constants';
import { spacing as spacingSizes, grid } from '../../constants';
import { GridBreakpoints } from '../../constants/grid';

type SpacingTypes = 'margin' | 'padding';

const createTopLevelSizes = (type: SpacingTypes) => {
if (type === 'margin') {
sizes.auto = 'auto';
}
const sizes = type === 'margin' ? { ...spacingSizes, auto: 'auto' } : { ...spacingSizes };

return Object.keys(sizes).reduce(
(classNames, size) => ({
Expand Down Expand Up @@ -41,9 +39,7 @@ const createTopLevelSizes = (type: SpacingTypes) => {
};

const createResponsiveSizes = (type: SpacingTypes) => {
if (type === 'margin') {
sizes.auto = 'auto';
}
const sizes = type === 'margin' ? { ...spacingSizes, auto: 'auto' } : { ...spacingSizes };

return Object.keys(grid.breakpoints)
.filter((v) => v !== 'xs')
Expand Down

0 comments on commit 5332fe4

Please sign in to comment.