-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feature/DES-408-media-query-syntax
- Loading branch information
Showing
32 changed files
with
274 additions
and
291 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# Grid cell | ||
|
||
Beslaat een aantal kolommen in een [Grid](?path=/docs/react_layout-grid--docs). | ||
|
||
## Gebruik | ||
|
||
Verdeel hiermee een grid in cellen. | ||
Geef aan hoeveel kolommen van het grid de cel beslaat. | ||
Dat aantal kan variëren voor smalle, middelbrede of brede schermen. | ||
In elke cel plaats je vervolgens de gewenste inhoud. | ||
|
||
## Ontwerp | ||
|
||
De [ontwerpkeuzes](?path=/docs/docs-designrichtlijnen-grid--docs) staan beschreven onder de designrichtlijnen. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
# Grid | ||
|
||
Levert een tweedimensionaal raster waarop alle elementen van een pagina uitgelijnd worden. | ||
|
||
## Gebruik | ||
|
||
Elke pagina moet het grid gebruiken als basis voor de layout, 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. | ||
Daarom wordt in HTML vóór deze componenten een instantie van Grid afgesloten en erbinnen een nieuwe geopend. | ||
|
||
Meerdere instanties van dit component zijn dus mogelijk op een pagina. | ||
Visueel moeten ze wel allemaal op elkaar aansluiten. | ||
|
||
## Ontwerp | ||
|
||
De [ontwerpkeuzes](?path=/docs/docs-designrichtlijnen-grid--docs) staan beschreven onder de designrichtlijnen. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* @license EUPL-1.2+ | ||
* Copyright (c) 2023 Gemeente Amsterdam | ||
*/ | ||
|
||
@import "../../utils/breakpoint"; | ||
|
||
.amsterdam-grid { | ||
display: grid; | ||
gap: var(--amsterdam-grid-gap); | ||
grid-template-columns: repeat(var(--amsterdam-grid-column-count), 1fr); | ||
margin-inline: auto; | ||
padding-inline: var(--amsterdam-grid-padding-inline); | ||
|
||
@media screen and (min-width: $amsterdam-breakpoint-medium) { | ||
grid-template-columns: repeat(var(--amsterdam-grid-medium-column-count), 1fr); | ||
} | ||
|
||
@media screen and (min-width: $amsterdam-breakpoint-wide) { | ||
grid-template-columns: repeat(var(--amsterdam-grid-wide-column-count), 1fr); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 8 additions & 18 deletions
26
packages/react/src/Grid/PageGrid.test.tsx → packages/react/src/Grid/Grid.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,43 +1,33 @@ | ||
import { render } from '@testing-library/react' | ||
import { createRef } from 'react' | ||
import { PageGrid } from './PageGrid' | ||
import { Grid } from './Grid' | ||
import '@testing-library/jest-dom' | ||
|
||
describe('PageGrid', () => { | ||
describe('Grid', () => { | ||
it('renders', () => { | ||
const { container } = render(<PageGrid />) | ||
|
||
const { container } = render(<Grid />) | ||
const component = container.querySelector(':only-child') | ||
|
||
expect(component).toBeInTheDocument() | ||
expect(component).toBeVisible() | ||
}) | ||
|
||
it('renders a design system BEM class name', () => { | ||
const { container } = render(<PageGrid />) | ||
|
||
const { container } = render(<Grid />) | ||
const component = container.querySelector(':only-child') | ||
|
||
expect(component).toHaveClass('amsterdam-page-grid') | ||
expect(component).toHaveClass('amsterdam-grid') | ||
}) | ||
|
||
it('can have a additional class name', () => { | ||
const { container } = render(<PageGrid className="extra" />) | ||
|
||
const { container } = render(<Grid className="extra" />) | ||
const component = container.querySelector(':only-child') | ||
|
||
expect(component).toHaveClass('extra') | ||
|
||
expect(component).toHaveClass('amsterdam-page-grid') | ||
expect(component).toHaveClass('amsterdam-grid') | ||
}) | ||
|
||
it('supports ForwardRef in React', () => { | ||
const ref = createRef<HTMLDivElement>() | ||
|
||
const { container } = render(<PageGrid ref={ref} />) | ||
|
||
const { container } = render(<Grid ref={ref} />) | ||
const component = container.querySelector(':only-child') | ||
|
||
expect(ref.current).toBe(component) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* @license EUPL-1.2+ | ||
* Copyright (c) 2023 Gemeente Amsterdam | ||
*/ | ||
|
||
import clsx from 'clsx' | ||
import { | ||
ForwardedRef, | ||
forwardRef, | ||
ForwardRefExoticComponent, | ||
HTMLAttributes, | ||
PropsWithChildren, | ||
RefAttributes, | ||
} from 'react' | ||
import { GridCell } from './GridCell' | ||
|
||
export type GridColumnNumber = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | ||
|
||
export type GridColumnNumbers = { | ||
narrow: GridColumnNumber | ||
medium: GridColumnNumber | ||
wide: GridColumnNumber | ||
} | ||
|
||
interface GridComponent | ||
extends ForwardRefExoticComponent<PropsWithChildren<HTMLAttributes<HTMLDivElement>> & RefAttributes<HTMLDivElement>> { | ||
Cell: typeof GridCell | ||
} | ||
|
||
export const Grid = forwardRef( | ||
( | ||
{ children, className, ...restProps }: PropsWithChildren<HTMLAttributes<HTMLDivElement>>, | ||
ref: ForwardedRef<HTMLDivElement>, | ||
) => ( | ||
<div {...restProps} ref={ref} className={clsx('amsterdam-grid', className)}> | ||
{children} | ||
</div> | ||
), | ||
) as GridComponent | ||
|
||
Grid.Cell = GridCell | ||
Grid.displayName = 'Grid' | ||
GridCell.displayName = 'Grid.Cell' |
Oops, something went wrong.