@hashicorp/design-system-components 0.12.6 → 0.12.7
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/CHANGELOG.md +6 -0
- package/addon/components/hds/form/checkbox/base.hbs +1 -0
- package/addon/components/hds/form/checkbox/base.js +19 -0
- package/addon/components/hds/form/checkbox/field.hbs +19 -0
- package/addon/components/hds/form/checkbox/group.hbs +9 -0
- package/addon/components/hds/form/error/index.hbs +6 -0
- package/addon/components/hds/form/error/index.js +56 -0
- package/addon/components/hds/form/error/message.hbs +3 -0
- package/addon/components/hds/form/field/index.hbs +21 -0
- package/addon/components/hds/form/field/index.js +66 -0
- package/addon/components/hds/form/fieldset/index.hbs +23 -0
- package/addon/components/hds/form/fieldset/index.js +49 -0
- package/addon/components/hds/form/helper-text/index.hbs +3 -0
- package/addon/components/hds/form/helper-text/index.js +56 -0
- package/addon/components/hds/form/label/index.hbs +3 -0
- package/addon/components/hds/form/label/index.js +24 -0
- package/addon/components/hds/form/legend/index.hbs +3 -0
- package/addon/components/hds/form/legend/index.js +24 -0
- package/addon/components/hds/form/radio/base.hbs +1 -0
- package/addon/components/hds/form/radio/base.js +19 -0
- package/addon/components/hds/form/radio/field.hbs +19 -0
- package/addon/components/hds/form/radio/group.hbs +7 -0
- package/addon/components/hds/form/select/base.hbs +3 -0
- package/addon/components/hds/form/select/base.js +22 -0
- package/addon/components/hds/form/select/field.hbs +18 -0
- package/addon/components/hds/form/text-input/base.hbs +1 -0
- package/addon/components/hds/form/text-input/base.js +56 -0
- package/addon/components/hds/form/text-input/field.hbs +16 -0
- package/addon/components/hds/form/textarea/base.hbs +2 -0
- package/addon/components/hds/form/textarea/base.js +22 -0
- package/addon/components/hds/form/textarea/field.hbs +15 -0
- package/addon/components/hds/form/toggle/base.hbs +4 -0
- package/addon/components/hds/form/toggle/base.js +27 -0
- package/addon/components/hds/form/toggle/field.hbs +20 -0
- package/addon/components/hds/form/utils/getAriaDescribedBy.js +21 -0
- package/addon/components/hds/form/utils/getElementId.js +14 -0
- package/app/components/hds/form/checkbox/base.js +1 -0
- package/app/components/hds/form/checkbox/field.js +1 -0
- package/app/components/hds/form/checkbox/group.js +1 -0
- package/app/components/hds/form/error/index.js +1 -0
- package/app/components/hds/form/error/message.js +1 -0
- package/app/components/hds/form/field/index.js +1 -0
- package/app/components/hds/form/fieldset/index.js +1 -0
- package/app/components/hds/form/helper-text/index.js +1 -0
- package/app/components/hds/form/label/index.js +1 -0
- package/app/components/hds/form/legend/index.js +1 -0
- package/app/components/hds/form/radio/base.js +1 -0
- package/app/components/hds/form/radio/field.js +1 -0
- package/app/components/hds/form/radio/group.js +1 -0
- package/app/components/hds/form/select/base.js +1 -0
- package/app/components/hds/form/select/field.js +1 -0
- package/app/components/hds/form/text-input/base.js +1 -0
- package/app/components/hds/form/text-input/field.js +1 -0
- package/app/components/hds/form/textarea/base.js +1 -0
- package/app/components/hds/form/textarea/field.js +1 -0
- package/app/components/hds/form/toggle/base.js +1 -0
- package/app/components/hds/form/toggle/field.js +1 -0
- package/app/styles/@hashicorp/design-system-components.scss +1 -0
- package/app/styles/components/badge.scss +1 -0
- package/app/styles/components/form/checkbox.scss +113 -0
- package/app/styles/components/form/error.scss +27 -0
- package/app/styles/components/form/field.scss +90 -0
- package/app/styles/components/form/group.scss +52 -0
- package/app/styles/components/form/helper-text.scss +10 -0
- package/app/styles/components/form/index.scss +18 -0
- package/app/styles/components/form/label.scss +12 -0
- package/app/styles/components/form/legend.scss +10 -0
- package/app/styles/components/form/radio.scss +115 -0
- package/app/styles/components/form/select.scss +55 -0
- package/app/styles/components/form/text-input.scss +136 -0
- package/app/styles/components/form/textarea.scss +71 -0
- package/app/styles/components/form/toggle.scss +185 -0
- package/blueprints/hds-component-test/files/tests/dummy/app/templates/components/__name__.hbs +3 -3
- package/package.json +1 -1
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import Component from '@glimmer/component';
|
|
2
|
+
|
|
3
|
+
export default class HdsFormToggleBaseComponent extends Component {
|
|
4
|
+
/**
|
|
5
|
+
* Get the class names to apply to the component.
|
|
6
|
+
* @method classNames
|
|
7
|
+
* @return {string} The "class" attribute to apply to the component.
|
|
8
|
+
*/
|
|
9
|
+
get classNames() {
|
|
10
|
+
let classes = ['hds-form-toggle'];
|
|
11
|
+
|
|
12
|
+
// add a class based on the @isInvalid argument
|
|
13
|
+
if (this.args.isInvalid) {
|
|
14
|
+
classes.push(`hds-form-toggle--is-invalid`);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// add a class based on the @_wrapperClass argument
|
|
18
|
+
// we need to use this special argument to pass a class to the wrapping element, because the ...attributes is applied to the control
|
|
19
|
+
// notice: this will *not* be documented for public use
|
|
20
|
+
// the reason for this is that the spread (...) of attributes is applied to the <input> element, but the component has a wrapping container and we need to pass a class to it
|
|
21
|
+
if (this.args._wrapperClass) {
|
|
22
|
+
classes.push(this.args._wrapperClass);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
return classes.join(' ');
|
|
26
|
+
}
|
|
27
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
<Hds::Form::Field
|
|
2
|
+
@layout="flag"
|
|
3
|
+
@contextualClass={{@contextualClass}}
|
|
4
|
+
@extraAriaDescribedBy={{@extraAriaDescribedBy}}
|
|
5
|
+
as |F|
|
|
6
|
+
>
|
|
7
|
+
{{! Notice: the order of the elements is not relevant here, because is controlled at "Hds::Form::Field" component level }}
|
|
8
|
+
{{yield (hash Label=F.Label HelperText=F.HelperText Error=F.Error)}}
|
|
9
|
+
<F.Control>
|
|
10
|
+
<Hds::Form::Toggle::Base
|
|
11
|
+
{{! template-lint-disable no-capital-arguments }}
|
|
12
|
+
@_wrapperClass="hds-form-field__control"
|
|
13
|
+
@value={{@value}}
|
|
14
|
+
@isInvalid={{@isInvalid}}
|
|
15
|
+
...attributes
|
|
16
|
+
id={{F.id}}
|
|
17
|
+
aria-describedby={{F.ariaDescribedBy}}
|
|
18
|
+
/>
|
|
19
|
+
</F.Control>
|
|
20
|
+
</Hds::Form::Field>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export function getAriaDescribedBy(element) {
|
|
2
|
+
let ariaDescribedBy = [];
|
|
3
|
+
|
|
4
|
+
// append descriptor's IDs, if provided
|
|
5
|
+
if (element.descriptors) {
|
|
6
|
+
element.descriptors.forEach((descriptor) =>
|
|
7
|
+
ariaDescribedBy.push(descriptor)
|
|
8
|
+
);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// append @extraAriaDescribedBy arg, if provided
|
|
12
|
+
if (element.args.extraAriaDescribedBy) {
|
|
13
|
+
ariaDescribedBy.push(element.args.extraAriaDescribedBy);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (ariaDescribedBy.length) {
|
|
17
|
+
return ariaDescribedBy.join(' ');
|
|
18
|
+
} else {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { guidFor } from '@ember/object/internals';
|
|
2
|
+
|
|
3
|
+
export function getElementId(element) {
|
|
4
|
+
// use @id arg, if provided
|
|
5
|
+
if (element.args.id) {
|
|
6
|
+
return element.args.id;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// otherwise, generate and memoize a guid
|
|
10
|
+
if (!element._id) {
|
|
11
|
+
element._id = guidFor(element);
|
|
12
|
+
}
|
|
13
|
+
return element._id;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@hashicorp/design-system-components/components/hds/form/checkbox/base';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@hashicorp/design-system-components/components/hds/form/checkbox/field';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@hashicorp/design-system-components/components/hds/form/checkbox/group';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@hashicorp/design-system-components/components/hds/form/error/index';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@hashicorp/design-system-components/components/hds/form/error/message';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@hashicorp/design-system-components/components/hds/form/field/index';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@hashicorp/design-system-components/components/hds/form/fieldset/index';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@hashicorp/design-system-components/components/hds/form/helper-text/index';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@hashicorp/design-system-components/components/hds/form/label/index';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@hashicorp/design-system-components/components/hds/form/legend/index';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@hashicorp/design-system-components/components/hds/form/radio/base';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@hashicorp/design-system-components/components/hds/form/radio/field';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@hashicorp/design-system-components/components/hds/form/radio/group';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@hashicorp/design-system-components/components/hds/form/select/base';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@hashicorp/design-system-components/components/hds/form/select/field';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@hashicorp/design-system-components/components/hds/form/text-input/base';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@hashicorp/design-system-components/components/hds/form/text-input/field';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@hashicorp/design-system-components/components/hds/form/textarea/base';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@hashicorp/design-system-components/components/hds/form/textarea/field';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@hashicorp/design-system-components/components/hds/form/toggle/base';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from '@hashicorp/design-system-components/components/hds/form/toggle/field';
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
@use "../components/card";
|
|
16
16
|
@use "../components/disclosure";
|
|
17
17
|
@use "../components/dropdown";
|
|
18
|
+
@use "../components/form"; // multiple components
|
|
18
19
|
@use "../components/icon-tile";
|
|
19
20
|
@use "../components/link/inline";
|
|
20
21
|
@use "../components/link/standalone";
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
//
|
|
2
|
+
// FORM > CHECKBOX
|
|
3
|
+
//
|
|
4
|
+
// properties within each class are sorted alphabetically
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
$hds-form-checkbox-control-size: 16px;
|
|
8
|
+
$hds-form-checkbox-control-border-radius: 3px;
|
|
9
|
+
|
|
10
|
+
// "BASE" CONTROL
|
|
11
|
+
|
|
12
|
+
.hds-form-checkbox {
|
|
13
|
+
appearance: none;
|
|
14
|
+
background-position: center center;
|
|
15
|
+
background-size: 12px 12px;
|
|
16
|
+
border-radius: $hds-form-checkbox-control-border-radius;
|
|
17
|
+
border-style: solid;
|
|
18
|
+
border-width: 1px;
|
|
19
|
+
cursor: pointer;
|
|
20
|
+
height: $hds-form-checkbox-control-size;
|
|
21
|
+
margin: 0;
|
|
22
|
+
padding: 0;
|
|
23
|
+
width: $hds-form-checkbox-control-size;
|
|
24
|
+
|
|
25
|
+
// STATUS
|
|
26
|
+
|
|
27
|
+
// base (default)
|
|
28
|
+
|
|
29
|
+
&:not(:checked) {
|
|
30
|
+
background-color: var(--token-color-surface-primary);
|
|
31
|
+
border-color: var(--token-color-palette-neutral-400);
|
|
32
|
+
box-shadow: var(--hds-elevation-inset-box-shadow);
|
|
33
|
+
}
|
|
34
|
+
&:checked {
|
|
35
|
+
background-color: var(--token-color-palette-blue-200);
|
|
36
|
+
border-color: var(--token-color-palette-blue-300);
|
|
37
|
+
// notice: the "tick" color is hardcoded here!
|
|
38
|
+
background-image: url("data:image/svg+xml,%3csvg viewBox='0 0 12 12' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M9.78033 3.21967C10.0732 3.51256 10.0732 3.98744 9.78033 4.28033L5.28033 8.78033C4.98744 9.07322 4.51256 9.07322 4.21967 8.78033L2.21967 6.78033C1.92678 6.48744 1.92678 6.01256 2.21967 5.71967C2.51256 5.42678 2.98744 5.42678 3.28033 5.71967L4.75 7.18934L8.71967 3.21967C9.01256 2.92678 9.48744 2.92678 9.78033 3.21967Z' fill='%23FFF'/%3e%3c/svg%3e");
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// hover
|
|
42
|
+
|
|
43
|
+
&:hover:not(:checked),
|
|
44
|
+
&.mock-hover:not(:checked) {
|
|
45
|
+
border-color: var(--token-color-palette-neutral-500);
|
|
46
|
+
}
|
|
47
|
+
&:hover:checked,
|
|
48
|
+
&.mock-hover:checked {
|
|
49
|
+
background-color: var(--token-color-palette-blue-300);
|
|
50
|
+
border-color: var(--token-color-palette-blue-400);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// focus (same for all the states)
|
|
54
|
+
&:focus:not(:checked),
|
|
55
|
+
&:focus:checked,
|
|
56
|
+
&.mock-focus:checked,
|
|
57
|
+
&.mock-focus:not(:checked) {
|
|
58
|
+
border-color: var(--token-color-palette-blue-400);
|
|
59
|
+
outline: 2px solid var(--token-color-focus-action-external);
|
|
60
|
+
outline-offset: 0px;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
// active
|
|
64
|
+
|
|
65
|
+
&:active:not(:checked),
|
|
66
|
+
&.mock-active:not(:checked),
|
|
67
|
+
&:active:checked,
|
|
68
|
+
&.mock-active:checked {
|
|
69
|
+
background-color: var(--token-color-palette-blue-400);
|
|
70
|
+
border-color: var(--token-color-palette-blue-400);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// INVALID
|
|
74
|
+
|
|
75
|
+
&.hds-form-checkbox--is-invalid:not(:checked) {
|
|
76
|
+
border-color: var(--token-color-palette-red-300);
|
|
77
|
+
}
|
|
78
|
+
&.hds-form-checkbox--is-invalid:checked {
|
|
79
|
+
background-color: var(--token-color-palette-red-200);
|
|
80
|
+
border-color: var(--token-color-palette-red-300);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
&.hds-form-checkbox--is-invalid:hover:not(:checked),
|
|
84
|
+
&.hds-form-checkbox--is-invalid.mock-hover:not(:checked) {
|
|
85
|
+
border-color: var(--token-color-palette-red-400);
|
|
86
|
+
}
|
|
87
|
+
&.hds-form-checkbox--is-invalid:hover:checked,
|
|
88
|
+
&.hds-form-checkbox--is-invalid.mock-hover:checked {
|
|
89
|
+
background-color: var(--token-color-palette-red-300);
|
|
90
|
+
border-color: var(--token-color-palette-red-400);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
&.hds-form-checkbox--is-invalid:active:not(:checked),
|
|
94
|
+
&.hds-form-checkbox--is-invalid.mock-active:not(:checked),
|
|
95
|
+
&.hds-form-checkbox--is-invalid:active:checked,
|
|
96
|
+
&.hds-form-checkbox--is-invalid.mock-active:checked {
|
|
97
|
+
background-color: var(--token-color-palette-red-400);
|
|
98
|
+
border-color: var(--token-color-palette-red-400);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// DISABLED
|
|
102
|
+
|
|
103
|
+
&:disabled:not(:checked),
|
|
104
|
+
&:disabled:checked,
|
|
105
|
+
&.hds-form-checkbox--is-invalid:disabled:not(:checked),
|
|
106
|
+
&.hds-form-checkbox--is-invalid:disabled:checked {
|
|
107
|
+
background-color: var(--token-color-surface-strong);
|
|
108
|
+
border-color: var(--token-color-border-primary);
|
|
109
|
+
box-shadow: none;
|
|
110
|
+
// notice: the "tick" color is hardcoded here!
|
|
111
|
+
background-image: url("data:image/svg+xml,%3csvg viewBox='0 0 12 12' xmlns='http://www.w3.org/2000/svg'%3e%3cpath d='M9.78033 3.21967C10.0732 3.51256 10.0732 3.98744 9.78033 4.28033L5.28033 8.78033C4.98744 9.07322 4.51256 9.07322 4.21967 8.78033L2.21967 6.78033C1.92678 6.48744 1.92678 6.01256 2.21967 5.71967C2.51256 5.42678 2.98744 5.42678 3.28033 5.71967L4.75 7.18934L8.71967 3.21967C9.01256 2.92678 9.48744 2.92678 9.78033 3.21967Z' fill='%238C909C'/%3e%3c/svg%3e");
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
//
|
|
2
|
+
// FORM > ERROR
|
|
3
|
+
//
|
|
4
|
+
// properties within each class are sorted alphabetically
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
.hds-form-error {
|
|
8
|
+
align-items: flex-start;
|
|
9
|
+
color: var(--token-color-foreground-critical-on-surface);
|
|
10
|
+
display: flex;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.hds-form-error__icon {
|
|
14
|
+
color: var(--token-color-foreground-critical-on-surface);
|
|
15
|
+
flex: none;
|
|
16
|
+
height: 14px;
|
|
17
|
+
margin: 2px 8px 2px 0;
|
|
18
|
+
width: 14px;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.hds-form-error__content {
|
|
22
|
+
flex: 1 1 auto;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.hds-form-error__message {
|
|
26
|
+
margin: 0;
|
|
27
|
+
}
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
//
|
|
2
|
+
// FORM > FIELD
|
|
3
|
+
//
|
|
4
|
+
// properties within each class are sorted alphabetically
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
// "VERTICAL" LAYOUT
|
|
9
|
+
// used for text-input, textarea, select
|
|
10
|
+
|
|
11
|
+
.hds-form-field--layout-vertical {
|
|
12
|
+
display: grid;
|
|
13
|
+
justify-items: start;
|
|
14
|
+
width: 100%; // we want the input element to fill the parent container
|
|
15
|
+
|
|
16
|
+
.hds-form-field__label {
|
|
17
|
+
width: fit-content; // needed to avoid extra invisible space since the <label> is interactive
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.hds-form-field__helper-text {
|
|
21
|
+
&:not(:first-child) {
|
|
22
|
+
margin-top: 4px;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// special case: if there are multiple helper text lines, we want to reduce the spacing between them
|
|
26
|
+
& + .hds-form-helper-text {
|
|
27
|
+
margin-top: 2px;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.hds-form-field__control {
|
|
32
|
+
&:not(:first-child) {
|
|
33
|
+
margin-top: 8px;
|
|
34
|
+
}
|
|
35
|
+
&:not(:last-child) {
|
|
36
|
+
margin-bottom: 8px;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
// "FLAG" LAYOUT
|
|
43
|
+
// used for checkbox, radio, toggle
|
|
44
|
+
// see https://codepen.io/didoo/pen/xxYPNeY
|
|
45
|
+
|
|
46
|
+
.hds-form-field--layout-flag {
|
|
47
|
+
display: grid;
|
|
48
|
+
grid-template-columns: auto 1fr;
|
|
49
|
+
grid-template-rows: auto auto auto;
|
|
50
|
+
grid-auto-flow: row;
|
|
51
|
+
grid-template-areas:
|
|
52
|
+
"control label"
|
|
53
|
+
"control helper-text"
|
|
54
|
+
"control error";
|
|
55
|
+
justify-items: start;
|
|
56
|
+
|
|
57
|
+
.hds-form-field__label {
|
|
58
|
+
grid-area: label;
|
|
59
|
+
width: fit-content; // needed to avoid extra invisible space since the <label> is interactive
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
.hds-form-field__helper-text {
|
|
63
|
+
grid-area: helper-text;
|
|
64
|
+
margin-top: 4px;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.hds-form-field__control {
|
|
68
|
+
grid-area: control;
|
|
69
|
+
|
|
70
|
+
&:not(:only-child) {
|
|
71
|
+
margin-top: 2px; // the line height of the label is bigger than the control size
|
|
72
|
+
margin-right: 8px;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.hds-form-field__error {
|
|
77
|
+
margin-top: 4px;
|
|
78
|
+
grid-area: error;
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
// Debug (please don't remove)
|
|
85
|
+
//
|
|
86
|
+
// .hds-form-field--layout-vertical,
|
|
87
|
+
// .hds-form-field--layout-flag { outline: 2px dashed pink; }
|
|
88
|
+
// .hds-form-field__label { background-color: #00ff00; }
|
|
89
|
+
// .hds-form-field__helper-text { background-color: #0000ff; }
|
|
90
|
+
// .hds-form-field__error { background-color: #ff0000; }
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
//
|
|
2
|
+
// FORM > GROUP
|
|
3
|
+
//
|
|
4
|
+
// properties within each class are sorted alphabetically
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
.hds-form-group { // notice: this is a <fieldset> element
|
|
8
|
+
border: none;
|
|
9
|
+
display: block;
|
|
10
|
+
margin: 0;
|
|
11
|
+
padding: 0;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.hds-form-group__legend { // notice: this is a <legend> element
|
|
15
|
+
margin: 0 0 4px 0;
|
|
16
|
+
padding: 0;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
.hds-form-group__control-fields-wrapper {
|
|
20
|
+
// when the group contains a "legend", we reduce the visual weight of the "label"
|
|
21
|
+
.hds-form-group__legend + & {
|
|
22
|
+
.hds-form-label {
|
|
23
|
+
font-weight: var(--token-typography-font-weight-regular);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.hds-form-group--layout-vertical {
|
|
29
|
+
.hds-form-group__control-field + .hds-form-group__control-field {
|
|
30
|
+
margin-top: 16px;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.hds-form-group--layout-horizontal {
|
|
35
|
+
.hds-form-group__control-fields-wrapper {
|
|
36
|
+
display: flex;
|
|
37
|
+
flex-wrap: wrap;
|
|
38
|
+
margin-bottom: -4px;
|
|
39
|
+
}
|
|
40
|
+
.hds-form-group__control-field {
|
|
41
|
+
margin-right: 16px;
|
|
42
|
+
margin-bottom: 4px;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.hds-form-group__helper-text {
|
|
47
|
+
margin-bottom: 8px;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
.hds-form-group__error {
|
|
51
|
+
margin-top: 8px;
|
|
52
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
//
|
|
2
|
+
// FORM > INDEX
|
|
3
|
+
//
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
@use "./label";
|
|
7
|
+
@use "./helper-text";
|
|
8
|
+
@use "./error";
|
|
9
|
+
@use "./field";
|
|
10
|
+
@use "./legend";
|
|
11
|
+
@use "./group";
|
|
12
|
+
|
|
13
|
+
@use "./checkbox";
|
|
14
|
+
@use "./radio";
|
|
15
|
+
@use "./select";
|
|
16
|
+
@use "./text-input";
|
|
17
|
+
@use "./textarea";
|
|
18
|
+
@use "./toggle";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
//
|
|
2
|
+
// FORM > LABEL
|
|
3
|
+
//
|
|
4
|
+
// properties within each class are sorted alphabetically
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
.hds-form-label {
|
|
8
|
+
color: var(--token-color-foreground-strong);
|
|
9
|
+
display: block;
|
|
10
|
+
max-width: 100%;
|
|
11
|
+
width: max-content; // to avoid it extends the full width of the parent container, leading to invisible interactive area
|
|
12
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
//
|
|
2
|
+
// FORM > RADIO
|
|
3
|
+
//
|
|
4
|
+
// properties within each class are sorted alphabetically
|
|
5
|
+
//
|
|
6
|
+
|
|
7
|
+
$hds-form-radio-control-size: 16px;
|
|
8
|
+
|
|
9
|
+
// "BASE" CONTROL
|
|
10
|
+
|
|
11
|
+
.hds-form-radio {
|
|
12
|
+
appearance: none;
|
|
13
|
+
background-position: center center;
|
|
14
|
+
background-size: 12px 12px;
|
|
15
|
+
border-radius: 50%;
|
|
16
|
+
border-style: solid;
|
|
17
|
+
border-width: 1px;
|
|
18
|
+
cursor: pointer;
|
|
19
|
+
height: $hds-form-radio-control-size;
|
|
20
|
+
margin: 0;
|
|
21
|
+
padding: 0;
|
|
22
|
+
width: $hds-form-radio-control-size;
|
|
23
|
+
|
|
24
|
+
// STATUS
|
|
25
|
+
|
|
26
|
+
// base (default)
|
|
27
|
+
|
|
28
|
+
&:not(:checked) {
|
|
29
|
+
background-color: var(--token-color-surface-primary);
|
|
30
|
+
border-color: var(--token-color-palette-neutral-400);
|
|
31
|
+
box-shadow: var(--hds-elevation-inset-box-shadow);
|
|
32
|
+
}
|
|
33
|
+
&:checked {
|
|
34
|
+
background-color: var(--token-color-palette-blue-200);
|
|
35
|
+
border-color: var(--token-color-palette-blue-300);
|
|
36
|
+
// notice: the "dot" color is hardcoded here!
|
|
37
|
+
background-image: url("data:image/svg+xml,%3csvg width='12' height='12' xmlns='http://www.w3.org/2000/svg'%3e%3ccircle cx='6' cy='6' r='2.5' fill='%23ffffff'/%3e%3c/svg%3e");
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// hover
|
|
41
|
+
|
|
42
|
+
&:hover:not(:checked),
|
|
43
|
+
&.mock-hover:not(:checked) {
|
|
44
|
+
border-color: var(--token-color-palette-neutral-500);
|
|
45
|
+
}
|
|
46
|
+
&:hover:checked,
|
|
47
|
+
&.mock-hover:checked {
|
|
48
|
+
background-color: var(--token-color-palette-blue-300);
|
|
49
|
+
border-color: var(--token-color-palette-blue-400);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// focus (same for all the states)
|
|
53
|
+
&:focus:not(:checked),
|
|
54
|
+
&:focus:checked,
|
|
55
|
+
&.mock-focus:checked,
|
|
56
|
+
&.mock-focus:not(:checked) {
|
|
57
|
+
border-color: var(--token-color-palette-blue-400);
|
|
58
|
+
outline: 2px solid var(--token-color-focus-action-external);
|
|
59
|
+
outline-offset: 0px;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// active
|
|
63
|
+
|
|
64
|
+
&:active:not(:checked),
|
|
65
|
+
&.mock-active:not(:checked),
|
|
66
|
+
&:active:checked,
|
|
67
|
+
&.mock-active:checked {
|
|
68
|
+
background-color: var(--token-color-palette-blue-400);
|
|
69
|
+
border-color: var(--token-color-palette-blue-400);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// INVALID
|
|
73
|
+
|
|
74
|
+
&.hds-form-radio--is-invalid:not(:checked) {
|
|
75
|
+
border-color: var(--token-color-palette-red-300);
|
|
76
|
+
}
|
|
77
|
+
&.hds-form-radio--is-invalid:checked {
|
|
78
|
+
background-color: var(--token-color-palette-red-200);
|
|
79
|
+
border-color: var(--token-color-palette-red-300);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
&.hds-form-radio--is-invalid:hover:not(:checked),
|
|
83
|
+
&.hds-form-radio--is-invalid.mock-hover:not(:checked) {
|
|
84
|
+
border-color: var(--token-color-palette-red-400);
|
|
85
|
+
}
|
|
86
|
+
&.hds-form-radio--is-invalid:hover:checked,
|
|
87
|
+
&.hds-form-radio--is-invalid.mock-hover:checked {
|
|
88
|
+
background-color: var(--token-color-palette-red-300);
|
|
89
|
+
border-color: var(--token-color-palette-red-400);
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
&.hds-form-radio--is-invalid:active:not(:checked),
|
|
93
|
+
&.hds-form-radio--is-invalid.mock-active:not(:checked),
|
|
94
|
+
&.hds-form-radio--is-invalid:active:checked,
|
|
95
|
+
&.hds-form-radio--is-invalid.mock-active:checked {
|
|
96
|
+
background-color: var(--token-color-palette-red-400);
|
|
97
|
+
border-color: var(--token-color-palette-red-400);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// DISABLED
|
|
101
|
+
|
|
102
|
+
&:disabled:not(:checked),
|
|
103
|
+
&.hds-form-checkbox--is-invalid:disabled:not(:checked) {
|
|
104
|
+
background-color: var(--token-color-surface-strong);
|
|
105
|
+
border-color: var(--token-color-border-primary);
|
|
106
|
+
}
|
|
107
|
+
&:disabled:checked,
|
|
108
|
+
&.hds-form-checkbox--is-invalid:disabled:checked {
|
|
109
|
+
background-color: var(--token-color-surface-strong);
|
|
110
|
+
border-color: var(--token-color-border-primary);
|
|
111
|
+
box-shadow: none;
|
|
112
|
+
// notice: the "dot" color is hardcoded here!
|
|
113
|
+
background-image: url("data:image/svg+xml,%3csvg width='12' height='12' xmlns='http://www.w3.org/2000/svg'%3e%3ccircle cx='6' cy='6' r='2.5' fill='%23656a76'/%3e%3c/svg%3e");
|
|
114
|
+
}
|
|
115
|
+
}
|