@madgex/design-system 13.6.1 → 13.6.3

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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@madgex/design-system",
3
3
  "author": "Madgex",
4
4
  "license": "UNLICENSED",
5
- "version": "13.6.1",
5
+ "version": "13.6.3",
6
6
  "main": "dist/js/index.js",
7
7
  "exports": {
8
8
  ".": "./dist/js/index.js",
@@ -8,6 +8,7 @@
8
8
  {% from 'src/components/image-cropper/_macro.njk' import MdsImageCropper %}
9
9
  {% from 'src/components/inputs/_checkbox-elem/_macro.njk' import MdsCheckboxElem %}
10
10
  {% from 'src/components/inputs/_message/_macro.njk' import MdsInputMessages %}
11
+ {% from 'src/components/inputs/button-checkbox/_macro.njk' import MdsButtonCheckbox %}
11
12
  {% from 'src/components/inputs/category-picker/_macro.njk' import MdsCategoryPicker %}
12
13
  {% from 'src/components/inputs/checkbox-list/_macro.njk' import MdsCheckboxList %}
13
14
  {% from 'src/components/inputs/combobox/_macro.njk' import MdsCombobox %}
@@ -1,15 +1,17 @@
1
1
  {% from "../../icons/_macro.njk" import MdsIcon %}
2
2
  <input
3
3
  type="checkbox"
4
- class="mds-form-check__input"
4
+ class="{{ params.inputClass | default('mds-form-check__input') }}"
5
5
  name="{{ params.name }}"
6
6
  id="{{ params.id }}"
7
7
  {% if params.disabled %}disabled="disabled"{% endif %}
8
8
  {% if params.describedBy %}aria-describedby="{{params.describedBy}}"{% endif %}
9
+ {% if params.labelledBy %}aria-labelledby="{{params.labelledBy}}"{% endif %}
9
10
  {% if params.isSelected == true %}checked="checked"{% endif %}
10
11
  value="{{ params.value }}"
11
12
  {% if params.dataPath %}data-path="{{ params.dataPath }}"{% endif %}
12
- />{#
13
+ {% if params.controls %}aria-controls="{{ params.controls }}"{% endif %}
14
+ />{%- if not params.inputOnly -%}{#
13
15
  #}<label class="mds-form-check__label" for="{{ params.id }}">{#
14
16
  #}{{- params.labelText | safe -}}{#
15
17
  #}{%- if not params.optional -%}
@@ -19,4 +21,5 @@
19
21
  visuallyHiddenLabel: params.i18n.requiredIcon | default('required')
20
22
  }) -}}
21
23
  {%- endif -%}{#
22
- #}</label>
24
+ #}</label>
25
+ {%- endif -%}
@@ -0,0 +1,38 @@
1
+ ## Parameters
2
+
3
+ - `id`: The id attribute of the field. Uses `name` if not specified. **optional**
4
+ - `name`: The name attribute of the input field. Uses `id` if not specified. **optional**
5
+ - NOTE: id or name are optional but one must be included
6
+ - `value`: The value of the checkbox input. **required**
7
+ - `isSelected`: Whether the checkbox is pre-checked. **optional**
8
+ - `disabled`: Should the input be disabled. **optional**
9
+ - `controls`: The `id` of the element this checkbox controls. Rendered as `aria-controls` on the input. **optional**
10
+ - `helpText`: Helper text to display above the checkbox button. **optional**
11
+ - `validationError`: The error message provided by validation. **optional**
12
+ - `i18n`: Text to translate/customise (object). **required**
13
+
14
+ ```
15
+ i18n: {
16
+ title: 'Featured Job',
17
+ description: 'Highlight your job in search results and reach up to twice as many candidates.',
18
+ price: '£500',
19
+ }
20
+ ```
21
+
22
+ ## Example
23
+
24
+ ```
25
+ {
26
+ name: 'job-boost',
27
+ value: 'job-boost',
28
+ i18n: {
29
+ title: 'Job boost',
30
+ description: 'Boost your job the best way with job boost. 100% more boosts',
31
+ price: '£300',
32
+ },
33
+ }
34
+ ```
35
+
36
+ ## Accessibility
37
+
38
+ The checkbox input uses `aria-labelledby` to associate the title and price elements as its label, and `aria-describedby` to associate any validation error, help text, and description elements. When `controls` is provided it is rendered as an `aria-controls` attribute on the input.
@@ -0,0 +1,3 @@
1
+ {% macro MdsButtonCheckbox(params) %}
2
+ {%- include "./_template.njk" -%}
3
+ {% endmacro %}
@@ -0,0 +1,51 @@
1
+ {% from "../_message/_macro.njk" import MdsInputMessages %}
2
+ {% from "../_checkbox-elem/_macro.njk" import MdsCheckboxElem %}
3
+ {% from "../../icons/_macro.njk" import MdsIcon %}
4
+
5
+ {%- set name = params.name or params.id -%}
6
+ {%- set id = params.id or params.name -%}
7
+ {%- set descriptionId = id + '-description' -%}
8
+ {%- set titleId = id + '-title' -%}
9
+ {%- set priceId = id + '-price' -%}
10
+
11
+ {%- if params.helpText -%}
12
+ {%- set helpTextId = id + '-help-text' -%}
13
+ {%- endif -%}
14
+
15
+ {%- if params.validationError -%}
16
+ {%- set validationErrorId = id + '-validation-error' -%}
17
+ {%- endif -%}
18
+
19
+ {%- set ariaDescribedBy = [validationErrorId, helpTextId, descriptionId] | select | join(' ') | trim -%}
20
+
21
+ <div class="mds-button-checkbox{% if params.validationError %} mds-button-checkbox--error{% endif %}">
22
+ {{- MdsInputMessages({
23
+ id: id,
24
+ helpTextId: helpTextId,
25
+ helpText: params.helpText,
26
+ validationErrorId: validationErrorId,
27
+ validationError: params.validationError
28
+ }) -}}
29
+ <label class="mds-button-checkbox__label">
30
+ {{- MdsCheckboxElem({
31
+ inputOnly: true,
32
+ inputClass: 'mds-visually-hidden',
33
+ name: name,
34
+ id: id,
35
+ disabled: params.disabled,
36
+ isSelected: params.isSelected,
37
+ value: params.value,
38
+ labelledBy: titleId + ' ' + priceId,
39
+ describedBy: ariaDescribedBy,
40
+ controls: params.controls
41
+ }) -}}
42
+ <span class="mds-button-checkbox__icon--add">{{- MdsIcon({ iconName: "add", classes: "mds-font-s2" }) -}}</span>
43
+ <span class="mds-button-checkbox__icon--remove">{{- MdsIcon({ iconName: "remove", classes: "mds-font-s2" }) -}}</span>
44
+ <span>
45
+ <span class="mds-button-checkbox__title mds-font-s2" id="{{ titleId }}">{{ params.i18n.title }}</span>
46
+ <span class="mds-button-checkbox__description" id="{{ descriptionId }}">{{ params.i18n.description }}</span>
47
+ </span>
48
+ <span class="mds-button-checkbox__price mds-font-s2" id="{{ priceId }}">{{ params.i18n.price }}</span>
49
+ </label>
50
+ </div>
51
+
@@ -0,0 +1,41 @@
1
+ module.exports = {
2
+ title: 'Button checkbox',
3
+ name: 'Button checkbox',
4
+ status: 'ready',
5
+ context: {
6
+ name: 'job-boost',
7
+ value: 'job-boost',
8
+ i18n: {
9
+ title: 'Job Boost',
10
+ description: "Increase your job's visibility to be seen by more relevant candidates.",
11
+ price: '£300',
12
+ },
13
+ },
14
+ variants: [
15
+ {
16
+ name: 'Featured Job',
17
+ context: {
18
+ name: 'featured-job',
19
+ value: 'featured-job',
20
+ i18n: {
21
+ title: 'Featured Job',
22
+ description: 'Highlight your job in search results and reach up to twice as many candidates.',
23
+ price: '£500',
24
+ },
25
+ },
26
+ },
27
+ {
28
+ name: 'Something wrong',
29
+ context: {
30
+ name: 'something-wrong',
31
+ value: 'something-wrong',
32
+ validationError: 'There was an error',
33
+ i18n: {
34
+ title: 'Unable to add upgrade',
35
+ description: "We couldn't apply this upgrade right now. Please try again or contact support.",
36
+ price: '£0',
37
+ },
38
+ },
39
+ },
40
+ ],
41
+ };
@@ -0,0 +1,15 @@
1
+ {% from "./inputs/button-checkbox/_macro.njk" import MdsButtonCheckbox %}
2
+
3
+ <div class="mds-form-field">
4
+ {{- MdsButtonCheckbox({
5
+ id: id,
6
+ name: name,
7
+ controls: controls,
8
+ isSelected: isSelected,
9
+ validationError: validationError,
10
+ helpText: helpText,
11
+ value: value,
12
+ i18n: i18n,
13
+ disabled: disabled
14
+ }) -}}
15
+ </div>
@@ -0,0 +1,86 @@
1
+ .mds-button-checkbox {
2
+ .mds-button-checkbox__label {
3
+ display: flex;
4
+ max-width: 500px;
5
+ gap: ($constant-size-baseline * 4);
6
+ cursor: pointer;
7
+ border: #{$regular-border};
8
+ border-radius: $border-radius;
9
+ justify-content: space-around;
10
+ padding-left: ($constant-size-baseline * 4);
11
+
12
+ & > * {
13
+ display: block;
14
+ padding: ($constant-size-baseline * 6) 0;
15
+ }
16
+
17
+ .mds-button-checkbox__icon--remove {
18
+ display: none;
19
+ }
20
+ }
21
+
22
+ .mds-button-checkbox__title {
23
+ display: block;
24
+ font-weight: bold;
25
+ margin-bottom: ($constant-size-baseline * 2);
26
+ }
27
+
28
+ .mds-button-checkbox__price {
29
+ align-content: center;
30
+ background: $constant-color-neutral-lightest;
31
+ padding-left: ($constant-size-baseline * 4);
32
+ flex: 0 0 auto;
33
+ width: 100px;
34
+ max-width: 30%;
35
+ white-space: nowrap;
36
+ }
37
+
38
+ // Selected (checked) state
39
+ .mds-button-checkbox__label:has(:checked) {
40
+ outline: 2.5px solid $constant-color-neutral-darker;
41
+
42
+ .mds-button-checkbox__price {
43
+ background: none;
44
+ }
45
+
46
+ .mds-button-checkbox__icon--remove {
47
+ display: inline;
48
+ }
49
+ .mds-button-checkbox__icon--add {
50
+ display: none;
51
+ }
52
+ }
53
+
54
+ // Focus state
55
+ .mds-button-checkbox__label:has(:focus-visible) {
56
+ outline: 2px solid var(--mds-color-link-base, #1b75bb);
57
+ outline-offset: 2px;
58
+
59
+ .mds-button-checkbox__price {
60
+ background: none;
61
+ }
62
+ }
63
+
64
+ // Hover
65
+ .mds-button-checkbox__label:hover .mds-button-checkbox__price {
66
+ background: none;
67
+ }
68
+
69
+ // Error
70
+ &.mds-button-checkbox--error {
71
+ .mds-button-checkbox__label {
72
+ border-color: $constant-color-status-error-dark;
73
+ }
74
+ }
75
+
76
+ // Mobile
77
+ @media only screen and (max-width: $constant-size-breakpoint-sm) {
78
+ .mds-button-checkbox__label:has(:checked),
79
+ .mds-button-checkbox__label {
80
+ .mds-button-checkbox__icon--remove,
81
+ .mds-button-checkbox__icon--add {
82
+ display: none;
83
+ }
84
+ }
85
+ }
86
+ }
@@ -18,7 +18,7 @@
18
18
  - `noImageCropper`: don't show image cropper when an image file is detected
19
19
  - `noAutoOpenImageCropper`: don't automatically open image cropper modal on file change
20
20
  - `siteContainerId`: see MdsModal for `siteContainerId`
21
- - `cropper`: see MdsImageCropper [here](/components/detail/image-cropper)
21
+ - `cropper`: see MdsImageCropper [here](/components/detail/image-cropper/index.html)
22
22
 
23
23
  ```
24
24
  i18n: {
@@ -36,7 +36,7 @@
36
36
  {% endif %}
37
37
 
38
38
  <div class="mds-form-element mds-form-element--checkbox{% if params.state %} mds-form-element--{{params.state}}{% endif %}{% if params.classes %} {{params.classes}}{% endif %}" data-test="checkbox{% if params.id %}-{{params.id}}{% endif %}">
39
- {{- MdsInputMessages({
39
+ {{- MdsInputMessages({
40
40
  id: params.id,
41
41
  helpTextId: helpTextId,
42
42
  helpText: params.helpText,
@@ -0,0 +1,16 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
3
+ <g clip-path="url(#clip0_7441_4029)">
4
+ <path
5
+ d="M12 0C9.62663 0 7.30655 0.703788 5.33316 2.02236C3.35977 3.34094 1.8217 5.21509 0.913451 7.4078C0.00519943 9.60051 -0.232441 12.0133 0.230582 14.3411C0.693605 16.6689 1.83649 18.8071 3.51472 20.4853C5.19295 22.1635 7.33115 23.3064 9.65892 23.7694C11.9867 24.2324 14.3995 23.9948 16.5922 23.0866C18.7849 22.1783 20.6591 20.6402 21.9776 18.6668C23.2962 16.6935 24 14.3734 24 12C24 8.8174 22.7357 5.76515 20.4853 3.51472C18.2348 1.26428 15.1826 0 12 0ZM12 21C10.22 21 8.47992 20.4722 6.99987 19.4832C5.51983 18.4943 4.36628 17.0887 3.68509 15.4442C3.0039 13.7996 2.82567 11.99 3.17294 10.2442C3.5202 8.49836 4.37737 6.89471 5.63604 5.63604C6.89472 4.37737 8.49836 3.5202 10.2442 3.17293C11.99 2.82567 13.7996 3.0039 15.4442 3.68508C17.0887 4.36627 18.4943 5.51983 19.4832 6.99987C20.4722 8.47991 21 10.22 21 12C21 14.3869 20.0518 16.6761 18.364 18.364C16.6761 20.0518 14.387 21 12 21Z"
6
+ fill="currentColor" />
7
+ <path
8
+ d="M17.25 10.57H13.68C13.6137 10.57 13.5501 10.5437 13.5032 10.4968C13.4563 10.4499 13.43 10.3863 13.43 10.32V6.75C13.4303 6.49322 13.3319 6.24616 13.155 6.06C12.9781 5.87384 12.7365 5.76284 12.48 5.75H11.48C11.2235 5.76284 10.9819 5.87384 10.805 6.06C10.6281 6.24616 10.5297 6.49322 10.53 6.75V10.32C10.53 10.3863 10.5037 10.4499 10.4568 10.4968C10.4099 10.5437 10.3463 10.57 10.28 10.57H6.75C6.49322 10.5697 6.24616 10.6681 6.06 10.845C5.87384 11.0219 5.76284 11.2635 5.75 11.52V12.52C5.76284 12.7765 5.87384 13.0181 6.06 13.195C6.24616 13.3719 6.49322 13.4703 6.75 13.47H10.32C10.3863 13.47 10.4499 13.4963 10.4968 13.5432C10.5437 13.5901 10.57 13.6537 10.57 13.72V17.29C10.5821 17.538 10.6861 17.7727 10.8617 17.9483C11.0373 18.1239 11.272 18.2279 11.52 18.24H12.52C12.768 18.2279 13.0027 18.1239 13.1783 17.9483C13.3539 17.7727 13.4579 17.538 13.47 17.29V13.68C13.47 13.6137 13.4963 13.5501 13.5432 13.5032C13.5901 13.4563 13.6537 13.43 13.72 13.43H17.29C17.538 13.4179 17.7727 13.3139 17.9483 13.1383C18.1239 12.9627 18.2279 12.728 18.24 12.48V11.48C18.2176 11.2324 18.1038 11.002 17.9208 10.8338C17.7378 10.6655 17.4986 10.5715 17.25 10.57Z"
9
+ fill="currentColor" />
10
+ </g>
11
+ <defs>
12
+ <clipPath id="clip0_7441_4029">
13
+ <rect width="24" height="24" fill="white" />
14
+ </clipPath>
15
+ </defs>
16
+ </svg>
@@ -0,0 +1,13 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
3
+ <g clip-path="url(#clip0_7448_4095)">
4
+ <path fill-rule="evenodd" clip-rule="evenodd"
5
+ d="M12.0001 0C15.1827 0 18.235 1.26421 20.4854 3.51465C22.7359 5.76509 24.0001 8.8174 24.0001 12C24.0001 14.3734 23.2962 16.6936 21.9776 18.667C20.6591 20.6403 18.7845 22.1787 16.5919 23.0869C14.3994 23.995 11.9868 24.2324 9.65927 23.7695C7.33149 23.3065 5.19297 22.1636 3.51474 20.4854C1.83651 18.8071 0.693578 16.6686 0.230556 14.3408C-0.23236 12.0133 0.00511932 9.6007 0.913173 7.4082C1.8214 5.21555 3.35978 3.34103 5.3331 2.02246C7.30648 0.703885 9.62671 1.13119e-06 12.0001 0ZM6.75009 10.5703C5.81161 10.5703 5.80003 11.497 5.79989 11.5195V12.4795C5.79989 13.4295 6.75009 13.4297 6.75009 13.4297H17.2599C18.2099 13.4297 18.21 12.4795 18.21 12.4795V11.5195C18.2098 10.5699 17.2599 10.5703 17.2599 10.5703H6.75009Z"
6
+ fill="currentColor" />
7
+ </g>
8
+ <defs>
9
+ <clipPath id="clip0_7448_4095">
10
+ <rect width="24" height="24" fill="white" />
11
+ </clipPath>
12
+ </defs>
13
+ </svg>
@@ -14,6 +14,7 @@
14
14
  @import '../../components/inputs/file-upload/file-upload';
15
15
  @import '../../components/inputs/textarea/textarea';
16
16
  @import '../../components/inputs/text-editor/text-editor';
17
+ @import '../../components/inputs/button-checkbox/button-checkbox';
17
18
  @import '../../components/modal/modal';
18
19
  @import '../../components/skip-link/skip-link';
19
20
  @import '../../components/media-block/media-block';
@@ -72,3 +72,59 @@
72
72
  margin-left: 0;
73
73
  }
74
74
  }
75
+
76
+ .mds-step-list {
77
+ list-style-type: none;
78
+ counter-reset: item;
79
+
80
+ .mds-step-list__item {
81
+ position: relative;
82
+ counter-increment: item;
83
+
84
+ a {
85
+ --text-decoration: none;
86
+ }
87
+
88
+ &:before {
89
+ content: counter(item);
90
+ width: 2.5em;
91
+ height: 2.5em;
92
+ margin-right: 0.5em;
93
+ margin-bottom: 1em;
94
+ border-radius: 50%;
95
+ border: solid 1px $constant-color-neutral-light;
96
+ display: inline-flex;
97
+ justify-content: center;
98
+ line-height: 2.5em;
99
+ }
100
+
101
+ & + .mds-step-list__item:after {
102
+ content: '';
103
+ position: absolute;
104
+ top: -1em;
105
+ left: 1.25em;
106
+ height: 1em;
107
+ border-right: 1px solid $constant-color-neutral-light;
108
+ }
109
+
110
+ &.mds-step-list__item--current {
111
+ font-weight: bold;
112
+
113
+ &:before {
114
+ border-width: 2px;
115
+ font-weight: bold;
116
+ background-color: $constant-color-neutral-lightest;
117
+ border-color: $constant-color-neutral-darker;
118
+ }
119
+ }
120
+
121
+ &.mds-step-list__item--future {
122
+ color: $constant-color-neutral-light;
123
+
124
+ &:before {
125
+ border-style: dashed;
126
+ color: $constant-color-neutral-light;
127
+ }
128
+ }
129
+ }
130
+ }
@@ -81,4 +81,18 @@
81
81
  <li class="mds-list__item">
82
82
  <a href="#three">three</a>
83
83
  </li>
84
- </ul>
84
+ </ul>
85
+
86
+ <h2>Step List</h2>
87
+ <ol class="mds-step-list">
88
+ <li class="mds-step-list__item">Step 1</li>
89
+ <li class="mds-step-list__item">Step 2</li>
90
+ <li class="mds-step-list__item">Step 3</li>
91
+ </ol>
92
+
93
+ <h2>Step List with page progress</h2>
94
+ <ol class="mds-step-list">
95
+ <li class="mds-step-list__item"><a href="https://www.google.com">Past page with link</a></li>
96
+ <li class="mds-step-list__item mds-step-list__item--current" aria-current="page">Current page</li>
97
+ <li class="mds-step-list__item mds-step-list__item--future">Ghost of pages future</li>
98
+ </ol>