Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Merge grid cell files into grid files and directories #815

Merged
merged 25 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2ad6741
Merge cell files into the grid ones
VincentSmedinga Nov 30, 2023
59ecd76
Improve docs and format Markdown
VincentSmedinga Nov 26, 2023
d68c66d
Grid Cell actions with ArgTypes
dlnr Nov 28, 2023
119901c
Radios looks better inline
dlnr Nov 28, 2023
6f14ac9
Fullwidth bug when defined
dlnr Nov 28, 2023
c99cc38
Add missing control options for span and start
VincentSmedinga Nov 30, 2023
1fd3274
Merge branch 'develop' into refactor/merge-grid-and-cell
VincentSmedinga Nov 30, 2023
413c058
Merge branch 'develop' into refactor/merge-grid-and-cell
VincentSmedinga Dec 5, 2023
30cf944
Merge Cell component into Grid file and stop exporting it individually
VincentSmedinga Dec 5, 2023
0b989a8
WIP Attempt to hide the ‘Grid Cell’ entry from the sidebar
VincentSmedinga Dec 6, 2023
6fa3288
Merge branch 'develop' into refactor/merge-grid-and-cell
VincentSmedinga Dec 8, 2023
e0b0da5
Merge branch 'develop' into refactor/merge-grid-and-cell
VincentSmedinga Dec 8, 2023
3bb7cd6
Merge branch 'develop' into refactor/merge-grid-and-cell
VincentSmedinga Dec 8, 2023
5b77c1d
Merge branch 'develop' into refactor/merge-grid-and-cell
VincentSmedinga Dec 11, 2023
4be1604
Move grid cell stories into grid docs
VincentSmedinga Dec 11, 2023
6344238
Merge branch 'develop' into refactor/merge-grid-and-cell
VincentSmedinga Dec 12, 2023
8dfb930
Apply BEM to grid cell class names
VincentSmedinga Dec 13, 2023
2c625d4
Remove unused Storybook config
VincentSmedinga Dec 13, 2023
d169c02
Fix earlier incorrect merge
VincentSmedinga Dec 13, 2023
2f69f45
Fix a line in docs
VincentSmedinga Dec 13, 2023
acdc2c7
Remove Dutch labels for stories
VincentSmedinga Dec 13, 2023
710e8a6
Improve grid docs
VincentSmedinga Dec 15, 2023
56a8d8a
Move grid cell component into its own file
VincentSmedinga Dec 15, 2023
b081434
Reuse array of grid cells
VincentSmedinga Dec 15, 2023
4e894d9
Merge branch 'develop' into refactor/merge-grid-and-cell
VincentSmedinga Dec 15, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 0 additions & 14 deletions packages/css/src/components/grid/README.grid-cell.md

This file was deleted.

17 changes: 0 additions & 17 deletions packages/css/src/components/grid/README.grid.md

This file was deleted.

21 changes: 21 additions & 0 deletions packages/css/src/components/grid/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Grid

Verdeelt de breedte van het scherm in kolommen waarop de elementen van een pagina worden uitgelijnd.

## Gebruik

Elke pagina moet het grid gebruiken als basis voor de layout.
Het staat dus direct binnen [Screen](?path=/docs/layout-screen--docs).

Een [Footer](?path=/docs/react_containers-footer--docs) en een [Highlight](?path=/docs/react_containers-highlight--docs) zijn iets breder dan het grid.
Vóór deze componenten sluit je een instantie van het grid af.
Erbinnen en eventueel erna start je een nieuwe.
Meerdere instanties van het grid component zijn dus mogelijk op een pagina.
De kolommen van alle grids moeten wel precies op elkaar aansluiten.

Binnen het grid maak je cellen die de gewenste inhoud bevatten.
Een cel beslaat vaak meerdere kolommen van het grid.

## Ontwerp

De [ontwerpkeuzes](?path=/docs/docs-designrichtlijnen-grid--docs) staan beschreven onder de designrichtlijnen.
46 changes: 0 additions & 46 deletions packages/css/src/components/grid/grid-cell.scss

This file was deleted.

40 changes: 40 additions & 0 deletions packages/css/src/components/grid/grid.scss
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,43 @@
.amsterdam-grid--padding-vertical--large {
padding-block: calc(var(--amsterdam-grid-gap) * 2);
}

.amsterdam-grid-cell--full-width {
alimpens marked this conversation as resolved.
Show resolved Hide resolved
grid-column: 1 / -1;
}

// The order of the following declaration blocks ensures the intended specificity.

@for $i from 1 through 12 {
.amsterdam-grid-cell--span-#{$i} {
grid-column-end: span $i;
}

.amsterdam-grid-cell--start-#{$i} {
grid-column-start: $i;
}
}

@media screen and (min-width: $amsterdam-breakpoint-medium) {
@for $i from 1 through 12 {
.amsterdam-grid-cell--span-#{$i}-medium {
grid-column-end: span $i;
}

.amsterdam-grid-cell--start-#{$i}-medium {
grid-column-start: $i;
}
}
}

@media screen and (min-width: $amsterdam-breakpoint-wide) {
@for $i from 1 through 12 {
.amsterdam-grid-cell--span-#{$i}-wide {
grid-column-end: span $i;
}

.amsterdam-grid-cell--start-#{$i}-wide {
grid-column-start: $i;
}
}
}
1 change: 0 additions & 1 deletion packages/css/src/components/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
@import "./checkbox/checkbox";
@import "./form-label/form-label";
@import "./grid/grid";
@import "./grid/grid-cell";
@import "./heading/heading";
@import "./spotlight/spotlight";
@import "./icon/icon";
Expand Down
37 changes: 36 additions & 1 deletion packages/react/src/Grid/Grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
PropsWithChildren,
RefAttributes,
} from 'react'
import { GridCell } from './GridCell'
import { gridCellClasses } from './gridCellClasses'

export type GridColumnNumber = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12

Expand Down Expand Up @@ -99,6 +99,41 @@ export const Grid = forwardRef(
),
) as GridComponent

type GridCellFullWidthProp = {
VincentSmedinga marked this conversation as resolved.
Show resolved Hide resolved
/** Whether the cell spans the full width of the grid. */
fullWidth?: boolean
span?: never
start?: never
}

type GridCellColumnProps = {
fullWidth?: never
/** The amount of grid columns the cell spans. */
span?: GridColumnNumber | GridColumnNumbers
/** The index of the grid column the cell starts at. */
start?: GridColumnNumber | GridColumnNumbers
}

export type GridCellProps = (GridCellFullWidthProp | GridCellColumnProps) &
PropsWithChildren<HTMLAttributes<HTMLDivElement>>

const GridCell = forwardRef(
alimpens marked this conversation as resolved.
Show resolved Hide resolved
alimpens marked this conversation as resolved.
Show resolved Hide resolved
({ children, className, fullWidth, span, start, ...restProps }: GridCellProps, ref: ForwardedRef<HTMLDivElement>) => (
<div
{...restProps}
ref={ref}
className={clsx(
'amsterdam-grid-cell',
fullWidth && 'amsterdam-grid-cell--full-width',
gridCellClasses(span, start),
className,
)}
>
{children}
</div>
),
)

Grid.Cell = GridCell
Grid.displayName = 'Grid'
GridCell.displayName = 'Grid.Cell'
46 changes: 0 additions & 46 deletions packages/react/src/Grid/GridCell.tsx

This file was deleted.

2 changes: 1 addition & 1 deletion packages/react/src/Grid/gridCellClasses.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GridCellProps } from './GridCell'
import { GridCellProps } from './Grid'

export const gridCellClasses = (span?: GridCellProps['span'], start?: GridCellProps['start']): string[] => {
if (!span && !start) {
Expand Down
4 changes: 1 addition & 3 deletions packages/react/src/Grid/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
export * from './Grid'
export * from './GridCell'

export type { GridCellProps } from './GridCell'
export type { GridCellProps } from './Grid'
12 changes: 11 additions & 1 deletion storybook/storybook-docs/config/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,14 @@ import { addons } from '@storybook/manager-api'
import { create } from '@storybook/theming/create'
import themeConfig from '../../../storybook/theme.config'

addons.setConfig({ theme: create(themeConfig) })
addons.setConfig({
theme: create(themeConfig),
sidebar: {
filters: {
hidden: (item) => {
console.log(item.title, item.tags)
return !item.tags.includes('hidden')
},
},
},
})
alimpens marked this conversation as resolved.
Show resolved Hide resolved
12 changes: 11 additions & 1 deletion storybook/storybook-react/config/manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,14 @@ import { addons } from '@storybook/manager-api'
import { create } from '@storybook/theming/create'
import themeConfig from '../../../storybook/theme.config'

addons.setConfig({ theme: create(themeConfig) })
addons.setConfig({
theme: create(themeConfig),
sidebar: {
filters: {
hidden: (item) => {
console.log(item.title, item.tags)
return !item.tags.includes('hidden')
},
},
},
})
alimpens marked this conversation as resolved.
Show resolved Hide resolved
Loading