Skip to content

Commit

Permalink
fix: Disallow invalid number of columns for narrow and medium Grids (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
RubenSibon authored Oct 17, 2024
1 parent e64947a commit 7dc0ee8
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
6 changes: 5 additions & 1 deletion packages/react/src/Grid/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,11 @@ import { GridCell } from './GridCell'
import { paddingClasses } from './paddingClasses'

export type GridColumnNumber = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12
export type GridColumnNumbers = { narrow: GridColumnNumber; medium: GridColumnNumber; wide: GridColumnNumber }
export type GridColumnNumbers = {
narrow: 1 | 2 | 3 | 4
medium: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8
wide: GridColumnNumber
}
export type GridPaddingSize = 'small' | 'medium' | 'large'

type GridPaddingVerticalProp = {
Expand Down
6 changes: 2 additions & 4 deletions packages/react/src/Grid/gridCellClasses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@
* Copyright Gemeente Amsterdam
*/

import type { GridColumnNumber, GridColumnNumbers } from './Grid'
import type { GridCellProps } from './GridCell'

export const addGridClass = (
prefix: string,
value?: number | { narrow: number; medium: number; wide: number } | 'all',
): string[] => {
export const addGridClass = (prefix: string, value?: GridColumnNumber | GridColumnNumbers | 'all'): string[] => {
if (value === 'all' || typeof value === 'number') {
return [`${prefix}${value}`]
} else if (value) {
Expand Down
2 changes: 1 addition & 1 deletion packages/react/src/Grid/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export { Grid } from './Grid'
export type { GridProps, GridColumnNumber, GridColumnNumbers } from './Grid'
export type { GridColumnNumber, GridColumnNumbers, GridProps } from './Grid'
export type { GridCellProps } from './GridCell'

0 comments on commit 7dc0ee8

Please sign in to comment.