@alleninstitute/cortex-ui 0.2.0 → 0.3.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 +52 -8
- package/dist/cjs/cortex-ui.cjs.js +3 -3
- package/dist/cjs/cui-divider.cjs.entry.js +49 -0
- package/dist/cjs/cui-icon.cjs.entry.js +100 -0
- package/dist/cjs/cui-progress.cjs.entry.js +4 -4
- package/dist/cjs/cui-tag.cjs.entry.js +4 -4
- package/dist/cjs/index-RBrlguTk.js +1565 -0
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/collection/collection-manifest.json +3 -1
- package/dist/collection/components/cui-divider/cui-divider.css +100 -0
- package/dist/collection/components/cui-divider/cui-divider.js +150 -0
- package/dist/collection/components/cui-icon/cui-icon.css +134 -0
- package/dist/collection/components/cui-icon/cui-icon.js +239 -0
- package/dist/collection/components/cui-progress/cui-progress.css +12 -12
- package/dist/collection/components/cui-progress/cui-progress.js +2 -2
- package/dist/collection/components/cui-tag/cui-tag.css +19 -19
- package/dist/collection/components/cui-tag/cui-tag.js +5 -5
- package/dist/components/cui-divider.d.ts +11 -0
- package/dist/components/cui-divider.js +1 -0
- package/dist/components/cui-icon.d.ts +11 -0
- package/dist/components/cui-icon.js +1 -0
- package/dist/components/cui-progress.js +1 -1
- package/dist/components/cui-tag.js +1 -1
- package/dist/components/index.js +1 -1
- package/dist/cortex-ui/cortex-ui.css +1 -1
- package/dist/cortex-ui/cortex-ui.esm.js +1 -1
- package/dist/cortex-ui/p-0e66a721.entry.js +1 -0
- package/dist/cortex-ui/p-1af73c5a.entry.js +1 -0
- package/dist/cortex-ui/p-2d2004f0.entry.js +1 -0
- package/dist/cortex-ui/p-8925abbe.entry.js +1 -0
- package/dist/cortex-ui/p-BZmInLSX.js +3 -0
- package/dist/esm/cortex-ui.js +4 -4
- package/dist/esm/cui-divider.entry.js +47 -0
- package/dist/esm/cui-icon.entry.js +98 -0
- package/dist/esm/cui-progress.entry.js +4 -4
- package/dist/esm/cui-tag.entry.js +4 -4
- package/dist/esm/index-BZmInLSX.js +1557 -0
- package/dist/esm/loader.js +3 -3
- package/dist/fonts/AllenInstituteHeadline-Bold.woff2 +0 -0
- package/dist/fonts/AllenInstituteHeadline-BoldItalic.woff2 +0 -0
- package/dist/fonts/AllenInstituteHeadline-Italic.woff2 +0 -0
- package/dist/fonts/AllenInstituteHeadline-Light.woff2 +0 -0
- package/dist/fonts/AllenInstituteHeadline-LightItalic.woff2 +0 -0
- package/dist/fonts/AllenInstituteHeadline-Medium.woff2 +0 -0
- package/dist/fonts/AllenInstituteHeadline-MediumItalic.woff2 +0 -0
- package/dist/fonts/AllenInstituteHeadline-Regular.woff2 +0 -0
- package/dist/fonts/AllenInstituteHeadline-Semibold.woff2 +0 -0
- package/dist/fonts/AllenInstituteHeadline-SemiboldItalic.woff2 +0 -0
- package/dist/fonts/AllenInstituteText-Bold.woff2 +0 -0
- package/dist/fonts/AllenInstituteText-BoldItalic.woff2 +0 -0
- package/dist/fonts/AllenInstituteText-Italic.woff2 +0 -0
- package/dist/fonts/AllenInstituteText-Light.woff2 +0 -0
- package/dist/fonts/AllenInstituteText-LightItalic.woff2 +0 -0
- package/dist/fonts/AllenInstituteText-Medium.woff2 +0 -0
- package/dist/fonts/AllenInstituteText-MediumItalic.woff2 +0 -0
- package/dist/fonts/AllenInstituteText-Regular.woff2 +0 -0
- package/dist/fonts/AllenInstituteText-Semibold.woff2 +0 -0
- package/dist/fonts/AllenInstituteText-SemiboldItalic.woff2 +0 -0
- package/dist/fonts.css +186 -0
- package/dist/types/components/cui-divider/cui-divider.d.ts +38 -0
- package/dist/types/components/cui-icon/cui-icon.d.ts +76 -0
- package/dist/types/components/cui-tag/cui-tag.d.ts +1 -1
- package/dist/types/components.d.ts +235 -6
- package/dist/types/stencil-public-runtime.d.ts +11 -0
- package/package.json +31 -22
- package/dist/cjs/index-CJFDVa2g.js +0 -1415
- package/dist/collection/stories/assets/accessibility.svg +0 -1
- package/dist/collection/stories/assets/discord.svg +0 -1
- package/dist/collection/stories/assets/github.svg +0 -1
- package/dist/collection/stories/assets/tutorials.svg +0 -1
- package/dist/collection/stories/assets/youtube.svg +0 -1
- package/dist/cortex-ui/p-371566cd.entry.js +0 -1
- package/dist/cortex-ui/p-60c5b038.entry.js +0 -1
- package/dist/cortex-ui/p-DbXnQj5f.js +0 -2
- package/dist/esm/index-DbXnQj5f.js +0 -1408
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var index = require('./index-
|
|
3
|
+
var index = require('./index-RBrlguTk.js');
|
|
4
4
|
|
|
5
5
|
const defineCustomElements = async (win, options) => {
|
|
6
6
|
if (typeof window === 'undefined') return undefined;
|
|
7
7
|
await index.globalScripts();
|
|
8
|
-
return index.bootstrapLazy([["cui-progress.cjs",[[1,"cui-progress",{"label":[1],"value":[2],"max":[2],"indeterminate":[4],"size":[1],"showValue":[4,"show-value"]}]]],["cui-tag.cjs",[[1,"cui-tag",{"label":[1],"variant":[1],"size":[1]}]]]], options);
|
|
8
|
+
return index.bootstrapLazy([["cui-divider.cjs",[[1,"cui-divider",{"orientation":[513],"spacing":[513],"variant":[1],"importance":[1]}]]],["cui-icon.cjs",[[257,"cui-icon",{"icon":[1],"variant":[1],"importance":[1],"size":[1],"label":[1]},null,{"icon":[{"onIconChange":0}],"label":[{"onLabelChange":0}]}]]],["cui-progress.cjs",[[1,"cui-progress",{"label":[1],"value":[2],"max":[2],"indeterminate":[4],"size":[1],"showValue":[4,"show-value"]}]]],["cui-tag.cjs",[[1,"cui-tag",{"label":[1],"variant":[1],"size":[1]}]]]], options);
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
exports.setNonce = index.setNonce;
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"entries": [
|
|
3
|
+
"components/cui-divider/cui-divider.js",
|
|
4
|
+
"components/cui-icon/cui-icon.js",
|
|
3
5
|
"components/cui-progress/cui-progress.js",
|
|
4
6
|
"components/cui-tag/cui-tag.js"
|
|
5
7
|
],
|
|
6
8
|
"mixins": [],
|
|
7
9
|
"compiler": {
|
|
8
10
|
"name": "@stencil/core",
|
|
9
|
-
"version": "4.
|
|
11
|
+
"version": "4.44.0",
|
|
10
12
|
"typescriptVersion": "5.8.3"
|
|
11
13
|
},
|
|
12
14
|
"collections": [],
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: block;
|
|
3
|
+
--cui-divider-gap: var(--cui-spacing-m);
|
|
4
|
+
margin-block: var(--cui-divider-gap);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
:host([hidden]) {
|
|
8
|
+
display: none;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
:host([spacing=none]) {
|
|
12
|
+
--cui-divider-gap: 0;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
:host([spacing=small]) {
|
|
16
|
+
--cui-divider-gap: var(--cui-spacing-s);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
:host([spacing=large]) {
|
|
20
|
+
--cui-divider-gap: var(--cui-spacing-l);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
:host([orientation=vertical]) {
|
|
24
|
+
display: inline-flex;
|
|
25
|
+
align-self: stretch;
|
|
26
|
+
min-height: var(--cui-spacing-l);
|
|
27
|
+
margin-block: 0;
|
|
28
|
+
margin-inline: var(--cui-divider-gap);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.cui-divider {
|
|
32
|
+
box-sizing: border-box;
|
|
33
|
+
margin: 0;
|
|
34
|
+
border: none;
|
|
35
|
+
}
|
|
36
|
+
.cui-divider--horizontal {
|
|
37
|
+
width: 100%;
|
|
38
|
+
height: var(--cui-border-width-s);
|
|
39
|
+
}
|
|
40
|
+
.cui-divider--vertical {
|
|
41
|
+
width: var(--cui-border-width-s);
|
|
42
|
+
height: auto;
|
|
43
|
+
align-self: stretch;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
.cui-divider--base {
|
|
47
|
+
background-color: var(--cui-base-divider-primary);
|
|
48
|
+
}
|
|
49
|
+
.cui-divider--base.cui-divider--secondary {
|
|
50
|
+
background-color: var(--cui-base-divider-secondary);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.cui-divider--accent {
|
|
54
|
+
background-color: var(--cui-accent-divider-primary-default);
|
|
55
|
+
}
|
|
56
|
+
.cui-divider--accent.cui-divider--secondary {
|
|
57
|
+
background-color: var(--cui-accent-divider-secondary-default);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.cui-divider--highlight {
|
|
61
|
+
background-color: var(--cui-highlight-divider-primary-default);
|
|
62
|
+
}
|
|
63
|
+
.cui-divider--highlight.cui-divider--secondary {
|
|
64
|
+
background-color: var(--cui-highlight-divider-secondary-default);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.cui-divider--info {
|
|
68
|
+
background-color: var(--cui-info-divider-primary-default);
|
|
69
|
+
}
|
|
70
|
+
.cui-divider--info.cui-divider--secondary {
|
|
71
|
+
background-color: var(--cui-info-divider-secondary-default);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.cui-divider--negative {
|
|
75
|
+
background-color: var(--cui-negative-divider-primary-default);
|
|
76
|
+
}
|
|
77
|
+
.cui-divider--negative.cui-divider--secondary {
|
|
78
|
+
background-color: var(--cui-negative-divider-secondary-default);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
.cui-divider--neutral {
|
|
82
|
+
background-color: var(--cui-neutral-divider-primary-default);
|
|
83
|
+
}
|
|
84
|
+
.cui-divider--neutral.cui-divider--secondary {
|
|
85
|
+
background-color: var(--cui-neutral-divider-secondary-default);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.cui-divider--positive {
|
|
89
|
+
background-color: var(--cui-positive-divider-primary-default);
|
|
90
|
+
}
|
|
91
|
+
.cui-divider--positive.cui-divider--secondary {
|
|
92
|
+
background-color: var(--cui-positive-divider-secondary-default);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.cui-divider--warning {
|
|
96
|
+
background-color: var(--cui-warning-divider-primary-default);
|
|
97
|
+
}
|
|
98
|
+
.cui-divider--warning.cui-divider--secondary {
|
|
99
|
+
background-color: var(--cui-warning-divider-secondary-default);
|
|
100
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { h } from "@stencil/core";
|
|
2
|
+
/**
|
|
3
|
+
* A Divider drawing a rule between sections of content, or between items in a row.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* <cui-divider></cui-divider>
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* <cui-divider orientation="vertical" spacing="small"></cui-divider>
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* <cui-divider variant="accent" importance="secondary"></cui-divider>
|
|
13
|
+
*
|
|
14
|
+
* @part base - The rule itself, for consumer-side style overrides.
|
|
15
|
+
*/
|
|
16
|
+
export class CuiDivider {
|
|
17
|
+
constructor() {
|
|
18
|
+
// `orientation` and `spacing` are reflected because they size and space the host's own
|
|
19
|
+
// box, and only an attribute can reach `:host()` from the stylesheet. `variant` and
|
|
20
|
+
// `importance` are not: they only colour the rule, which the modifier classes handle.
|
|
21
|
+
/**
|
|
22
|
+
* Which way the rule runs. A vertical divider stretches to the height of the flex row
|
|
23
|
+
* it sits in.
|
|
24
|
+
*/
|
|
25
|
+
this.orientation = 'horizontal';
|
|
26
|
+
/** Space reserved on either side of the rule, along the axis it separates. */
|
|
27
|
+
this.spacing = 'medium';
|
|
28
|
+
/**
|
|
29
|
+
* Which intent's `divider` colour the rule is drawn in. `base` is the intent-free rule for
|
|
30
|
+
* ordinary page chrome; the seven intents tint a divider that sits inside a component
|
|
31
|
+
* already carrying that intent, such as a rule between rows of a negative-intent alert.
|
|
32
|
+
*/
|
|
33
|
+
this.variant = 'base';
|
|
34
|
+
/**
|
|
35
|
+
* Which of the two `divider` importances the rule is drawn from. Match it to the importance of
|
|
36
|
+
* the surface the divider sits on — `secondary` on a quiet tint, `primary` on a saturated fill —
|
|
37
|
+
* rather than treating it as a loudness control: on a secondary surface the primary rule is the
|
|
38
|
+
* *less* perceivable of the two. For `base`, whose surface is the page itself, `primary` is
|
|
39
|
+
* simply the stronger of the two rules.
|
|
40
|
+
*/
|
|
41
|
+
this.importance = 'primary';
|
|
42
|
+
}
|
|
43
|
+
render() {
|
|
44
|
+
return (
|
|
45
|
+
// A native <hr> carries the separator role to assistive technology for free, and
|
|
46
|
+
// is the one element that means "boundary" rather than "a box that looks like one".
|
|
47
|
+
h("hr", { key: 'd33f3260a5f708f379428a7d338e6329248f23ff', part: "base", class: {
|
|
48
|
+
'cui-divider': true,
|
|
49
|
+
[`cui-divider--${this.orientation}`]: true,
|
|
50
|
+
[`cui-divider--${this.variant}`]: true,
|
|
51
|
+
[`cui-divider--${this.importance}`]: true,
|
|
52
|
+
}, "aria-orientation": this.orientation === 'vertical' ? 'vertical' : undefined }));
|
|
53
|
+
}
|
|
54
|
+
static get is() { return "cui-divider"; }
|
|
55
|
+
static get encapsulation() { return "shadow"; }
|
|
56
|
+
static get originalStyleUrls() {
|
|
57
|
+
return {
|
|
58
|
+
"$": ["cui-divider.scss"]
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
static get styleUrls() {
|
|
62
|
+
return {
|
|
63
|
+
"$": ["cui-divider.css"]
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
static get properties() {
|
|
67
|
+
return {
|
|
68
|
+
"orientation": {
|
|
69
|
+
"type": "string",
|
|
70
|
+
"mutable": false,
|
|
71
|
+
"complexType": {
|
|
72
|
+
"original": "'horizontal' | 'vertical'",
|
|
73
|
+
"resolved": "\"horizontal\" | \"vertical\"",
|
|
74
|
+
"references": {}
|
|
75
|
+
},
|
|
76
|
+
"required": false,
|
|
77
|
+
"optional": false,
|
|
78
|
+
"docs": {
|
|
79
|
+
"tags": [],
|
|
80
|
+
"text": "Which way the rule runs. A vertical divider stretches to the height of the flex row\nit sits in."
|
|
81
|
+
},
|
|
82
|
+
"getter": false,
|
|
83
|
+
"setter": false,
|
|
84
|
+
"reflect": true,
|
|
85
|
+
"attribute": "orientation",
|
|
86
|
+
"defaultValue": "'horizontal'"
|
|
87
|
+
},
|
|
88
|
+
"spacing": {
|
|
89
|
+
"type": "string",
|
|
90
|
+
"mutable": false,
|
|
91
|
+
"complexType": {
|
|
92
|
+
"original": "'none' | 'small' | 'medium' | 'large'",
|
|
93
|
+
"resolved": "\"large\" | \"medium\" | \"none\" | \"small\"",
|
|
94
|
+
"references": {}
|
|
95
|
+
},
|
|
96
|
+
"required": false,
|
|
97
|
+
"optional": false,
|
|
98
|
+
"docs": {
|
|
99
|
+
"tags": [],
|
|
100
|
+
"text": "Space reserved on either side of the rule, along the axis it separates."
|
|
101
|
+
},
|
|
102
|
+
"getter": false,
|
|
103
|
+
"setter": false,
|
|
104
|
+
"reflect": true,
|
|
105
|
+
"attribute": "spacing",
|
|
106
|
+
"defaultValue": "'medium'"
|
|
107
|
+
},
|
|
108
|
+
"variant": {
|
|
109
|
+
"type": "string",
|
|
110
|
+
"mutable": false,
|
|
111
|
+
"complexType": {
|
|
112
|
+
"original": "'base' | 'accent' | 'highlight' | 'info' | 'negative' | 'neutral' | 'positive' | 'warning'",
|
|
113
|
+
"resolved": "\"accent\" | \"base\" | \"highlight\" | \"info\" | \"negative\" | \"neutral\" | \"positive\" | \"warning\"",
|
|
114
|
+
"references": {}
|
|
115
|
+
},
|
|
116
|
+
"required": false,
|
|
117
|
+
"optional": false,
|
|
118
|
+
"docs": {
|
|
119
|
+
"tags": [],
|
|
120
|
+
"text": "Which intent's `divider` colour the rule is drawn in. `base` is the intent-free rule for\nordinary page chrome; the seven intents tint a divider that sits inside a component\nalready carrying that intent, such as a rule between rows of a negative-intent alert."
|
|
121
|
+
},
|
|
122
|
+
"getter": false,
|
|
123
|
+
"setter": false,
|
|
124
|
+
"reflect": false,
|
|
125
|
+
"attribute": "variant",
|
|
126
|
+
"defaultValue": "'base'"
|
|
127
|
+
},
|
|
128
|
+
"importance": {
|
|
129
|
+
"type": "string",
|
|
130
|
+
"mutable": false,
|
|
131
|
+
"complexType": {
|
|
132
|
+
"original": "'primary' | 'secondary'",
|
|
133
|
+
"resolved": "\"primary\" | \"secondary\"",
|
|
134
|
+
"references": {}
|
|
135
|
+
},
|
|
136
|
+
"required": false,
|
|
137
|
+
"optional": false,
|
|
138
|
+
"docs": {
|
|
139
|
+
"tags": [],
|
|
140
|
+
"text": "Which of the two `divider` importances the rule is drawn from. Match it to the importance of\nthe surface the divider sits on \u2014 `secondary` on a quiet tint, `primary` on a saturated fill \u2014\nrather than treating it as a loudness control: on a secondary surface the primary rule is the\n*less* perceivable of the two. For `base`, whose surface is the page itself, `primary` is\nsimply the stronger of the two rules."
|
|
141
|
+
},
|
|
142
|
+
"getter": false,
|
|
143
|
+
"setter": false,
|
|
144
|
+
"reflect": false,
|
|
145
|
+
"attribute": "importance",
|
|
146
|
+
"defaultValue": "'primary'"
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
@charset "UTF-8";
|
|
2
|
+
/**
|
|
3
|
+
* Stencil reads the documented custom properties out of the stylesheet, not out of the
|
|
4
|
+
* component's JSDoc, so these are what reach readme.md and the generated AI docs.
|
|
5
|
+
*
|
|
6
|
+
* Unlike cui-progress, these are deliberately *not* declared with a default on :host — the
|
|
7
|
+
* default differs per variant and size, so each rule below passes its token as the var()
|
|
8
|
+
* fallback instead. That already lets a consumer's value win, without a specificity fight.
|
|
9
|
+
*
|
|
10
|
+
* @prop --cui-icon-color: Overrides the colour chosen by `variant` and `importance`. Set it to `currentColor` to make the icon follow the surrounding text colour.
|
|
11
|
+
* @prop --cui-icon-size: Overrides the size chosen by `size`.
|
|
12
|
+
*/
|
|
13
|
+
:host {
|
|
14
|
+
display: inline-flex;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
:host([hidden]) {
|
|
18
|
+
display: none;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.cui-icon {
|
|
22
|
+
display: inline-flex;
|
|
23
|
+
align-items: center;
|
|
24
|
+
justify-content: center;
|
|
25
|
+
line-height: 1;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
::slotted(:not([data-cui-icon-glyph])) {
|
|
29
|
+
display: none;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
.cui-icon--xxs {
|
|
33
|
+
font-size: var(--cui-icon-size, var(--cui-font-size-xxs));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
.cui-icon--xs {
|
|
37
|
+
font-size: var(--cui-icon-size, var(--cui-font-size-xs));
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.cui-icon--s {
|
|
41
|
+
font-size: var(--cui-icon-size, var(--cui-font-size-s));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
.cui-icon--m {
|
|
45
|
+
font-size: var(--cui-icon-size, var(--cui-font-size-m));
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
.cui-icon--l {
|
|
49
|
+
font-size: var(--cui-icon-size, var(--cui-font-size-l));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.cui-icon--xl {
|
|
53
|
+
font-size: var(--cui-icon-size, var(--cui-font-size-xl));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.cui-icon--xxl {
|
|
57
|
+
font-size: var(--cui-icon-size, var(--cui-font-size-xxl));
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.cui-icon--display-s {
|
|
61
|
+
font-size: var(--cui-icon-size, var(--cui-font-size-display-s));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
.cui-icon--display-m {
|
|
65
|
+
font-size: var(--cui-icon-size, var(--cui-font-size-display-m));
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
.cui-icon--display-l {
|
|
69
|
+
font-size: var(--cui-icon-size, var(--cui-font-size-display-l));
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
.cui-icon--base.cui-icon--primary {
|
|
73
|
+
color: var(--cui-icon-color, var(--cui-base-text-primary));
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
.cui-icon--base.cui-icon--secondary {
|
|
77
|
+
color: var(--cui-icon-color, var(--cui-base-text-secondary));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
.cui-icon--accent.cui-icon--primary {
|
|
81
|
+
color: var(--cui-icon-color, var(--cui-accent-text-primary-default));
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
.cui-icon--accent.cui-icon--secondary {
|
|
85
|
+
color: var(--cui-icon-color, var(--cui-accent-text-secondary-default));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
.cui-icon--highlight.cui-icon--primary {
|
|
89
|
+
color: var(--cui-icon-color, var(--cui-highlight-text-primary-default));
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
.cui-icon--highlight.cui-icon--secondary {
|
|
93
|
+
color: var(--cui-icon-color, var(--cui-highlight-text-secondary-default));
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
.cui-icon--info.cui-icon--primary {
|
|
97
|
+
color: var(--cui-icon-color, var(--cui-info-text-primary-default));
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
.cui-icon--info.cui-icon--secondary {
|
|
101
|
+
color: var(--cui-icon-color, var(--cui-info-text-secondary-default));
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
.cui-icon--negative.cui-icon--primary {
|
|
105
|
+
color: var(--cui-icon-color, var(--cui-negative-text-primary-default));
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
.cui-icon--negative.cui-icon--secondary {
|
|
109
|
+
color: var(--cui-icon-color, var(--cui-negative-text-secondary-default));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
.cui-icon--neutral.cui-icon--primary {
|
|
113
|
+
color: var(--cui-icon-color, var(--cui-neutral-text-primary-default));
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
.cui-icon--neutral.cui-icon--secondary {
|
|
117
|
+
color: var(--cui-icon-color, var(--cui-neutral-text-secondary-default));
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
.cui-icon--positive.cui-icon--primary {
|
|
121
|
+
color: var(--cui-icon-color, var(--cui-positive-text-primary-default));
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
.cui-icon--positive.cui-icon--secondary {
|
|
125
|
+
color: var(--cui-icon-color, var(--cui-positive-text-secondary-default));
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
.cui-icon--warning.cui-icon--primary {
|
|
129
|
+
color: var(--cui-icon-color, var(--cui-warning-text-primary-default));
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
.cui-icon--warning.cui-icon--secondary {
|
|
133
|
+
color: var(--cui-icon-color, var(--cui-warning-text-secondary-default));
|
|
134
|
+
}
|
|
@@ -0,0 +1,239 @@
|
|
|
1
|
+
import { h } from "@stencil/core";
|
|
2
|
+
/**
|
|
3
|
+
* An Icon component that renders a Font Awesome glyph with cortex-ui's semantic colours and sizes.
|
|
4
|
+
*
|
|
5
|
+
* Font Awesome itself is **not** bundled — the consuming application loads a Font Awesome
|
|
6
|
+
* stylesheet (the free set, or a licensed pro build) and `icon` takes the raw Font Awesome
|
|
7
|
+
* classes. Any Font Awesome utility class can be passed along in the same string, so
|
|
8
|
+
* `icon="fa-solid fa-spinner fa-spin"` works without this component knowing about `fa-spin`.
|
|
9
|
+
*
|
|
10
|
+
* Loading that stylesheet is the human application owner's responsibility, never an agent's: an AI
|
|
11
|
+
* agent writing `cui-icon` markup must not install a Font Awesome package, add the stylesheet to
|
|
12
|
+
* the page, or invent a Pro Kit URL — it should write the markup and tell the person their page
|
|
13
|
+
* needs Font Awesome. Icons rendering as empty boxes in a page with no Font Awesome is the
|
|
14
|
+
* expected result, not a bug to code around.
|
|
15
|
+
*
|
|
16
|
+
* Icons are decorative by default and hidden from assistive technology. Set `label` only when the
|
|
17
|
+
* icon carries meaning that the surrounding text does not already convey.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* <cui-icon icon="fa-solid fa-user"></cui-icon>
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* <cui-icon icon="fa-solid fa-triangle-exclamation" variant="warning" size="l"></cui-icon>
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* <cui-icon icon="fa-solid fa-trash" label="Delete item"></cui-icon>
|
|
27
|
+
*
|
|
28
|
+
* @slot - The glyph element. This component creates and owns it, so do not place your own
|
|
29
|
+
* content in `cui-icon` — anything else you slot here is hidden.
|
|
30
|
+
* @part base - The root element, for consumer-side style overrides.
|
|
31
|
+
* @cssprop --cui-icon-color - Overrides the colour chosen by `variant` and `importance`. Set it to
|
|
32
|
+
* `currentColor` to make the icon follow the text colour of whatever surrounds it.
|
|
33
|
+
* @cssprop --cui-icon-size - Overrides the size chosen by `size`.
|
|
34
|
+
*/
|
|
35
|
+
export class CuiIcon {
|
|
36
|
+
constructor() {
|
|
37
|
+
/**
|
|
38
|
+
* Semantic colour set. `base` is the intent-free choice for ordinary content and is correct on
|
|
39
|
+
* a plain page background; the intents are for an icon that sits on that intent's surface.
|
|
40
|
+
* This is styling, not semantics — never let colour be the only thing conveying meaning.
|
|
41
|
+
*/
|
|
42
|
+
this.variant = 'base';
|
|
43
|
+
/**
|
|
44
|
+
* Which rung of the `text` token family to use. It tracks the surface the icon sits on:
|
|
45
|
+
* `primary` belongs on that variant's primary surface, `secondary` on its secondary surface or
|
|
46
|
+
* on a plain background. Pairing an intent's `primary` text with a plain page background is
|
|
47
|
+
* outside the token system's design and will not be legible.
|
|
48
|
+
*/
|
|
49
|
+
this.importance = 'secondary';
|
|
50
|
+
/** Size of the glyph, from the font-size token scale. */
|
|
51
|
+
this.size = 'm';
|
|
52
|
+
}
|
|
53
|
+
connectedCallback() {
|
|
54
|
+
// Both the glyph and the host's ARIA are applied here rather than from render(): the
|
|
55
|
+
// glyph has to live in the light DOM for the consumer's document-level Font Awesome CSS
|
|
56
|
+
// to match it (selectors do not cross a shadow boundary, though @font-face and custom
|
|
57
|
+
// properties do), and setting the host's ARIA imperatively keeps it out of reach of the
|
|
58
|
+
// vdom, which on first render would otherwise overwrite a <Host> attribute with the
|
|
59
|
+
// same-named host *property* whenever a consumer also wrote that attribute in markup.
|
|
60
|
+
this.syncGlyph();
|
|
61
|
+
this.syncAria();
|
|
62
|
+
}
|
|
63
|
+
onIconChange() {
|
|
64
|
+
this.syncGlyph();
|
|
65
|
+
}
|
|
66
|
+
onLabelChange() {
|
|
67
|
+
this.syncAria();
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Creates or updates the light-DOM glyph. Queries rather than caching a node reference, so it
|
|
71
|
+
* is idempotent: connectedCallback fires again every time the host is moved in the DOM, and a
|
|
72
|
+
* cached reference can also go stale (see below).
|
|
73
|
+
*/
|
|
74
|
+
syncGlyph() {
|
|
75
|
+
var _a;
|
|
76
|
+
const existing = this.el.querySelector(':scope > [data-cui-icon-glyph]');
|
|
77
|
+
// Font Awesome's SVG-and-JS build rewrites our <i> into an <svg> that it owns, and
|
|
78
|
+
// rebuilds the class list while doing so. Rewriting that node's classes would do nothing,
|
|
79
|
+
// so drop it and let Font Awesome convert a fresh <i> instead.
|
|
80
|
+
if (existing && existing.tagName !== 'I') {
|
|
81
|
+
existing.remove();
|
|
82
|
+
}
|
|
83
|
+
let glyph = this.el.querySelector(':scope > i[data-cui-icon-glyph]');
|
|
84
|
+
if (!glyph) {
|
|
85
|
+
glyph = document.createElement('i');
|
|
86
|
+
glyph.setAttribute('data-cui-icon-glyph', '');
|
|
87
|
+
// The glyph is always hidden in its own right; the host carries the accessible name.
|
|
88
|
+
glyph.setAttribute('aria-hidden', 'true');
|
|
89
|
+
this.el.appendChild(glyph);
|
|
90
|
+
}
|
|
91
|
+
glyph.className = (_a = this.icon) !== null && _a !== void 0 ? _a : '';
|
|
92
|
+
}
|
|
93
|
+
/** An icon is either named or hidden — never both, and never named with an empty string. */
|
|
94
|
+
syncAria() {
|
|
95
|
+
var _a;
|
|
96
|
+
const name = (_a = this.label) === null || _a === void 0 ? void 0 : _a.trim();
|
|
97
|
+
if (name) {
|
|
98
|
+
this.el.setAttribute('role', 'img');
|
|
99
|
+
this.el.setAttribute('aria-label', name);
|
|
100
|
+
this.el.removeAttribute('aria-hidden');
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
this.el.setAttribute('aria-hidden', 'true');
|
|
104
|
+
this.el.removeAttribute('role');
|
|
105
|
+
this.el.removeAttribute('aria-label');
|
|
106
|
+
}
|
|
107
|
+
render() {
|
|
108
|
+
return (h("span", { key: '76b54ef28027419bfbb5500c5cf4a88a7d01131e', part: "base", class: {
|
|
109
|
+
'cui-icon': true,
|
|
110
|
+
[`cui-icon--${this.variant}`]: true,
|
|
111
|
+
[`cui-icon--${this.importance}`]: true,
|
|
112
|
+
[`cui-icon--${this.size}`]: true,
|
|
113
|
+
} }, h("slot", { key: '8c4d13ffa3b1cfe3e4d7d47c29127784d62381ff' })));
|
|
114
|
+
}
|
|
115
|
+
static get is() { return "cui-icon"; }
|
|
116
|
+
static get encapsulation() { return "shadow"; }
|
|
117
|
+
static get originalStyleUrls() {
|
|
118
|
+
return {
|
|
119
|
+
"$": ["cui-icon.scss"]
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
static get styleUrls() {
|
|
123
|
+
return {
|
|
124
|
+
"$": ["cui-icon.css"]
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
static get properties() {
|
|
128
|
+
return {
|
|
129
|
+
"icon": {
|
|
130
|
+
"type": "string",
|
|
131
|
+
"mutable": false,
|
|
132
|
+
"complexType": {
|
|
133
|
+
"original": "string",
|
|
134
|
+
"resolved": "string",
|
|
135
|
+
"references": {}
|
|
136
|
+
},
|
|
137
|
+
"required": true,
|
|
138
|
+
"optional": false,
|
|
139
|
+
"docs": {
|
|
140
|
+
"tags": [],
|
|
141
|
+
"text": "The Font Awesome classes naming the icon, e.g. `fa-solid fa-user`. The style is part of the\nstring, so `fa-regular`, `fa-brands` and licensed pro styles like `fa-duotone` all work.\nRequired \u2014 there is no sensible fallback glyph."
|
|
142
|
+
},
|
|
143
|
+
"getter": false,
|
|
144
|
+
"setter": false,
|
|
145
|
+
"reflect": false,
|
|
146
|
+
"attribute": "icon"
|
|
147
|
+
},
|
|
148
|
+
"variant": {
|
|
149
|
+
"type": "string",
|
|
150
|
+
"mutable": false,
|
|
151
|
+
"complexType": {
|
|
152
|
+
"original": "'accent' | 'base' | 'highlight' | 'info' | 'negative' | 'neutral' | 'positive' | 'warning'",
|
|
153
|
+
"resolved": "\"accent\" | \"base\" | \"highlight\" | \"info\" | \"negative\" | \"neutral\" | \"positive\" | \"warning\"",
|
|
154
|
+
"references": {}
|
|
155
|
+
},
|
|
156
|
+
"required": false,
|
|
157
|
+
"optional": false,
|
|
158
|
+
"docs": {
|
|
159
|
+
"tags": [],
|
|
160
|
+
"text": "Semantic colour set. `base` is the intent-free choice for ordinary content and is correct on\na plain page background; the intents are for an icon that sits on that intent's surface.\nThis is styling, not semantics \u2014 never let colour be the only thing conveying meaning."
|
|
161
|
+
},
|
|
162
|
+
"getter": false,
|
|
163
|
+
"setter": false,
|
|
164
|
+
"reflect": false,
|
|
165
|
+
"attribute": "variant",
|
|
166
|
+
"defaultValue": "'base'"
|
|
167
|
+
},
|
|
168
|
+
"importance": {
|
|
169
|
+
"type": "string",
|
|
170
|
+
"mutable": false,
|
|
171
|
+
"complexType": {
|
|
172
|
+
"original": "'primary' | 'secondary'",
|
|
173
|
+
"resolved": "\"primary\" | \"secondary\"",
|
|
174
|
+
"references": {}
|
|
175
|
+
},
|
|
176
|
+
"required": false,
|
|
177
|
+
"optional": false,
|
|
178
|
+
"docs": {
|
|
179
|
+
"tags": [],
|
|
180
|
+
"text": "Which rung of the `text` token family to use. It tracks the surface the icon sits on:\n`primary` belongs on that variant's primary surface, `secondary` on its secondary surface or\non a plain background. Pairing an intent's `primary` text with a plain page background is\noutside the token system's design and will not be legible."
|
|
181
|
+
},
|
|
182
|
+
"getter": false,
|
|
183
|
+
"setter": false,
|
|
184
|
+
"reflect": false,
|
|
185
|
+
"attribute": "importance",
|
|
186
|
+
"defaultValue": "'secondary'"
|
|
187
|
+
},
|
|
188
|
+
"size": {
|
|
189
|
+
"type": "string",
|
|
190
|
+
"mutable": false,
|
|
191
|
+
"complexType": {
|
|
192
|
+
"original": "'display-l' | 'display-m' | 'display-s' | 'l' | 'm' | 's' | 'xl' | 'xs' | 'xxl' | 'xxs'",
|
|
193
|
+
"resolved": "\"display-l\" | \"display-m\" | \"display-s\" | \"l\" | \"m\" | \"s\" | \"xl\" | \"xs\" | \"xxl\" | \"xxs\"",
|
|
194
|
+
"references": {}
|
|
195
|
+
},
|
|
196
|
+
"required": false,
|
|
197
|
+
"optional": false,
|
|
198
|
+
"docs": {
|
|
199
|
+
"tags": [],
|
|
200
|
+
"text": "Size of the glyph, from the font-size token scale."
|
|
201
|
+
},
|
|
202
|
+
"getter": false,
|
|
203
|
+
"setter": false,
|
|
204
|
+
"reflect": false,
|
|
205
|
+
"attribute": "size",
|
|
206
|
+
"defaultValue": "'m'"
|
|
207
|
+
},
|
|
208
|
+
"label": {
|
|
209
|
+
"type": "string",
|
|
210
|
+
"mutable": false,
|
|
211
|
+
"complexType": {
|
|
212
|
+
"original": "string",
|
|
213
|
+
"resolved": "string | undefined",
|
|
214
|
+
"references": {}
|
|
215
|
+
},
|
|
216
|
+
"required": false,
|
|
217
|
+
"optional": true,
|
|
218
|
+
"docs": {
|
|
219
|
+
"tags": [],
|
|
220
|
+
"text": "Accessible name, for an icon that carries meaning on its own \u2014 an icon-only button, or a\nstatus glyph with no adjacent text. Leave it unset for a decorative icon beside text, which\nis the common case; the icon is then hidden from assistive technology so screen readers do\nnot announce it twice."
|
|
221
|
+
},
|
|
222
|
+
"getter": false,
|
|
223
|
+
"setter": false,
|
|
224
|
+
"reflect": false,
|
|
225
|
+
"attribute": "label"
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
static get elementRef() { return "el"; }
|
|
230
|
+
static get watchers() {
|
|
231
|
+
return [{
|
|
232
|
+
"propName": "icon",
|
|
233
|
+
"methodName": "onIconChange"
|
|
234
|
+
}, {
|
|
235
|
+
"propName": "label",
|
|
236
|
+
"methodName": "onLabelChange"
|
|
237
|
+
}];
|
|
238
|
+
}
|
|
239
|
+
}
|