@muonic/muon 0.0.2-beta.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 (124) hide show
  1. package/.nycrc +17 -0
  2. package/.versionrc +3 -0
  3. package/CHANGELOG.md +389 -0
  4. package/components/card/index.js +1 -0
  5. package/components/card/src/card-component.js +43 -0
  6. package/components/card/src/card-styles.css +25 -0
  7. package/components/card/src/config-tokens.json +11 -0
  8. package/components/card/src/design-tokens.json +34 -0
  9. package/components/card/story.js +52 -0
  10. package/components/cta/index.js +1 -0
  11. package/components/cta/src/config-tokens.json +11 -0
  12. package/components/cta/src/cta-component.js +174 -0
  13. package/components/cta/src/cta-styles.css +105 -0
  14. package/components/cta/src/design-tokens.json +132 -0
  15. package/components/cta/story.js +99 -0
  16. package/components/detail/index.js +1 -0
  17. package/components/detail/src/config-tokens.json +11 -0
  18. package/components/detail/src/design-tokens.json +102 -0
  19. package/components/detail/src/detail-component.js +27 -0
  20. package/components/detail/src/detail-styles.css +83 -0
  21. package/components/detail/story.js +33 -0
  22. package/components/form/index.js +1 -0
  23. package/components/form/src/config-tokens.json +11 -0
  24. package/components/form/src/design-tokens.json +9 -0
  25. package/components/form/src/form-component.js +197 -0
  26. package/components/form/src/form-styles.css +10 -0
  27. package/components/form/story.js +71 -0
  28. package/components/icon/index.js +1 -0
  29. package/components/icon/src/config-tokens.json +31 -0
  30. package/components/icon/src/design-tokens.json +8 -0
  31. package/components/icon/src/icon-component.js +91 -0
  32. package/components/icon/src/icon-styles.css +26 -0
  33. package/components/icon/story.js +26 -0
  34. package/components/image/index.js +1 -0
  35. package/components/image/src/config-tokens.json +26 -0
  36. package/components/image/src/image-component.js +96 -0
  37. package/components/image/src/image-styles.css +71 -0
  38. package/components/image/story.js +31 -0
  39. package/components/inputter/index.js +1 -0
  40. package/components/inputter/src/config-tokens.json +14 -0
  41. package/components/inputter/src/design-tokens.json +308 -0
  42. package/components/inputter/src/inputter-component.js +227 -0
  43. package/components/inputter/src/inputter-styles-detail.css +59 -0
  44. package/components/inputter/src/inputter-styles.css +305 -0
  45. package/components/inputter/src/inputter-styles.slotted.css +64 -0
  46. package/components/inputter/story.js +243 -0
  47. package/css/accessibility.css +3 -0
  48. package/css/default.css +9 -0
  49. package/css/global.css +8 -0
  50. package/directives/image-loader-directive.js +116 -0
  51. package/directives/svg-loader-directive.js +94 -0
  52. package/index.js +52 -0
  53. package/mixins/card-mixin.js +27 -0
  54. package/mixins/detail-mixin.js +128 -0
  55. package/mixins/form-associate-mixin.js +36 -0
  56. package/mixins/form-element-mixin.js +378 -0
  57. package/mixins/image-holder-mixin.js +20 -0
  58. package/mixins/mask-mixin.js +159 -0
  59. package/mixins/validation-mixin.js +272 -0
  60. package/muon-element/index.js +97 -0
  61. package/package.json +72 -0
  62. package/rollup.config.mjs +30 -0
  63. package/scripts/build/storybook/index.mjs +11 -0
  64. package/scripts/build/storybook/run.mjs +47 -0
  65. package/scripts/rollup-plugins.mjs +116 -0
  66. package/scripts/serve/index.mjs +11 -0
  67. package/scripts/serve/run.mjs +27 -0
  68. package/scripts/style-dictionary.mjs +64 -0
  69. package/scripts/utils/config.mjs +30 -0
  70. package/scripts/utils/index.mjs +283 -0
  71. package/storybook/find-stories.js +36 -0
  72. package/storybook/server.config.mjs +19 -0
  73. package/storybook/stories.js +86 -0
  74. package/storybook/tokens/color.js +87 -0
  75. package/storybook/tokens/font.js +52 -0
  76. package/storybook/tokens/spacer.js +48 -0
  77. package/tests/README.md +3 -0
  78. package/tests/components/card/__snapshots__/card.test.snap.js +70 -0
  79. package/tests/components/card/card.test.js +81 -0
  80. package/tests/components/cta/__snapshots__/cta.test.snap.js +246 -0
  81. package/tests/components/cta/cta.test.js +212 -0
  82. package/tests/components/form/__snapshots__/form.test.snap.js +115 -0
  83. package/tests/components/form/form.test.js +336 -0
  84. package/tests/components/icon/__snapshots__/icon.test.snap.js +95 -0
  85. package/tests/components/icon/icon.test.js +197 -0
  86. package/tests/components/image/__snapshots__/image.test.snap.js +205 -0
  87. package/tests/components/image/image.test.js +314 -0
  88. package/tests/components/image/images/15.png +0 -0
  89. package/tests/components/image/images/150.png +0 -0
  90. package/tests/components/inputter/__snapshots__/inputter.test.snap.js +357 -0
  91. package/tests/components/inputter/inputter.test.js +427 -0
  92. package/tests/helpers/index.js +30 -0
  93. package/tests/mixins/__snapshots__/card.test.snap.js +35 -0
  94. package/tests/mixins/__snapshots__/detail.test.snap.js +237 -0
  95. package/tests/mixins/__snapshots__/form-element.test.snap.js +137 -0
  96. package/tests/mixins/__snapshots__/mask.test.snap.js +53 -0
  97. package/tests/mixins/__snapshots__/validation.test.snap.js +297 -0
  98. package/tests/mixins/card.test.js +63 -0
  99. package/tests/mixins/detail.test.js +223 -0
  100. package/tests/mixins/form-element.test.js +473 -0
  101. package/tests/mixins/mask.test.js +261 -0
  102. package/tests/mixins/muon-element.test.js +52 -0
  103. package/tests/mixins/validation.test.js +423 -0
  104. package/tests/runner/commands.mjs +19 -0
  105. package/tests/scripts/utils/card-component.js +26 -0
  106. package/tests/scripts/utils/muon.config.test.json +13 -0
  107. package/tests/scripts/utils/single.component.config.json +5 -0
  108. package/tests/scripts/utils/test-runner.mjs +1 -0
  109. package/tests/scripts/utils/utils-test.mjs +284 -0
  110. package/tests/utils/validation.functions.test.js +199 -0
  111. package/tokens/theme/color.json +482 -0
  112. package/tokens/theme/font.json +61 -0
  113. package/tokens/theme/size.json +27 -0
  114. package/tokens/theme/spacer.json +73 -0
  115. package/tokens/utils/formats/reference.js +17 -0
  116. package/tokens/utils/modular-scale.js +33 -0
  117. package/tokens/utils/templates/font-face.css.template +30 -0
  118. package/tokens/utils/transforms/color.js +27 -0
  119. package/tokens/utils/transforms/string.js +6 -0
  120. package/tokens/utils/validation.json +76 -0
  121. package/utils/scroll/index.js +31 -0
  122. package/utils/validation/index.js +205 -0
  123. package/web-test-runner.browserstack.config.mjs +123 -0
  124. package/web-test-runner.config.mjs +44 -0
@@ -0,0 +1 @@
1
+ export { Cta } from './src/cta-component';
@@ -0,0 +1,11 @@
1
+ {
2
+ "cta": {
3
+ "config": {
4
+ "type": {
5
+ "description": "Default value for `type` property which renders the template.",
6
+ "value": "standard",
7
+ "type": "string"
8
+ }
9
+ }
10
+ }
11
+ }
@@ -0,0 +1,174 @@
1
+ import { MuonElement, html, classMap, ScopedElementsMixin, literal, staticHTML, ifDefined } from '@muonic/muon';
2
+ import { Icon } from '@muon/components/icon';
3
+ import {
4
+ CTA_CONFIG_TYPE,
5
+ CTA_LOADING_MESSAGE,
6
+ CTA_LOADING_ICON_NAME,
7
+ CTA_ICON_NAME,
8
+ CTA_ICON_POSITION
9
+ } from '@muon/tokens';
10
+ import styles from './cta-styles.css';
11
+
12
+ /**
13
+ * A call-to-action allows users to take action once they are ready for it.
14
+ *
15
+ * @element cta
16
+ */
17
+
18
+ export class Cta extends ScopedElementsMixin(MuonElement) {
19
+
20
+ static get scopedElements() {
21
+ return {
22
+ 'cta-icon': Icon
23
+ };
24
+ }
25
+
26
+ static get properties() {
27
+ return {
28
+ loading: { type: Boolean },
29
+ loadingMessage: { type: String, attribute: 'loading-message' },
30
+ disabled: { type: Boolean },
31
+ icon: { type: String },
32
+ href: { type: String },
33
+ _iconPosition: { type: String, state: true },
34
+ _isButton: { type: Boolean, state: true }
35
+ };
36
+ }
37
+
38
+ static get styles() {
39
+ return styles;
40
+ }
41
+
42
+ constructor() {
43
+ super();
44
+ this.type = CTA_CONFIG_TYPE;
45
+ this.loading = false;
46
+ this.loadingMessage = CTA_LOADING_MESSAGE;
47
+ this.disabled = false;
48
+ this._iconPosition = CTA_ICON_POSITION;
49
+ this.icon = CTA_ICON_NAME;
50
+ }
51
+
52
+ /**
53
+ * Adds icon html.
54
+ *
55
+ * @returns {object} TemplateResult - Icon html.
56
+ * @protected
57
+ */
58
+ get _addIcon() {
59
+ let icon = this.loading ? CTA_LOADING_ICON_NAME : this.icon;
60
+
61
+ if (!icon) {
62
+ return undefined;
63
+ }
64
+
65
+ if (this.loading) {
66
+ icon = CTA_LOADING_ICON_NAME;
67
+ }
68
+
69
+ return html`
70
+ <cta-icon class="icon" name="${icon}"></cta-icon>
71
+ `;
72
+ }
73
+
74
+ /**
75
+ * A method to wrap the cta content with button / a / div.
76
+ *
77
+ * @param {string | HTMLSlotElement} content - Text content or slot element.
78
+ * @returns {object} TemplateResult - Cta shadow html.
79
+ * @protected
80
+ */
81
+ _wrapperElement(content) {
82
+ const parentElement = this.parentElement;
83
+ const parentName = parentElement?.nodeName;
84
+ const isInLink = parentName === 'A';
85
+ const isInBtn = parentName === 'BUTTON';
86
+ const isInNativeForm = parentName === 'FORM';
87
+ const isDisabled = parentElement.getAttribute('disabled') || this.disabled;
88
+ let element = this.href?.length > 0 ? 'a' : 'div';
89
+
90
+ if (
91
+ element !== 'a' &&
92
+ !isInNativeForm &&
93
+ !isInLink &&
94
+ !isInBtn &&
95
+ !isDisabled &&
96
+ !this._isButton
97
+ ) {
98
+ if (!this.getAttribute('role')) {
99
+ this.setAttribute('role', 'button');
100
+ }
101
+
102
+ if (!this.getAttribute('tabindex')) {
103
+ this.setAttribute('tabindex', '0');
104
+ }
105
+ }
106
+
107
+ if (isDisabled) {
108
+ if (!this.getAttribute('aria-disabled')) {
109
+ this.setAttribute('aria-disabled', 'true');
110
+ }
111
+ } else {
112
+ this.removeAttribute('aria-disabled');
113
+ }
114
+
115
+ if (isInNativeForm || this._isButton) {
116
+ element = 'button';
117
+ }
118
+
119
+ if (isInNativeForm || this._isButton || isInBtn) {
120
+ this.removeAttribute('role'); // isButton might be called after the first render of the cta
121
+ this.removeAttribute('tabindex');
122
+ }
123
+
124
+ // eslint-disable-next-line no-nested-ternary
125
+ const tabIndex = isInLink ? -1 : element !== 'div' ? 0 : undefined;
126
+ const classes = {
127
+ cta: true,
128
+ [this.type]: true,
129
+ loading: this.loading,
130
+ disabled: isDisabled
131
+ };
132
+
133
+ // eslint-disable-next-line no-nested-ternary
134
+ const elementTag = element === 'button' ? literal`button` : element === 'a' ? literal`a` : literal`div`;
135
+
136
+ return staticHTML`
137
+ <${elementTag} .href=${element === 'a' && this.href} ?disabled=${element === 'button' && (this.loading || this.disabled)} tabindex="${ifDefined(tabIndex)}" aria-label="${this.textContent}" class=${classMap(classes)}>
138
+ ${content}
139
+ </${elementTag}>
140
+ `;
141
+ }
142
+
143
+ get standardTemplate() {
144
+ const isLoading = this.loading;
145
+ const iconAdd = this._addIcon;
146
+ const hasIconStart = this._iconPosition === 'start';
147
+ const hasIconEnd = this._iconPosition === 'end';
148
+
149
+ const internal = html`
150
+ ${hasIconStart ? iconAdd : undefined}
151
+ <span class="label-holder">
152
+ ${isLoading ? this.loadingMessage : html`<slot></slot>`}
153
+ </span>
154
+ ${hasIconEnd ? iconAdd : undefined}
155
+ `;
156
+
157
+ return html`
158
+ ${isLoading ? html`<span role="alert" aria-live="assertive" class="sr-only">${this.loadingMessage}</span>` : ``}
159
+ ${this._wrapperElement(internal)}
160
+ `;
161
+ }
162
+
163
+ get submitTemplate() {
164
+ this.setAttribute('type', 'submit');
165
+
166
+ return this.standardTemplate;
167
+ }
168
+
169
+ get resetTemplate() {
170
+ this.setAttribute('type', 'reset');
171
+
172
+ return this.standardTemplate;
173
+ }
174
+ }
@@ -0,0 +1,105 @@
1
+ @import "@muonic/muon/css/default.css";
2
+
3
+ :host {
4
+ display: inline-block;
5
+ user-select: none;
6
+ font-family: $CTA_FONT_FAMILY;
7
+
8
+ /**
9
+ * Styles specifically for the `<a>` element.
10
+ * Retain the order `:link`, `:visited`, `:hover`, `:active`
11
+ */
12
+ & a {
13
+ &:link {
14
+ text-decoration: none;
15
+ }
16
+ }
17
+
18
+ /**
19
+ * Styles specifically for the `<button>` element.
20
+ * The `<button>` element does not inherit font-family, font-size, font-weight or line-height.
21
+ */
22
+ & button {
23
+ font-family: inherit;
24
+ font-size: inherit;
25
+ font-weight: inherit;
26
+ line-height: inherit;
27
+ }
28
+
29
+ & .cta {
30
+ display: flex;
31
+ align-items: center;
32
+ column-gap: $CTA_GAP;
33
+ padding-block-start: $CTA_PADDING_BLOCK;
34
+ padding-block-end: $CTA_PADDING_BLOCK;
35
+ padding-inline-start: $CTA_PADDING_INLINE;
36
+ padding-inline-end: $CTA_PADDING_INLINE;
37
+ background-color: $CTA_BACKGROUND_COLOR;
38
+ color: $CTA_COLOR;
39
+ border-color: $CTA_BORDER_COLOR;
40
+ border-width: 2px;
41
+ border-style: solid;
42
+ border-radius: 10px;
43
+
44
+ &:hover {
45
+ background-color: $CTA_HOVER_BACKGROUND_COLOR;
46
+ border-color: $CTA_HOVER_BORDER_COLOR;
47
+ text-decoration: underline;
48
+ }
49
+
50
+ & :focus:not(:focus-visible) {
51
+ /*
52
+ https://matthiasott.com/notes/focus-visible-is-here and
53
+ https://www.tpgi.com/focus-visible-and-backwards-compatibility/
54
+ */
55
+ outline-style: none;
56
+ }
57
+
58
+ &:focus-visible {
59
+ outline-color: $CTA_FOCUS_OUTLINE_COLOR;
60
+ outline-style: solid;
61
+ outline-width: 3px;
62
+ outline-offset: 0;
63
+ text-decoration: underline;
64
+ }
65
+
66
+ &:active {
67
+ background-color: $CTA_ACTIVE_BACKGROUND_COLOR;
68
+ border-color: $CTA_ACTIVE_BORDER_COLOR;
69
+ }
70
+
71
+ &[disabled],
72
+ &.disabled {
73
+ background-color: $CTA_DISABLED_BACKGROUND_COLOR;
74
+ border-color: $CTA_DISABLED_BORDER_COLOR;
75
+ pointer-events: none;
76
+ }
77
+
78
+ &.loading {
79
+ background-color: $CTA_LOADING_BACKGROUND_COLOR;
80
+ border-color: $CTA_LOADING_BORDER_COLOR;
81
+ pointer-events: none;
82
+ }
83
+
84
+ & .label-holder {
85
+ min-inline-size: 10em;
86
+ max-inline-size: 32em;
87
+ }
88
+
89
+ & .icon {
90
+ width: $CTA_ICON_SIZE;
91
+ height: $CTA_ICON_SIZE;
92
+ flex-shrink: 0;
93
+ }
94
+ }
95
+ }
96
+
97
+ /* TODO: move these `[disabled]` and `[loading]` styles to default.css */
98
+
99
+ /* stylelint-disable no-descending-specificity */
100
+ :host([disabled]),
101
+ :host([loading]) {
102
+ cursor: auto;
103
+ pointer-events: none;
104
+ }
105
+ /* stylelint-enable no-descending-specificity */
@@ -0,0 +1,132 @@
1
+ {
2
+ "cta": {
3
+ "color": {
4
+ "description": "Text color. Defaults to the lightest theme color.",
5
+ "value": "{ theme.color.lightest.value }"
6
+ },
7
+ "background": {
8
+ "color": {
9
+ "description": "Background color. Defaults to the primary theme color.",
10
+ "value": "{ theme.color.primary.value }"
11
+ }
12
+ },
13
+ "gap": {
14
+ "description": "Space between the text and the icon.",
15
+ "value": "{ theme.spacer.md.value }"
16
+ },
17
+ "padding": {
18
+ "block": {
19
+ "description": "Padding space above and below. Equal values in the block axis.",
20
+ "value": "{ theme.spacer.sm.value }"
21
+ },
22
+ "inline": {
23
+ "description": "Padding space left and right. Equal values in the inline axis.",
24
+ "value": "{ theme.spacer.md.value }"
25
+ }
26
+ },
27
+ "border": {
28
+ "color": {
29
+ "description": "Border color. Inherits the background color.",
30
+ "value": "{ cta.background.color.value }"
31
+ }
32
+ },
33
+ "loading": {
34
+ "message": {
35
+ "description": "Value for the `loading` attribute. Default is `Loading...`.",
36
+ "value": "Loading...",
37
+ "type": "string"
38
+ },
39
+ "icon": {
40
+ "name": {
41
+ "description": "Name for the icon displayed during the `loading` state.",
42
+ "value": "spinner",
43
+ "type": "string"
44
+ }
45
+ },
46
+ "background": {
47
+ "color": {
48
+ "description": "Background color during the `loading` state.",
49
+ "value": "{ cta.background.color.value }"
50
+ }
51
+ },
52
+ "border": {
53
+ "color": {
54
+ "description": "Border color during the `loading` state.",
55
+ "value": "{ cta.loading.background.color.value }"
56
+ }
57
+ }
58
+ },
59
+ "icon": {
60
+ "name": {
61
+ "description": "Icon to indicate progress.",
62
+ "value": "arrow-right",
63
+ "type": "string"
64
+ },
65
+ "position": {
66
+ "description": "Position of the icon. Valid values: `start`, `end`.",
67
+ "value": "end",
68
+ "type": "string"
69
+ },
70
+ "size": {
71
+ "description": "Size of the icon.",
72
+ "value": "{ theme.size.md.value }"
73
+ }
74
+ },
75
+ "font": {
76
+ "family": {
77
+ "description": "Font family which defaults to sans-serif.",
78
+ "value": "{ theme.font.family.default.value }"
79
+ }
80
+ },
81
+ "hover": {
82
+ "background": {
83
+ "color": {
84
+ "description": "Background color during the `hover` state.",
85
+ "value": "{ theme.color.primary.value }"
86
+ }
87
+ },
88
+ "border": {
89
+ "color": {
90
+ "description": "Border color during the `hover` state.",
91
+ "value": "{ cta.hover.background.color.value }"
92
+ }
93
+ }
94
+ },
95
+ "focus": {
96
+ "outline": {
97
+ "color": {
98
+ "description": "Outline color during the `focus` state.",
99
+ "value": "{ theme.color.focus.value }"
100
+ }
101
+ }
102
+ },
103
+ "active": {
104
+ "background": {
105
+ "color": {
106
+ "description": "Background color during the `active` state.",
107
+ "value": "{ theme.color.primary.value }"
108
+ }
109
+ },
110
+ "border": {
111
+ "color": {
112
+ "description": "Border color during the `active` state.",
113
+ "value": "{ cta.active.background.color.value }"
114
+ }
115
+ }
116
+ },
117
+ "disabled": {
118
+ "background": {
119
+ "color": {
120
+ "description": "Background color for the `disabled` state.",
121
+ "value": "{ theme.color.disabled.value }"
122
+ }
123
+ },
124
+ "border": {
125
+ "color": {
126
+ "description": "Border color for the `disabled` state.",
127
+ "value": "{ cta.disabled.background.color.value }"
128
+ }
129
+ }
130
+ }
131
+ }
132
+ }
@@ -0,0 +1,99 @@
1
+ import { Cta } from '@muonic/muon/components/cta';
2
+ import setup from '@muonic/muon/storybook/stories';
3
+ import { staticHTML } from '@muonic/muon';
4
+
5
+ const details = setup('cta', Cta);
6
+ const tag = details.getTagEl();
7
+
8
+ export default {
9
+ ...details.defaultValues,
10
+ parameters: {
11
+ controls: {
12
+ exclude: ['standardTemplate', 'submitTemplate', 'resetTemplate', 'loading-message']
13
+ }
14
+ }
15
+ };
16
+
17
+ const StandardTemplate = (args) => staticHTML`${details.template(args, (args) => args.text)}`;
18
+ const ButtonTemplate = (args) => {
19
+ const dArgs = details.dynamicArgs(args);
20
+
21
+ return staticHTML`<${tag} ${dArgs} ._isButton=${true}>${args.text}</${tag}>`;
22
+ };
23
+
24
+ const FormTemplate = (args) => staticHTML`<form>${StandardTemplate(args)}</form>`;
25
+ const WithinLinkTemplate = (args) => staticHTML`<a href="${args.link}">${StandardTemplate(args)}</a>`;
26
+ const WithinButtonTemplate = (args) => staticHTML`<button>${StandardTemplate(args)}</button>`;
27
+ const WithinDisabledButtonTemplate = (args) => staticHTML`<button disabled>${StandardTemplate(args)}</button>`;
28
+
29
+ export const Standard = StandardTemplate.bind({});
30
+ Standard.args = { text: 'Highpoint' };
31
+
32
+ export const Disabled = StandardTemplate.bind({});
33
+ Disabled.args = { text: 'Highpoint', disabled: true };
34
+
35
+ export const Hidden = StandardTemplate.bind({});
36
+ Hidden.args = { text: 'Highpoint', hidden: true };
37
+
38
+ export const Loading = StandardTemplate.bind({});
39
+ Loading.args = { text: 'Highpoint', loading: true };
40
+
41
+ export const StandardLink = StandardTemplate.bind({});
42
+ StandardLink.storyName = 'Standard [link]';
43
+ StandardLink.args = { text: 'Highpoint', href: '#!' };
44
+
45
+ export const DisabledLink = StandardTemplate.bind({});
46
+ DisabledLink.storyName = 'Disabled [link]';
47
+ DisabledLink.args = { text: 'Highpoint', disabled: true, href: '#!' };
48
+
49
+ export const LoadingLink = StandardTemplate.bind({});
50
+ LoadingLink.storyName = 'Loading [link]';
51
+ LoadingLink.args = { text: 'Highpoint', loading: true, href: '#!' };
52
+
53
+ export const StandardButton = ButtonTemplate.bind({});
54
+ StandardButton.storyName = 'Standard [button]';
55
+ StandardButton.args = { text: 'Highpoint' };
56
+
57
+ export const DisabledButton = ButtonTemplate.bind({});
58
+ DisabledButton.storyName = 'Disabled [button]';
59
+ DisabledButton.args = { text: 'Highpoint', disabled: true };
60
+
61
+ export const LoadingButton = ButtonTemplate.bind({});
62
+ LoadingButton.storyName = 'Loading [button]';
63
+ LoadingButton.args = { text: 'Highpoint', loading: true };
64
+
65
+ export const StandardForm = FormTemplate.bind({});
66
+ StandardForm.storyName = 'Standard [within form]';
67
+ StandardForm.args = { text: 'Highpoint' };
68
+
69
+ export const DisabledForm = FormTemplate.bind({});
70
+ DisabledForm.storyName = 'Disabled [within form]';
71
+ DisabledForm.args = { text: 'Highpoint', disabled: true };
72
+
73
+ export const LoadingForm = FormTemplate.bind({});
74
+ LoadingForm.storyName = 'Loading [within form]';
75
+ LoadingForm.args = { text: 'Highpoint', loading: true };
76
+
77
+ export const StandardWithinLink = WithinLinkTemplate.bind({});
78
+ StandardWithinLink.storyName = 'Standard [within link]';
79
+ StandardWithinLink.args = { text: 'Highpoint', link: '#!' };
80
+
81
+ export const DisabledWithinLink = WithinLinkTemplate.bind({});
82
+ DisabledWithinLink.storyName = 'Disabled [within link]';
83
+ DisabledWithinLink.args = { text: 'Highpoint', disabled: true, link: '#!' };
84
+
85
+ export const LoadingWithinLink = WithinLinkTemplate.bind({});
86
+ LoadingWithinLink.storyName = 'Loading [within link]';
87
+ LoadingWithinLink.args = { text: 'Highpoint', loading: true, link: '#!' };
88
+
89
+ export const StandardWithinButton = WithinButtonTemplate.bind({});
90
+ StandardWithinButton.storyName = 'Standard [within button]';
91
+ StandardWithinButton.args = { text: 'Highpoint', link: '#!' };
92
+
93
+ export const DisabledWithinButton = WithinDisabledButtonTemplate.bind({});
94
+ DisabledWithinButton.storyName = 'Disabled [within button]';
95
+ DisabledWithinButton.args = { text: 'Highpoint', disabled: true, link: '#!' };
96
+
97
+ export const LoadingWithinButton = WithinButtonTemplate.bind({});
98
+ LoadingWithinButton.storyName = 'Loading [within button]';
99
+ LoadingWithinButton.args = { text: 'Highpoint', loading: true, link: '#!' };
@@ -0,0 +1 @@
1
+ export { Detail } from './src/detail-component.js';
@@ -0,0 +1,11 @@
1
+ {
2
+ "detail": {
3
+ "config": {
4
+ "type": {
5
+ "description": "Default value for `type` property which renders the template.",
6
+ "value": "standard",
7
+ "type": "string"
8
+ }
9
+ }
10
+ }
11
+ }
@@ -0,0 +1,102 @@
1
+ {
2
+ "detail": {
3
+ "toggle": {
4
+ "open": {
5
+ "description": "Icon to indicate the open action.",
6
+ "value": "chevron-circle-down"
7
+ },
8
+ "close": {
9
+ "description": "Icon to indicate the close action.",
10
+ "value": "chevron-circle-up"
11
+ },
12
+ "position": {
13
+ "description": "Position of the toggle icon. Valid values: `start`, `end`.",
14
+ "value": "end"
15
+ },
16
+ "icon": {
17
+ "size": {
18
+ "description": "Size of the toggle icon.",
19
+ "value": "{ theme.size.lg.value }"
20
+ }
21
+ }
22
+ },
23
+ "heading": {
24
+ "color": {
25
+ "description": "Text color for the heading.",
26
+ "value": "{ theme.color.neutral.dark.200.value }"
27
+ },
28
+ "background": {
29
+ "color": {
30
+ "description": "Background color for the heading. Defaults to the base background color.",
31
+ "value": "{ theme.color.base.background.value }"
32
+ }
33
+ },
34
+ "gap": {
35
+ "description": "Gap between the icon and the heading.",
36
+ "value": "{ theme.spacer.md.value }"
37
+ },
38
+ "padding": {
39
+ "block": {
40
+ "description": "Padding space above and below the heading. Equal values in the block axis.",
41
+ "value": "{ theme.spacer.sm.value }"
42
+ },
43
+ "inline": {
44
+ "description": "Padding space left and right of the heading. Equal values in the inline axis.",
45
+ "value": "{ theme.spacer.md.value }"
46
+ }
47
+ },
48
+ "hover": {
49
+ "color": {
50
+ "description": "Text color for the heading in `hover` state.",
51
+ "value": "{ theme.color.darkest.value }"
52
+ },
53
+ "background": {
54
+ "color": {
55
+ "description": "Background color for the heading in `hover` state. Defaults to the heading background color.",
56
+ "value": "{ detail.heading.background.color.value }"
57
+ }
58
+ }
59
+ },
60
+ "focus": {
61
+ "color": {
62
+ "description": "Text color for the heading in `focus` state.",
63
+ "value": "{ detail.heading.hover.color.value }"
64
+ },
65
+ "background": {
66
+ "color": {
67
+ "description": "Background color for the heading in `focus` state. Defaults to the heading background color.",
68
+ "value": "{ detail.heading.background.color.value }"
69
+ }
70
+ },
71
+ "outline": {
72
+ "color": {
73
+ "description": "Color of the keyboard focus outline. Defaults to the focus color.",
74
+ "value": "{ theme.color.focus.value }"
75
+ }
76
+ }
77
+ }
78
+ },
79
+ "content": {
80
+ "color": {
81
+ "description": "Text color for the content.",
82
+ "value": "{ detail.heading.color.value }"
83
+ },
84
+ "padding": {
85
+ "block": {
86
+ "description": "Padding space above and below the content. Equal values in the block axis.",
87
+ "value": "{ theme.spacer.sm.value }"
88
+ },
89
+ "inline": {
90
+ "description": "Padding space left and right of the content. Equal values in the inline axis.",
91
+ "value": "{ theme.spacer.md.value }"
92
+ }
93
+ },
94
+ "icon": {
95
+ "spacer": {
96
+ "description": "Space at the start of the content if an icon exists at the start of the heading.",
97
+ "value": "calc({ detail.heading.padding.inline.value } + { detail.toggle.icon.size.value } + { detail.heading.gap.value })"
98
+ }
99
+ }
100
+ }
101
+ }
102
+ }
@@ -0,0 +1,27 @@
1
+ import { MuonElement, css, unsafeCSS } from '@muonic/muon';
2
+ import { DetailMixin } from '@muon/mixins/detail-mixin';
3
+ import styles from './detail-styles.css';
4
+ import {
5
+ DETAIL_TOGGLE_OPEN,
6
+ DETAIL_TOGGLE_CLOSE,
7
+ DETAIL_TOGGLE_POSITION
8
+ } from '@muon/tokens';
9
+
10
+ /**
11
+ * A component to show and hide content related to a heading.
12
+ *
13
+ * @element detail
14
+ */
15
+ export class Detail extends DetailMixin(MuonElement) {
16
+
17
+ constructor() {
18
+ super();
19
+ this._toggleOpen = DETAIL_TOGGLE_OPEN;
20
+ this._toggleClose = DETAIL_TOGGLE_CLOSE;
21
+ this._togglePosition = DETAIL_TOGGLE_POSITION;
22
+ }
23
+
24
+ static get styles() {
25
+ return css`${unsafeCSS(styles)}`;
26
+ }
27
+ }