@madgex/design-system 14.3.1 → 14.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/icons-inline.svg +1 -1
- package/dist/assets/icons.json +1 -1
- package/dist/assets/icons.svg +1 -1
- package/dist/js/index.js +1 -1
- package/package.json +4 -4
- package/src/components/accordion/_template.njk +35 -33
- package/src/components/accordion/accordion.config.js +0 -81
- package/src/components/accordion/accordion.js +53 -43
- package/src/components/accordion/accordion.njk +1 -24
- package/src/components/button/button.config.js +1 -42
- package/src/components/button/button.njk +1 -14
- package/src/components/card/card.config.js +0 -93
- package/src/components/card/card.njk +1 -22
- package/src/components/icons/icons.njk +1 -161
- package/src/js/index.js +5 -2
- package/src/layout/containers/index.njk +1 -0
- package/src/typography/index.njk +1 -0
- package/tasks/svgsprite.js +62 -49
- package/src/components/accordion/README.md +0 -46
- package/src/components/button/README.md +0 -27
- package/src/components/card/README.md +0 -114
- package/src/components/icons/README.md +0 -62
- package/src/layout/containers/01-base-containers.njk +0 -30
- package/src/layout/containers/02-branded-containers.njk +0 -13
- package/src/layout/containers/03-ad-containers.njk +0 -6
- package/src/layout/containers/04-highlighted-containers.njk +0 -3
- package/src/layout/containers/README.md +0 -30
- package/src/layout/containers/ad-containers.config.json +0 -3
- package/src/layout/containers/base-containers.config.json +0 -3
- package/src/layout/containers/branded-containers.config.json +0 -3
- package/src/layout/containers/highlighted-containers.config.json +0 -3
- package/src/typography/font-types.config.json +0 -3
- package/src/typography/font-types.njk +0 -43
- package/src/typography/headings.njk +0 -9
- package/src/typography/lists.njk +0 -111
package/src/js/index.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import './common';
|
|
2
2
|
import tabs from '../components/tabs/tabs';
|
|
3
|
-
import accordion from '../components/accordion/accordion';
|
|
4
3
|
import subnavigation from '../components/subnavigation/subnavigation';
|
|
5
4
|
import checkboxList from '../components/inputs/checkbox-list/checkbox-list';
|
|
6
5
|
import popovers from '../components/popover/popover';
|
|
@@ -9,6 +8,7 @@ import { MdsFileUpload } from '../components/inputs/file-upload/file-upload';
|
|
|
9
8
|
import characterCount from '../components/inputs/character-count/character-count';
|
|
10
9
|
import button from '../components/button/button';
|
|
11
10
|
import prose from '../helpers/prose/prose';
|
|
11
|
+
import { MdsAccordion } from '../components/accordion/accordion';
|
|
12
12
|
import { MdsDropdownNav } from '../components/dropdown-nav/dropdown-nav';
|
|
13
13
|
import { MdsTimeoutDialog } from '../components/timeout-dialog/timeout-dialog';
|
|
14
14
|
import { MdsCardLink } from '../components/card/card-link';
|
|
@@ -19,6 +19,10 @@ import { MdsScrollSpy } from '../components/scroll-spy/scroll-spy';
|
|
|
19
19
|
import { MdsConsentGate } from '../components/consent-gate/consent-gate.js';
|
|
20
20
|
export { setConsentAdapter } from '../components/consent-gate/consent-gate.js';
|
|
21
21
|
|
|
22
|
+
if (!window.customElements.get('mds-accordion')) {
|
|
23
|
+
window.customElements.define('mds-accordion', MdsAccordion);
|
|
24
|
+
}
|
|
25
|
+
|
|
22
26
|
if (!window.customElements.get('mds-dropdown-nav')) {
|
|
23
27
|
window.customElements.define('mds-dropdown-nav', MdsDropdownNav);
|
|
24
28
|
}
|
|
@@ -49,7 +53,6 @@ if (!window.customElements.get('mds-consent-gate')) {
|
|
|
49
53
|
|
|
50
54
|
const initAll = () => {
|
|
51
55
|
tabs.init();
|
|
52
|
-
accordion.init();
|
|
53
56
|
subnavigation.init();
|
|
54
57
|
checkboxList.init();
|
|
55
58
|
modals.init();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<a href="/storybook/" target="_top">Moved to Storybook</a>
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
<a href="/storybook/" target="_top">Moved to Storybook</a>
|
package/tasks/svgsprite.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
const path = require('path');
|
|
2
2
|
const fs = require('fs');
|
|
3
|
+
const { createHash } = require('node:crypto');
|
|
3
4
|
const { optimize } = require('svgo');
|
|
4
5
|
const svgstore = require('svgstore');
|
|
5
6
|
|
|
6
|
-
const
|
|
7
|
-
const prefix = path.basename(filepath, path.extname(filepath));
|
|
7
|
+
const iconsDir = path.resolve(__dirname, '../src/icons/');
|
|
8
8
|
|
|
9
9
|
const svgoOptions = {
|
|
10
10
|
plugins: [
|
|
@@ -12,11 +12,9 @@ const svgoOptions = {
|
|
|
12
12
|
name: 'preset-default',
|
|
13
13
|
params: {
|
|
14
14
|
overrides: {
|
|
15
|
-
|
|
16
|
-
prefix: `${prefix}-`,
|
|
15
|
+
cleanupIds: {
|
|
17
16
|
minify: true,
|
|
18
17
|
},
|
|
19
|
-
removeViewBox: false,
|
|
20
18
|
},
|
|
21
19
|
},
|
|
22
20
|
},
|
|
@@ -26,57 +24,72 @@ const svgoOptions = {
|
|
|
26
24
|
attrs: 'fill',
|
|
27
25
|
},
|
|
28
26
|
},
|
|
27
|
+
// ensure `id` attributes of different .svg files are different
|
|
28
|
+
// so that when a spritesheet is created they wont clash (many same named ids, sprites using the wrong reference!)
|
|
29
|
+
{
|
|
30
|
+
name: 'prefixIds',
|
|
31
|
+
params: {
|
|
32
|
+
delim: '',
|
|
33
|
+
// base the unique id prefix on the svg file path, this way it will be consistent inside the file, but unique to that file
|
|
34
|
+
prefix: (_, opt) => createHash('md5').update(opt.path).digest('hex').substring(0, 6) + '-',
|
|
35
|
+
},
|
|
36
|
+
},
|
|
29
37
|
],
|
|
30
38
|
};
|
|
31
39
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
/**
|
|
41
|
+
* load all icons data into a map, keyed by file path
|
|
42
|
+
*
|
|
43
|
+
* @returns {Map<string,string>} Map<iconFilePath, svgString>
|
|
44
|
+
*/
|
|
45
|
+
async function getIcons() {
|
|
46
|
+
const iconFilePaths = await Array.fromAsync(fs.promises.glob(path.join(iconsDir, '*.svg')));
|
|
47
|
+
const icons = new Map();
|
|
48
|
+
for (const iconFilePath of iconFilePaths) {
|
|
49
|
+
const svgString = await fs.promises.readFile(iconFilePath, 'utf8');
|
|
50
|
+
icons.set(iconFilePath, svgString);
|
|
51
|
+
}
|
|
52
|
+
return icons;
|
|
53
|
+
}
|
|
54
|
+
exports.getIcons = getIcons;
|
|
42
55
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
56
|
+
/**
|
|
57
|
+
* @param {Map<string,string>} icons
|
|
58
|
+
* @returns {{spritesheet:object, inlineSpritesheet:object, jsonSpritesheet:object}}
|
|
59
|
+
*/
|
|
60
|
+
async function generateSpritesheets(icons) {
|
|
61
|
+
// load all icon data
|
|
62
|
+
const spritesheet = svgstore();
|
|
63
|
+
const inlineSpritesheet = svgstore({ inline: true, svgAttrs: { id: 'spritesheet', style: 'display: none' } });
|
|
64
|
+
const jsonSpritesheet = {};
|
|
65
|
+
for (const [iconFilePath, svgString] of icons.entries()) {
|
|
66
|
+
// optimize icons - overwrite svgString data in icons map
|
|
67
|
+
const optimizedIcon = optimize(svgString, { path: iconFilePath, ...svgoOptions }).data;
|
|
68
|
+
|
|
69
|
+
// add icons to spritesheets
|
|
70
|
+
const nameFromFilename = path.basename(iconFilePath).replace(/.svg/i, '');
|
|
71
|
+
const prefixedName = `icon-${nameFromFilename}`;
|
|
54
72
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
73
|
+
spritesheet.add(prefixedName, optimizedIcon);
|
|
74
|
+
inlineSpritesheet.add(prefixedName, optimizedIcon);
|
|
75
|
+
jsonSpritesheet[prefixedName] = optimizedIcon;
|
|
76
|
+
}
|
|
77
|
+
return { spritesheet, inlineSpritesheet, jsonSpritesheet };
|
|
78
|
+
}
|
|
79
|
+
exports.generateSpritesheets = generateSpritesheets;
|
|
60
80
|
|
|
61
|
-
|
|
62
|
-
|
|
81
|
+
/**
|
|
82
|
+
* generate spritesheets, and write to disk
|
|
83
|
+
*/
|
|
84
|
+
async function createSvgStack() {
|
|
85
|
+
const icons = await getIcons();
|
|
86
|
+
const { spritesheet, inlineSpritesheet, jsonSpritesheet } = await generateSpritesheets(icons);
|
|
87
|
+
const ourDir = path.resolve(__dirname, '../dist/assets');
|
|
63
88
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
`${path.resolve(__dirname, '../dist/assets', 'icons-inline.svg')}`,
|
|
69
|
-
inlineSprites.toString()
|
|
70
|
-
);
|
|
71
|
-
fs.writeFileSync(`${path.resolve(__dirname, '../dist/assets', 'icons.json')}`, JSON.stringify(icons));
|
|
72
|
-
});
|
|
73
|
-
})
|
|
74
|
-
.catch((err) => {
|
|
75
|
-
reject(err);
|
|
76
|
-
});
|
|
77
|
-
resolve('SVG Stack compiled');
|
|
78
|
-
});
|
|
79
|
-
});
|
|
89
|
+
await fs.promises.mkdir(ourDir, { recursive: true });
|
|
90
|
+
await fs.promises.writeFile(path.join(ourDir, 'icons.svg'), spritesheet.toString(), 'utf-8');
|
|
91
|
+
await fs.promises.writeFile(path.join(ourDir, 'icons-inline.svg'), inlineSpritesheet.toString(), 'utf-8');
|
|
92
|
+
await fs.promises.writeFile(path.join(ourDir, 'icons.json'), JSON.stringify(jsonSpritesheet), 'utf-8');
|
|
80
93
|
}
|
|
81
94
|
|
|
82
95
|
async function svgsprite() {
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
## Callable
|
|
2
|
-
|
|
3
|
-
Use the [callable](https://mozilla.github.io/nunjucks/templating.html#call) syntax to populate the main content
|
|
4
|
-
|
|
5
|
-
## Parameters
|
|
6
|
-
|
|
7
|
-
- `label`: The text inside the trigger button. Be as descriptive as you can as it will help for a11y. **required**
|
|
8
|
-
- `labelOpen`: The text inside of the trigger button when accordion is expanded
|
|
9
|
-
- `labelClasses`: class will be added to the trigger (useful to change the font size)
|
|
10
|
-
- `icon`: override the default icon for the closed state
|
|
11
|
-
- `iconOpen`: override the default icon for the open state
|
|
12
|
-
- `noIcon`: Boolean, removes the icon from the accordion completely
|
|
13
|
-
- `startsOpen`: if `true`, the accordion will be expanded by default. This will be overridden in JS when used as part of a checkbox list with pills, but is still recommended
|
|
14
|
-
as it will auto open the component for people not using JS surfacing the categories.
|
|
15
|
-
- `nonClosing`: boolean to visually hide (for accessibility) the trigger and keep the accordion expanded
|
|
16
|
-
- `breakpoint`: if a value (in px, em, rem) is passed, the accordion will be enabled only when screen size is smaller than the breakpoint
|
|
17
|
-
- `leftAligned`: This will determine if the icon should sit on the left or the right of the trigger (default: false) - See design usage guidelines
|
|
18
|
-
- `contentFirst`: Boolean, places the content above the trigger, pushing the trigger down below the content when open
|
|
19
|
-
|
|
20
|
-
**Note:** Checkbox list with pills is a dependent component and should be checked and updated if any changes to this component are made.
|
|
21
|
-
|
|
22
|
-
## Accessibility
|
|
23
|
-
|
|
24
|
-
When using the non closing accordion, the trigger will be disabled and hidden from view so screenreaders can inform that the content has been expanded. The trigger is also removed from the navigation flow to make sure that it can't be tabbed into when using a keyboard.
|
|
25
|
-
|
|
26
|
-
## Design usage guidelines
|
|
27
|
-
|
|
28
|
-
Where possible, the defaults should remain as they are to ensure we remain consistent across the platform, though there are a few areas where you may need to step
|
|
29
|
-
outside these guidelines, this offers an insight into the design decisions to best ensure you understand context and usage.
|
|
30
|
-
|
|
31
|
-
- `icon`: Where possible, we should ensure that this remains unchanged as the triangles are a universal indicator of collapsable content. However, there are scenarios where this may not work for you. In these scenarios, it is suggested you use one of the following icons: `minus`
|
|
32
|
-
- `iconOpen`: Where possible, we should ensure that this remains unchanged as the triangles are a universal indicator of expandable content. However, there are scenarios where this may not work for you. In these scenarios, it is suggested you use one of the following icons: `plus-small` (Plus is a little too big to align nicely with the content of the trigger)
|
|
33
|
-
- `leftAligned`: Usage for this parameter depends largely on the content surrounding it. There are some cases where we have a list where some items are expandable while others are not so to avoid a misalignment due to the presence of icons or not, we've decided that when in a list the accordions would have the icons on the right. When used as a single component on the page, the icon is on the left instead.
|
|
34
|
-
|
|
35
|
-
## Notes
|
|
36
|
-
|
|
37
|
-
- 15/08/24 - Move to `details` broswer native accordion type component.
|
|
38
|
-
|
|
39
|
-
- 09/12/20 - Non closing accordion - Moved `mds-visually-hidden` to trigger's parent. We noticed an issue on NVDA in Chrome, where the changes on the button like `aria-expanded` or `aria-disabled` were not announced when the button itself was visually hidden.
|
|
40
|
-
|
|
41
|
-
- 02/11/20 - `aria-controls` attribute has been removed from the accordion as it is poorly supported and doesn't work as expected.
|
|
42
|
-
|
|
43
|
-
References:
|
|
44
|
-
|
|
45
|
-
- https://heydonworks.com/article/aria-controls-is-poop/ (that article's title says it all)
|
|
46
|
-
- https://a11ysupport.io/tech/aria/aria-controls_attribute
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
## Callable
|
|
2
|
-
|
|
3
|
-
Use the [callable](https://mozilla.github.io/nunjucks/templating.html#call) syntax to populate the main content
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
## Parameters
|
|
7
|
-
|
|
8
|
-
- `href`: this sets the href and changes the button to an anchor element
|
|
9
|
-
- `classes`: css classes to add on the button (for example `mds-width-full`)
|
|
10
|
-
- `attributes`: you can add extra attributes by passing an object to the parameter. Example: `attributes: { attribute-name: 'attribute-value' }`
|
|
11
|
-
|
|
12
|
-
## Full width button
|
|
13
|
-
|
|
14
|
-
We have 2 helpers classes that can help you achieve full width buttons at different sizes.
|
|
15
|
-
`.mds-width-full` and `.mds-width-auto`.
|
|
16
|
-
|
|
17
|
-
For example, if you would like your button to be full width at mobile size and have `width: auto` at any wider size, add the following classes on the button (using the `classes` parameter): `mds-width-full mds-width-md-auto`.
|
|
18
|
-
|
|
19
|
-
`mds-button--icon` can be used to adjust the padding to better fit around an icon button.
|
|
20
|
-
|
|
21
|
-
Both helper classes are set with breakpoints. Just add the name of the class followed by the breakpoint name (`sm`, `md`, `lg`, `xl`) and the value (`full` or `auto`).
|
|
22
|
-
|
|
23
|
-
## Prevent Double Submit
|
|
24
|
-
|
|
25
|
-
Helper class `.js-mds-button-double-submit`
|
|
26
|
-
|
|
27
|
-
If you click the form button twice in a row (slower than dobule click but faster than submitting), the browser can submit the form twice. Adding this class will disable the button for 1 second to prevent a double submission.
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
The card component adds a border and padding around the content.
|
|
2
|
-
|
|
3
|
-
## Callable
|
|
4
|
-
|
|
5
|
-
Use the [callable](https://mozilla.github.io/nunjucks/templating.html#call) syntax to populate the main content
|
|
6
|
-
|
|
7
|
-
## Parameters
|
|
8
|
-
|
|
9
|
-
- `inList`: if `true`, the container element will be an `<li>` instead of a `<div>` (useful when used in listers) **optional**
|
|
10
|
-
- `classes`: CSS classes to add to the container (`mds-card`) **optional**
|
|
11
|
-
- `id`: used for the name of `data-test` attribute **optional**
|
|
12
|
-
- `badges`: add badges at the top of the card, on the left or right (object) **optional**
|
|
13
|
-
- `link`: add link parameters (object) **optional**
|
|
14
|
-
- `href`: the link URL **required**
|
|
15
|
-
- `title`: title of the link, appearing at the top of the card **required**
|
|
16
|
-
- `containerElement`: optional selection of element, defaults to a paragraph tag **optional**
|
|
17
|
-
|
|
18
|
-
### `classes` parameter
|
|
19
|
-
|
|
20
|
-
Use the class `mds-card--highlighted` in the `classes` parameter to apply a grey background to the card (colour: $constant-color-neutral-lightest)
|
|
21
|
-
|
|
22
|
-
You can customise the `background`, `border` and add a `box-shadow` using the custom brand tokens and passing the class newly created as a parameter. `mds-card--[id of the custom style]`. In the example below, it would be `mds-card--1`.
|
|
23
|
-
|
|
24
|
-
In your brand.json, you would add for example:
|
|
25
|
-
```
|
|
26
|
-
{
|
|
27
|
-
...(other tokens like color, font, size, etc)
|
|
28
|
-
"custom": {
|
|
29
|
-
"card": {
|
|
30
|
-
"1": {
|
|
31
|
-
"background": {
|
|
32
|
-
"value": "{color.brand.1.lightest.value}"
|
|
33
|
-
},
|
|
34
|
-
"border": {
|
|
35
|
-
"value": "{size.border.width.base.value} solid {color.brand.1.base.value}"
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
```
|
|
42
|
-
|
|
43
|
-
Note: The styling above has been added to the design system defaults. So if you use the class `mds-card--1`, you will get by default the background in the "lightest" version of the brand colour 1 and a border of 1px in the colour of brand 1.
|
|
44
|
-
|
|
45
|
-
### `badges` parameter
|
|
46
|
-
|
|
47
|
-
Add your badge object to the `left` or `right` array, depending where you want it be displayed.
|
|
48
|
-
The badge object is composed of the label you want to display and the css class you want to use for the styling of the badge.
|
|
49
|
-
Example:
|
|
50
|
-
```
|
|
51
|
-
badges: {
|
|
52
|
-
left: [
|
|
53
|
-
{
|
|
54
|
-
label: 'Top Job',
|
|
55
|
-
styleId: '1',
|
|
56
|
-
},
|
|
57
|
-
],
|
|
58
|
-
right: [
|
|
59
|
-
{
|
|
60
|
-
label: 'Approved Employer',
|
|
61
|
-
styleId: '1',
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
label: 'New',
|
|
65
|
-
styleId: '2',
|
|
66
|
-
},
|
|
67
|
-
],
|
|
68
|
-
}
|
|
69
|
-
```
|
|
70
|
-
Note: the `styleId` is used to create the class which will apply the styling to the badge i.e. `mds-badge--1`. It can be any string, it doesn't have to be a number and it obviously needs to match the name used when defining the tokens for the badge.
|
|
71
|
-
|
|
72
|
-
## Badges default stylings
|
|
73
|
-
|
|
74
|
-
The design system has some default styling for the badges.
|
|
75
|
-
|
|
76
|
-
- `mds-badge--1`: black background, white text
|
|
77
|
-
- `mds-badge--2`: green background, white text
|
|
78
|
-
|
|
79
|
-
In the context of the jobseekers frontend, they will be used for the top job product and the new badge on the job card.
|
|
80
|
-
|
|
81
|
-
The styling can be overridden or different ones can be added per project, using the `custom.badge` tokens.
|
|
82
|
-
|
|
83
|
-
We only accept the following CSS properties: `background`, `color`, `font-size`, `font-weight`, `text-transform`, `padding`, `border`.
|
|
84
|
-
|
|
85
|
-
Example:
|
|
86
|
-
You want to change the colour of the black badge and add a badge for a premium job product.
|
|
87
|
-
|
|
88
|
-
In your brand.json, you would add:
|
|
89
|
-
```
|
|
90
|
-
{
|
|
91
|
-
...(other tokens like color, font, size, etc)
|
|
92
|
-
"custom": {
|
|
93
|
-
"badge": {
|
|
94
|
-
"1": {
|
|
95
|
-
"background": {
|
|
96
|
-
"value" : "#333"
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
// the name can be whatever you want a number like `3` here or could be `premium-job` etc
|
|
100
|
-
"3": {
|
|
101
|
-
"background": {
|
|
102
|
-
"value" : "#93c0f7"
|
|
103
|
-
},
|
|
104
|
-
"color": {
|
|
105
|
-
"value" : "#000"
|
|
106
|
-
},
|
|
107
|
-
"border": {
|
|
108
|
-
"value": "#000"
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
```
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
## Setup
|
|
2
|
-
|
|
3
|
-
**Default path of the icons file**:
|
|
4
|
-
|
|
5
|
-
You need to set `defaultIconPath` as a Nunjucks global if you want to use an external file (for example, `/assets/icons/svg`).
|
|
6
|
-
https://mozilla.github.io/nunjucks/api.html#addglobal
|
|
7
|
-
|
|
8
|
-
If you prefer using inline svgs, don't set the path and include the file `icons-inline.svg` in your template instead.
|
|
9
|
-
|
|
10
|
-
## Parameters
|
|
11
|
-
|
|
12
|
-
- `iconName`: the name of the icon you want to use
|
|
13
|
-
- `classes`: add extra CSS classes to the icon
|
|
14
|
-
- `path`: if you need to use a different path than your default
|
|
15
|
-
- `visuallyHiddenLabel`: add a visually hidden label (see Accessibility notes below)
|
|
16
|
-
- `hasContainer`: `true/false` - used to add a container arount the icon _optional_
|
|
17
|
-
- `containerClasses`: classes for the container (see Container notes below)
|
|
18
|
-
|
|
19
|
-
## Accessibility
|
|
20
|
-
|
|
21
|
-
The SVGs are hidden from screen readers by default (with the use of `aria-hidden=true` and `focusable=false`). When the icons are used without a visible label, a **visually hidden label needs to be added** instead.
|
|
22
|
-
|
|
23
|
-
If using the 'Icon' macro, simply pass the parameter `visuallyHiddenLabel` with the label you'd like as its value. It will add a `<span>` next to the SVG that will be visually hidden but accessible to screen readers (thanks to the class `mds-visually-hidden`).
|
|
24
|
-
|
|
25
|
-
## Sizes
|
|
26
|
-
|
|
27
|
-
By default, the icon size (width and height) is set to 1em.
|
|
28
|
-
We also have 3 fixed sizes:
|
|
29
|
-
|
|
30
|
-
- `.mds-icon--sm` : 16px
|
|
31
|
-
- `.mds-icon--md` : 24px
|
|
32
|
-
- `.mds-icon--lg` : 32px
|
|
33
|
-
- `.mds-icon--xl` : 48px
|
|
34
|
-
- `.mds-icon--xxl` : 72px
|
|
35
|
-
|
|
36
|
-
### Next to text
|
|
37
|
-
|
|
38
|
-
If using an icon next to some text, use classes `mds-icon--before` or `mds-icon--after` to add `margin-right` or `margin-left` to the icon.
|
|
39
|
-
|
|
40
|
-
## Alignment
|
|
41
|
-
|
|
42
|
-
To make sure that the icons have the same baseline as the text, we are adding `top: 0.125em` on them which corresponds to the icon offset divided by the size of the icon. Please see https://blog.prototypr.io/align-svg-icons-to-text-and-say-goodbye-to-font-icons-d44b3d7b26b4 to see how it is calculated.
|
|
43
|
-
|
|
44
|
-
## Container
|
|
45
|
-
|
|
46
|
-
You can use the attributes `hasContainer` and `containerClasses` to add an icon within an container.
|
|
47
|
-
We currently only have a circle.
|
|
48
|
-
Add `mds-icon-container--circle` in `containerClasses`.
|
|
49
|
-
|
|
50
|
-
To add a colour to the container, add one of the following classes:
|
|
51
|
-
|
|
52
|
-
- `mds-icon-container--error` = `$constant-color-status-error-dark`
|
|
53
|
-
- `mds-icon-container--success` = `$constant-color-status-success-dark`
|
|
54
|
-
- `mds-icon-container--success` = `$constant-color-status-info-dark`
|
|
55
|
-
|
|
56
|
-
Reference: [Colours tokens](/docs/tokens/colour)
|
|
57
|
-
|
|
58
|
-
If the icon is next to some text, you can also add `mds-icon-container--before` or `mds-icon-container--before` to add `margin-right` or `margin-left` to the icon (It will be the same value as `mds-icon--before` or `mds-icon--after`).
|
|
59
|
-
|
|
60
|
-
### IE support
|
|
61
|
-
|
|
62
|
-
Internet Explorer doesn't support `<use href="url" />` if we use a URL in the href. We are using https://github.com/Keyamoon/svgxuse as a polyfill.
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
<div class="mds-site-container container-example" style="margin: 80px 0;">
|
|
2
|
-
<main class="mds-main" role="main">
|
|
3
|
-
<div class="mds-wrapper">
|
|
4
|
-
<div class="mds-surface mds-margin-bottom-b5">
|
|
5
|
-
<div class="mds-surface__inner">
|
|
6
|
-
<h2>Content inside the site-container and wrapper</h2>
|
|
7
|
-
<p>site-container is 100%</p>
|
|
8
|
-
<p>wrapper is 97% - 20px (gutter width) and max-width 1240px</p>
|
|
9
|
-
<div style="height: 100px;"></div>
|
|
10
|
-
</div>
|
|
11
|
-
</div>
|
|
12
|
-
<div class="mds-grid-row mds-margin-bottom-b5">
|
|
13
|
-
<div class="mds-grid-col-12 mds-grid-col-sm-12 mds-grid-col-md-5 mds-grid-col-lg-8 mds-grid-col-xl-7">
|
|
14
|
-
<div class="mds-surface">
|
|
15
|
-
<div class="mds-surface__inner">Surface - test padding</div>
|
|
16
|
-
</div>
|
|
17
|
-
</div>
|
|
18
|
-
<div class="mds-grid-col-5 mds-grid-col-sm-5 mds-grid-col-md-7 mds-grid-col-lg-4 mds-grid-col-xl-5">
|
|
19
|
-
<div class="mds-surface">
|
|
20
|
-
<div class="mds-surface__inner">Surface - test padding</div>
|
|
21
|
-
</div>
|
|
22
|
-
</div>
|
|
23
|
-
</div>
|
|
24
|
-
<div class="mds-fixed-container mds-fixed-container--sticky mds-padding-b5 mds-text-align-center">This is a sticky container</div>
|
|
25
|
-
</div>
|
|
26
|
-
</main>
|
|
27
|
-
</div>
|
|
28
|
-
|
|
29
|
-
{# <div class="mds-fixed-container mds-padding-b5 mds-text-align-center">This a fixed container at the bottom</div> #}
|
|
30
|
-
<div class="mds-fixed-container mds-fixed-container--top mds-padding-b5 mds-text-align-center">This a fixed container at the top</div>
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
{% from "../components/icons/_macro.njk" import MdsIcon %}
|
|
2
|
-
{% from "../components/button/_macro.njk" import MdsButton %}
|
|
3
|
-
|
|
4
|
-
<div class="mds-branded-container mds-branded-container--1 mds-padding-b4">
|
|
5
|
-
{{- MdsIcon({ iconName: 'email', classes: 'mds-icon--lg mds-margin-bottom-b2' }) -}}
|
|
6
|
-
<h3>Get job alerts</h3>
|
|
7
|
-
<p>Create a job alert and receive personalised <a href="/some-link">job recommendations</a> straight to your inbox</p>
|
|
8
|
-
{% call MdsButton({
|
|
9
|
-
href: '/somewhere'
|
|
10
|
-
}) -%}
|
|
11
|
-
Create alert
|
|
12
|
-
{%- endcall %}
|
|
13
|
-
</div>
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
<div style="background-color: #ddd; padding: 20px;">
|
|
2
|
-
<div class="mds-ad-container mds-ad-container--leaderboard">
|
|
3
|
-
<div style="width:728px;height:90px;background-color:#f0f8ff;border:1px solid #14f;">ad example</div>
|
|
4
|
-
</div>
|
|
5
|
-
<div class="mds-ad-container mds-ad-container--leaderboard mds-padding-top-b3 mds-padding-bottom-b3"></div>
|
|
6
|
-
</div>
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
## Containers
|
|
2
|
-
|
|
3
|
-
Class `mds-site-container` should be added right after the body, it contains all the visual elements of the site
|
|
4
|
-
`mds-wrapper` inside `mds-site-container` will give a max-width to the content of the pages
|
|
5
|
-
|
|
6
|
-
`mds-surface` will add a block with a white background, border and and border-radius. Add `mds-surface__inner` inside it to get the padding.
|
|
7
|
-
`mds-surface__inner` has a default padding of 16px but it doubles from the `md` breakpoint (600px). However, when using the grid, if the surface block is contained inside a grid column that is less than half the width of the grid, the padding will stay at 16px.
|
|
8
|
-
|
|
9
|
-
To add a `position: fixed` container, use `mds-fixed-container`. By default it will be fixed at the bottom. Use `mds-fixed-container--top` to fix it at the top.
|
|
10
|
-
|
|
11
|
-
To add a `position: sticky` to the container, use the modifier `mds-fixed-container--sticky`.
|
|
12
|
-
|
|
13
|
-
When placed inside a `mds-wrapper` block, the container will stretch automatically to the full width of the container by default and will go back to be within the wrapper constraints from 600px.
|
|
14
|
-
|
|
15
|
-
_Note: We don't currently use the sticky block inside a wrapper block at tablet/desktop size so it may have to be reviewed when we do._
|
|
16
|
-
|
|
17
|
-
`mds-main` - this class is added to the HTML `<main>` element which represents the dominant content of the <body> of a document. (Note: A document mustn't have more than one `<main>` element that doesn't have the hidden attribute specified.)
|
|
18
|
-
This class is there to be able to customise this container like adding a background, margin or padding with the help of branding tokens.
|
|
19
|
-
|
|
20
|
-
## Branded Containers
|
|
21
|
-
|
|
22
|
-
Use `mds-branded-container mds-branded-container--1` to get a container with the brand colour 1 as a background and white text (the background and the text are tokens that can be changed per project).
|
|
23
|
-
The headings and links will inherit the colour set on the container (white by default).
|
|
24
|
-
We currently only have brand colour 1 but we will add more if needed.
|
|
25
|
-
|
|
26
|
-
## Ad Containers
|
|
27
|
-
|
|
28
|
-
Use `mds-ad-container mds-ad-container--leaderboard` to get a container with ad-container-leaderboard-background token value (color-background-body by default)
|
|
29
|
-
Use token `mds-color-ad-container-leaderboard-background` to set background color
|
|
30
|
-
`mds-ad-container` won't display if empty
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"notes": "## Ad Containers\n\nUse `mds-ad-container mds-ad-container--leaderboard` to get a container with ad-container-leaderboard-background token value (color-background-body by default)\n\nUse token `mds-color-ad-container-leaderboard-background` to set background color\n`mds-ad-container` won't display if empty"
|
|
3
|
-
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"notes": "## Containers\n\nClass `mds-site-container` should be added right after the body, it contains all the visual elements of the site\n\n`mds-wrapper` inside `mds-site-container` will give a max-width to the content of the pages\n\n`mds-surface` will add a block with a white background, border and and border-radius. Add `mds-surface__inner` inside it to get the padding.\n\n`mds-surface__inner` has a default padding of 16px but it doubles from the `md` breakpoint (600px). However, when using the grid, if the surface block is contained inside a grid column that is less than half the width of the grid, the padding will stay at 16px.\n\nTo add a `position: fixed` container, use `mds-fixed-container`. By default it will be fixed at the bottom. Use `mds-fixed-container--top` to fix it at the top.\n\nTo add a `position: sticky` to the container, use the modifier `mds-fixed-container--sticky`.\n\nWhen placed inside a `mds-wrapper` block, the container will stretch automatically to the full width of the container by default and will go back to be within the wrapper constraints from 600px.\n\n*Note: We don't currently use the sticky block inside a wrapper block at tablet/desktop size so it may have to be reviewed when we do.*\n\n`mds-main` - this class is added to the HTML `<main>` element which represents the dominant content of the <body> of a document. (Note: A document mustn't have more than one `<main>` element that doesn't have the hidden attribute specified.)\nThis class is there to be able to customise this container like adding a background, margin or padding with the help of branding tokens."
|
|
3
|
-
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"notes": "## Branded Containers\n\nUse `mds-branded-container mds-branded-container--1` to get a container with the brand colour 1 as a background and white text (the background and the text are tokens that can be changed per project).\n\nThe headings and links will inherit the colour set on the container (white by default).\n\nWe currently only have brand colour 1 but we will add more if needed."
|
|
3
|
-
}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"notes": "We're using Utopia fluid type scale: https://utopia.fyi/type/calculator?c=320,16,1.067,1240,16,1.125,9,3,&s=0.75|0.5|0.25,1.5|2|3|4|6,s-l&g=s,l,xl,12\n\nWe customised font `s-2` and `s-1` so they have a fixed value and don't change depending on the size of the viewport.\nThose 2 fonts being already quite small, we didn't want them getting smaller for accessibility or bigger as they would get too close to the base size and we would lose the visual hierarchy of the text."
|
|
3
|
-
}
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
{# Comments from https://utopia.fyi/type/calculator?c=320,16,1.067,1240,16,1.125,9,3,&s=0.75|0.5|0.25,1.5|2|3|4|6,s-l&g=s,l,xl,12 #}
|
|
2
|
-
{% set fontSizesDoc = {
|
|
3
|
-
's-2': '12px',
|
|
4
|
-
's-1': '14px',
|
|
5
|
-
's0': '16px',
|
|
6
|
-
's1': '17.072px → 18px',
|
|
7
|
-
's2': '18.2158px → 20.25px',
|
|
8
|
-
's3': '19.4363px → 22.7813px',
|
|
9
|
-
's4': '20.7385px → 25.6289px',
|
|
10
|
-
's5': '22.128px → 28.8325px',
|
|
11
|
-
's6': '23.6106px → 32.4366px',
|
|
12
|
-
's7': '25.1925px → 36.4912px',
|
|
13
|
-
's8': '26.8804px → 41.0526px',
|
|
14
|
-
's9': '28.6814px → 46.1841px'
|
|
15
|
-
} %}
|
|
16
|
-
|
|
17
|
-
<style>
|
|
18
|
-
.breakpoint-indicator { display: flex; width: 100%; position: sticky; top: 0; background: white; }
|
|
19
|
-
.example-copy { background-color: #f8f8f8; }
|
|
20
|
-
.example-copy:hover { background-color: #ececec; }
|
|
21
|
-
</style>
|
|
22
|
-
|
|
23
|
-
{% for fontName, item in tokens.font.type %}
|
|
24
|
-
<div class="mds-margin-bottom-b10">
|
|
25
|
-
<h2 class="mds-margin-bottom-b5"><strong>{{ fontName }}</strong></h2>
|
|
26
|
-
<ul>
|
|
27
|
-
<li>Size (in px): <strong>{{ fontSizesDoc[fontName] }}</strong> <span class="mds-font-s-1">(Viewport width: min 320px → max 1240px)</span></li>
|
|
28
|
-
<li>Line height: <strong>{{ item['line-height'].value }}</strong></li>
|
|
29
|
-
</ul>
|
|
30
|
-
<p class="mds-margin-bottom-b1" style="font-size: 16px;">Example:</p>
|
|
31
|
-
<div class="example-copy mds-highlighted-container" style="margin-bottom: 80px;">
|
|
32
|
-
<div class="mds-font-{{ fontName }}">
|
|
33
|
-
<p>
|
|
34
|
-
The quick brown fox jumps over the lazy dog
|
|
35
|
-
</p>
|
|
36
|
-
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer eleifend accumsan elementum. Praesent quis facilisis elit. Donec vel suscipit leo. Cras tincidunt lacus sed mauris fringilla sodales. Praesent quis facilisis elit. Donec vel suscipit leo. Cras tincidunt lacus sed mauris fringilla sodales.</p>
|
|
37
|
-
</div>
|
|
38
|
-
</div>
|
|
39
|
-
|
|
40
|
-
<hr style="border: 1px solid #eee; height: 0; margin-bottom: 80px;">
|
|
41
|
-
|
|
42
|
-
</div>
|
|
43
|
-
{% endfor %}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
<h1>The quick brown fox jumps over the lazy dog</h1>
|
|
2
|
-
|
|
3
|
-
<h1><a>The quick brown link jumps over the lazy link</a></h1>
|
|
4
|
-
|
|
5
|
-
<h2>The quick brown fox jumps over the lazy dog</h2>
|
|
6
|
-
|
|
7
|
-
<h3>The quick brown fox jumps over the lazy dog</h3>
|
|
8
|
-
|
|
9
|
-
<h4>The quick brown fox jumps over the lazy dog</h4>
|