@qhealth-design-system/core 1.16.4 → 1.17.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.
Files changed (103) hide show
  1. package/.storybook/assets/storybook.css +1 -1
  2. package/.storybook/globals.js +10 -0
  3. package/CHANGELOG.md +4 -0
  4. package/package.json +1 -1
  5. package/src/components/_global/css/cta_links/component.scss +107 -14
  6. package/src/components/_global/css/forms/control_inputs/component.scss +65 -77
  7. package/src/components/_global/css/link_columns/component.scss +2 -2
  8. package/src/components/_global/html/scripts.html +0 -2
  9. package/src/components/_global/js/cta_links/global.js +33 -0
  10. package/src/components/_global/js/global.js +175 -138
  11. package/src/components/_global/js/tabs/global.js +6 -2
  12. package/src/components/_template/html/component-page.html +25 -31
  13. package/src/components/banner_advanced/html/component.hbs +1 -1
  14. package/src/components/breadcrumbs/js/global.js +17 -4
  15. package/src/components/card_feature/html/component.hbs +1 -1
  16. package/src/components/card_multi_action/html/component.hbs +1 -1
  17. package/src/components/card_single_action/css/component.scss +38 -47
  18. package/src/components/card_single_action/html/component.hbs +1 -1
  19. package/src/components/code/css/component.scss +72 -73
  20. package/src/components/code/html/component.hbs +62 -19
  21. package/src/components/code/js/global.js +102 -86
  22. package/src/components/footer/css/component.scss +2 -4
  23. package/src/components/footer/html/component.hbs +11 -8
  24. package/src/components/header/css/component.scss +11 -11
  25. package/src/components/header/html/component.hbs +3 -3
  26. package/src/components/header/js/global.js +58 -65
  27. package/src/components/in_page_navigation/js/global.js +34 -31
  28. package/src/components/internal_navigation/js/global.js +13 -3
  29. package/src/components/main_navigation/css/component.scss +79 -13
  30. package/src/components/main_navigation/html/component.hbs +5 -5
  31. package/src/components/main_navigation/js/global.js +94 -115
  32. package/src/components/mega_main_navigation/css/component.scss +27 -14
  33. package/src/components/mega_main_navigation/html/component.hbs +5 -5
  34. package/src/components/mega_main_navigation/js/global.js +50 -55
  35. package/src/components/page_alert/css/component.scss +141 -179
  36. package/src/components/prefooter/css/component.scss +62 -0
  37. package/src/components/prefooter/js/manifest.json +9 -0
  38. package/src/data/current.json +3 -9
  39. package/src/data/site.json +3 -3
  40. package/src/html/component-a-z_listing.html +13 -41
  41. package/src/html/component-abstract.html +536 -40
  42. package/src/html/component-accordion.html +537 -41
  43. package/src/html/component-banner.html +537 -40
  44. package/src/html/component-banner_advanced.html +14 -41
  45. package/src/html/component-banner_basic.html +13 -40
  46. package/src/html/component-banner_intermediate.html +14 -41
  47. package/src/html/component-basic_search.html +10 -26
  48. package/src/html/component-body.html +541 -52
  49. package/src/html/component-breadcrumbs.html +538 -43
  50. package/src/html/component-btn.html +471 -69
  51. package/src/html/component-callout.html +536 -40
  52. package/src/html/component-card_feature.html +282 -312
  53. package/src/html/component-card_multi_action.html +651 -217
  54. package/src/html/component-card_no_action.html +163 -289
  55. package/src/html/component-card_single_action.html +283 -312
  56. package/src/html/component-code.html +13 -40
  57. package/src/html/component-file_upload.html +13 -41
  58. package/src/html/component-footer.html +537 -41
  59. package/src/html/component-forms.html +206 -72
  60. package/src/html/component-global-elements.html +720 -152
  61. package/src/html/component-global_alert.html +536 -41
  62. package/src/html/component-header.html +537 -42
  63. package/src/html/component-horizontal_rule.html +459 -65
  64. package/src/html/component-in_page_navigation.html +544 -48
  65. package/src/html/component-internal_navigation.html +537 -41
  66. package/src/html/component-left_hand_navigation.html +13 -41
  67. package/src/html/component-loading_spinner.html +13 -42
  68. package/src/html/component-main_navigation.html +537 -41
  69. package/src/html/component-mega_main_navigation.html +537 -42
  70. package/src/html/component-multi_column.html +536 -40
  71. package/src/html/component-overflow_menu.html +12 -35
  72. package/src/html/component-page_alert.html +536 -40
  73. package/src/html/component-page_footer_info.html +583 -0
  74. package/src/html/component-pagination.html +459 -65
  75. package/src/html/component-promo_panel.html +13 -43
  76. package/src/html/component-tab.html +13 -41
  77. package/src/html/component-tag_list.html +495 -77
  78. package/src/html/component-toggle_tip.html +2 -3
  79. package/src/html/component-tool_tip.html +2 -3
  80. package/src/html/component-video_player.html +13 -41
  81. package/src/html/components.html +306 -88
  82. package/src/html/home.html +1807 -628
  83. package/src/html/index.html +9 -22
  84. package/src/html/inner-with-nav.html +551 -137
  85. package/src/html/inner.html +570 -59
  86. package/src/stories/Checkboxes/Checkboxes.js +41 -0
  87. package/src/stories/Checkboxes/Checkboxes.mdx +45 -0
  88. package/src/stories/Checkboxes/Checkboxes.stories.js +209 -0
  89. package/src/stories/RadioButtons/RadioButtons.js +41 -0
  90. package/src/stories/RadioButtons/RadioButtons.mdx +45 -0
  91. package/src/stories/RadioButtons/RadioButtons.stories.js +209 -0
  92. package/src/styles/imports/mixins.scss +5 -43
  93. package/src/components/updated_date/css/component.scss +0 -24
  94. package/src/components/updated_date/js/manifest.json +0 -9
  95. package/src/components/widgets/css/component.scss +0 -130
  96. package/src/components/widgets/html/component.hbs +0 -8
  97. package/src/components/widgets/html/default.html +0 -3
  98. package/src/components/widgets/js/current.json +0 -471
  99. package/src/components/widgets/js/manifest.json +0 -9
  100. package/src/components/widgets/js/site.json +0 -350
  101. package/src/html/component-updated_date.html +0 -88
  102. package/src/html/component-widgets.html +0 -90
  103. /package/src/components/{updated_date → prefooter}/html/component.hbs +0 -0
@@ -0,0 +1,41 @@
1
+ export const Checkboxes = ({ id, legend, hintText, isRequired, inError, errorMessage, inSuccess, successMessage, inputs, isSmall }) => {
2
+ const getInputClasses = (input) => {
3
+ if (input.inError) return "qld__input--error";
4
+ else if (input.inSuccess) return "qld__input--valid";
5
+ else return "";
6
+ };
7
+
8
+ const getFeedbackMessage = () => {
9
+ if (inError) {
10
+ return `
11
+ <span id="qld__checkboxes-status-${id}" class="qld__input--error" role="status" aria-live="polite">
12
+ <svg class="qld__icon qld__icon--lead qld__icon--sm" aria-hidden="true"><title>Error icon</title><desc>Indicates an error</desc><use href="QLD-icons.svg#status-error"></use></svg>${errorMessage}
13
+ </span>
14
+ `;
15
+ } else if (inSuccess) {
16
+ return `
17
+ <span id="qld__checkboxes-status-${id}" class="qld__input--success" role="status" aria-live="polite">
18
+ <svg class="qld__icon qld__icon--lead qld__icon--sm" aria-hidden="true"><title>Success icon</title><desc>Indicates a correct answer</desc><use href="QLD-icons.svg#status-success"></svg>${successMessage}
19
+ </span>
20
+ `;
21
+ } else return "";
22
+ };
23
+
24
+ const getHintText = () => {
25
+ return hintText ? `<span class="qld__hint-text" id="qld__checkboxes-hint-${id}">${hintText}</span>` : "";
26
+ };
27
+
28
+ const inputsMapped = inputs
29
+ ?.map((input) => {
30
+ return `<div class="qld__control-input ${isSmall ? "qld__control-input--small" : ""}"><input type="checkbox" id="qld__checkbox-${input.id}" ${
31
+ getInputClasses(input) ? `class="${getInputClasses(input)}"` : ""
32
+ } name="qld__checkbox-${id}" ${input.checked ? "checked" : ""} ${input.disabled ? "disabled" : ""}><label for="qld__checkbox-${input.id}">${input.label}</label></div>`;
33
+ })
34
+ .join("");
35
+
36
+ return `
37
+ <fieldset class="qld__checkboxes" role="group" aria-labelledby="qld__checkboxes-legend-${id}" ${getFeedbackMessage() ? `aria-describedby="qld__checkboxes-status-${id}"` : ""}>
38
+ <legend id="qld__checkboxes-legend-${id}">${isRequired ? "<abbr title='required'>*</abbr>" : ""}${legend}</legend>${getHintText()}${getFeedbackMessage()}${inputsMapped}
39
+ </fieldset>
40
+ `;
41
+ };
@@ -0,0 +1,45 @@
1
+ import { Meta, Primary, Controls, Story, Source } from "@storybook/blocks";
2
+ import * as checkboxesStories from "./Checkboxes.stories";
3
+ import { figmaLinks } from "../../../.storybook/globals";
4
+
5
+ <Meta of={checkboxesStories} />
6
+
7
+ # Checkboxes
8
+
9
+ ## Overview
10
+
11
+ These components help users select one or more items from multiple options.
12
+
13
+ <Primary />
14
+
15
+ ## Props
16
+
17
+ <Controls />
18
+
19
+ ### Valid and invalid states
20
+
21
+ Add a border around the control inputs to indicate valid or invalid selections.
22
+
23
+ <Story of={checkboxesStories.successVariant} />
24
+
25
+ <br />
26
+
27
+ <Story of={checkboxesStories.errorVariant} />
28
+
29
+ ### Disabled control inputs
30
+
31
+ Disabled control inputs can be used to indicate inputs that are no longer valid or have expired.
32
+
33
+ <Story of={checkboxesStories.disabledVariant} />
34
+
35
+ ## Design resources
36
+
37
+ - <a className="figma-link" href={figmaLinks.checkboxes.design} target="_blank" rel="noopener noreferrer">
38
+ Component design view (Figma)
39
+ </a>
40
+ - <a className="figma-link" href={figmaLinks.checkboxes.file} target="_blank" rel="noopener noreferrer">
41
+ Component file (Figma)
42
+ </a>
43
+ - <a className="figma-link" href={figmaLinks.checkboxes.ds} target="_blank" rel="noopener noreferrer">
44
+ Design System website
45
+ </a>
@@ -0,0 +1,209 @@
1
+ import { Checkboxes } from "./Checkboxes";
2
+ import { themes, figmaLinks } from "../../../.storybook/globals";
3
+
4
+ const checkboxesArgs = {
5
+ id: "cb1",
6
+ legend: "Checkbox legend",
7
+ hintText: "",
8
+ isRequired: false,
9
+ inError: false,
10
+ errorMessage: "Error message",
11
+ inSuccess: false,
12
+ successMessage: "Success message",
13
+ inputs: [
14
+ { id: "cb11", label: "Option 1", checked: true, disabled: false, inError: false, inSuccess: false },
15
+ { id: "cb12", label: "Option 2", checked: false, disabled: false, inError: false, inSuccess: false },
16
+ { id: "cb13", label: "Option 3", checked: true, disabled: false, inError: false, inSuccess: false },
17
+ { id: "cb14", label: "Option 4", checked: false, disabled: false, inError: false, inSuccess: false },
18
+ { id: "cb15", label: "Option 5", checked: true, disabled: false, inError: false, inSuccess: false },
19
+ ],
20
+ isSmall: false,
21
+ };
22
+
23
+ export default {
24
+ title: "Components/Checkboxes",
25
+ render: (args) => Checkboxes(args),
26
+ argTypes: {
27
+ id: { control: "text", description: "The id for this component" },
28
+ legend: { control: "text", description: "The legend of the checkbox group" },
29
+ hintText: { control: "text", description: "The hint text of the checkbox group" },
30
+ isRequired: { control: "boolean", description: "If the component requires a response" },
31
+ inError: { control: "boolean", description: "If the entire component is in an error state", if: { arg: "inSuccess", eq: false } },
32
+ errorMessage: { control: "text", description: "The error message to be displayed if component is in error" },
33
+ inSuccess: { control: "boolean", description: "If the entire component is in a success state", if: { arg: "inError", eq: false } },
34
+ successMessage: { control: "text", description: "The success message to be displayed if component is in success" },
35
+ inputs: {
36
+ control: "array",
37
+ description: "The inputs of the group",
38
+ },
39
+ isSmall: { control: "boolean", description: "If the check box should use it's smaller variant" },
40
+ },
41
+ args: { ...checkboxesArgs },
42
+ parameters: {
43
+ design: {
44
+ type: "figma",
45
+ url: figmaLinks.checkboxes.design,
46
+ },
47
+ },
48
+ };
49
+
50
+ export const Default = {
51
+ args: {
52
+ ...checkboxesArgs,
53
+ },
54
+ };
55
+
56
+ export const defaultVariant = (checkboxesArgs) => Checkboxes({ ...checkboxesArgs });
57
+ defaultVariant.tags = ["!dev"];
58
+
59
+ export const disabledVariant = (checkboxesArgs) =>
60
+ Checkboxes({
61
+ ...checkboxesArgs,
62
+ id: "cb2",
63
+ inputs: [
64
+ { id: "cb21", label: "Option 1", checked: true, disabled: true },
65
+ { id: "cb22", label: "Option 2", checked: false, disabled: true },
66
+ { id: "cb23", label: "Option 3", checked: true, disabled: true },
67
+ { id: "cb24", label: "Option 4", checked: false, disabled: true },
68
+ { id: "cb25", label: "Option 5", checked: true, disabled: true },
69
+ ],
70
+ });
71
+ disabledVariant.tags = ["!dev"];
72
+
73
+ export const errorVariant = (checkboxesArgs) =>
74
+ Checkboxes({
75
+ ...checkboxesArgs,
76
+ id: "cb3",
77
+ inError: true,
78
+ errorMessage: "Error message",
79
+ inSuccess: false,
80
+ successMessage: "Success message",
81
+ inputs: [
82
+ { id: "cb31", label: "Option 1", checked: true, inError: true, inSuccess: false },
83
+ { id: "cb32", label: "Option 2", checked: false, inError: true, inSuccess: false },
84
+ { id: "cb33", label: "Option 3", checked: true, inError: true, inSuccess: false },
85
+ { id: "cb34", label: "Option 4", checked: false, inError: true, inSuccess: false },
86
+ { id: "cb35", label: "Option 5", checked: true, inError: true, inSuccess: false },
87
+ ],
88
+ });
89
+ errorVariant.tags = ["!dev"];
90
+
91
+ export const successVariant = (checkboxesArgs) =>
92
+ Checkboxes({
93
+ ...checkboxesArgs,
94
+ id: "cb4",
95
+ inError: false,
96
+ errorMessage: "Error message",
97
+ inSuccess: true,
98
+ successMessage: "Success message",
99
+ inputs: [
100
+ { id: "cb41", label: "Option 1", checked: true, inError: false, inSuccess: true },
101
+ { id: "cb42", label: "Option 2", checked: false, inError: false, inSuccess: true },
102
+ { id: "cb43", label: "Option 3", checked: true, inError: false, inSuccess: true },
103
+ { id: "cb44", label: "Option 4", checked: false, inError: false, inSuccess: true },
104
+ { id: "cb45", label: "Option 5", checked: true, inError: false, inSuccess: true },
105
+ ],
106
+ });
107
+ successVariant.tags = ["!dev"];
108
+
109
+ export const requiredVariant = (checkboxesArgs) =>
110
+ Checkboxes({
111
+ ...checkboxesArgs,
112
+ id: "cb5",
113
+ isRequired: true,
114
+ inputs: [
115
+ { id: "cb51", label: "Option 1", checked: true },
116
+ { id: "cb52", label: "Option 2", checked: false },
117
+ { id: "cb53", label: "Option 3", checked: true },
118
+ { id: "cb54", label: "Option 4", checked: false },
119
+ { id: "cb55", label: "Option 5", checked: true },
120
+ ],
121
+ });
122
+ requiredVariant.tags = ["!dev"];
123
+
124
+ export const smallVariant = (checkboxesArgs) =>
125
+ Checkboxes({
126
+ ...checkboxesArgs,
127
+ id: "cb6",
128
+ inputs: [
129
+ { id: "cb61", label: "Option 1", checked: true },
130
+ { id: "cb62", label: "Option 2", checked: false },
131
+ { id: "cb63", label: "Option 3", checked: true },
132
+ { id: "cb64", label: "Option 4", checked: false },
133
+ { id: "cb65", label: "Option 5", checked: true },
134
+ ],
135
+ isSmall: true,
136
+ });
137
+ smallVariant.tags = ["!dev"];
138
+
139
+ export const hintTextVariant = (checkboxesArgs) =>
140
+ Checkboxes({
141
+ ...checkboxesArgs,
142
+ hintText: "Select all that apply",
143
+ id: "cb7",
144
+ inputs: [
145
+ { id: "cb71", label: "Option 1", checked: true },
146
+ { id: "cb72", label: "Option 2", checked: false },
147
+ { id: "cb73", label: "Option 3", checked: true },
148
+ { id: "cb74", label: "Option 4", checked: false },
149
+ { id: "cb75", label: "Option 5", checked: true },
150
+ ],
151
+ });
152
+ hintTextVariant.tags = ["!dev"];
153
+
154
+ export const allVariants = (args, theme) => {
155
+ return `
156
+ <div class="${theme}" style="padding: 2rem;">
157
+ <h3>Default checkboxes</h3>
158
+ ${defaultVariant(args)}
159
+ <h3>Disabled checkboxes</h3>
160
+ ${disabledVariant(args)}
161
+ <h3>Error checkboxes</h3>
162
+ ${errorVariant(args)}
163
+ <h3>Success checkboxes</h3>
164
+ ${successVariant(args)}
165
+ <h3>Required checkboxes</h3>
166
+ ${requiredVariant(args)}
167
+ <h3>Small checkboxes</h3>
168
+ ${smallVariant(args)}
169
+ <h3>Hint text checkboxes</h3>
170
+ ${hintTextVariant(args)}
171
+ </div>
172
+ `;
173
+ };
174
+ allVariants.tags = ["!dev"];
175
+
176
+ export const white = {
177
+ args: checkboxesArgs,
178
+ render: (args) => {
179
+ return allVariants(args, themes["white"]);
180
+ },
181
+ };
182
+
183
+ export const light = {
184
+ args: checkboxesArgs,
185
+ render: (args) => {
186
+ return allVariants(args, themes["light"]);
187
+ },
188
+ };
189
+
190
+ export const lightAlt = {
191
+ args: checkboxesArgs,
192
+ render: (args) => {
193
+ return allVariants(args, themes["light alt"]);
194
+ },
195
+ };
196
+
197
+ export const dark = {
198
+ args: checkboxesArgs,
199
+ render: (args) => {
200
+ return allVariants(args, themes["dark"]);
201
+ },
202
+ };
203
+
204
+ export const darkAlt = {
205
+ args: checkboxesArgs,
206
+ render: (args) => {
207
+ return allVariants(args, themes["dark alt"]);
208
+ },
209
+ };
@@ -0,0 +1,41 @@
1
+ export const RadioButtons = ({ id, legend, hintText, isRequired, inError, errorMessage, inSuccess, successMessage, inputs, isSmall }) => {
2
+ const getInputClasses = (input) => {
3
+ if (input.inError) return "qld__input--error";
4
+ else if (input.inSuccess) return "qld__input--valid";
5
+ else return "";
6
+ };
7
+
8
+ const getFeedbackMessage = () => {
9
+ if (inError) {
10
+ return `
11
+ <span id="qld__radio-buttons-status-${id}" class="qld__input--error" role="status" aria-live="polite">
12
+ <svg class="qld__icon qld__icon--lead qld__icon--sm" aria-hidden="true"><title>Error icon</title><desc>Indicates an error</desc><use href="QLD-icons.svg#status-error"></use></svg>${errorMessage}
13
+ </span>
14
+ `;
15
+ } else if (inSuccess) {
16
+ return `
17
+ <span id="qld__radio-buttons-status-${id}" class="qld__input--success" role="status" aria-live="polite">
18
+ <svg class="qld__icon qld__icon--lead qld__icon--sm" aria-hidden="true"><title>Success icon</title><desc>Indicates a correct answer</desc><use href="QLD-icons.svg#status-success"></svg>${successMessage}
19
+ </span>
20
+ `;
21
+ } else return "";
22
+ };
23
+
24
+ const getHintText = () => {
25
+ return hintText ? `<span class="qld__hint-text" id="qld__radio-buttons-hint-${id}">${hintText}</span>` : "";
26
+ };
27
+
28
+ const inputsMapped = inputs
29
+ ?.map((input) => {
30
+ return `<div class="qld__control-input ${isSmall ? "qld__control-input--small" : ""}"><input type="radio" id="qld__radio-${input.id}" ${
31
+ getInputClasses(input) ? `class="${getInputClasses(input)}"` : ""
32
+ } name="qld__radio-${id}" ${input.checked ? "checked" : ""} ${input.disabled ? "disabled" : ""} value="qld__radio-${input.id}"><label for="qld__radio-${input.id}">${input.label}</label></div>`;
33
+ })
34
+ .join("");
35
+
36
+ return `
37
+ <fieldset class="qld__radio-buttons" role="radiogroup" aria-labelledby="qld__radio-buttons-legend-${id}" ${getFeedbackMessage() ? `aria-describedby="qld__radio-buttons-status-${id}"` : ""}>
38
+ <legend id="qld__radio-buttons-legend-${id}">${isRequired ? "<abbr title='required'>*</abbr>" : ""}${legend}</legend>${getHintText()}${getFeedbackMessage()}${inputsMapped}
39
+ </fieldset>
40
+ `;
41
+ };
@@ -0,0 +1,45 @@
1
+ import { Meta, Primary, Controls, Story, Source } from "@storybook/blocks";
2
+ import * as radioButtonsStories from "./RadioButtons.stories";
3
+ import { figmaLinks } from "../../../.storybook/globals";
4
+
5
+ <Meta of={radioButtonsStories} />
6
+
7
+ # RadioButtons
8
+
9
+ ## Overview
10
+
11
+ Radio buttons are a type of control input that allow users to select one item from a predefined set of mutually exclusive options.
12
+
13
+ <Primary />
14
+
15
+ ## Props
16
+
17
+ <Controls />
18
+
19
+ ### Valid and invalid states
20
+
21
+ Adds a border around the control inputs to indicate valid or invalid selections.
22
+
23
+ <Story of={radioButtonsStories.successVariant} />
24
+
25
+ <br />
26
+
27
+ <Story of={radioButtonsStories.errorVariant} />
28
+
29
+ ### Disabled control inputs
30
+
31
+ Disabled control inputs can be used to indicate inputs that are no longer valid or expired.
32
+
33
+ <Story of={radioButtonsStories.disabledVariant} />
34
+
35
+ ## Design resources
36
+
37
+ - <a className="figma-link" href={figmaLinks.radioButtons.design} target="_blank" rel="noopener noreferrer">
38
+ Component design view (Figma)
39
+ </a>
40
+ - <a className="figma-link" href={figmaLinks.radioButtons.file} target="_blank" rel="noopener noreferrer">
41
+ Component file (Figma)
42
+ </a>
43
+ - <a className="figma-link" href={figmaLinks.radioButtons.ds} target="_blank" rel="noopener noreferrer">
44
+ Design System website
45
+ </a>
@@ -0,0 +1,209 @@
1
+ import { RadioButtons } from "./RadioButtons";
2
+ import { themes, figmaLinks } from "../../../.storybook/globals";
3
+
4
+ const radioButtonsArgs = {
5
+ id: "rb1",
6
+ legend: "Radio buttons legend",
7
+ hintText: "",
8
+ isRequired: false,
9
+ inError: false,
10
+ errorMessage: "Error message",
11
+ inSuccess: false,
12
+ successMessage: "Success message",
13
+ inputs: [
14
+ { id: "rb11", label: "Option 1", checked: true, disabled: false, inError: false, inSuccess: false },
15
+ { id: "rb12", label: "Option 2", checked: false, disabled: false, inError: false, inSuccess: false },
16
+ { id: "rb13", label: "Option 3", checked: true, disabled: false, inError: false, inSuccess: false },
17
+ { id: "rb14", label: "Option 4", checked: false, disabled: false, inError: false, inSuccess: false },
18
+ { id: "rb15", label: "Option 5", checked: true, disabled: false, inError: false, inSuccess: false },
19
+ ],
20
+ isSmall: false,
21
+ };
22
+
23
+ export default {
24
+ title: "Components/Radio Buttons",
25
+ render: (args) => RadioButtons(args),
26
+ argTypes: {
27
+ id: { control: "text", description: "The id for this component" },
28
+ legend: { control: "text", description: "The legend of the radio button group" },
29
+ hintText: { control: "text", description: "The hint text of the radio button group" },
30
+ isRequired: { control: "boolean", description: "If the component requires a response" },
31
+ inError: { control: "boolean", description: "If the entire component is in an error state", if: { arg: "inSuccess", eq: false } },
32
+ errorMessage: { control: "text", description: "The error message to be displayed if component is in error" },
33
+ inSuccess: { control: "boolean", description: "If the entire component is in a success state", if: { arg: "inError", eq: false } },
34
+ successMessage: { control: "text", description: "The success message to be displayed if component is in success" },
35
+ inputs: {
36
+ control: "array",
37
+ description: "The inputs of the group",
38
+ },
39
+ isSmall: { control: "boolean", description: "If the radio buttons should use it's smaller variant" },
40
+ },
41
+ args: { ...radioButtonsArgs },
42
+ parameters: {
43
+ design: {
44
+ type: "figma",
45
+ url: figmaLinks.radioButtons.design,
46
+ },
47
+ },
48
+ };
49
+
50
+ export const Default = {
51
+ args: {
52
+ ...radioButtonsArgs,
53
+ },
54
+ };
55
+
56
+ export const defaultVariant = (radioButtonsArgs) => RadioButtons({ ...radioButtonsArgs });
57
+ defaultVariant.tags = ["!dev"];
58
+
59
+ export const disabledVariant = (radioButtonsArgs) =>
60
+ RadioButtons({
61
+ ...radioButtonsArgs,
62
+ id: "rb2",
63
+ inputs: [
64
+ { id: "rb21", label: "Option 1", checked: true, disabled: true },
65
+ { id: "rb22", label: "Option 2", checked: false, disabled: true },
66
+ { id: "rb23", label: "Option 3", checked: true, disabled: true },
67
+ { id: "rb24", label: "Option 4", checked: false, disabled: true },
68
+ { id: "rb25", label: "Option 5", checked: true, disabled: true },
69
+ ],
70
+ });
71
+ disabledVariant.tags = ["!dev"];
72
+
73
+ export const errorVariant = (radioButtonsArgs) =>
74
+ RadioButtons({
75
+ ...radioButtonsArgs,
76
+ id: "rb3",
77
+ inError: true,
78
+ errorMessage: "Error message",
79
+ inSuccess: false,
80
+ successMessage: "Success message",
81
+ inputs: [
82
+ { id: "rb31", label: "Option 1", checked: true, inError: true, inSuccess: false },
83
+ { id: "rb32", label: "Option 2", checked: false, inError: true, inSuccess: false },
84
+ { id: "rb33", label: "Option 3", checked: true, inError: true, inSuccess: false },
85
+ { id: "rb34", label: "Option 4", checked: false, inError: true, inSuccess: false },
86
+ { id: "rb35", label: "Option 5", checked: true, inError: true, inSuccess: false },
87
+ ],
88
+ });
89
+ errorVariant.tags = ["!dev"];
90
+
91
+ export const successVariant = (radioButtonsArgs) =>
92
+ RadioButtons({
93
+ ...radioButtonsArgs,
94
+ id: "rb4",
95
+ inError: false,
96
+ errorMessage: "Error message",
97
+ inSuccess: true,
98
+ successMessage: "Success message",
99
+ inputs: [
100
+ { id: "rb41", label: "Option 1", checked: true, inError: false, inSuccess: true },
101
+ { id: "rb42", label: "Option 2", checked: false, inError: false, inSuccess: true },
102
+ { id: "rb43", label: "Option 3", checked: true, inError: false, inSuccess: true },
103
+ { id: "rb44", label: "Option 4", checked: false, inError: false, inSuccess: true },
104
+ { id: "rb45", label: "Option 5", checked: true, inError: false, inSuccess: true },
105
+ ],
106
+ });
107
+ successVariant.tags = ["!dev"];
108
+
109
+ export const requiredVariant = (radioButtonsArgs) =>
110
+ RadioButtons({
111
+ ...radioButtonsArgs,
112
+ id: "rb5",
113
+ isRequired: true,
114
+ inputs: [
115
+ { id: "rb51", label: "Option 1", checked: true },
116
+ { id: "rb52", label: "Option 2", checked: false },
117
+ { id: "rb53", label: "Option 3", checked: true },
118
+ { id: "rb54", label: "Option 4", checked: false },
119
+ { id: "rb55", label: "Option 5", checked: true },
120
+ ],
121
+ });
122
+ requiredVariant.tags = ["!dev"];
123
+
124
+ export const smallVariant = (radioButtonsArgs) =>
125
+ RadioButtons({
126
+ ...radioButtonsArgs,
127
+ id: "rb6",
128
+ inputs: [
129
+ { id: "rb61", label: "Option 1", checked: true },
130
+ { id: "rb62", label: "Option 2", checked: false },
131
+ { id: "rb63", label: "Option 3", checked: true },
132
+ { id: "rb64", label: "Option 4", checked: false },
133
+ { id: "rb65", label: "Option 5", checked: true },
134
+ ],
135
+ isSmall: true,
136
+ });
137
+ smallVariant.tags = ["!dev"];
138
+
139
+ export const hintTextVariant = (radioButtonsArgs) =>
140
+ RadioButtons({
141
+ ...radioButtonsArgs,
142
+ id: "rb7",
143
+ hintText: "Select one option",
144
+ inputs: [
145
+ { id: "rb71", label: "Option 1", checked: true },
146
+ { id: "rb72", label: "Option 2", checked: false },
147
+ { id: "rb73", label: "Option 3", checked: true },
148
+ { id: "rb74", label: "Option 4", checked: false },
149
+ { id: "rb75", label: "Option 5", checked: true },
150
+ ],
151
+ });
152
+ hintTextVariant.tags = ["!dev"];
153
+
154
+ export const allVariants = (args, theme) => {
155
+ return `
156
+ <div class="${theme}" style="padding: 2rem;">
157
+ <h3>Default radio buttons</h3>
158
+ ${defaultVariant(args)}
159
+ <h3>Disabled radio buttons</h3>
160
+ ${disabledVariant(args)}
161
+ <h3>Error radio buttons</h3>
162
+ ${errorVariant(args)}
163
+ <h3>Success radio buttons</h3>
164
+ ${successVariant(args)}
165
+ <h3>Required radio buttons</h3>
166
+ ${requiredVariant(args)}
167
+ <h3>Small radio buttons</h3>
168
+ ${smallVariant(args)}
169
+ <h3>Hint text radio buttons</h3>
170
+ ${hintTextVariant(args)}
171
+ </div>
172
+ `;
173
+ };
174
+ allVariants.tags = ["!dev"];
175
+
176
+ export const white = {
177
+ args: radioButtonsArgs,
178
+ render: (args) => {
179
+ return allVariants(args, themes["white"]);
180
+ },
181
+ };
182
+
183
+ export const light = {
184
+ args: radioButtonsArgs,
185
+ render: (args) => {
186
+ return allVariants(args, themes["light"]);
187
+ },
188
+ };
189
+
190
+ export const lightAlt = {
191
+ args: radioButtonsArgs,
192
+ render: (args) => {
193
+ return allVariants(args, themes["light alt"]);
194
+ },
195
+ };
196
+
197
+ export const dark = {
198
+ args: radioButtonsArgs,
199
+ render: (args) => {
200
+ return allVariants(args, themes["dark"]);
201
+ },
202
+ };
203
+
204
+ export const darkAlt = {
205
+ args: radioButtonsArgs,
206
+ render: (args) => {
207
+ return allVariants(args, themes["dark alt"]);
208
+ },
209
+ };
@@ -405,28 +405,27 @@
405
405
  *
406
406
  * @return {string} - The code
407
407
  */
408
- @mixin QLD-outline($theme: "light", $rounded: true) {
408
+ @mixin QLD-outline($theme: "light", $rounded: true, $offset: 2px) {
409
409
  @if $theme == "dark" {
410
410
  outline: 3px solid var(--QLD-color-dark__focus);
411
411
  } @else {
412
412
  outline: 3px solid var(--QLD-color-light__focus);
413
-
414
- // Only add the offset if it's the default style
415
- outline-offset: 2px;
416
413
  }
417
414
 
418
415
  // Apply radius if rounded is true
419
416
  @if $rounded {
420
417
  border-radius: $QLD-border-radius-xs;
421
418
  }
419
+
420
+ outline-offset: $offset;
422
421
  }
423
422
 
424
423
  /**
425
424
  * QLD-focus - Add the outline to focus
426
425
  */
427
- @mixin QLD-focus($theme: "light", $rounded: true) {
426
+ @mixin QLD-focus($theme: "light", $rounded: true, $offset: 2px) {
428
427
  &:focus {
429
- @include QLD-outline($theme, $rounded);
428
+ @include QLD-outline($theme, $rounded, $offset);
430
429
  }
431
430
 
432
431
  // Remove Modzilla inner HTML dotted line. github.com/necolas/normalize.css/blob/master/normalize.css#L285
@@ -558,43 +557,6 @@
558
557
  $output: $output;
559
558
  }
560
559
 
561
- /**
562
- * QLD-getControlShape Mixin for setting a background image SVG for a control input
563
- *
564
- * @param {keywords} $kind - Either one of the following keywords: checkbox, radio
565
- * @param {keywords} $part - Either one of the following keywords: foreground, background
566
- * @param {string} $color1 - String representing the hex code of the first fill color
567
- * @param {string} $color2 - String representing the hex code of the second fill color
568
- *
569
- * @return {string} - The code; background image containing the encoded SVG
570
- */
571
- @mixin QLD-getControlShape($kind, $part, $color1: transparent, $color2: transparent) {
572
- $start: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">';
573
- $end: "</svg>";
574
-
575
- $checkbox-background: '<path fill="#{ $color1 }" d="M0,0h32v32H0V0z"/><path fill="#{ $color2 }" d="M2,2h28v28H2V2z"/>';
576
- $checkbox-foreground: '<path fill="#{ $color1 }" d="M25.6,11.4c0.2-0.2,0.2-0.5,0-0.7l-2.3-2.3c-0.2-0.2-0.5-0.2-0.7,0L14,17l-3.6-3.6c-0.2-0.2-0.5-0.2-0.7,0l-2.3,2.3 c-0.2,0.2-0.2,0.5,0,0.7l6.3,6.3c0.2,0.2,0.5,0.2,0.7,0L25.6,11.4L25.6,11.4z"/>';
577
-
578
- $radio-background: '<circle fill="#{ $color1 }" cx="16" cy="16" r="16"/><circle fill="#{ $color2 }" cx="16" cy="16" r="14"/>';
579
- $radio-foreground: '<circle fill="#{ $color1 }" cx="16" cy="16" r="12"/>';
580
-
581
- @if ($kind == "checkbox" and $part == "background") {
582
- background-image: QLD-svguri($start + $checkbox-background + $end);
583
- }
584
-
585
- @if ($kind == "checkbox" and $part == "foreground") {
586
- background-image: QLD-svguri($start + $checkbox-foreground + $end);
587
- }
588
-
589
- @if ($kind == "radio" and $part == "background") {
590
- background-image: QLD-svguri($start + $radio-background + $end);
591
- }
592
-
593
- @if ($kind == "radio" and $part == "foreground") {
594
- background-image: QLD-svguri($start + $radio-foreground + $end);
595
- }
596
- }
597
-
598
560
  /**
599
561
  * QLD-side-nav-indent - Mixin for creating indent based off depth
600
562
  *