generated from nl-design-system/example
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
242 additions
and
0 deletions.
There are no files selected for viewing
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,29 @@ | ||
# Page component | ||
|
||
Component that centers the page. The page maximizes the width of the content for large viewports, to keep the line length of texts readable and avoid large horizontal distances between related components. | ||
|
||
Typically the contents of the page component are: | ||
|
||
- Page Header component | ||
- Page Content component | ||
- Main content | ||
- Complimentary content | ||
- Page Footer component | ||
|
||
## API | ||
|
||
- CSS class name: `utrecht-page` | ||
- Web component: `<utrecht-page>` | ||
- Angular/React/Vue.js component: `UtrechtPage` | ||
|
||
## CSS implementation | ||
|
||
### Margin | ||
|
||
To create some transparent space around the page, `margin-inline` CSS variables are provided. However, to automatically horizontally center the page `margin-inline: auto` needs to be used. | ||
|
||
Achieving both goals is made possible by implementing the `margin-inline` as `padding-inline` on a transparent container element. The only downside to this approach is that margin collapsing won't work anymore, but that doesn't seem like anyone would ever need for a component that realistically is only used once per document. | ||
|
||
### Padding | ||
|
||
Padding is not applied directly in the page component itself, but in the child components such as Page Header, Page Content and Page Footer. |
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,6 @@ | ||
/** | ||
* @license EUPL-1.2 | ||
* Copyright (c) 2021 Robbert Broersma | ||
*/ | ||
|
||
export const Page = ({ innerHTML = '' }) => `<div class="utrecht-page">${innerHTML}</div>`; |
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) 2021 Gemeente Utrecht | ||
* Copyright (c) 2021 Robbert Broersma | ||
*/ | ||
|
||
.utrecht-page { | ||
margin-inline-end: auto; | ||
margin-inline-start: auto; | ||
max-inline-size: calc( | ||
var(--utrecht-page-max-inline-size) - var(--utrecht-page-margin-inline-start, 0px) - | ||
var(--utrecht-page-margin-inline-end, 0px) | ||
); | ||
padding-inline-end: var(--utrecht-page-margin-inline-end); | ||
padding-inline-start: var(--utrecht-page-margin-inline-start); | ||
} | ||
|
||
.utrecht-page__content { | ||
background-color: var(--utrecht-page-background-color); | ||
color: var(--utrecht-page-color); | ||
max-inline-size: var(--utrecht-page-max-inline-size); | ||
} |
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,41 @@ | ||
<!-- | ||
@license EUPL-1.2 | ||
Copyright (c) 2021 Robbert Broersma | ||
--> | ||
|
||
import { Canvas, Meta, Story } from "@storybook/addon-docs"; | ||
import { PageContent } from "../page-content/bem"; | ||
import { PageFooter } from "../page-footer/bem"; | ||
import { PageHeader } from "../page-header/bem"; | ||
import { Page } from "./bem.js"; | ||
import "./bem.scss"; | ||
|
||
<Meta | ||
title="CSS Component/Page" | ||
parameters={{ | ||
docs: { | ||
transformSource: (_src, { args }) => Page(args), | ||
}, | ||
layout: "fullscreen", | ||
status: { | ||
type: "WORK IN PROGRESS", | ||
}, | ||
}} | ||
/> | ||
|
||
# Page component | ||
|
||
<Canvas> | ||
<Story | ||
name="Page" | ||
args={{ | ||
innerHTML: [ | ||
PageHeader({ innerHTML: "Header area" }), | ||
PageContent({ innerHTML: "Content area" }), | ||
PageFooter({ innerHTML: "Footer area" }), | ||
].join("\n"), | ||
}} | ||
> | ||
{Page.bind({})} | ||
</Story> | ||
</Canvas> |
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,36 @@ | ||
{ | ||
"utrecht": { | ||
"page": { | ||
"background-color": { | ||
"css": { | ||
"syntax": "<color>", | ||
"inherits": true | ||
} | ||
}, | ||
"color": { | ||
"css": { | ||
"syntax": "<color>", | ||
"inherits": true | ||
} | ||
}, | ||
"margin-inline-start": { | ||
"css": { | ||
"syntax": "<length>", | ||
"inherits": true | ||
} | ||
}, | ||
"margin-inline-end": { | ||
"css": { | ||
"syntax": "<length>", | ||
"inherits": true | ||
} | ||
}, | ||
"max-inline-size": { | ||
"css": { | ||
"syntax": "<length>", | ||
"inherits": true | ||
} | ||
} | ||
} | ||
} | ||
} |
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,12 @@ | ||
import { Description, Meta } from "@storybook/addon-docs"; | ||
import { ComponentTokensTable } from "../../documentation/components/ComponentTokensTable"; | ||
import tokens from "../../proprietary/design-tokens/dist/index.json"; | ||
import document from "./README.md"; | ||
|
||
<Meta title="CSS Component/Page/README" /> | ||
|
||
<Description>{document}</Description> | ||
|
||
## Design Tokens | ||
|
||
<ComponentTokensTable tokens={tokens} component="utrecht-page"></ComponentTokensTable> |
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 @@ | ||
/** | ||
* @license EUPL-1.2 | ||
* Copyright (c) 2021 Robbert Broersma | ||
*/ | ||
|
||
@import "./bem"; | ||
|
||
:host { | ||
display: block; | ||
} | ||
|
||
:host([hidden]) { | ||
display: none !important; | ||
} |
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,42 @@ | ||
<!-- | ||
@license EUPL-1.2 | ||
Copyright (c) 2021 Robbert Broersma | ||
--> | ||
|
||
import { ArgsTable, Canvas, Meta, Story } from "@storybook/addon-docs"; | ||
|
||
export const Template = ({ contentHTML = "", footerHTML = "", headerHTML = "" }) => `<utrecht-page> | ||
<utrecht-page-header>${headerHTML}</utrecht-page-header> | ||
<utrecht-page-content>${contentHTML}</utrecht-page-content> | ||
<utrecht-page-footer>${footerHTML}</utrecht-page-footer> | ||
</utrecht-page>`; | ||
|
||
<Meta | ||
title="Web Component/Page" | ||
argTypes={{}} | ||
parameters={{ | ||
docs: { | ||
transformSource: (_src, { args }) => Template(args), | ||
}, | ||
status: { | ||
type: "WORK IN PROGRESS", | ||
}, | ||
}} | ||
/> | ||
|
||
# Page component | ||
|
||
<Canvas> | ||
<Story | ||
name="Page" | ||
args={{ | ||
contentHTML: "Main content", | ||
footerHTML: "Footer content", | ||
headerHTML: "Header content", | ||
}} | ||
> | ||
{Template.bind({})} | ||
</Story> | ||
</Canvas> | ||
|
||
<ArgsTable story="Page" /> |
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,23 @@ | ||
import { Component, h } from "@stencil/core"; | ||
|
||
/** | ||
* @license EUPL-1.2 | ||
* Copyright (c) 2021 Gemeente Utrecht | ||
*/ | ||
|
||
@Component({ | ||
tag: "utrecht-page", | ||
styleUrl: "stencil.scss", | ||
shadow: true, | ||
}) | ||
export class Page { | ||
render() { | ||
return ( | ||
<div class="utrecht-page"> | ||
<div class="utrecht-page__content"> | ||
<slot></slot> | ||
</div> | ||
</div> | ||
); | ||
} | ||
} |
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
15 changes: 15 additions & 0 deletions
15
proprietary/design-tokens/src/component/utrecht/page/block.tokens.json
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,15 @@ | ||
{ | ||
"utrecht": { | ||
"page": { | ||
"background-color": { "value": "{utrecht.color.white.value}" }, | ||
"color": { "value": "{utrecht.color.grey.10.value}" }, | ||
"margin-inline-start": { "value": "2em" }, | ||
"margin-inline-end": { "value": "2em" }, | ||
"max-inline-size": { "value": "1184px" }, | ||
"padding-block-start": { "value": "1.8em" }, | ||
"padding-inline-end": { "value": "2.4em" }, | ||
"padding-block-end": { "value": "1em" }, | ||
"padding-inline-start": { "value": "2em" } | ||
} | ||
} | ||
} |