@crowdstrike/glide-core 0.9.6 → 0.11.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.
- package/README.md +17 -53
- package/dist/accordion.d.ts +10 -10
- package/dist/accordion.js +1 -1
- package/dist/accordion.stories.d.ts +0 -1
- package/dist/accordion.styles.js +36 -38
- package/dist/accordion.test.basics.js +13 -95
- package/dist/accordion.test.events.js +21 -33
- package/dist/accordion.test.focus.d.ts +1 -0
- package/dist/accordion.test.focus.js +11 -0
- package/dist/accordion.test.interactions.d.ts +1 -0
- package/dist/accordion.test.interactions.js +75 -0
- package/dist/button-group.button.d.ts +2 -4
- package/dist/button-group.button.js +1 -1
- package/dist/button-group.button.styles.js +6 -14
- package/dist/button-group.button.test.basics.js +8 -17
- package/dist/button-group.button.test.interactions.js +4 -4
- package/dist/button-group.d.ts +0 -2
- package/dist/button-group.test.basics.js +10 -10
- package/dist/button-group.test.events.js +2 -2
- package/dist/button-group.test.interactions.js +1 -1
- package/dist/button.d.ts +7 -10
- package/dist/button.js +1 -1
- package/dist/button.styles.js +4 -7
- package/dist/button.test.basics.js +10 -26
- package/dist/button.test.events.js +9 -9
- package/dist/checkbox-group.d.ts +3 -4
- package/dist/checkbox-group.js +1 -1
- package/dist/checkbox-group.styles.js +13 -1
- package/dist/checkbox-group.test.basics.js +8 -12
- package/dist/checkbox-group.test.focus.js +7 -7
- package/dist/checkbox-group.test.interactions.d.ts +1 -0
- package/dist/checkbox-group.test.interactions.js +82 -0
- package/dist/checkbox.d.ts +5 -4
- package/dist/checkbox.js +1 -1
- package/dist/checkbox.styles.js +35 -15
- package/dist/checkbox.test.basics.js +6 -15
- package/dist/checkbox.test.events.js +9 -0
- package/dist/checkbox.test.focus.js +4 -2
- package/dist/checkbox.test.interactions.js +11 -11
- package/dist/drawer.d.ts +2 -5
- package/dist/drawer.js +1 -1
- package/dist/drawer.test.accessibility.js +8 -8
- package/dist/drawer.test.basics.js +16 -16
- package/dist/drawer.test.closing.js +18 -16
- package/dist/drawer.test.events.js +13 -24
- package/dist/drawer.test.methods.js +22 -22
- package/dist/dropdown.d.ts +7 -5
- package/dist/dropdown.js +1 -1
- package/dist/dropdown.option.d.ts +2 -3
- package/dist/dropdown.option.js +1 -1
- package/dist/dropdown.option.styles.js +31 -19
- package/dist/dropdown.option.test.basics.js +4 -4
- package/dist/dropdown.option.test.events.js +9 -1
- package/dist/dropdown.option.test.interactions.single.js +2 -2
- package/dist/dropdown.styles.js +39 -3
- package/dist/dropdown.test.basics.d.ts +1 -1
- package/dist/dropdown.test.basics.js +27 -14
- package/dist/dropdown.test.basics.multiple.js +65 -32
- package/dist/dropdown.test.basics.single.js +49 -0
- package/dist/dropdown.test.events.filterable.js +13 -2
- package/dist/dropdown.test.focus.filterable.js +12 -3
- package/dist/dropdown.test.focus.js +18 -2
- package/dist/dropdown.test.form.multiple.js +3 -2
- package/dist/dropdown.test.interactions.filterable.js +141 -45
- package/dist/dropdown.test.interactions.js +24 -0
- package/dist/dropdown.test.interactions.multiple.js +87 -30
- package/dist/dropdown.test.interactions.single.js +40 -4
- package/dist/form-controls-layout.d.ts +0 -2
- package/dist/icon-button.d.ts +2 -4
- package/dist/icon-button.js +1 -1
- package/dist/icon-button.test.basics.js +14 -82
- package/dist/icon-button.test.focus.d.ts +1 -0
- package/dist/icon-button.test.focus.js +13 -0
- package/dist/input.d.ts +4 -5
- package/dist/input.js +1 -1
- package/dist/input.styles.js +4 -4
- package/dist/input.test.basics.js +0 -52
- package/dist/input.test.events.js +27 -27
- package/dist/input.test.focus.js +27 -26
- package/dist/input.test.form.js +6 -6
- package/dist/input.test.validity.js +130 -130
- package/dist/label.d.ts +1 -3
- package/dist/label.js +1 -1
- package/dist/label.styles.js +5 -6
- package/dist/label.test.basics.js +4 -4
- package/dist/library/ow.js +1 -1
- package/dist/menu.button.d.ts +0 -2
- package/dist/menu.button.test.basics.js +3 -3
- package/dist/menu.d.ts +1 -4
- package/dist/menu.js +1 -1
- package/dist/menu.link.d.ts +1 -2
- package/dist/menu.link.js +1 -1
- package/dist/menu.options.d.ts +0 -2
- package/dist/menu.test.events.js +6 -6
- package/dist/menu.test.focus.js +5 -18
- package/dist/menu.test.interactions.js +48 -24
- package/dist/modal.d.ts +6 -17
- package/dist/modal.icon-button.d.ts +0 -2
- package/dist/modal.icon-button.test.basics.js +3 -3
- package/dist/modal.js +1 -1
- package/dist/modal.styles.js +13 -19
- package/dist/modal.tertiary-icon.d.ts +0 -3
- package/dist/modal.tertiary-icon.test.basics.js +3 -3
- package/dist/modal.test.basics.js +9 -5
- package/dist/modal.test.close.js +2 -2
- package/dist/modal.test.events.js +2 -2
- package/dist/radio-group.d.ts +0 -3
- package/dist/radio-group.js +1 -1
- package/dist/radio-group.test.basics.js +61 -61
- package/dist/radio-group.test.events.js +13 -13
- package/dist/radio-group.test.focus.js +1 -1
- package/dist/radio-group.test.form.js +2 -2
- package/dist/radio-group.test.validity.js +12 -12
- package/dist/radio.d.ts +0 -3
- package/dist/radio.styles.js +4 -12
- package/dist/split-button.d.ts +8 -11
- package/dist/split-button.js +1 -1
- package/dist/split-button.primary-button.d.ts +21 -0
- package/dist/split-button.primary-button.js +1 -0
- package/dist/split-button.primary-button.styles.js +96 -0
- package/dist/split-button.primary-button.test.basics.d.ts +1 -0
- package/dist/split-button.primary-button.test.basics.js +31 -0
- package/dist/split-button.primary-button.test.focus.d.ts +1 -0
- package/dist/split-button.primary-button.test.focus.js +14 -0
- package/dist/split-button.primary-link.d.ts +19 -0
- package/dist/split-button.primary-link.js +1 -0
- package/dist/split-button.primary-link.test.basics.d.ts +1 -0
- package/dist/split-button.primary-link.test.basics.js +30 -0
- package/dist/split-button.primary-link.test.focus.d.ts +1 -0
- package/dist/split-button.primary-link.test.focus.js +15 -0
- package/dist/split-button.secondary-button.d.ts +25 -0
- package/dist/split-button.secondary-button.js +1 -0
- package/dist/split-button.secondary-button.styles.js +103 -0
- package/dist/split-button.secondary-button.test.basics.d.ts +1 -0
- package/dist/split-button.secondary-button.test.basics.js +58 -0
- package/dist/split-button.secondary-button.test.focus.d.ts +1 -0
- package/dist/split-button.secondary-button.test.focus.js +14 -0
- package/dist/split-button.secondary-button.test.interactions.d.ts +2 -0
- package/dist/split-button.secondary-button.test.interactions.js +30 -0
- package/dist/split-button.stories.d.ts +4 -3
- package/dist/split-button.styles.js +1 -94
- package/dist/split-button.test.basics.d.ts +2 -1
- package/dist/split-button.test.basics.js +67 -80
- package/dist/split-button.test.interactions.d.ts +4 -0
- package/dist/split-button.test.interactions.js +51 -0
- package/dist/styles/opacity-and-scale-animation.js +2 -6
- package/dist/styles/variables.css +1 -1
- package/dist/tab.d.ts +2 -11
- package/dist/tab.group.d.ts +3 -5
- package/dist/tab.group.js +1 -1
- package/dist/tab.group.styles.js +18 -15
- package/dist/tab.group.test.basics.js +49 -34
- package/dist/tab.group.test.interactions.js +17 -14
- package/dist/tab.panel.d.ts +0 -3
- package/dist/tab.test.basics.js +6 -5
- package/dist/tag.d.ts +5 -4
- package/dist/tag.js +1 -1
- package/dist/tag.styles.js +47 -38
- package/dist/tag.test.basics.js +18 -110
- package/dist/tag.test.events.js +12 -8
- package/dist/tag.test.focus.js +2 -3
- package/dist/tag.test.interactions.d.ts +1 -0
- package/dist/tag.test.interactions.js +36 -0
- package/dist/textarea.d.ts +2 -3
- package/dist/textarea.js +2 -2
- package/dist/textarea.test.basics.js +8 -8
- package/dist/textarea.test.events.js +55 -55
- package/dist/textarea.test.form.js +9 -9
- package/dist/textarea.test.validity.js +167 -135
- package/dist/toasts.d.ts +1 -5
- package/dist/toasts.test.basics.js +2 -1
- package/dist/toasts.toast.d.ts +1 -4
- package/dist/toasts.toast.js +1 -1
- package/dist/toasts.toast.styles.js +12 -0
- package/dist/toggle.d.ts +0 -2
- package/dist/toggle.styles.js +1 -5
- package/dist/toggle.test.basics.js +2 -2
- package/dist/toggle.test.interactions.js +7 -7
- package/dist/tooltip.d.ts +2 -1
- package/dist/tooltip.js +1 -1
- package/dist/tooltip.styles.js +37 -13
- package/dist/tooltip.test.basics.d.ts +1 -1
- package/dist/tooltip.test.basics.js +19 -19
- package/dist/tree.d.ts +0 -2
- package/dist/tree.item.d.ts +5 -7
- package/dist/tree.item.icon-button.d.ts +1 -4
- package/dist/tree.item.js +1 -1
- package/dist/tree.item.menu.d.ts +1 -2
- package/dist/tree.item.menu.js +1 -1
- package/dist/tree.item.menu.test.basics.js +31 -10
- package/dist/tree.item.styles.js +7 -9
- package/dist/tree.item.test.basics.js +43 -31
- package/dist/tree.test.basics.js +29 -29
- package/dist/tree.test.focus.js +77 -74
- package/package.json +12 -14
- package/dist/split-container.d.ts +0 -31
- package/dist/split-container.js +0 -1
- package/dist/split-container.styles.js +0 -132
- package/dist/split-container.test.basics.d.ts +0 -3
- package/dist/split-container.test.basics.js +0 -445
- package/dist/split-container.test.interactions.d.ts +0 -1
- package/dist/split-container.test.interactions.js +0 -20
- package/dist/split-link.d.ts +0 -25
- package/dist/split-link.js +0 -1
- package/dist/split-link.test.basics.d.ts +0 -1
- package/dist/split-link.test.basics.js +0 -93
- package/dist/split-link.test.interactions.d.ts +0 -1
- package/dist/split-link.test.interactions.js +0 -20
- package/dist/status-indicator.d.ts +0 -30
- package/dist/status-indicator.js +0 -1
- package/dist/status-indicator.stories.d.ts +0 -5
- package/dist/status-indicator.styles.js +0 -58
- package/dist/status-indicator.test.basics.d.ts +0 -1
- package/dist/status-indicator.test.basics.js +0 -102
- /package/dist/{split-container.styles.d.ts → split-button.primary-button.styles.d.ts} +0 -0
- /package/dist/{status-indicator.styles.d.ts → split-button.secondary-button.styles.d.ts} +0 -0
package/README.md
CHANGED
@@ -1,21 +1,19 @@
|
|
1
|
-
<
|
1
|
+
<div align="center">
|
2
2
|
<a href="https://glide-core.crowdstrike-ux.workers.dev">
|
3
3
|
<img src="https://github.com/CrowdStrike/glide-core/blob/main/.github/glide-core.png?raw=true" alt="Glide Core logo" width="300" />
|
4
4
|
</a>
|
5
|
-
</p>
|
6
5
|
|
7
|
-
<
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
This package contains Web Components built with [Lit](https://lit.dev/).
|
6
|
+
<p align="center">
|
7
|
+
A Web Component design system from CrowdStrike.
|
8
|
+
</p>
|
9
|
+
</div>
|
12
10
|
|
13
11
|
## Usage
|
14
12
|
|
15
|
-
### 1.
|
13
|
+
### 1. Install the dependencies
|
16
14
|
|
17
15
|
```bash
|
18
|
-
pnpm install @crowdstrike/glide-core lit
|
16
|
+
$ pnpm install @crowdstrike/glide-core lit
|
19
17
|
```
|
20
18
|
|
21
19
|
### 2. Import the fonts and variables
|
@@ -25,7 +23,7 @@ pnpm install @crowdstrike/glide-core lit
|
|
25
23
|
@import '@crowdstrike/glide-core/styles/variables.css';
|
26
24
|
```
|
27
25
|
|
28
|
-
### 3. Import
|
26
|
+
### 3. Import your component
|
29
27
|
|
30
28
|
```js
|
31
29
|
import '@crowdstrike/glide-core/button.js';
|
@@ -34,57 +32,23 @@ import '@crowdstrike/glide-core/button.js';
|
|
34
32
|
### 4. Render your component
|
35
33
|
|
36
34
|
```html
|
37
|
-
<glide-core-button
|
35
|
+
<glide-core-button label="Button"></glide-core-button>
|
38
36
|
```
|
39
37
|
|
40
38
|
## Development
|
41
39
|
|
42
|
-
### Contributing
|
43
|
-
|
44
|
-
Follow our [Contribution Guidelines](./CONTRIBUTING.md).
|
45
|
-
|
46
40
|
### Getting started
|
47
41
|
|
48
|
-
First you'll need to install the dependencies for the repository. We use [PNPM](https://pnpm.io). Run the following command from the root of the repository:
|
49
|
-
|
50
|
-
```bash
|
51
|
-
pnpm install
|
52
|
-
pnpm dlx playwright install
|
53
|
-
```
|
54
|
-
|
55
|
-
> [!NOTE]
|
56
|
-
>
|
57
|
-
> - If you have `ignore-scripts=true` in your `~/.npmrc`, you'll also need to run `pnpm prepare`, which will install some Git hooks for linting, formatting, typechecking, and testing.
|
58
|
-
> - We recommend using [Corepack](https://pnpm.io/installation#using-corepack) to help manage the version of `pnpm` installed in this repository; however, it is not a requirement.
|
59
|
-
|
60
|
-
### Running Storybook
|
61
|
-
|
62
|
-
Run the following command from the root of the repository:
|
63
|
-
|
64
42
|
```bash
|
65
|
-
pnpm
|
43
|
+
$ pnpm install
|
44
|
+
$ pnpm start
|
66
45
|
```
|
67
46
|
|
68
|
-
|
69
|
-
|
47
|
+
- Follow our [contribution guidelines](./CONTRIBUTING.md) before opening a pull request.
|
48
|
+
- We recommend using [Corepack](https://pnpm.io/installation#using-corepack) to manage PNPM.
|
49
|
+
- If you have `ignore-scripts=true` in your `~/.npmrc`, also run `pnpm prepare` to install the Git hooks.
|
70
50
|
|
71
|
-
###
|
51
|
+
### Updating style variables
|
72
52
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
Prior to running the script, you'll need to follow the steps to [generate a Figma personal access token](https://help.figma.com/hc/en-us/articles/8085703771159-Manage-personal-access-tokens).
|
77
|
-
|
78
|
-
Store this access token in your `.zshrc` or `.bashrc` as the following:
|
79
|
-
|
80
|
-
```bash
|
81
|
-
export FIGMA_TOKEN="<your-token-here>"
|
82
|
-
```
|
83
|
-
|
84
|
-
This setup is required only once; however, your access token may expire and require an update now and then. An error will be thrown if this occurs. Review the link above on managing access tokens in Figma if this happens.
|
85
|
-
|
86
|
-
After the steps above are completed, to get new or updated custom properties run the following command:
|
87
|
-
|
88
|
-
```bash
|
89
|
-
pnpm start:production:figma
|
90
|
-
```
|
53
|
+
1. Generate a Figma [personal access token](https://help.figma.com/hc/en-us/articles/8085703771159-Manage-personal-access-tokens).
|
54
|
+
1. `$ FIGMA_TOKEN=<token> pnpm start:production:figma`
|
package/dist/accordion.d.ts
CHANGED
@@ -5,23 +5,23 @@ declare global {
|
|
5
5
|
}
|
6
6
|
}
|
7
7
|
/**
|
8
|
-
* @
|
9
|
-
*
|
10
|
-
* @event toggle - `(event: "toggle", listener: (event: CustomEvent<{ newState: "open" | "closed", oldState: "open" | "closed" }>) => void) => void`.
|
11
|
-
* Emitted when the Accordion opens or closes.
|
8
|
+
* @event toggle - `(event: "toggle", listener: (event: Event) => void) => void`.
|
12
9
|
*
|
13
10
|
* @slot - The content of the accordion.
|
14
|
-
* @slot prefix - An optional icon
|
15
|
-
* @slot suffix - Optional icons
|
11
|
+
* @slot prefix-icon - An optional icon before the label.
|
12
|
+
* @slot suffix-icons - Optional icons after the label.
|
16
13
|
*/
|
17
14
|
export default class GlideCoreAccordion extends LitElement {
|
18
15
|
#private;
|
19
16
|
static shadowRootOptions: ShadowRootInit;
|
20
17
|
static styles: import("lit").CSSResult[];
|
21
|
-
label
|
22
|
-
open: boolean;
|
18
|
+
label?: string;
|
19
|
+
get open(): boolean;
|
20
|
+
set open(isOpen: boolean);
|
21
|
+
click(): void;
|
23
22
|
firstUpdated(): void;
|
24
23
|
render(): import("lit").TemplateResult<1>;
|
25
|
-
private
|
26
|
-
private
|
24
|
+
private hasPrefixIcon;
|
25
|
+
private hasSuffixIcons;
|
26
|
+
private isClosing;
|
27
27
|
}
|
package/dist/accordion.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
var __decorate=this&&this.__decorate||function(e,t,o,s){var i
|
1
|
+
var __decorate=this&&this.__decorate||function(e,t,o,s){var l,i=arguments.length,n=i<3?t:null===s?s=Object.getOwnPropertyDescriptor(t,o):s;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(e,t,o,s);else for(var a=e.length-1;a>=0;a--)(l=e[a])&&(n=(i<3?l(n):i>3?l(t,o,n):l(t,o))||n);return i>3&&n&&Object.defineProperty(t,o,n),n};import{LitElement,html}from"lit";import{classMap}from"lit/directives/class-map.js";import{createRef,ref}from"lit/directives/ref.js";import{customElement,property,state}from"lit/decorators.js";import{owSlot}from"./library/ow.js";import styles from"./accordion.styles.js";let GlideCoreAccordion=class GlideCoreAccordion extends LitElement{constructor(){super(...arguments),this.hasPrefixIcon=!1,this.hasSuffixIcons=!1,this.isClosing=!1,this.#e=createRef(),this.#t=createRef(),this.#o=!1,this.#s=createRef(),this.#l=createRef(),this.#i=createRef()}static{this.shadowRootOptions={...LitElement.shadowRootOptions,delegatesFocus:!0,mode:"closed"}}static{this.styles=styles}get open(){return this.#o}set open(e){this.#o=e;if(window.matchMedia("(prefers-reduced-motion: reduce)").matches&&this.#t.value)return this.#t.value.open=e,void this.dispatchEvent(new Event("toggle",{bubbles:!0}));if(e)this.updateComplete.then((()=>{if(this.#t.value&&this.#e.value){const e=Number.parseFloat(getComputedStyle(this.#e.value)?.paddingBottom);this.#t.value.open=!0,this.#e.value.animate({height:["0px",this.#e.value.offsetHeight-e+"px"],opacity:[0,1]},{duration:150,easing:"ease-in"}).addEventListener("finish",(()=>{this.#t.value&&this.dispatchEvent(new Event("toggle",{bubbles:!0}))}))}}));else if(this.isClosing=!0,this.#e.value){const e=Number.parseFloat(getComputedStyle(this.#e.value)?.paddingBottom);this.#e.value.animate({height:[this.#e.value.offsetHeight-e+"px","0px"],opacity:[1,0]},{duration:100,easing:"ease-out"}).addEventListener("finish",(()=>{this.#t.value&&(this.#t.value.open=!1,this.isClosing=!1,this.dispatchEvent(new Event("toggle",{bubbles:!0})))}))}}click(){this.#i.value?.click()}firstUpdated(){owSlot(this.#e.value)}render(){return html`<details class="component" ${ref(this.#t)}><summary class="${classMap({summary:!0,active:this.open||this.isClosing})}" data-test="summary" @click="${this.#n}" ${ref(this.#i)}><svg class="${classMap({chevron:!0,unrotated:this.open})}" width="16" height="16" viewBox="0 0 24 24" fill="none"><path d="M6 9L12 15L18 9" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg><div class="label-container"><slot class="prefix-icon-slot" name="prefix-icon" @slotchange="${this.#a}" ${ref(this.#s)}></slot><span class="label">${this.label}</span></div><slot class="${classMap({"suffix-icons-slot":!0,icons:this.hasSuffixIcons})}" name="suffix-icons" @slotchange="${this.#r}" ${ref(this.#l)}></slot></summary><slot class="${classMap({"default-slot":!0,indented:this.hasPrefixIcon})}" data-test="default-slot" @slotchange="${this.#f}" ${ref(this.#e)}></slot></details>`}#e;#t;#o;#s;#l;#i;#f(){owSlot(this.#e.value)}#a(){const e=this.#s.value?.assignedNodes();this.hasPrefixIcon=Boolean(e&&e.length>0)}#r(){const e=this.#l.value?.assignedNodes();this.hasSuffixIcons=Boolean(e&&e.length>0)}#n(e){e.preventDefault(),this.open=!this.open}};__decorate([property({reflect:!0})],GlideCoreAccordion.prototype,"label",void 0),__decorate([property({reflect:!0,type:Boolean})],GlideCoreAccordion.prototype,"open",null),__decorate([state()],GlideCoreAccordion.prototype,"hasPrefixIcon",void 0),__decorate([state()],GlideCoreAccordion.prototype,"hasSuffixIcons",void 0),__decorate([state()],GlideCoreAccordion.prototype,"isClosing",void 0),GlideCoreAccordion=__decorate([customElement("glide-core-accordion")],GlideCoreAccordion);export default GlideCoreAccordion;
|
package/dist/accordion.styles.js
CHANGED
@@ -31,42 +31,24 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";export
|
|
31
31
|
display: none;
|
32
32
|
}
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
display: flex;
|
37
|
-
flex: 1;
|
38
|
-
overflow: hidden;
|
39
|
-
white-space: nowrap;
|
40
|
-
|
41
|
-
&.heading-box-with-prefix {
|
42
|
-
gap: var(--glide-core-spacing-xs);
|
43
|
-
}
|
44
|
-
|
45
|
-
.prefix-slot-box {
|
46
|
-
display: flex;
|
47
|
-
}
|
48
|
-
|
49
|
-
.label {
|
50
|
-
display: block;
|
51
|
-
overflow: hidden;
|
52
|
-
text-overflow: ellipsis;
|
53
|
-
}
|
34
|
+
&.active {
|
35
|
+
padding-block-end: var(--glide-core-spacing-xxs);
|
54
36
|
}
|
37
|
+
}
|
55
38
|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
}
|
65
|
-
}
|
39
|
+
.label-container {
|
40
|
+
align-items: center;
|
41
|
+
display: flex;
|
42
|
+
flex: 1;
|
43
|
+
gap: var(--glide-core-spacing-xs);
|
44
|
+
overflow: hidden;
|
45
|
+
white-space: nowrap;
|
46
|
+
}
|
66
47
|
|
67
|
-
|
68
|
-
|
69
|
-
|
48
|
+
.label {
|
49
|
+
display: block;
|
50
|
+
overflow: hidden;
|
51
|
+
text-overflow: ellipsis;
|
70
52
|
}
|
71
53
|
|
72
54
|
.chevron {
|
@@ -74,24 +56,40 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";export
|
|
74
56
|
display: flex;
|
75
57
|
margin-inline-end: var(--glide-core-spacing-xxs);
|
76
58
|
rotate: -90deg;
|
77
|
-
transition: 250ms rotate ease;
|
78
59
|
|
79
|
-
|
60
|
+
&.unrotated {
|
80
61
|
rotate: 0deg;
|
81
62
|
}
|
63
|
+
|
64
|
+
@media (prefers-reduced-motion: no-preference) {
|
65
|
+
transition: 250ms rotate ease;
|
66
|
+
}
|
82
67
|
}
|
83
68
|
|
84
|
-
.
|
69
|
+
.default-slot {
|
85
70
|
color: var(--glide-core-text-body-1);
|
71
|
+
display: block;
|
86
72
|
font-size: var(--glide-core-body-sm-font-size);
|
87
73
|
font-weight: var(--glide-core-body-xs-font-weight);
|
74
|
+
overflow: hidden;
|
88
75
|
padding-block-end: var(--glide-core-spacing-sm);
|
89
76
|
|
90
77
|
/* Hardcoded spacing here is intentional so that it better aligns with the Accordion label */
|
91
78
|
padding-inline: 2rem var(--glide-core-spacing-sm);
|
79
|
+
|
80
|
+
&.indented {
|
81
|
+
padding-inline-start: 3.5rem;
|
82
|
+
}
|
92
83
|
}
|
93
84
|
|
94
|
-
.
|
95
|
-
|
85
|
+
.suffix-icons-slot {
|
86
|
+
align-items: center;
|
87
|
+
color: var(--glide-core-icon-primary);
|
88
|
+
gap: 0.625rem;
|
89
|
+
margin-inline-start: var(--glide-core-spacing-xs);
|
90
|
+
|
91
|
+
&.icons {
|
92
|
+
display: flex;
|
93
|
+
}
|
96
94
|
}
|
97
95
|
`];
|
@@ -1,110 +1,28 @@
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
2
2
|
import './accordion.js';
|
3
|
-
import {
|
3
|
+
import { expect, fixture, html } from '@open-wc/testing';
|
4
4
|
import GlideCoreAccordion from './accordion.js';
|
5
5
|
GlideCoreAccordion.shadowRootOptions.mode = 'open';
|
6
6
|
it('registers', async () => {
|
7
7
|
expect(window.customElements.get('glide-core-accordion')).to.equal(GlideCoreAccordion);
|
8
8
|
});
|
9
9
|
it('is accessible', async () => {
|
10
|
-
const component = await fixture(html `<glide-core-accordion label="
|
11
|
-
Inner content
|
12
|
-
</glide-core-accordion>`);
|
10
|
+
const component = await fixture(html `<glide-core-accordion label="Label">Content</glide-core-accordion>`);
|
13
11
|
await expect(component).to.be.accessible();
|
14
12
|
});
|
15
|
-
it('
|
16
|
-
const component = await fixture(html `<glide-core-accordion label="
|
17
|
-
|
18
|
-
</glide-core-accordion>`);
|
19
|
-
const accordion = component.shadowRoot?.querySelector('details');
|
20
|
-
expect(accordion).to.be.ok;
|
21
|
-
expect(accordion?.hasAttribute('open')).to.be.false;
|
22
|
-
});
|
23
|
-
it('defaults to "open" when provided with the attribute', async () => {
|
24
|
-
const component = await fixture(html `<glide-core-accordion label="label" open>
|
25
|
-
Inner content
|
26
|
-
</glide-core-accordion>`);
|
27
|
-
const accordion = component.shadowRoot?.querySelector('details');
|
28
|
-
expect(accordion).to.be.ok;
|
29
|
-
expect(accordion?.hasAttribute('open')).to.be.true;
|
30
|
-
});
|
31
|
-
it('renders the provided "label"', async () => {
|
32
|
-
const component = await fixture(html `<glide-core-accordion label="Accordion Title">
|
33
|
-
Inner content
|
34
|
-
</glide-core-accordion>`);
|
35
|
-
const label = component.shadowRoot?.querySelector('[data-test="label"]');
|
36
|
-
expect(label).to.be.ok;
|
37
|
-
expect(label?.textContent?.trim()).to.equal('Accordion Title');
|
38
|
-
});
|
39
|
-
it('renders the provided default slotted content', async () => {
|
40
|
-
const component = await fixture(html `<glide-core-accordion label="label"
|
41
|
-
><p data-body>Inner content</p></glide-core-accordion
|
42
|
-
>`);
|
43
|
-
const body = component.querySelector('[data-body]');
|
44
|
-
expect(body).to.be.ok;
|
45
|
-
});
|
46
|
-
it('renders with a prefix slot and applies the appropriate classes', async () => {
|
47
|
-
const component = await fixture(html `<glide-core-accordion label="label">
|
48
|
-
Inner content
|
49
|
-
<span slot="prefix" data-prefix>prefix</span>
|
50
|
-
</glide-core-accordion>`);
|
51
|
-
expect(document.querySelector('[data-prefix]')).to.be.ok;
|
52
|
-
expect([
|
53
|
-
...component.shadowRoot.querySelector('[data-test="label"]').classList,
|
54
|
-
]).to.deep.equal(['heading-box', 'heading-box-with-prefix']);
|
55
|
-
expect([
|
56
|
-
...component.shadowRoot.querySelector('[data-test="content"]').classList,
|
57
|
-
]).to.deep.equal(['content', 'content-with-prefix']);
|
58
|
-
});
|
59
|
-
it('does not apply prefix classes when no prefix slot is provided', async () => {
|
60
|
-
const component = await fixture(html `<glide-core-accordion label="label">
|
61
|
-
Inner content
|
62
|
-
</glide-core-accordion>`);
|
63
|
-
expect([
|
64
|
-
...component.shadowRoot.querySelector('[data-test="label"]').classList,
|
65
|
-
]).to.deep.equal(['heading-box']);
|
66
|
-
expect([
|
67
|
-
...component.shadowRoot.querySelector('[data-test="content"]').classList,
|
68
|
-
]).to.deep.equal(['content']);
|
13
|
+
it('has defaults', async () => {
|
14
|
+
const component = await fixture(html `<glide-core-accordion label="Label">Content</glide-core-accordion>`);
|
15
|
+
expect(component.open).to.be.false;
|
69
16
|
});
|
70
|
-
it('
|
71
|
-
|
72
|
-
|
73
|
-
<
|
17
|
+
it('`#onPrefixIconSlotChange` coverage', async () => {
|
18
|
+
await fixture(html `<glide-core-accordion label="Label">
|
19
|
+
Content
|
20
|
+
<div slot="prefix-icon"></div>
|
74
21
|
</glide-core-accordion>`);
|
75
|
-
expect(component.querySelector('[data-suffix]')).to.be.ok;
|
76
|
-
expect([
|
77
|
-
...component.shadowRoot.querySelector('[data-test="suffix"]').classList,
|
78
|
-
]).to.deep.equal(['suffix-slot-box', 'suffix-slot-box-with-content']);
|
79
22
|
});
|
80
|
-
it('
|
81
|
-
|
82
|
-
|
23
|
+
it('`#onSuffixIconsSlotChange` coverage', async () => {
|
24
|
+
await fixture(html `<glide-core-accordion label="Label">
|
25
|
+
Content
|
26
|
+
<div slot="suffix-icons"></div>
|
83
27
|
</glide-core-accordion>`);
|
84
|
-
expect([
|
85
|
-
...component.shadowRoot.querySelector('[data-test="suffix"]').classList,
|
86
|
-
]).to.deep.equal(['suffix-slot-box']);
|
87
|
-
});
|
88
|
-
it('renders without prefix and suffix classes after both are removed', async () => {
|
89
|
-
const component = await fixture(html `
|
90
|
-
<glide-core-accordion label="label">
|
91
|
-
Inner content
|
92
|
-
<span slot="prefix">prefix</span>
|
93
|
-
<span slot="suffix">suffix</span>
|
94
|
-
</glide-core-accordion>
|
95
|
-
`);
|
96
|
-
component.querySelector('[slot="prefix"]')?.remove();
|
97
|
-
component.querySelector('[slot="suffix"]')?.remove();
|
98
|
-
await elementUpdated(component);
|
99
|
-
// prefix
|
100
|
-
expect([
|
101
|
-
...component.shadowRoot.querySelector('[data-test="label"]').classList,
|
102
|
-
]).to.deep.equal(['heading-box']);
|
103
|
-
expect([
|
104
|
-
...component.shadowRoot.querySelector('[data-test="content"]').classList,
|
105
|
-
]).to.deep.equal(['content']);
|
106
|
-
// suffix
|
107
|
-
expect([
|
108
|
-
...component.shadowRoot.querySelector('[data-test="suffix"]').classList,
|
109
|
-
]).to.deep.equal(['suffix-slot-box']);
|
110
28
|
});
|
@@ -1,40 +1,28 @@
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
2
2
|
import './accordion.js';
|
3
|
-
import {
|
3
|
+
import { emulateMedia } from '@web/test-runner-commands';
|
4
|
+
import { expect, fixture, html, oneEvent } from '@open-wc/testing';
|
4
5
|
import GlideCoreAccordion from './accordion.js';
|
5
6
|
GlideCoreAccordion.shadowRootOptions.mode = 'open';
|
6
|
-
it('dispatches a "toggle" event
|
7
|
-
|
8
|
-
const component = await fixture(html `<glide-core-accordion label="
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
const
|
13
|
-
expect(
|
14
|
-
|
15
|
-
await oneEvent(component, 'toggle');
|
16
|
-
expect(hasToggleBeenCalled).to.be.true;
|
7
|
+
it('dispatches a "toggle" event on open', async () => {
|
8
|
+
await emulateMedia({ reducedMotion: 'reduce' });
|
9
|
+
const component = await fixture(html `<glide-core-accordion label="Label">Content</glide-core-accordion>`);
|
10
|
+
setTimeout(() => {
|
11
|
+
component.click();
|
12
|
+
});
|
13
|
+
const event = await oneEvent(component, 'toggle');
|
14
|
+
expect(event instanceof Event).to.be.true;
|
15
|
+
expect(event.bubbles).to.be.true;
|
17
16
|
});
|
18
|
-
it('dispatches a "toggle" event
|
19
|
-
|
20
|
-
const component = await fixture(html `<glide-core-accordion label="
|
21
|
-
|
17
|
+
it('dispatches a "toggle" event on close', async () => {
|
18
|
+
await emulateMedia({ reducedMotion: 'reduce' });
|
19
|
+
const component = await fixture(html `<glide-core-accordion label="Label" open>
|
20
|
+
Content
|
22
21
|
</glide-core-accordion>`);
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
component.shadowRoot
|
30
|
-
?.querySelector('[data-test="content"]')
|
31
|
-
?.getAnimations()
|
32
|
-
?.at(0)
|
33
|
-
?.finish();
|
34
|
-
component.shadowRoot
|
35
|
-
?.querySelector('[data-test="content"]')
|
36
|
-
?.dispatchEvent(new AnimationEvent('finish'));
|
37
|
-
await elementUpdated(component);
|
38
|
-
await oneEvent(component, 'toggle');
|
39
|
-
expect(hasToggleBeenCalled).to.be.true;
|
22
|
+
setTimeout(() => {
|
23
|
+
component.click();
|
24
|
+
});
|
25
|
+
const event = await oneEvent(component, 'toggle');
|
26
|
+
expect(event instanceof Event).to.be.true;
|
27
|
+
expect(event.bubbles).to.be.true;
|
40
28
|
});
|
@@ -0,0 +1 @@
|
|
1
|
+
import './accordion.js';
|
@@ -0,0 +1,11 @@
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
2
|
+
import './accordion.js';
|
3
|
+
import { expect, fixture, html } from '@open-wc/testing';
|
4
|
+
import GlideCoreAccordion from './accordion.js';
|
5
|
+
GlideCoreAccordion.shadowRootOptions.mode = 'open';
|
6
|
+
it('focuses itself when `focus()` is called', async () => {
|
7
|
+
const component = await fixture(html `<glide-core-accordion label="Label">Content</glide-core-accordion>`);
|
8
|
+
component.focus();
|
9
|
+
const summary = component?.shadowRoot?.querySelector('[data-test="summary"]');
|
10
|
+
expect(component?.shadowRoot?.activeElement).to.equal(summary);
|
11
|
+
});
|
@@ -0,0 +1 @@
|
|
1
|
+
import './accordion.js';
|
@@ -0,0 +1,75 @@
|
|
1
|
+
/* eslint-disable @typescript-eslint/no-unused-expressions */
|
2
|
+
import './accordion.js';
|
3
|
+
import { emulateMedia } from '@web/test-runner-commands';
|
4
|
+
import { expect, fixture, html, waitUntil } from '@open-wc/testing';
|
5
|
+
import { sendKeys } from '@web/test-runner-commands';
|
6
|
+
import GlideCoreAccordion from './accordion.js';
|
7
|
+
GlideCoreAccordion.shadowRootOptions.mode = 'open';
|
8
|
+
it('can be opened via click', async () => {
|
9
|
+
await emulateMedia({ reducedMotion: 'reduce' });
|
10
|
+
const component = await fixture(html `<glide-core-accordion label="Label">Content</glide-core-accordion>`);
|
11
|
+
component.click();
|
12
|
+
expect(component.open).to.be.true;
|
13
|
+
});
|
14
|
+
it('can be opened via click when animated', async () => {
|
15
|
+
await emulateMedia({ reducedMotion: 'no-preference' });
|
16
|
+
const component = await fixture(html `<glide-core-accordion label="Label">Content</glide-core-accordion>`);
|
17
|
+
component.click();
|
18
|
+
let animation;
|
19
|
+
let isAnimationFinished = false;
|
20
|
+
await waitUntil(() => {
|
21
|
+
animation = component.shadowRoot
|
22
|
+
?.querySelector('[data-test="default-slot"]')
|
23
|
+
?.getAnimations()
|
24
|
+
?.at(0);
|
25
|
+
return animation;
|
26
|
+
});
|
27
|
+
animation?.addEventListener('finish', () => {
|
28
|
+
isAnimationFinished = true;
|
29
|
+
});
|
30
|
+
await waitUntil(() => isAnimationFinished);
|
31
|
+
expect(component.open).to.be.true;
|
32
|
+
});
|
33
|
+
it('can be opened via Space', async () => {
|
34
|
+
await emulateMedia({ reducedMotion: 'reduce' });
|
35
|
+
const component = await fixture(html `<glide-core-accordion label="Label">Content</glide-core-accordion>`);
|
36
|
+
component.focus();
|
37
|
+
await sendKeys({ press: ' ' });
|
38
|
+
expect(component.open).to.be.true;
|
39
|
+
});
|
40
|
+
it('can be opened via Enter', async () => {
|
41
|
+
await emulateMedia({ reducedMotion: 'reduce' });
|
42
|
+
const component = await fixture(html `<glide-core-accordion label="Label">Content</glide-core-accordion>`);
|
43
|
+
component.focus();
|
44
|
+
await sendKeys({ press: 'Enter' });
|
45
|
+
expect(component.open).to.be.true;
|
46
|
+
});
|
47
|
+
it('can be closed via click', async () => {
|
48
|
+
await emulateMedia({ reducedMotion: 'reduce' });
|
49
|
+
const component = await fixture(html `<glide-core-accordion label="Label" open>
|
50
|
+
Content
|
51
|
+
</glide-core-accordion>`);
|
52
|
+
component.click();
|
53
|
+
expect(component.open).to.be.false;
|
54
|
+
});
|
55
|
+
it('can be closed via click when animated', async () => {
|
56
|
+
await emulateMedia({ reducedMotion: 'no-preference' });
|
57
|
+
const component = await fixture(html `<glide-core-accordion label="Label" open>
|
58
|
+
Content
|
59
|
+
</glide-core-accordion>`);
|
60
|
+
component.click();
|
61
|
+
let animation;
|
62
|
+
let isAnimationFinished = false;
|
63
|
+
await waitUntil(() => {
|
64
|
+
animation = component.shadowRoot
|
65
|
+
?.querySelector('[data-test="default-slot"]')
|
66
|
+
?.getAnimations()
|
67
|
+
?.at(0);
|
68
|
+
return animation;
|
69
|
+
});
|
70
|
+
animation?.addEventListener('finish', () => {
|
71
|
+
isAnimationFinished = true;
|
72
|
+
});
|
73
|
+
await waitUntil(() => isAnimationFinished);
|
74
|
+
expect(component.open).to.be.false;
|
75
|
+
});
|
@@ -5,10 +5,8 @@ declare global {
|
|
5
5
|
}
|
6
6
|
}
|
7
7
|
/**
|
8
|
-
* @description A button with a label and optional icon for use in a `<glide-core-button-group>`.
|
9
|
-
*
|
10
8
|
* @slot - A label.
|
11
|
-
* @slot
|
9
|
+
* @slot icon - An optional icon before the label.
|
12
10
|
*/
|
13
11
|
export default class GlideCoreButtonGroupButton extends LitElement {
|
14
12
|
#private;
|
@@ -25,5 +23,5 @@ export default class GlideCoreButtonGroupButton extends LitElement {
|
|
25
23
|
firstUpdated(): void;
|
26
24
|
focus(options?: FocusOptions): void;
|
27
25
|
render(): import("lit").TemplateResult<1>;
|
28
|
-
private
|
26
|
+
private hasIcon;
|
29
27
|
}
|
@@ -1 +1 @@
|
|
1
|
-
var __decorate=this&&this.__decorate||function(e,
|
1
|
+
var __decorate=this&&this.__decorate||function(t,e,o,i){var r,l=arguments.length,n=l<3?e:null===i?i=Object.getOwnPropertyDescriptor(e,o):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)n=Reflect.decorate(t,e,o,i);else for(var s=t.length-1;s>=0;s--)(r=t[s])&&(n=(l<3?r(n):l>3?r(e,o,n):r(e,o))||n);return l>3&&n&&Object.defineProperty(e,o,n),n};import{LitElement,html}from"lit";import{classMap}from"lit/directives/class-map.js";import{createRef,ref}from"lit/directives/ref.js";import{customElement,property,state}from"lit/decorators.js";import ow,{owSlot}from"./library/ow.js";import styles from"./button-group.button.styles.js";let GlideCoreButtonGroupButton=class GlideCoreButtonGroupButton extends LitElement{constructor(){super(...arguments),this.label="",this.disabled=!1,this.value="",this.privateOrientation="horizontal",this.hasIcon=!1,this.#t=createRef(),this.#e=createRef(),this.#o=!1}static{this.shadowRootOptions={...LitElement.shadowRootOptions,mode:"closed"}}static{this.styles=styles}get selected(){return this.#o}set selected(t){this.#o=t,this.dispatchEvent(new Event("private-selected",{bubbles:!0}))}click(){this.#t.value?.click()}firstUpdated(){"icon-only"===this.privateVariant&&owSlot(this.#e.value)}focus(t){this.#t.value?.focus(t)}render(){return html`<div aria-checked="${this.selected}" aria-disabled="${this.disabled}" class="${classMap({component:!0,selected:this.selected,disabled:this.disabled,[this.privateOrientation]:!0,icon:this.hasIcon,"icon-only":"icon-only"===this.privateVariant})}" role="radio" tabindex="${!this.selected||this.disabled?-1:0}" ${ref(this.#t)}><slot name="icon" @slotchange="${this.#i}" ${ref(this.#e)}></slot><div class="${classMap({label:!0,"visually-hidden":"icon-only"===this.privateVariant})}">${this.label}</div></div>`}#t;#e;#o;#i(){ow(this.#e.value,ow.object.instanceOf(HTMLElement)),this.hasIcon=this.#e.value?.assignedNodes().length>0}};__decorate([property({reflect:!0})],GlideCoreButtonGroupButton.prototype,"label",void 0),__decorate([property({type:Boolean,reflect:!0})],GlideCoreButtonGroupButton.prototype,"selected",null),__decorate([property({type:Boolean,reflect:!0})],GlideCoreButtonGroupButton.prototype,"disabled",void 0),__decorate([property({reflect:!0})],GlideCoreButtonGroupButton.prototype,"value",void 0),__decorate([property()],GlideCoreButtonGroupButton.prototype,"privateOrientation",void 0),__decorate([property()],GlideCoreButtonGroupButton.prototype,"privateVariant",void 0),__decorate([state()],GlideCoreButtonGroupButton.prototype,"hasIcon",void 0),GlideCoreButtonGroupButton=__decorate([customElement("glide-core-button-group-button")],GlideCoreButtonGroupButton);export default GlideCoreButtonGroupButton;
|
@@ -70,7 +70,7 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";import
|
|
70
70
|
&.vertical {
|
71
71
|
border-block-end: 1px solid var(--glide-core-border-base-lighter);
|
72
72
|
|
73
|
-
&.
|
73
|
+
&.icon {
|
74
74
|
&:not(.icon-only) {
|
75
75
|
justify-content: flex-start;
|
76
76
|
}
|
@@ -90,12 +90,6 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";import
|
|
90
90
|
}
|
91
91
|
|
92
92
|
&:not(.disabled) {
|
93
|
-
&:active {
|
94
|
-
background-color: var(--glide-core-surface-selected);
|
95
|
-
border-color: var(--glide-core-border-focus);
|
96
|
-
color: var(--glide-core-color-white);
|
97
|
-
}
|
98
|
-
|
99
93
|
&.selected {
|
100
94
|
background-color: var(--glide-core-surface-selected);
|
101
95
|
border-color: var(--glide-core-surface-selected);
|
@@ -103,13 +97,11 @@ import{css}from"lit";import focusOutline from"./styles/focus-outline.js";import
|
|
103
97
|
}
|
104
98
|
}
|
105
99
|
|
106
|
-
&:not(.disabled, :
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
color: var(--glide-core-text-primary);
|
112
|
-
}
|
100
|
+
&:not(.disabled, .selected):hover {
|
101
|
+
background-color: var(--glide-core-surface-hover);
|
102
|
+
border-color: transparent;
|
103
|
+
box-shadow: var(--glide-core-glow-sm);
|
104
|
+
color: var(--glide-core-text-primary);
|
113
105
|
}
|
114
106
|
}
|
115
107
|
`];
|