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

feat: Add document-level classes and guidelines #1136

Merged
merged 19 commits into from
Mar 26, 2024
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
8db3476
Add class for necessary body styles
VincentSmedinga Mar 14, 2024
239822a
Use our extra bold font weight for strong emphasis
VincentSmedinga Mar 20, 2024
ff33aa9
Merge branch 'develop' into DES-559-document-classes-and-docs
VincentSmedinga Mar 20, 2024
33cdc75
Improve a documentation fragment
VincentSmedinga Mar 21, 2024
1fca09e
Introduce text rendering mixin
VincentSmedinga Mar 22, 2024
6bf13c6
Set consistent name and position for mixins
VincentSmedinga Mar 22, 2024
b50d300
Disallow overriding the root font size
VincentSmedinga Mar 24, 2024
e0d8912
Remove background color and height
VincentSmedinga Mar 24, 2024
1d6eb5a
Use comment syntax that doesn’t compile to CSS
VincentSmedinga Mar 24, 2024
1fc2af9
Merge branch 'develop' into DES-559-document-classes-and-docs
VincentSmedinga Mar 24, 2024
3c5a9a3
Move coding convention to correct docs file
VincentSmedinga Mar 25, 2024
8deb903
Allow gradual adoption by documenting the root font size instead of f…
VincentSmedinga Mar 25, 2024
cbb5e13
Remove styling for bold text until we have a better approach
VincentSmedinga Mar 25, 2024
dc684b4
Merge branch 'develop' into DES-559-document-classes-and-docs
VincentSmedinga Mar 25, 2024
17d75df
Update packages/css/README.md
VincentSmedinga Mar 26, 2024
70df9d2
Remove incorrect statement
VincentSmedinga Mar 26, 2024
d4d8d54
Restore correct url in mock content
VincentSmedinga Mar 26, 2024
55e4c3a
Remove incorrect statement
VincentSmedinga Mar 26, 2024
c0b7978
Update packages/css/README.md
VincentSmedinga Mar 26, 2024
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
22 changes: 22 additions & 0 deletions packages/css/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,3 +49,25 @@ To use the compact mode, import the compact css **after** theme css, like so:
import "@amsterdam/design-system-tokens/dist/index.css";
import "@amsterdam/design-system-tokens/dist/compact.css";
```

## Global styles

Some elements of your document are out of reach for the Design System components.
However, their styles can influence the appearance of the components.

### Base font size

Do not change the base font-size – e.g. through `html { font-size: 62.5% }`.
This interferes with users choosing a different default font size in their browser.
alimpens marked this conversation as resolved.
Show resolved Hide resolved
Out typography system also expects `1rem` to be the browser default of 16 pixels.
VincentSmedinga marked this conversation as resolved.
Show resolved Hide resolved

If your application does use a rule like this and you can’t easily remove it, you may adopt the Design System components gradually by setting `font-size: 100%` on the parts that use them.

### Remove body margin

If you haven’t removed the margin on the `<body>` element that browsers set by default, you can add our `ams-body` to it to do so.
VincentSmedinga marked this conversation as resolved.
Show resolved Hide resolved

### Use our extra bold font weight

We only use the regular and extra bold weights of our font, Amsterdam Sans.
Apply `font-weight: var(--ams-text-font-weight-bold)` to elements that display bold text, e.g. `b`, `strong`, and `dt`.
8 changes: 8 additions & 0 deletions packages/css/documentation/coding-conventions.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,11 @@ Still, we define its thickness and offset for the initial state.
}
}
```

## Use mixins for patterns and resets

We use Sass mixins to extract common patterns, especially if they need more than 1 declaration.
We collect reset styles in mixins as well.
Both the name of the mixins and their documentation help explain the approach.
Mixins sit at the end of the declaration block to ensure their effect.
The general ‘reset’ mixin is the very last.
alimpens marked this conversation as resolved.
Show resolved Hide resolved
15 changes: 15 additions & 0 deletions packages/css/src/common/text-rendering.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/**
* @license EUPL-1.2+
* Copyright Gemeente Amsterdam
*/

/**
* Prioritizes legibility over speed when rendering text
* and disables text inflation on some mobile devices.
*/
@mixin text-rendering {
text-rendering: optimizeLegibility;
-moz-text-size-adjust: none;
-webkit-text-size-adjust: none;
text-size-adjust: none;
}
8 changes: 3 additions & 5 deletions packages/css/src/components/accordion/accordion.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,14 @@
* Copyright Gemeente Amsterdam
*/

@import "../../common/text-rendering";

.ams-accordion__header {
display: flex;
margin-block: 0;
margin-inline: 0;
}

@mixin reset {
-webkit-text-size-adjust: 100%;
}

.ams-accordion__button {
background-color: transparent;
border: 0;
Expand Down Expand Up @@ -45,7 +43,7 @@
}
}

@include reset;
@include text-rendering;
}

.ams-accordion__button[aria-expanded="true"] svg {
Expand Down
3 changes: 2 additions & 1 deletion packages/css/src/components/blockquote/blockquote.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
*/

@import "../../common/hyphenation";
@import "../../common/text-rendering";

@mixin reset {
box-sizing: border-box;
margin-block: 0;
margin-inline: 0;
-webkit-text-size-adjust: 100%;
}

.ams-blockquote {
Expand All @@ -30,6 +30,7 @@
}

@include hyphenation;
@include text-rendering;
@include reset;
}

Expand Down
4 changes: 3 additions & 1 deletion packages/css/src/components/breadcrumb/breadcrumb.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@
* Copyright Gemeente Amsterdam
*/

@import "../../common/text-rendering";

@mixin reset {
box-sizing: border-box;
margin-block: 0;
padding-inline: 0;
-webkit-text-size-adjust: 100%;
}

.ams-breadcrumb {
Expand All @@ -21,6 +22,7 @@
break-after: avoid;
break-inside: avoid;

@include text-rendering;
@include reset;
}

Expand Down
6 changes: 2 additions & 4 deletions packages/css/src/components/button/button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
* Copyright Gemeente Amsterdam
*/

@mixin reset {
-webkit-text-size-adjust: 100%;
}
@import "../../common/text-rendering";

.ams-button {
border: none;
Expand All @@ -25,7 +23,7 @@
cursor: var(--ams-button-disabled-cursor);
}

@include reset;
@include text-rendering;
}

@mixin ams-button-forced-color-mode {
Expand Down
7 changes: 2 additions & 5 deletions packages/css/src/components/checkbox/checkbox.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

@import "../../common/input-label-focus";
@import "../../common/hide-input";
@import "../../common/text-rendering";

.ams-checkbox__input {
@include hide-input;
Expand Down Expand Up @@ -32,10 +33,6 @@
}
}

@mixin reset {
-webkit-text-size-adjust: 100%;
}

.ams-checkbox__label {
color: var(--ams-checkbox-color);
cursor: pointer;
Expand All @@ -59,7 +56,7 @@
}
}

@include reset;
@include text-rendering;
}

// Default checked
Expand Down
14 changes: 14 additions & 0 deletions packages/css/src/components/document/document.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/**
* @license EUPL-1.2+
* Copyright Gemeente Amsterdam
*/

alimpens marked this conversation as resolved.
Show resolved Hide resolved
@mixin reset-body {
margin-block: 0;
margin-inline: 0;
}

// Add this class if you haven’t removed the default margin on the `<body>` element.
.ams-body {
@include reset-body;
}
7 changes: 4 additions & 3 deletions packages/css/src/components/fieldset/fieldset.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

@import "../../common/hyphenation";
@import "../../common/text-rendering";

@mixin reset {
border: none;
Expand All @@ -16,9 +17,8 @@
@include reset;
}

@mixin legend-reset {
@mixin reset-legend {
padding-inline: 0;
-webkit-text-size-adjust: 100%;
}

.ams-fieldset__legend {
Expand All @@ -30,5 +30,6 @@
margin-block-end: 1rem; /* Because of a bug in Chrome we can’t use display grid or flex for this gap */

@include hyphenation;
@include legend-reset;
@include text-rendering;
@include reset-legend;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
* Copyright Gemeente Amsterdam
*/

@mixin reset {
-webkit-text-size-adjust: 100%;
}
@import "../../common/text-rendering";

.ams-form-field-character-counter {
color: var(--ams-form-field-character-counter-color);
Expand All @@ -14,7 +12,7 @@
font-weight: var(--ams-form-field-character-counter-font-weight);
line-height: var(--ams-form-field-character-counter-line-height);

@include reset;
@include text-rendering;
}

.ams-form-field-character-counter--error {
Expand Down
7 changes: 2 additions & 5 deletions packages/css/src/components/form-label/form-label.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,7 @@
*/

@import "../../common/hyphenation";

@mixin reset {
-webkit-text-size-adjust: 100%;
}
@import "../../common/text-rendering";

.ams-form-label {
color: var(--ams-form-label-color);
Expand All @@ -17,5 +14,5 @@
line-height: var(--ams-form-label-line-height);

@include hyphenation;
@include reset;
@include text-rendering;
}
3 changes: 2 additions & 1 deletion packages/css/src/components/heading/heading.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
*/

@import "../../common/hyphenation";
@import "../../common/text-rendering";

@mixin reset {
box-sizing: border-box;
margin-block: 0;
-webkit-text-size-adjust: 100%;
}

.ams-heading {
Expand All @@ -19,6 +19,7 @@
font-weight: var(--ams-heading-font-weight);

@include hyphenation;
@include text-rendering;
@include reset;
}

Expand Down
1 change: 1 addition & 0 deletions packages/css/src/components/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

/* Append here */
@import "./document/document";
@import "./avatar/avatar";
@import "./form-field-character-counter/form-field-character-counter";
@import "./row/row";
Expand Down
7 changes: 4 additions & 3 deletions packages/css/src/components/link-list/link-list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,21 @@
*/

@import "../../common/hyphenation";
@import "../../common/text-rendering";

@mixin reset-list {
box-sizing: border-box;
list-style: none;
margin-block: 0;
padding-inline-start: 0;
-webkit-text-size-adjust: 100%;
}

.ams-link-list {
@include reset-list;

display: grid;
gap: var(--ams-link-list-gap);

@include text-rendering;
@include reset-list;
}

.ams-link-list__link {
Expand Down
6 changes: 2 additions & 4 deletions packages/css/src/components/link/link.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
* Copyright Gemeente Amsterdam
*/

@mixin reset {
-webkit-text-size-adjust: 100%;
}
@import "../../common/text-rendering";

.ams-link {
color: var(--ams-link-color);
Expand All @@ -17,7 +15,7 @@
color: var(--ams-link-hover-color);
}

@include reset;
@include text-rendering;
}

.ams-link--standalone {
Expand Down
8 changes: 5 additions & 3 deletions packages/css/src/components/ordered-list/ordered-list.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,23 @@
* Copyright Gemeente Amsterdam
*/

@import "../../common/text-rendering";

/** Apply border box sizing, reset white space and list styles. */
@mixin reset {
box-sizing: border-box;
list-style-type: none;
margin-block: 0;
padding-inline-start: 0;
-webkit-text-size-adjust: 100%;
}

/** A list is a grid column with a gap between items. */
.ams-ordered-list {
@include reset;

display: grid;
gap: var(--ams-ordered-list-gap);

@include text-rendering;
@include reset;
}

/** A list with markers sets typography for its text content. */
Expand Down
3 changes: 2 additions & 1 deletion packages/css/src/components/page-heading/page-heading.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
*/

@import "../../common/hyphenation";
@import "../../common/text-rendering";

@mixin reset {
box-sizing: border-box;
margin-block: 0;
-webkit-text-size-adjust: 100%;
}

.ams-page-heading {
Expand All @@ -21,6 +21,7 @@
line-height: var(--ams-page-heading-line-height);

@include hyphenation;
@include text-rendering;
@include reset;
}

Expand Down
Loading
Loading