@haiilo/catalyst 0.6.0 → 0.7.2

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 (164) hide show
  1. package/dist/catalyst/catalyst.esm.js +1 -1
  2. package/dist/catalyst/catalyst.esm.js.map +1 -1
  3. package/dist/catalyst/p-12486027.js.map +1 -1
  4. package/dist/catalyst/p-12b96af6.js +2 -0
  5. package/dist/catalyst/p-12b96af6.js.map +1 -0
  6. package/dist/catalyst/p-4254363e.entry.js +2 -0
  7. package/dist/catalyst/p-4254363e.entry.js.map +1 -0
  8. package/dist/catalyst/p-5616e2cd.js +2 -0
  9. package/dist/catalyst/p-5616e2cd.js.map +1 -0
  10. package/dist/catalyst/p-dda85567.entry.js +10 -0
  11. package/dist/catalyst/p-dda85567.entry.js.map +1 -0
  12. package/dist/catalyst/scss/_mixins.scss +9 -0
  13. package/dist/catalyst/scss/_variables.scss +64 -0
  14. package/dist/catalyst/scss/_variables.tokens.scss +84 -0
  15. package/dist/catalyst/scss/core/_base.scss +12 -0
  16. package/dist/catalyst/scss/core/_nav.scss +23 -0
  17. package/dist/catalyst/scss/core/_typography.scss +237 -0
  18. package/dist/catalyst/scss/fonts/_fonts.mixins.azeret.scss +14 -0
  19. package/dist/catalyst/scss/fonts/_fonts.mixins.dm.scss +53 -0
  20. package/dist/catalyst/scss/fonts/_fonts.mixins.lato.scss +185 -0
  21. package/dist/catalyst/scss/fonts/_fonts.mixins.scss +3 -0
  22. package/dist/catalyst/scss/fonts/_fonts.scss +13 -0
  23. package/dist/catalyst/scss/index.scss +32 -0
  24. package/dist/catalyst/scss/utils/_color.scss +52 -0
  25. package/dist/catalyst/scss/utils/_disabled.mixins.scss +7 -0
  26. package/dist/catalyst/scss/utils/_display.scss +20 -0
  27. package/dist/catalyst/scss/utils/_elevation.mixins.scss +10 -0
  28. package/dist/catalyst/scss/utils/_elevation.scss +19 -0
  29. package/dist/catalyst/scss/utils/_layout.scss +78 -0
  30. package/dist/catalyst/scss/utils/_media.mixins.scss +37 -0
  31. package/dist/catalyst/scss/utils/_ratio.mixins.scss +12 -0
  32. package/dist/catalyst/scss/utils/_ratio.scss +20 -0
  33. package/dist/catalyst/scss/utils/_sizing.mixins.scss +15 -0
  34. package/dist/catalyst/scss/utils/_sizing.scss +16 -0
  35. package/dist/catalyst/scss/utils/_spacing.mixins.scss +5 -0
  36. package/dist/catalyst/scss/utils/_spacing.scss +49 -0
  37. package/dist/catalyst/scss/utils/_toast.scss +77 -0
  38. package/dist/catalyst/scss/utils/_typography.mixins.scss +102 -0
  39. package/dist/catalyst/scss/utils/_typography.scss +34 -0
  40. package/dist/catalyst/scss/utils/_visibility.mixins.scss +29 -0
  41. package/dist/catalyst/scss/utils/_visibility.scss +13 -0
  42. package/dist/cjs/app-globals-aa29ad72.js.map +1 -1
  43. package/dist/cjs/{cat-alert_16.cjs.entry.js → cat-alert_18.cjs.entry.js} +174 -44
  44. package/dist/cjs/cat-alert_18.cjs.entry.js.map +1 -0
  45. package/dist/cjs/cat-form-hint-93a6936b.js +22 -0
  46. package/dist/cjs/cat-form-hint-93a6936b.js.map +1 -0
  47. package/dist/cjs/cat-textarea.cjs.entry.js +13 -12
  48. package/dist/cjs/cat-textarea.cjs.entry.js.map +1 -1
  49. package/dist/cjs/catalyst.cjs.js +2 -2
  50. package/dist/cjs/{index-5d72f0e4.js → index-499bad41.js} +44 -1
  51. package/dist/cjs/index-499bad41.js.map +1 -0
  52. package/dist/cjs/loader.cjs.js +2 -2
  53. package/dist/collection/collection-manifest.json +2 -0
  54. package/dist/collection/components/cat-checkbox/cat-checkbox.css +14 -0
  55. package/dist/collection/components/cat-checkbox/cat-checkbox.js +44 -11
  56. package/dist/collection/components/cat-checkbox/cat-checkbox.js.map +1 -1
  57. package/dist/collection/components/cat-form-hint/cat-form-hint.js +16 -0
  58. package/dist/collection/components/cat-form-hint/cat-form-hint.js.map +1 -0
  59. package/dist/collection/components/cat-icon/cat-icon.css +4 -1
  60. package/dist/collection/components/cat-input/cat-input.css +12 -6
  61. package/dist/collection/components/cat-input/cat-input.js +24 -25
  62. package/dist/collection/components/cat-input/cat-input.js.map +1 -1
  63. package/dist/collection/components/cat-radio/cat-radio.css +14 -0
  64. package/dist/collection/components/cat-radio/cat-radio.js +41 -8
  65. package/dist/collection/components/cat-radio/cat-radio.js.map +1 -1
  66. package/dist/collection/components/cat-tab/cat-tab.css +12 -0
  67. package/dist/collection/components/cat-tab/cat-tab.js +203 -0
  68. package/dist/collection/components/cat-tab/cat-tab.js.map +1 -0
  69. package/dist/collection/components/cat-tabs/cat-tabs.css +33 -0
  70. package/dist/collection/components/cat-tabs/cat-tabs.js +122 -0
  71. package/dist/collection/components/cat-tabs/cat-tabs.js.map +1 -0
  72. package/dist/collection/components/cat-textarea/cat-textarea.css +12 -6
  73. package/dist/collection/components/cat-textarea/cat-textarea.js +24 -18
  74. package/dist/collection/components/cat-textarea/cat-textarea.js.map +1 -1
  75. package/dist/collection/components/cat-toggle/cat-toggle.css +14 -0
  76. package/dist/collection/components/cat-toggle/cat-toggle.js +40 -7
  77. package/dist/collection/components/cat-toggle/cat-toggle.js.map +1 -1
  78. package/dist/collection/components/cat-tooltip/cat-tooltip.js +13 -8
  79. package/dist/collection/components/cat-tooltip/cat-tooltip.js.map +1 -1
  80. package/dist/collection/scss/_mixins.scss +9 -0
  81. package/dist/collection/scss/_variables.scss +64 -0
  82. package/dist/collection/scss/_variables.tokens.scss +84 -0
  83. package/dist/collection/scss/core/_base.scss +12 -0
  84. package/dist/collection/scss/core/_nav.scss +23 -0
  85. package/dist/collection/scss/core/_typography.scss +237 -0
  86. package/dist/collection/scss/fonts/_fonts.mixins.azeret.scss +14 -0
  87. package/dist/collection/scss/fonts/_fonts.mixins.dm.scss +53 -0
  88. package/dist/collection/scss/fonts/_fonts.mixins.lato.scss +185 -0
  89. package/dist/collection/scss/fonts/_fonts.mixins.scss +3 -0
  90. package/dist/collection/scss/fonts/_fonts.scss +13 -0
  91. package/dist/collection/scss/index.scss +32 -0
  92. package/dist/collection/scss/utils/_color.scss +52 -0
  93. package/dist/collection/scss/utils/_disabled.mixins.scss +7 -0
  94. package/dist/collection/scss/utils/_display.scss +20 -0
  95. package/dist/collection/scss/utils/_elevation.mixins.scss +10 -0
  96. package/dist/collection/scss/utils/_elevation.scss +19 -0
  97. package/dist/collection/scss/utils/_layout.scss +78 -0
  98. package/dist/collection/scss/utils/_media.mixins.scss +37 -0
  99. package/dist/collection/scss/utils/_ratio.mixins.scss +12 -0
  100. package/dist/collection/scss/utils/_ratio.scss +20 -0
  101. package/dist/collection/scss/utils/_sizing.mixins.scss +15 -0
  102. package/dist/collection/scss/utils/_sizing.scss +16 -0
  103. package/dist/collection/scss/utils/_spacing.mixins.scss +5 -0
  104. package/dist/collection/scss/utils/_spacing.scss +49 -0
  105. package/dist/collection/scss/utils/_toast.scss +77 -0
  106. package/dist/collection/scss/utils/_typography.mixins.scss +102 -0
  107. package/dist/collection/scss/utils/_typography.scss +34 -0
  108. package/dist/collection/scss/utils/_visibility.mixins.scss +29 -0
  109. package/dist/collection/scss/utils/_visibility.scss +13 -0
  110. package/dist/components/cat-checkbox.js +16 -5
  111. package/dist/components/cat-checkbox.js.map +1 -1
  112. package/dist/components/cat-form-hint.js +20 -0
  113. package/dist/components/cat-form-hint.js.map +1 -0
  114. package/dist/components/cat-icon2.js +1 -1
  115. package/dist/components/cat-icon2.js.map +1 -1
  116. package/dist/components/cat-input.js +16 -18
  117. package/dist/components/cat-input.js.map +1 -1
  118. package/dist/components/cat-radio.js +16 -5
  119. package/dist/components/cat-radio.js.map +1 -1
  120. package/dist/components/cat-tab.d.ts +11 -0
  121. package/dist/components/cat-tab.js +70 -0
  122. package/dist/components/cat-tab.js.map +1 -0
  123. package/dist/components/cat-tabs.d.ts +11 -0
  124. package/dist/components/cat-tabs.js +107 -0
  125. package/dist/components/cat-tabs.js.map +1 -0
  126. package/dist/components/cat-textarea.js +14 -12
  127. package/dist/components/cat-textarea.js.map +1 -1
  128. package/dist/components/cat-toggle.js +16 -5
  129. package/dist/components/cat-toggle.js.map +1 -1
  130. package/dist/components/cat-tooltip.js +13 -8
  131. package/dist/components/cat-tooltip.js.map +1 -1
  132. package/dist/components/index.js.map +1 -1
  133. package/dist/esm/app-globals-cf55f7f5.js.map +1 -1
  134. package/dist/esm/{cat-alert_16.entry.js → cat-alert_18.entry.js} +173 -45
  135. package/dist/esm/cat-alert_18.entry.js.map +1 -0
  136. package/dist/esm/cat-form-hint-dc443c7c.js +20 -0
  137. package/dist/esm/cat-form-hint-dc443c7c.js.map +1 -0
  138. package/dist/esm/cat-textarea.entry.js +13 -12
  139. package/dist/esm/cat-textarea.entry.js.map +1 -1
  140. package/dist/esm/catalyst.js +2 -2
  141. package/dist/esm/{index-fd12be19.js → index-039e6f5f.js} +44 -2
  142. package/dist/esm/index-039e6f5f.js.map +1 -0
  143. package/dist/esm/loader.js +2 -2
  144. package/dist/types/components/cat-checkbox/cat-checkbox.d.ts +9 -0
  145. package/dist/types/components/cat-form-hint/cat-form-hint.d.ts +19 -0
  146. package/dist/types/components/cat-input/cat-input.d.ts +7 -5
  147. package/dist/types/components/cat-radio/cat-radio.d.ts +9 -0
  148. package/dist/types/components/cat-tab/cat-tab.d.ts +43 -0
  149. package/dist/types/components/cat-tabs/cat-tabs.d.ts +25 -0
  150. package/dist/types/components/cat-textarea/cat-textarea.d.ts +7 -2
  151. package/dist/types/components/cat-toggle/cat-toggle.d.ts +9 -0
  152. package/dist/types/components/cat-tooltip/cat-tooltip.d.ts +1 -0
  153. package/dist/types/components.d.ts +134 -8
  154. package/package.json +2 -2
  155. package/dist/catalyst/p-6a5f0d4a.entry.js +0 -10
  156. package/dist/catalyst/p-6a5f0d4a.entry.js.map +0 -1
  157. package/dist/catalyst/p-a8629c54.entry.js +0 -2
  158. package/dist/catalyst/p-a8629c54.entry.js.map +0 -1
  159. package/dist/catalyst/p-bfc656ca.js +0 -2
  160. package/dist/catalyst/p-bfc656ca.js.map +0 -1
  161. package/dist/cjs/cat-alert_16.cjs.entry.js.map +0 -1
  162. package/dist/cjs/index-5d72f0e4.js.map +0 -1
  163. package/dist/esm/cat-alert_16.entry.js.map +0 -1
  164. package/dist/esm/index-fd12be19.js.map +0 -1
@@ -1,16 +1,20 @@
1
- import { Component, Event, h, Prop, Method } from '@stencil/core';
1
+ import { Component, Element, Event, h, Host, Method, Prop, State } from '@stencil/core';
2
2
  import log from 'loglevel';
3
+ import { CatFormHint } from '../cat-form-hint/cat-form-hint';
3
4
  let nextUniqueId = 0;
4
5
  /**
5
6
  * Toggles are graphical interface switches that give user control over a
6
7
  * feature or option that can be turned on or off.
7
8
  *
9
+ * @slot hint - Optional hint element to be displayed with the toggle.
10
+ * @slot label - The slotted label. If both the label property and the label slot are present, only the label slot will be displayed.
8
11
  * @part toggle - The toggle element.
9
12
  * @part label - The label content.
10
13
  */
11
14
  export class CatToggle {
12
15
  constructor() {
13
16
  this.id = `cat-toggle-${nextUniqueId++}`;
17
+ this.hasSlottedLabel = false;
14
18
  /**
15
19
  * Checked state of the toggle.
16
20
  */
@@ -33,7 +37,8 @@ export class CatToggle {
33
37
  this.required = false;
34
38
  }
35
39
  componentWillRender() {
36
- if (!this.label) {
40
+ this.hasSlottedLabel = !!this.hostElement.querySelector('[slot="label"]');
41
+ if (!this.label && !this.hasSlottedLabel) {
37
42
  log.error('[A11y] Missing ARIA label on toggle', this);
38
43
  }
39
44
  }
@@ -47,12 +52,19 @@ export class CatToggle {
47
52
  this.input.focus(options);
48
53
  }
49
54
  render() {
50
- return (h("label", { htmlFor: this.id, class: { 'is-hidden': this.labelHidden, 'is-disabled': this.disabled } },
51
- h("input", { ref: el => (this.input = el), id: this.id, type: "checkbox", name: this.name, value: this.value, checked: this.checked, required: this.required, disabled: this.disabled, class: "form-check-input", role: "switch", onInput: this.onInput.bind(this), onFocus: this.onFocus.bind(this), onBlur: this.onBlur.bind(this) }),
52
- h("span", { class: "toggle", part: "toggle" }),
53
- h("span", { class: "label", part: "label" }, this.label)));
55
+ return (h(Host, null,
56
+ h("label", { htmlFor: this.id, class: { 'is-hidden': this.labelHidden, 'is-disabled': this.disabled } },
57
+ h("input", { ref: el => (this.input = el), id: this.id, type: "checkbox", name: this.name, value: this.value, checked: this.checked, required: this.required, disabled: this.disabled, class: "form-check-input", role: "switch", onInput: this.onInput.bind(this), onFocus: this.onFocus.bind(this), onBlur: this.onBlur.bind(this) }),
58
+ h("span", { class: "toggle", part: "toggle" }),
59
+ h("span", { class: "label", part: "label" }, (this.hasSlottedLabel && h("slot", { name: "label" })) || this.label)),
60
+ this.hintSection));
61
+ }
62
+ get hintSection() {
63
+ const hasSlottedHint = !!this.hostElement.querySelector('[slot="hint"]');
64
+ return ((this.hint || hasSlottedHint) && (h(CatFormHint, { hint: this.hint, slottedHint: hasSlottedHint && h("slot", { name: "hint" }) })));
54
65
  }
55
66
  onInput(event) {
67
+ this.value = this.input.value;
56
68
  this.catChange.emit(event);
57
69
  }
58
70
  onFocus(event) {
@@ -179,7 +191,7 @@ export class CatToggle {
179
191
  },
180
192
  "value": {
181
193
  "type": "string",
182
- "mutable": false,
194
+ "mutable": true,
183
195
  "complexType": {
184
196
  "original": "string",
185
197
  "resolved": "string | undefined",
@@ -193,8 +205,28 @@ export class CatToggle {
193
205
  },
194
206
  "attribute": "value",
195
207
  "reflect": false
208
+ },
209
+ "hint": {
210
+ "type": "string",
211
+ "mutable": false,
212
+ "complexType": {
213
+ "original": "string | string[]",
214
+ "resolved": "string | string[] | undefined",
215
+ "references": {}
216
+ },
217
+ "required": false,
218
+ "optional": true,
219
+ "docs": {
220
+ "tags": [],
221
+ "text": "Optional hint text(s) to be displayed with the toggle."
222
+ },
223
+ "attribute": "hint",
224
+ "reflect": false
196
225
  }
197
226
  }; }
227
+ static get states() { return {
228
+ "hasSlottedLabel": {}
229
+ }; }
198
230
  static get events() { return [{
199
231
  "method": "catChange",
200
232
  "name": "catChange",
@@ -279,5 +311,6 @@ export class CatToggle {
279
311
  }
280
312
  }
281
313
  }; }
314
+ static get elementRef() { return "hostElement"; }
282
315
  }
283
316
  //# sourceMappingURL=cat-toggle.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"cat-toggle.js","sourceRoot":"","sources":["../../../src/components/cat-toggle/cat-toggle.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAgB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,GAAG,MAAM,UAAU,CAAC;AAE3B,IAAI,YAAY,GAAG,CAAC,CAAC;AAErB;;;;;;GAMG;AAMH,MAAM,OAAO,SAAS;EALtB;IAMmB,OAAE,GAAG,cAAc,YAAY,EAAE,EAAE,CAAC;IAGrD;;OAEG;IACK,YAAO,GAAG,KAAK,CAAC;IAExB;;OAEG;IACK,aAAQ,GAAG,KAAK,CAAC;IAEzB;;OAEG;IACK,UAAK,GAAG,EAAE,CAAC;IAEnB;;OAEG;IACK,gBAAW,GAAG,KAAK,CAAC;IAO5B;;OAEG;IACK,aAAQ,GAAG,KAAK,CAAC;GA4E1B;EAtDC,mBAAmB;IACjB,IAAI,CAAC,IAAI,CAAC,KAAK,EAAE;MACf,GAAG,CAAC,KAAK,CAAC,qCAAqC,EAAE,IAAI,CAAC,CAAC;KACxD;EACH,CAAC;EAED;;;;;KAKG;EAEH,KAAK,CAAC,QAAQ,CAAC,OAAsB;IACnC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;EAC5B,CAAC;EAED,MAAM;IACJ,OAAO,CACL,aAAO,OAAO,EAAE,IAAI,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,WAAW,EAAE,IAAI,CAAC,WAAW,EAAE,aAAa,EAAE,IAAI,CAAC,QAAQ,EAAE;MAC7F,aACE,GAAG,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,IAAI,CAAC,KAAK,GAAG,EAAsB,CAAC,EAChD,EAAE,EAAE,IAAI,CAAC,EAAE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, h, Prop, Method } from '@stencil/core';\nimport log from 'loglevel';\n\nlet nextUniqueId = 0;\n\n/**\n * Toggles are graphical interface switches that give user control over a\n * feature or option that can be turned on or off.\n *\n * @part toggle - The toggle element.\n * @part label - The label content.\n */\n@Component({\n tag: 'cat-toggle',\n styleUrls: ['cat-toggle.scss'],\n shadow: true\n})\nexport class CatToggle {\n private readonly id = `cat-toggle-${nextUniqueId++}`;\n private input!: HTMLInputElement;\n\n /**\n * Checked state of the toggle.\n */\n @Prop() checked = false;\n\n /**\n * Disabled state of the toggle.\n */\n @Prop() disabled = false;\n\n /**\n * The label of the toggle that is visible.\n */\n @Prop() label = '';\n\n /**\n * Visually hide the label, but still show it to assistive technologies like screen readers.\n */\n @Prop() labelHidden = false;\n\n /**\n * The name of the input\n */\n @Prop() name?: string;\n\n /**\n * Required state of the toggle\n */\n @Prop() required = false;\n\n /**\n * The value of the toggle\n */\n @Prop() value?: string;\n\n /**\n * Emitted when the checked status of the toggle is changed.\n */\n @Event() catChange!: EventEmitter;\n\n /**\n * Emitted when the toggle received focus.\n */\n @Event() catFocus!: EventEmitter<FocusEvent>;\n\n /**\n * Emitted when the toggle loses focus.\n */\n @Event() catBlur!: EventEmitter<FocusEvent>;\n\n componentWillRender(): void {\n if (!this.label) {\n log.error('[A11y] Missing ARIA label on toggle', this);\n }\n }\n\n /**\n * Sets focus on the toggle. Use this method instead of `toggle.focus()`.\n *\n * @param options An optional object providing options to control aspects of\n * the focusing process.\n */\n @Method()\n async setFocus(options?: FocusOptions): Promise<void> {\n this.input.focus(options);\n }\n\n render() {\n return (\n <label htmlFor={this.id} class={{ 'is-hidden': this.labelHidden, 'is-disabled': this.disabled }}>\n <input\n ref={el => (this.input = el as HTMLInputElement)}\n id={this.id}\n type=\"checkbox\"\n name={this.name}\n value={this.value}\n checked={this.checked}\n required={this.required}\n disabled={this.disabled}\n class=\"form-check-input\"\n role=\"switch\"\n onInput={this.onInput.bind(this)}\n onFocus={this.onFocus.bind(this)}\n onBlur={this.onBlur.bind(this)}\n />\n <span class=\"toggle\" part=\"toggle\"></span>\n <span class=\"label\" part=\"label\">\n {this.label}\n </span>\n </label>\n );\n }\n\n private onInput(event: Event) {\n this.catChange.emit(event);\n }\n\n private onFocus(event: FocusEvent) {\n this.catFocus.emit(event);\n }\n\n private onBlur(event: FocusEvent) {\n this.catBlur.emit(event);\n }\n}\n"]}
1
+ {"version":3,"file":"cat-toggle.js","sourceRoot":"","sources":["../../../src/components/cat-toggle/cat-toggle.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,KAAK,EAAgB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AACtG,OAAO,GAAG,MAAM,UAAU,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAE7D,IAAI,YAAY,GAAG,CAAC,CAAC;AAErB;;;;;;;;GAQG;AAMH,MAAM,OAAO,SAAS;EALtB;IAMmB,OAAE,GAAG,cAAc,YAAY,EAAE,EAAE,CAAC;IAK5C,oBAAe,GAAG,KAAK,CAAC;IAEjC;;OAEG;IACK,YAAO,GAAG,KAAK,CAAC;IAExB;;OAEG;IACK,aAAQ,GAAG,KAAK,CAAC;IAEzB;;OAEG;IACK,UAAK,GAAG,EAAE,CAAC;IAEnB;;OAEG;IACK,gBAAW,GAAG,KAAK,CAAC;IAO5B;;OAEG;IACK,aAAQ,GAAG,KAAK,CAAC;GA+F1B;EApEC,mBAAmB;IACjB,IAAI,CAAC,eAAe,GAAG,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC;IAC1E,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,CAAC,eAAe,EAAE;MACxC,GAAG,CAAC,KAAK,CAAC,qCAAqC,EAAE,IAAI,CAAC,CAAC;KACxD;EACH,CAAC;EAED;;;;;KAKG;EAEH,K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Aa,CAAC,eAAe,CAAC,CAAC;IACzE,OAAO,CACL,CAAC,IAAI,CAAC,IAAI,IAAI,cAAc,CAAC,IAAI,CAC/B,EAAC,WAAW,IAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,WAAW,EAAE,cAAc,IAAI,YAAM,IAAI,EAAC,MAAM,GAAQ,GAAI,CAC3F,CACF,CAAC;EACJ,CAAC;EAEO,OAAO,CAAC,KAAY;IAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC;IAC9B,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;EAC7B,CAAC;EAEO,OAAO,CAAC,KAAiB;IAC/B,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;EAC5B,CAAC;EAEO,MAAM,CAAC,KAAiB;IAC9B,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;EAC3B,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import { Component, Element, Event, EventEmitter, h, Host, Method, Prop, State } from '@stencil/core';\nimport log from 'loglevel';\nimport { CatFormHint } from '../cat-form-hint/cat-form-hint';\n\nlet nextUniqueId = 0;\n\n/**\n * Toggles are graphical interface switches that give user control over a\n * feature or option that can be turned on or off.\n *\n * @slot hint - Optional hint element to be displayed with the toggle.\n * @slot label - The slotted label. If both the label property and the label slot are present, only the label slot will be displayed.\n * @part toggle - The toggle element.\n * @part label - The label content.\n */\n@Component({\n tag: 'cat-toggle',\n styleUrls: ['cat-toggle.scss'],\n shadow: true\n})\nexport class CatToggle {\n private readonly id = `cat-toggle-${nextUniqueId++}`;\n private input!: HTMLInputElement;\n\n @Element() hostElement!: HTMLElement;\n\n @State() hasSlottedLabel = false;\n\n /**\n * Checked state of the toggle.\n */\n @Prop() checked = false;\n\n /**\n * Disabled state of the toggle.\n */\n @Prop() disabled = false;\n\n /**\n * The label of the toggle that is visible.\n */\n @Prop() label = '';\n\n /**\n * Visually hide the label, but still show it to assistive technologies like screen readers.\n */\n @Prop() labelHidden = false;\n\n /**\n * The name of the input\n */\n @Prop() name?: string;\n\n /**\n * Required state of the toggle\n */\n @Prop() required = false;\n\n /**\n * The value of the toggle\n */\n @Prop({ mutable: true }) value?: string;\n\n /**\n * Optional hint text(s) to be displayed with the toggle.\n */\n @Prop() hint?: string | string[];\n\n /**\n * Emitted when the checked status of the toggle is changed.\n */\n @Event() catChange!: EventEmitter;\n\n /**\n * Emitted when the toggle received focus.\n */\n @Event() catFocus!: EventEmitter<FocusEvent>;\n\n /**\n * Emitted when the toggle loses focus.\n */\n @Event() catBlur!: EventEmitter<FocusEvent>;\n\n componentWillRender(): void {\n this.hasSlottedLabel = !!this.hostElement.querySelector('[slot=\"label\"]');\n if (!this.label && !this.hasSlottedLabel) {\n log.error('[A11y] Missing ARIA label on toggle', this);\n }\n }\n\n /**\n * Sets focus on the toggle. Use this method instead of `toggle.focus()`.\n *\n * @param options An optional object providing options to control aspects of\n * the focusing process.\n */\n @Method()\n async setFocus(options?: FocusOptions): Promise<void> {\n this.input.focus(options);\n }\n\n render() {\n return (\n <Host>\n <label htmlFor={this.id} class={{ 'is-hidden': this.labelHidden, 'is-disabled': this.disabled }}>\n <input\n ref={el => (this.input = el as HTMLInputElement)}\n id={this.id}\n type=\"checkbox\"\n name={this.name}\n value={this.value}\n checked={this.checked}\n required={this.required}\n disabled={this.disabled}\n class=\"form-check-input\"\n role=\"switch\"\n onInput={this.onInput.bind(this)}\n onFocus={this.onFocus.bind(this)}\n onBlur={this.onBlur.bind(this)}\n />\n <span class=\"toggle\" part=\"toggle\"></span>\n <span class=\"label\" part=\"label\">\n {(this.hasSlottedLabel && <slot name=\"label\"></slot>) || this.label}\n </span>\n </label>\n {this.hintSection}\n </Host>\n );\n }\n\n private get hintSection() {\n const hasSlottedHint = !!this.hostElement.querySelector('[slot=\"hint\"]');\n return (\n (this.hint || hasSlottedHint) && (\n <CatFormHint hint={this.hint} slottedHint={hasSlottedHint && <slot name=\"hint\"></slot>} />\n )\n );\n }\n\n private onInput(event: Event) {\n this.value = this.input.value;\n this.catChange.emit(event);\n }\n\n private onFocus(event: FocusEvent) {\n this.catFocus.emit(event);\n }\n\n private onBlur(event: FocusEvent) {\n this.catBlur.emit(event);\n }\n}\n"]}
@@ -45,6 +45,7 @@ export class CatTooltip {
45
45
  autoUpdate(this.trigger, this.tooltip, () => this.update());
46
46
  }
47
47
  if (isTouchScreen) {
48
+ window.addEventListener('touchstart', this.windowTouchStartListener.bind(this));
48
49
  (_b = this.trigger) === null || _b === void 0 ? void 0 : _b.addEventListener('touchstart', this.touchStartListener.bind(this));
49
50
  (_c = this.trigger) === null || _c === void 0 ? void 0 : _c.addEventListener('touchend', this.touchEndListener.bind(this));
50
51
  }
@@ -58,6 +59,7 @@ export class CatTooltip {
58
59
  disconnectedCallback() {
59
60
  var _a, _b, _c, _d, _e, _f;
60
61
  if (isTouchScreen) {
62
+ window.removeEventListener('touchstart', this.windowTouchStartListener.bind(this));
61
63
  (_a = this.trigger) === null || _a === void 0 ? void 0 : _a.removeEventListener('touchstart', this.touchStartListener.bind(this));
62
64
  (_b = this.trigger) === null || _b === void 0 ? void 0 : _b.removeEventListener('touchend', this.touchEndListener.bind(this));
63
65
  }
@@ -95,28 +97,31 @@ export class CatTooltip {
95
97
  showListener() {
96
98
  window.clearTimeout(this.hideTimeout);
97
99
  this.showTimeout = window.setTimeout(() => {
98
- var _a, _b;
99
- (_a = this.trigger) === null || _a === void 0 ? void 0 : _a.focus();
100
- (_b = this.tooltip) === null || _b === void 0 ? void 0 : _b.classList.add('tooltip-show');
100
+ var _a;
101
+ (_a = this.tooltip) === null || _a === void 0 ? void 0 : _a.classList.add('tooltip-show');
101
102
  }, this.showDelay);
102
103
  }
103
104
  hideListener() {
104
105
  window.clearTimeout(this.showTimeout);
105
106
  this.hideTimeout = window.setTimeout(() => {
106
- var _a, _b;
107
- (_a = this.trigger) === null || _a === void 0 ? void 0 : _a.blur();
108
- (_b = this.tooltip) === null || _b === void 0 ? void 0 : _b.classList.remove('tooltip-show');
107
+ var _a;
108
+ (_a = this.tooltip) === null || _a === void 0 ? void 0 : _a.classList.remove('tooltip-show');
109
109
  }, this.hideDelay);
110
110
  }
111
- touchStartListener() {
111
+ touchStartListener(event) {
112
+ event.stopPropagation();
112
113
  this.touchTimeout = window.setTimeout(() => {
113
114
  var _a;
114
115
  (_a = this.tooltip) === null || _a === void 0 ? void 0 : _a.classList.add('tooltip-show');
115
116
  }, this.longTouchDuration);
116
117
  }
117
118
  touchEndListener() {
119
+ if (this.touchTimeout) {
120
+ window.clearTimeout(this.touchTimeout);
121
+ }
122
+ }
123
+ windowTouchStartListener() {
118
124
  var _a;
119
- window.clearTimeout(this.touchTimeout);
120
125
  (_a = this.tooltip) === null || _a === void 0 ? void 0 : _a.classList.remove('tooltip-show');
121
126
  }
122
127
  static get is() { return "cat-tooltip"; }
@@ -1 +1 @@
1
- {"version":3,"file":"cat-tooltip.js","sourceRoot":"","sources":["../../../src/components/cat-tooltip/cat-tooltip.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACjE,OAAO,EAAE,UAAU,EAAE,eAAe,EAAE,IAAI,EAAE,MAAM,EAAa,MAAM,kBAAkB,CAAC;AACxF,OAAO,aAAa,MAAM,6BAA6B,CAAC;AACxD,OAAO,aAAa,MAAM,4BAA4B,CAAC;AAGvD,IAAI,YAAY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AzIuB,iBAAM,GAAG,CAAE,CAAA","sourcesContent":["import { Component, h, Host, Listen, Prop } from '@stencil/core';\nimport { autoUpdate, computePosition, flip, offset, Placement } from '@floating-ui/dom';\nimport isTouchScreen from '../../utils/is-touch-screen';\nimport firstTabbable from '../../utils/first-tabbable';\nimport { FocusableElement } from 'tabbable';\n\nlet nextUniqueId = 0;\n\n@Component({\n tag: 'cat-tooltip',\n styleUrl: 'cat-tooltip.scss',\n shadow: true\n})\nexport class CatTooltip {\n private static readonly OFFSET = 4;\n private readonly id = `cat-tooltip-${nextUniqueId++}`;\n private tooltip?: HTMLElement;\n private triggerElement?: HTMLElement;\n private trigger?: FocusableElement;\n private showTimeout?: number;\n private hideTimeout?: number;\n private touchTimeout?: number;\n\n /**\n * The content of the tooltip.\n */\n @Prop() content = '';\n\n /**\n * Specifies that the tooltip should be disabled. A disabled tooltip is unusable,\n * and invisible. Corresponds with the native HTML disabled attribute.\n */\n @Prop() disabled = false;\n\n /**\n * The placement of the tooltip.\n */\n @Prop() placement: Placement = 'top';\n\n /**\n * The delay time for showing tooltip in ms.\n */\n @Prop() showDelay = 500;\n\n /**\n * The delay time for hiding tooltip in ms.\n */\n @Prop() hideDelay = 0;\n\n /**\n * The duration of tap to show the tooltip.\n */\n @Prop() longTouchDuration = 1000;\n\n @Listen('keydown')\n handleKeyDown({ key }: KeyboardEvent) {\n key === 'Escape' && this.hideListener();\n }\n\n componentDidLoad(): void {\n this.trigger = firstTabbable(this.triggerElement) || this.triggerElement;\n if (!this.isTabbable) {\n this.trigger?.setAttribute('tabindex', '0');\n }\n if (this.trigger && this.tooltip) {\n autoUpdate(this.trigger, this.tooltip, () => this.update());\n }\n\n if (isTouchScreen) {\n this.trigger?.addEventListener('touchstart', this.touchStartListener.bind(this));\n this.trigger?.addEventListener('touchend', this.touchEndListener.bind(this));\n } else {\n this.trigger?.addEventListener('focusin', this.showListener.bind(this));\n this.trigger?.addEventListener('focusout', this.hideListener.bind(this));\n this.trigger?.addEventListener('mouseenter', this.showListener.bind(this));\n this.trigger?.addEventListener('mouseleave', this.hideListener.bind(this));\n }\n }\n\n disconnectedCallback(): void {\n if (isTouchScreen) {\n this.trigger?.removeEventListener('touchstart', this.touchStartListener.bind(this));\n this.trigger?.removeEventListener('touchend', this.touchEndListener.bind(this));\n } else {\n this.trigger?.removeEventListener('mouseenter', this.showListener.bind(this));\n this.trigger?.removeEventListener('mouseleave', this.hideListener.bind(this));\n this.trigger?.removeEventListener('focusin', this.showListener.bind(this));\n this.trigger?.removeEventListener('focusout', this.hideListener.bind(this));\n }\n }\n\n render() {\n return (\n <Host>\n <div ref={el => (this.triggerElement = el)} aria-describedby={this.id} class=\"tooltip-trigger\">\n <slot />\n </div>\n {this.content && !this.disabled && (\n <div ref={el => (this.tooltip = el)} id={this.id} class=\"tooltip\">\n {this.content}\n </div>\n )}\n </Host>\n );\n }\n\n private get isTabbable() {\n return firstTabbable(this.trigger);\n }\n\n private update() {\n if (this.trigger && this.tooltip) {\n computePosition(this.trigger, this.tooltip, {\n placement: this.placement,\n middleware: [offset(CatTooltip.OFFSET), flip()]\n }).then(({ x, y }) => {\n if (this.tooltip) {\n Object.assign(this.tooltip.style, {\n left: `${Math.max(0, x)}px`,\n top: `${y}px`\n });\n }\n });\n }\n }\n\n private showListener() {\n window.clearTimeout(this.hideTimeout);\n this.showTimeout = window.setTimeout(() => {\n this.trigger?.focus();\n this.tooltip?.classList.add('tooltip-show');\n }, this.showDelay);\n }\n\n private hideListener() {\n window.clearTimeout(this.showTimeout);\n this.hideTimeout = window.setTimeout(() => {\n this.trigger?.blur();\n this.tooltip?.classList.remove('tooltip-show');\n }, this.hideDelay);\n }\n\n private touchStartListener() {\n this.touchTimeout = window.setTimeout(() => {\n this.tooltip?.classList.add('tooltip-show');\n }, this.longTouchDuration);\n }\n\n private touchEndListener() {\n window.clearTimeout(this.touchTimeout);\n this.tooltip?.classList.remove('tooltip-show');\n }\n}\n"]}
1
+ {"version":3,"file":"cat-tooltip.js","source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AAC,GAAG,EAAE;;MACzC,MAAA,IAAI,CAAC,OAAO,0CAAE,SAAS,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IAC9C,CAAC,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAC;EAC7B,CAAC;EAEO,gBAAgB;IACtB,IAAI,IAAI,CAAC,YAAY,EAAE;MACrB,MAAM,CAAC,YAAY,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;KACxC;EACH,CAAC;EAEO,wBAAwB;;IAC9B,MAAA,IAAI,CAAC,OAAO,0CAAE,SAAS,CAAC,MAAM,CAAC,cAAc,CAAC,CAAC;EACjD,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA/IuB,iBAAM,GAAG,CAAE,CAAA","sourcesContent":["import { Component, h, Host, Listen, Prop } from '@stencil/core';\nimport { autoUpdate, computePosition, flip, offset, Placement } from '@floating-ui/dom';\nimport isTouchScreen from '../../utils/is-touch-screen';\nimport firstTabbable from '../../utils/first-tabbable';\nimport { FocusableElement } from 'tabbable';\n\nlet nextUniqueId = 0;\n\n@Component({\n tag: 'cat-tooltip',\n styleUrl: 'cat-tooltip.scss',\n shadow: true\n})\nexport class CatTooltip {\n private static readonly OFFSET = 4;\n private readonly id = `cat-tooltip-${nextUniqueId++}`;\n private tooltip?: HTMLElement;\n private triggerElement?: HTMLElement;\n private trigger?: FocusableElement;\n private showTimeout?: number;\n private hideTimeout?: number;\n private touchTimeout?: number;\n\n /**\n * The content of the tooltip.\n */\n @Prop() content = '';\n\n /**\n * Specifies that the tooltip should be disabled. A disabled tooltip is unusable,\n * and invisible. Corresponds with the native HTML disabled attribute.\n */\n @Prop() disabled = false;\n\n /**\n * The placement of the tooltip.\n */\n @Prop() placement: Placement = 'top';\n\n /**\n * The delay time for showing tooltip in ms.\n */\n @Prop() showDelay = 500;\n\n /**\n * The delay time for hiding tooltip in ms.\n */\n @Prop() hideDelay = 0;\n\n /**\n * The duration of tap to show the tooltip.\n */\n @Prop() longTouchDuration = 1000;\n\n @Listen('keydown')\n handleKeyDown({ key }: KeyboardEvent) {\n key === 'Escape' && this.hideListener();\n }\n\n componentDidLoad(): void {\n this.trigger = firstTabbable(this.triggerElement) || this.triggerElement;\n if (!this.isTabbable) {\n this.trigger?.setAttribute('tabindex', '0');\n }\n if (this.trigger && this.tooltip) {\n autoUpdate(this.trigger, this.tooltip, () => this.update());\n }\n\n if (isTouchScreen) {\n window.addEventListener('touchstart', this.windowTouchStartListener.bind(this));\n this.trigger?.addEventListener('touchstart', this.touchStartListener.bind(this));\n this.trigger?.addEventListener('touchend', this.touchEndListener.bind(this));\n } else {\n this.trigger?.addEventListener('focusin', this.showListener.bind(this));\n this.trigger?.addEventListener('focusout', this.hideListener.bind(this));\n this.trigger?.addEventListener('mouseenter', this.showListener.bind(this));\n this.trigger?.addEventListener('mouseleave', this.hideListener.bind(this));\n }\n }\n\n disconnectedCallback(): void {\n if (isTouchScreen) {\n window.removeEventListener('touchstart', this.windowTouchStartListener.bind(this));\n this.trigger?.removeEventListener('touchstart', this.touchStartListener.bind(this));\n this.trigger?.removeEventListener('touchend', this.touchEndListener.bind(this));\n } else {\n this.trigger?.removeEventListener('mouseenter', this.showListener.bind(this));\n this.trigger?.removeEventListener('mouseleave', this.hideListener.bind(this));\n this.trigger?.removeEventListener('focusin', this.showListener.bind(this));\n this.trigger?.removeEventListener('focusout', this.hideListener.bind(this));\n }\n }\n\n render() {\n return (\n <Host>\n <div ref={el => (this.triggerElement = el)} aria-describedby={this.id} class=\"tooltip-trigger\">\n <slot />\n </div>\n {this.content && !this.disabled && (\n <div ref={el => (this.tooltip = el)} id={this.id} class=\"tooltip\">\n {this.content}\n </div>\n )}\n </Host>\n );\n }\n\n private get isTabbable() {\n return firstTabbable(this.trigger);\n }\n\n private update() {\n if (this.trigger && this.tooltip) {\n computePosition(this.trigger, this.tooltip, {\n placement: this.placement,\n middleware: [offset(CatTooltip.OFFSET), flip()]\n }).then(({ x, y }) => {\n if (this.tooltip) {\n Object.assign(this.tooltip.style, {\n left: `${Math.max(0, x)}px`,\n top: `${y}px`\n });\n }\n });\n }\n }\n\n private showListener() {\n window.clearTimeout(this.hideTimeout);\n this.showTimeout = window.setTimeout(() => {\n this.tooltip?.classList.add('tooltip-show');\n }, this.showDelay);\n }\n\n private hideListener() {\n window.clearTimeout(this.showTimeout);\n this.hideTimeout = window.setTimeout(() => {\n this.tooltip?.classList.remove('tooltip-show');\n }, this.hideDelay);\n }\n\n private touchStartListener(event: Event) {\n event.stopPropagation();\n this.touchTimeout = window.setTimeout(() => {\n this.tooltip?.classList.add('tooltip-show');\n }, this.longTouchDuration);\n }\n\n private touchEndListener() {\n if (this.touchTimeout) {\n window.clearTimeout(this.touchTimeout);\n }\n }\n\n private windowTouchStartListener() {\n this.tooltip?.classList.remove('tooltip-show');\n }\n}\n"]}
@@ -0,0 +1,9 @@
1
+ @forward 'fonts/fonts.mixins';
2
+ @forward 'utils/disabled.mixins';
3
+ @forward 'utils/elevation.mixins';
4
+ @forward 'utils/media.mixins';
5
+ @forward 'utils/sizing.mixins';
6
+ @forward 'utils/spacing.mixins';
7
+ @forward 'utils/typography.mixins';
8
+ @forward 'utils/visibility.mixins';
9
+ @forward 'utils/ratio.mixins';
@@ -0,0 +1,64 @@
1
+ @use 'variables.tokens' as *;
2
+ @forward 'variables.tokens';
3
+
4
+ // --------
5
+ // -- Composits
6
+ // --------
7
+
8
+ $cat-head-margin-bottom: cat-token('size.spacing.s');
9
+ $cat-body-margin-bottom: cat-token('size.spacing.m');
10
+ $cat-nav-padding-horizontal: cat-token('size.spacing.m');
11
+
12
+ // --------
13
+ // -- z-indexes
14
+ // --------
15
+
16
+ $cat-menu-z-index: 100;
17
+ $cat-tooltip-z-index: 200;
18
+
19
+ // --------
20
+ // -- Typography
21
+ // --------
22
+
23
+ /* stylelint-disable value-keyword-case */
24
+ $font-fallback-sans-serif: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', 'Noto Sans',
25
+ 'Liberation Sans', Arial, sans-serif, 'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol', 'Noto Color Emoji' !default;
26
+ $font-fallback-monospace: SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New', monospace !default;
27
+ $cat-link-text-decoration: none;
28
+ $cat-link-text-decoration-hover: underline;
29
+ $cat-mark-color: cat-token('color.theme.primary.bg', 0.2);
30
+ /* stylelint-enable value-keyword-case */
31
+
32
+ // --------
33
+ // -- Scrollable
34
+ // --------
35
+
36
+ $cat-scrollable-shadow: 0 0 4px 1px rgba(16, 29, 48, 20%);
37
+ $cat-scrollable-shadow-transition: box-shadow 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
38
+
39
+ // --------
40
+ // -- Elevations
41
+ // --------
42
+
43
+ $cat-elevation-transition: box-shadow 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
44
+ $cat-elevation: (
45
+ 0: none,
46
+ 1: (
47
+ 0 1px 4px 0 rgba(16, 29, 48, 20%)
48
+ ),
49
+ 2: (
50
+ 0 2px 4px -1px rgba(16, 29, 48, 20%),
51
+ 0 4px 5px 0 rgba(16, 29, 48, 26%),
52
+ 0 1px 10px -1px rgba(16, 29, 48, 12%)
53
+ ),
54
+ 3: (
55
+ 0 2px 4px -1px rgba(16, 29, 48, 20%),
56
+ 0 9px 16px -3px rgba(16, 29, 48, 14%),
57
+ 0 10px 20px -8px rgba(16, 29, 48, 12%)
58
+ ),
59
+ 4: (
60
+ 0 2px 4px -1px rgba(16, 29, 48, 5%),
61
+ 0 9px 16px -3px rgba(16, 29, 48, 14%),
62
+ 0 32px 20px -20px rgba(16, 29, 48, 20%)
63
+ )
64
+ );
@@ -0,0 +1,84 @@
1
+ @use 'sass:list';
2
+ @use 'sass:map';
3
+ @use 'sass:meta';
4
+ @use 'sass:color';
5
+ @use 'sass:string';
6
+
7
+ @use '~@haiilo/catalyst-tokens/dist/scss/variables' as *;
8
+ @forward '~@haiilo/catalyst-tokens/dist/scss/variables' show $tokens;
9
+
10
+ // -----
11
+ // -- Split a string using the given separator.
12
+ // -----
13
+ @function -cat-split($string, $separator: ' ') {
14
+ $result: ();
15
+ $index: string.index($string, $separator);
16
+ @while $index != null {
17
+ $item: string.slice($string, 1, $index - 1);
18
+ $result: list.append($result, $item);
19
+ $string: string.slice($string, $index + string.length($separator));
20
+ $index: string.index($string, $separator);
21
+ }
22
+ $result: list.append($result, $string);
23
+ @return $result;
24
+ }
25
+
26
+ // -----
27
+ // -- Join strings using the given separator.
28
+ // -----
29
+ @function -cat-join($strings, $separator: ' ') {
30
+ $result: '';
31
+ @each $string in $strings {
32
+ $result: $result + $separator + $string;
33
+ }
34
+ @return string.slice($result, string.length($separator) + 1);
35
+ }
36
+
37
+ // -----
38
+ // -- Deep map.get using a dot-separated key.
39
+ // -----
40
+ @function -cat-get($map, $key) {
41
+ $keys: -cat-split('' + $key, '.');
42
+ @each $key in $keys {
43
+ @if $map {
44
+ $map: map.get($map, $key);
45
+ }
46
+ }
47
+ @return $map;
48
+ }
49
+
50
+ @function cat-token-wrap($value, $alpha: 1) {
51
+ @if meta.type-of($value) == 'string' {
52
+ @if $alpha < 1 {
53
+ @return rgba($value, $alpha);
54
+ } @else {
55
+ @return rgb($value);
56
+ }
57
+ } @else if meta.type-of($value) == 'list' {
58
+ @return color.adjust(
59
+ #00000000,
60
+ $red: list.nth($value, 1),
61
+ $green: list.nth($value, 2),
62
+ $blue: list.nth($value, 3),
63
+ $alpha: $alpha
64
+ );
65
+ } @else {
66
+ @return $value;
67
+ }
68
+ }
69
+
70
+ // -----
71
+ // -- Accessor for $tokens using a dot-separated key.
72
+ // -- Automatically wraps RGB partials into an rgb() expression and
73
+ // -- optionally adds an RGB alpha value.
74
+ // -----
75
+ @function cat-token($key, $alpha: 1, $wrap: true) {
76
+ $value: -cat-get($tokens, $key);
77
+ @if not $value {
78
+ @error 'Unknown token "#{-cat-join($key, '.')}".';
79
+ }
80
+ @if $wrap and string.index($key, 'color.') == 1 {
81
+ @return cat-token-wrap($value, $alpha);
82
+ }
83
+ @return $value;
84
+ }
@@ -0,0 +1,12 @@
1
+ @use '../variables' as *;
2
+ @use '../mixins' as *;
3
+
4
+ // ---- Typography
5
+
6
+ body {
7
+ @include cat-body('m');
8
+ font-family: cat-body-font-family();
9
+ font-weight: cat-token('font.weight.body');
10
+ color: cat-token('color.ui.font.body');
11
+ background-color: cat-token('color.ui.background.canvas');
12
+ }
@@ -0,0 +1,23 @@
1
+ @use '../variables' as *;
2
+ @use '../mixins' as *;
3
+
4
+ nav {
5
+ hr,
6
+ .cat-hr {
7
+ margin-top: $cat-nav-padding-horizontal * 0.5;
8
+ margin-bottom: $cat-nav-padding-horizontal * 0.5;
9
+ }
10
+
11
+ .cat-head,
12
+ .cat-text {
13
+ padding: $cat-nav-padding-horizontal * 0.5 $cat-nav-padding-horizontal;
14
+
15
+ > :last-child {
16
+ margin-bottom: 0;
17
+ }
18
+ }
19
+
20
+ .cat-head {
21
+ @include cat-head(5);
22
+ }
23
+ }
@@ -0,0 +1,237 @@
1
+ @use '../variables' as *;
2
+ @use '../mixins' as *;
3
+
4
+ h1,
5
+ h2,
6
+ h3,
7
+ h4,
8
+ h5,
9
+ h6,
10
+ .cat-h1,
11
+ .cat-h2,
12
+ .cat-h3,
13
+ .cat-h4,
14
+ .cat-h5,
15
+ .cat-h6 {
16
+ margin-top: 0;
17
+ margin-bottom: $cat-head-margin-bottom;
18
+ font-weight: cat-token('font.weight.head');
19
+ }
20
+
21
+ // -- head styles
22
+ @each $key, $value in cat-token('size.font.head') {
23
+ h#{$key},
24
+ .cat-h#{$key} {
25
+ @include cat-head($key);
26
+ }
27
+ }
28
+
29
+ // -- body styles
30
+ @each $key, $value in cat-token('size.font.body') {
31
+ .cat-text-#{$key} {
32
+ @include cat-body($key);
33
+ }
34
+ }
35
+
36
+ // -- mono styles
37
+ @each $key, $value in cat-token('size.font.mono') {
38
+ .cat-mono-#{$key} {
39
+ @include cat-mono($key);
40
+ }
41
+ }
42
+
43
+ p {
44
+ margin-top: 0;
45
+ margin-bottom: $cat-body-margin-bottom;
46
+ }
47
+
48
+ hr,
49
+ .cat-hr {
50
+ display: block;
51
+ margin: $cat-body-margin-bottom 0;
52
+ border: 0;
53
+ height: 1px;
54
+ background-color: cat-token('color.ui.border.default');
55
+ overflow: hidden;
56
+ }
57
+
58
+ // ----- links
59
+
60
+ a {
61
+ color: cat-token('color.theme.primary.text');
62
+ text-decoration: $cat-link-text-decoration;
63
+ transition: color cat-token('time.transition.s') linear;
64
+
65
+ &:hover {
66
+ color: cat-token('color.theme.primary.textHover');
67
+ text-decoration: $cat-link-text-decoration-hover;
68
+ }
69
+
70
+ &:active {
71
+ color: cat-token('color.theme.primary.textActive');
72
+ }
73
+
74
+ &:focus-visible {
75
+ outline: 2px solid cat-token('color.ui.border.focus');
76
+ // outline-offset: -2px;
77
+ }
78
+ }
79
+
80
+ a[tabindex='-1']:focus {
81
+ outline: none;
82
+ }
83
+
84
+ // ----- emphasis
85
+
86
+ b,
87
+ strong,
88
+ .cat-strong {
89
+ font-weight: 600;
90
+ }
91
+
92
+ mark,
93
+ .cat-mark {
94
+ padding: 0.125rem 0.25rem;
95
+ background-color: $cat-mark-color;
96
+ }
97
+
98
+ small,
99
+ .cat-small {
100
+ font-size: 0.875em;
101
+ }
102
+
103
+ .cat-underline {
104
+ text-decoration: underline;
105
+ }
106
+
107
+ .cat-line-through {
108
+ text-decoration: line-through;
109
+ }
110
+
111
+ .cat-muted {
112
+ color: cat-token('color.ui.font.muted');
113
+ }
114
+
115
+ // ----- lists
116
+
117
+ ol,
118
+ ul {
119
+ padding-left: 2rem;
120
+ }
121
+
122
+ ol,
123
+ ul,
124
+ dl {
125
+ margin-top: 0;
126
+ margin-bottom: 1rem;
127
+
128
+ ol,
129
+ ul,
130
+ dl {
131
+ margin-bottom: 0;
132
+ }
133
+ }
134
+
135
+ nav {
136
+ ol,
137
+ ul {
138
+ list-style-type: none;
139
+ margin: 0;
140
+ padding: 0;
141
+ }
142
+ }
143
+
144
+ dt {
145
+ font-weight: 600;
146
+ }
147
+
148
+ dd {
149
+ margin-bottom: 0.5rem;
150
+ margin-left: 0;
151
+ }
152
+
153
+ // ----- lead
154
+
155
+ .cat-lead {
156
+ @include cat-body('xl', 300);
157
+ }
158
+
159
+ // ----- blockquotes & figures
160
+
161
+ blockquote {
162
+ margin: 0 0 $cat-body-margin-bottom;
163
+ font-style: italic;
164
+ @include cat-body('l');
165
+ color: cat-token('color.ui.font.quote');
166
+
167
+ > :last-child {
168
+ margin-bottom: 0;
169
+ }
170
+ }
171
+
172
+ figure {
173
+ margin: 0 0 $cat-body-margin-bottom;
174
+
175
+ figcaption {
176
+ margin-top: -$cat-body-margin-bottom * 0.5;
177
+ margin-bottom: 0;
178
+ @include cat-body('s');
179
+ color: cat-token('color.ui.font.muted');
180
+
181
+ &::before {
182
+ content: '\2014\00A0'; // em dash, nbsp
183
+ }
184
+ }
185
+ }
186
+
187
+ // ----- code
188
+
189
+ code,
190
+ samp,
191
+ kbd,
192
+ pre {
193
+ @include cat-mono('m');
194
+ font-weight: cat-token('font.weight.mono');
195
+ }
196
+
197
+ pre {
198
+ margin-top: 0;
199
+ margin-bottom: $cat-body-margin-bottom;
200
+ overflow: auto;
201
+
202
+ code {
203
+ margin: 0;
204
+ padding: 0;
205
+ color: inherit;
206
+ background: none;
207
+ box-shadow: none;
208
+ border-radius: 0;
209
+ word-wrap: normal;
210
+ word-break: normal;
211
+ }
212
+ }
213
+
214
+ kbd,
215
+ code {
216
+ margin: 0 0.125rem;
217
+ color: cat-token('color.ui.font.muted');
218
+ background: cat-token('color.ui.background.body');
219
+ box-shadow: 0 0 0 2px cat-token('color.ui.border.default');
220
+ border-radius: cat-border-radius('s');
221
+ }
222
+
223
+ kbd {
224
+ font-size: cat-mono-font-size('s');
225
+ display: inline-block;
226
+ min-width: 1.5rem;
227
+ line-height: cat-body-line-height('m');
228
+ padding: 0 0.375rem;
229
+ text-align: center;
230
+ vertical-align: top;
231
+ white-space: nowrap;
232
+ }
233
+
234
+ code {
235
+ @include cat-break-word;
236
+ padding: 0.0625rem 0.25rem;
237
+ }