@nuralyui/icon 0.0.6 → 0.0.8

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.
@@ -3,24 +3,57 @@
3
3
  * Copyright 2023 Nuraly Laabidi Aymen
4
4
  * SPDX-License-Identifier: MIT
5
5
  */
6
- /// <reference types="react" />
7
6
  import { LitElement } from 'lit';
8
7
  import { IconTypes } from './icon.types.js';
9
- export declare class HyIconElement extends LitElement {
8
+ /**
9
+ * Enhanced Icon component with clickable functionality, custom styling, and comprehensive theming
10
+ *
11
+ * @example
12
+ * ```html
13
+ * <nr-icon name="envelope"></nr-icon>
14
+ * <nr-icon name="check" clickable @icon-click="${this.handleIconClick}"></nr-icon>
15
+ * <nr-icon name="warning" type="regular" disabled></nr-icon>
16
+ * <nr-icon name="star" color="#ffd700" size="large"></nr-icon>
17
+ * ```
18
+ *
19
+ * @fires icon-click - Dispatched when icon is clicked (contains iconName, iconType, originalEvent, timestamp)
20
+ * @fires icon-keyboard-activation - Dispatched when icon is activated via keyboard (contains iconName, iconType, key, originalEvent, timestamp)
21
+ */
22
+ declare const IconBaseMixin: (new (...args: any[]) => import("./mixins/clickable-mixin.js").ClickableCapable) & (new (...args: any[]) => import("@nuralyui/common/mixins").DependencyAware) & (new (...args: any[]) => import("@nuralyui/common/mixins").ThemeAware) & (new (...args: any[]) => import("@nuralyui/common/mixins").EventHandlerCapable) & typeof LitElement;
23
+ export declare class HyIconElement extends IconBaseMixin {
24
+ static readonly styles: import("lit").CSSResult[];
25
+ /** The FontAwesome icon name */
10
26
  name: string;
27
+ /** The icon type (solid or regular) */
11
28
  type: IconTypes;
12
- static readonly styles: import("lit").CSSResult[];
29
+ /** Alternative text for accessibility */
30
+ alt: string;
31
+ /** Icon size (small, medium, large, xlarge, xxlarge) */
32
+ size?: 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge';
33
+ /** Icon color override */
34
+ color?: string;
35
+ /** Custom width override */
36
+ width?: string;
37
+ /** Custom height override */
38
+ height?: string;
39
+ /**
40
+ * Validate component properties on update
41
+ */
42
+ willUpdate(changedProperties: Map<string, any>): void;
13
43
  render(): import("lit").TemplateResult<1>;
14
- getIconPath(): any;
15
- }
16
- declare global {
17
- interface HTMLElementTagNameMap {
18
- 'hy-icon': HyIconElement;
19
- }
20
- namespace JSX {
21
- interface IntrinsicElements {
22
- 'hy-icon': React.DetailedHTMLProps<React.HTMLAttributes<HyIconElement>, HyIconElement> | Partial<HyIconElement>;
23
- }
24
- }
44
+ getIconPath(): string;
45
+ /**
46
+ * Get the appropriate ARIA role for the icon
47
+ */
48
+ getIconRole(): string;
49
+ /**
50
+ * Get the appropriate tabindex for the icon
51
+ */
52
+ getIconTabIndex(): string;
53
+ /**
54
+ * Get the appropriate aria-disabled value
55
+ */
56
+ getAriaDisabled(): string | undefined;
25
57
  }
58
+ export {};
26
59
  //# sourceMappingURL=icon.component.d.ts.map
package/icon.component.js CHANGED
@@ -19,22 +19,144 @@ library.add(fas, far);
19
19
  dom.watch();
20
20
  import { styles } from './icon.style.js';
21
21
  import { regularIconPack, solidIconPack } from './icon.types.js';
22
- let HyIconElement = class HyIconElement extends LitElement {
22
+ import { NuralyUIBaseMixin } from '@nuralyui/common/mixins';
23
+ import { ClickableMixin } from './mixins/index.js';
24
+ /**
25
+ * Enhanced Icon component with clickable functionality, custom styling, and comprehensive theming
26
+ *
27
+ * @example
28
+ * ```html
29
+ * <nr-icon name="envelope"></nr-icon>
30
+ * <nr-icon name="check" clickable @icon-click="${this.handleIconClick}"></nr-icon>
31
+ * <nr-icon name="warning" type="regular" disabled></nr-icon>
32
+ * <nr-icon name="star" color="#ffd700" size="large"></nr-icon>
33
+ * ```
34
+ *
35
+ * @fires icon-click - Dispatched when icon is clicked (contains iconName, iconType, originalEvent, timestamp)
36
+ * @fires icon-keyboard-activation - Dispatched when icon is activated via keyboard (contains iconName, iconType, key, originalEvent, timestamp)
37
+ */
38
+ const IconBaseMixin = ClickableMixin(NuralyUIBaseMixin(LitElement));
39
+ let HyIconElement = class HyIconElement extends IconBaseMixin {
23
40
  constructor() {
24
41
  super(...arguments);
42
+ /** The icon type (solid or regular) */
25
43
  this.type = "solid" /* IconTypes.Solid */;
44
+ /** Alternative text for accessibility */
45
+ this.alt = '';
46
+ }
47
+ /**
48
+ * Validate component properties on update
49
+ */
50
+ willUpdate(changedProperties) {
51
+ super.willUpdate(changedProperties);
52
+ if (changedProperties.has('name') && !this.name) {
53
+ console.error('HyIconElement: "name" property is required');
54
+ }
55
+ if (changedProperties.has('type') &&
56
+ this.type !== "solid" /* IconTypes.Solid */ && this.type !== "regular" /* IconTypes.Regular */) {
57
+ console.warn(`HyIconElement: Invalid type "${this.type}". Using default "${"solid" /* IconTypes.Solid */}"`);
58
+ this.type = "solid" /* IconTypes.Solid */;
59
+ }
60
+ if (changedProperties.has('size') && this.size) {
61
+ const validSizes = ['small', 'medium', 'large', 'xlarge', 'xxlarge'];
62
+ if (!validSizes.includes(this.size)) {
63
+ console.warn(`HyIconElement: Invalid size "${this.size}". Valid sizes are: ${validSizes.join(', ')}`);
64
+ }
65
+ }
26
66
  }
27
67
  render() {
68
+ const iconPath = this.getIconPath();
69
+ const role = this.getIconRole();
70
+ const tabIndex = this.getIconTabIndex();
71
+ const ariaDisabled = this.getAriaDisabled();
72
+ // Build dynamic styles using CSS custom properties
73
+ let dynamicStyles = '';
74
+ if (this.color) {
75
+ dynamicStyles += `--nuraly-color-icon: ${this.color};`;
76
+ }
77
+ if (this.width) {
78
+ dynamicStyles += `width: ${this.width};`;
79
+ }
80
+ if (this.height) {
81
+ dynamicStyles += `height: ${this.height};`;
82
+ }
83
+ // Build CSS classes
84
+ const cssClasses = [
85
+ 'svg-icon',
86
+ this.clickable ? 'clickable' : '',
87
+ this.disabled ? 'disabled' : ''
88
+ ].filter(Boolean).join(' ');
28
89
  return html `
29
- <svg class="svg-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 550 550">
30
- <path d="${this.getIconPath()}" />
90
+ <svg
91
+ class="${cssClasses}"
92
+ style="${dynamicStyles}"
93
+ xmlns="http://www.w3.org/2000/svg"
94
+ viewBox="0 0 550 550"
95
+ role="${role}"
96
+ tabindex="${tabIndex}"
97
+ aria-label="${this.alt || this.name}"
98
+ aria-disabled="${ariaDisabled || 'false'}"
99
+ data-theme="${this.currentTheme}"
100
+ @click="${this.clickable ? this.handleIconClick : undefined}"
101
+ @keydown="${this.clickable ? this.handleIconKeydown : undefined}"
102
+ >
103
+ <path d="${iconPath}" />
31
104
  </svg>
32
105
  `;
33
106
  }
34
107
  getIconPath() {
108
+ if (!this.name) {
109
+ console.warn('HyIconElement: Icon name is required');
110
+ return '';
111
+ }
35
112
  const iconPack = this.type == "solid" /* IconTypes.Solid */ ? solidIconPack : regularIconPack;
36
- const iconDefinition = library.definitions[iconPack][this.name];
37
- return iconDefinition ? iconDefinition[4] : '';
113
+ try {
114
+ const definitions = library.definitions;
115
+ if (!definitions || !definitions[iconPack]) {
116
+ console.warn(`HyIconElement: Icon pack "${iconPack}" not found`);
117
+ return '';
118
+ }
119
+ const iconDefinition = definitions[iconPack][this.name];
120
+ if (!iconDefinition) {
121
+ console.warn(`HyIconElement: Icon "${this.name}" not found in ${iconPack} pack`);
122
+ return '';
123
+ }
124
+ // Validate that the path data exists
125
+ const pathData = iconDefinition[4];
126
+ if (!pathData || typeof pathData !== 'string') {
127
+ console.warn(`HyIconElement: Invalid path data for icon "${this.name}"`);
128
+ return '';
129
+ }
130
+ return pathData;
131
+ }
132
+ catch (error) {
133
+ console.error(`HyIconElement: Error loading icon "${this.name}":`, error);
134
+ return '';
135
+ }
136
+ }
137
+ /**
138
+ * Get the appropriate ARIA role for the icon
139
+ */
140
+ getIconRole() {
141
+ if (this.clickable) {
142
+ return 'button';
143
+ }
144
+ return this.alt ? 'img' : 'presentation';
145
+ }
146
+ /**
147
+ * Get the appropriate tabindex for the icon
148
+ */
149
+ getIconTabIndex() {
150
+ if (this.clickable && !this.disabled) {
151
+ return '0';
152
+ }
153
+ return '-1';
154
+ }
155
+ /**
156
+ * Get the appropriate aria-disabled value
157
+ */
158
+ getAriaDisabled() {
159
+ return this.disabled ? 'true' : undefined;
38
160
  }
39
161
  };
40
162
  HyIconElement.styles = styles;
@@ -44,8 +166,23 @@ __decorate([
44
166
  __decorate([
45
167
  property()
46
168
  ], HyIconElement.prototype, "type", void 0);
169
+ __decorate([
170
+ property({ type: String, attribute: 'alt' })
171
+ ], HyIconElement.prototype, "alt", void 0);
172
+ __decorate([
173
+ property({ type: String, reflect: true })
174
+ ], HyIconElement.prototype, "size", void 0);
175
+ __decorate([
176
+ property({ type: String })
177
+ ], HyIconElement.prototype, "color", void 0);
178
+ __decorate([
179
+ property({ type: String })
180
+ ], HyIconElement.prototype, "width", void 0);
181
+ __decorate([
182
+ property({ type: String })
183
+ ], HyIconElement.prototype, "height", void 0);
47
184
  HyIconElement = __decorate([
48
- customElement('hy-icon')
185
+ customElement('nr-icon')
49
186
  ], HyIconElement);
50
187
  export { HyIconElement };
51
188
  //# sourceMappingURL=icon.component.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"icon.component.js","sourceRoot":"","sources":["../../../src/components/icon/icon.component.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD;;;;GAIG;;;;;;;AAEH,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,GAAG,EAAE,MAAM,qCAAqC,CAAC;AAC1D,OAAO,EAAE,GAAG,EAAE,MAAM,mCAAmC,CAAC;AACxD,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACtB,GAAG,CAAC,KAAK,EAAE,CAAC;AAEZ,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAa,eAAe,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAG5E,IAAa,aAAa,GAA1B,MAAa,aAAc,SAAQ,UAAU;IAA7C;;QAIE,SAAI,iCAAmB;IAezB,CAAC;IAZU,MAAM;QACb,OAAO,IAAI,CAAA;;mBAEI,IAAI,CAAC,WAAW,EAAE;;KAEhC,CAAC;IACJ,CAAC;IACD,WAAW;QACT,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,iCAAmB,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,eAAe,CAAC;QAChF,MAAM,cAAc,GAAI,OAAe,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzE,OAAO,cAAc,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACjD,CAAC;CACF,CAAA;AAb0B,oBAAM,GAAG,MAAO,CAAA;AAJzC;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;2CACX;AAEd;IADC,QAAQ,EAAE;2CACY;AAJZ,aAAa;IADzB,aAAa,CAAC,SAAS,CAAC;GACZ,aAAa,CAmBzB;SAnBY,aAAa","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/**\n * @license\n * Copyright 2023 Nuraly Laabidi Aymen\n * SPDX-License-Identifier: MIT\n */\n\nimport { LitElement, html } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { library, dom } from '@fortawesome/fontawesome-svg-core';\nimport { far } from '@fortawesome/free-regular-svg-icons';\nimport { fas } from '@fortawesome/free-solid-svg-icons';\nlibrary.add(fas, far);\ndom.watch();\n\nimport { styles } from './icon.style.js';\nimport { IconTypes, regularIconPack, solidIconPack } from './icon.types.js';\n\n@customElement('hy-icon')\nexport class HyIconElement extends LitElement {\n @property({type: String})\n name!: string;\n @property()\n type = IconTypes.Solid;\n\n static override readonly styles = styles;\n override render() {\n return html`\n <svg class=\"svg-icon\" xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"0 0 550 550\">\n <path d=\"${this.getIconPath()}\" />\n </svg>\n `;\n }\n getIconPath() {\n const iconPack = this.type == IconTypes.Solid ? solidIconPack : regularIconPack;\n const iconDefinition = (library as any).definitions[iconPack][this.name];\n return iconDefinition ? iconDefinition[4] : '';\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'hy-icon': HyIconElement;\n }\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace JSX {\n interface IntrinsicElements {\n 'hy-icon': React.DetailedHTMLProps<React.HTMLAttributes<HyIconElement>, HyIconElement> | Partial<HyIconElement>;\n }\n }\n}\n"]}
1
+ {"version":3,"file":"icon.component.js","sourceRoot":"","sources":["../../../src/components/icon/icon.component.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD;;;;GAIG;;;;;;;AAEH,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACvC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,mCAAmC,CAAC;AACjE,OAAO,EAAE,GAAG,EAAE,MAAM,qCAAqC,CAAC;AAC1D,OAAO,EAAE,GAAG,EAAE,MAAM,mCAAmC,CAAC;AACxD,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AACtB,GAAG,CAAC,KAAK,EAAE,CAAC;AAEZ,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACzC,OAAO,EAAa,eAAe,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAC5E,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAEnD;;;;;;;;;;;;;GAaG;AAEH,MAAM,aAAa,GAAG,cAAc,CAAC,iBAA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,EAAE;YACpC,OAAO,GAAG,CAAC;SACZ;QACD,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;OAEG;IACM,eAAe;QACtB,OAAO,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;IAC5C,CAAC;CACF,CAAA;AA7J0B,oBAAM,GAAG,MAAO,CAAA;AAIzC;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;2CACX;AAId;IADC,QAAQ,EAAE;2CACY;AAIvB;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,SAAS,EAAE,KAAK,EAAC,CAAC;0CAClC;AAIT;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAC,CAAC;2CACmB;AAI3D;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;4CACV;AAIf;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;4CACV;AAIf;IADC,QAAQ,CAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;6CACT;AA7BL,aAAa;IADzB,aAAa,CAAC,SAAS,CAAC;GACZ,aAAa,CA8JzB;SA9JY,aAAa","sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\n/**\n * @license\n * Copyright 2023 Nuraly Laabidi Aymen\n * SPDX-License-Identifier: MIT\n */\n\nimport { LitElement, html } from 'lit';\nimport { customElement, property } from 'lit/decorators.js';\nimport { library, dom } from '@fortawesome/fontawesome-svg-core';\nimport { far } from '@fortawesome/free-regular-svg-icons';\nimport { fas } from '@fortawesome/free-solid-svg-icons';\nlibrary.add(fas, far);\ndom.watch();\n\nimport { styles } from './icon.style.js';\nimport { IconTypes, regularIconPack, solidIconPack } from './icon.types.js';\nimport { NuralyUIBaseMixin } from '@nuralyui/common/mixins';\nimport { ClickableMixin } from './mixins/index.js';\n\n/**\n * Enhanced Icon component with clickable functionality, custom styling, and comprehensive theming\n * \n * @example\n * ```html\n * <nr-icon name=\"envelope\"></nr-icon>\n * <nr-icon name=\"check\" clickable @icon-click=\"${this.handleIconClick}\"></nr-icon>\n * <nr-icon name=\"warning\" type=\"regular\" disabled></nr-icon>\n * <nr-icon name=\"star\" color=\"#ffd700\" size=\"large\"></nr-icon>\n * ```\n * \n * @fires icon-click - Dispatched when icon is clicked (contains iconName, iconType, originalEvent, timestamp)\n * @fires icon-keyboard-activation - Dispatched when icon is activated via keyboard (contains iconName, iconType, key, originalEvent, timestamp)\n */\n\nconst IconBaseMixin = ClickableMixin(NuralyUIBaseMixin(LitElement));\n@customElement('nr-icon')\nexport class HyIconElement extends IconBaseMixin {\n static override readonly styles = styles;\n\n /** The FontAwesome icon name */\n @property({type: String})\n name!: string;\n\n /** The icon type (solid or regular) */\n @property()\n type = IconTypes.Solid;\n\n /** Alternative text for accessibility */\n @property({type: String, attribute: 'alt'})\n alt = '';\n\n /** Icon size (small, medium, large, xlarge, xxlarge) */\n @property({type: String, reflect: true})\n size?: 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge';\n\n /** Icon color override */\n @property({type: String})\n color?: string;\n\n /** Custom width override */\n @property({type: String})\n width?: string;\n\n /** Custom height override */\n @property({type: String})\n height?: string;\n\n /**\n * Validate component properties on update\n */\n override willUpdate(changedProperties: Map<string, any>) {\n super.willUpdate(changedProperties);\n \n if (changedProperties.has('name') && !this.name) {\n console.error('HyIconElement: \"name\" property is required');\n }\n \n if (changedProperties.has('type') && \n this.type !== IconTypes.Solid && this.type !== IconTypes.Regular) {\n console.warn(`HyIconElement: Invalid type \"${this.type}\". Using default \"${IconTypes.Solid}\"`);\n this.type = IconTypes.Solid;\n }\n\n if (changedProperties.has('size') && this.size) {\n const validSizes = ['small', 'medium', 'large', 'xlarge', 'xxlarge'];\n if (!validSizes.includes(this.size)) {\n console.warn(`HyIconElement: Invalid size \"${this.size}\". Valid sizes are: ${validSizes.join(', ')}`);\n }\n }\n }\n override render() {\n const iconPath = this.getIconPath();\n const role = this.getIconRole();\n const tabIndex = this.getIconTabIndex();\n const ariaDisabled = this.getAriaDisabled();\n \n // Build dynamic styles using CSS custom properties\n let dynamicStyles = '';\n if (this.color) {\n dynamicStyles += `--nuraly-color-icon: ${this.color};`;\n }\n if (this.width) {\n dynamicStyles += `width: ${this.width};`;\n }\n if (this.height) {\n dynamicStyles += `height: ${this.height};`;\n }\n \n // Build CSS classes\n const cssClasses = [\n 'svg-icon',\n this.clickable ? 'clickable' : '',\n this.disabled ? 'disabled' : ''\n ].filter(Boolean).join(' ');\n \n return html`\n <svg \n class=\"${cssClasses}\"\n style=\"${dynamicStyles}\"\n xmlns=\"http://www.w3.org/2000/svg\" \n viewBox=\"0 0 550 550\"\n role=\"${role}\"\n tabindex=\"${tabIndex}\"\n aria-label=\"${this.alt || this.name}\"\n aria-disabled=\"${ariaDisabled || 'false'}\"\n data-theme=\"${this.currentTheme}\"\n @click=\"${this.clickable ? this.handleIconClick : undefined}\"\n @keydown=\"${this.clickable ? this.handleIconKeydown : undefined}\"\n >\n <path d=\"${iconPath}\" />\n </svg>\n `;\n }\n getIconPath() {\n if (!this.name) {\n console.warn('HyIconElement: Icon name is required');\n return '';\n }\n\n const iconPack = this.type == IconTypes.Solid ? solidIconPack : regularIconPack;\n \n try {\n const definitions = (library as any).definitions;\n if (!definitions || !definitions[iconPack]) {\n console.warn(`HyIconElement: Icon pack \"${iconPack}\" not found`);\n return '';\n }\n\n const iconDefinition = definitions[iconPack][this.name];\n if (!iconDefinition) {\n console.warn(`HyIconElement: Icon \"${this.name}\" not found in ${iconPack} pack`);\n return '';\n }\n\n // Validate that the path data exists\n const pathData = iconDefinition[4];\n if (!pathData || typeof pathData !== 'string') {\n console.warn(`HyIconElement: Invalid path data for icon \"${this.name}\"`);\n return '';\n }\n\n return pathData;\n } catch (error) {\n console.error(`HyIconElement: Error loading icon \"${this.name}\":`, error);\n return '';\n }\n }\n\n /**\n * Get the appropriate ARIA role for the icon\n */\n override getIconRole(): string {\n if (this.clickable) {\n return 'button';\n }\n return this.alt ? 'img' : 'presentation';\n }\n\n /**\n * Get the appropriate tabindex for the icon\n */\n override getIconTabIndex(): string {\n if (this.clickable && !this.disabled) {\n return '0';\n }\n return '-1';\n }\n\n /**\n * Get the appropriate aria-disabled value\n */\n override getAriaDisabled(): string | undefined {\n return this.disabled ? 'true' : undefined;\n }\n}\n"]}
package/icon.style.js CHANGED
@@ -1,11 +1,184 @@
1
1
  import { css } from 'lit';
2
2
  import { styleVariables } from './icon.variables.js';
3
- const iconStyles = css `
3
+ /**
4
+ * Icon component styles for the Hybrid UI Library
5
+ *
6
+ * This file contains all the styling for the nr-icon component, including:
7
+ * - Base icon styles with CSS custom properties for theming
8
+ * - Multiple icon states (default, hover, active, disabled, focus)
9
+ * - Size variations (small, medium, large, custom)
10
+ * - Interactive states for clickable icons
11
+ * - Theme compatibility (light, dark, carbon, default design systems)
12
+ * - Accessibility features and reduced motion support
13
+ *
14
+ * The styling system uses CSS custom properties with fallbacks to allow
15
+ * for both global and local customization of icon appearance.
16
+ */
17
+ const iconStyle = css `
18
+ /*
19
+ * Host element base styles
20
+ * Container for the icon component with flexible positioning
21
+ */
22
+ :host {
23
+ display: inline-flex;
24
+ align-items: center;
25
+ justify-content: center;
26
+ line-height: 1;
27
+ vertical-align: baseline;
28
+ position: relative;
29
+ font-family: var(--nuraly-font-family-icon, 'IBM Plex Sans', ui-sans-serif, system-ui);
30
+ }
31
+
32
+ /*
33
+ * Base SVG icon styles
34
+ * Uses theme CSS custom properties for comprehensive theming support
35
+ */
4
36
  .svg-icon {
5
- fill: var(--hybrid-icon-color, #000000);
6
- width: var(--hybrid-icon-width);
7
- height: var(--hybrid-icon-height);
37
+ /* Basic properties with theme support */
38
+ fill: var(--nuraly-color-icon, var(--nuraly-color-icon-fallback, #161616));
39
+ width: var(--nuraly-icon-size, var(--nuraly-icon-size-fallback, 18px));
40
+ height: var(--nuraly-icon-size, var(--nuraly-icon-size-fallback, 18px));
41
+ min-width: var(--nuraly-icon-min-size, var(--nuraly-icon-min-size-fallback, 16px));
42
+ min-height: var(--nuraly-icon-min-size, var(--nuraly-icon-min-size-fallback, 16px));
43
+
44
+ /* Transition and display properties */
45
+ transition: var(--nuraly-icon-transition, var(--nuraly-icon-transition-fallback, opacity 0.2s ease, transform 0.2s ease, fill 0.2s ease));
46
+ display: block;
47
+ flex-shrink: 0;
48
+
49
+ /* Cursor handling */
50
+ cursor: var(--nuraly-cursor-default, default);
51
+ }
52
+
53
+ /* ========================================
54
+ * CLICKABLE STATES
55
+ * ======================================== */
56
+
57
+ .svg-icon.clickable {
58
+ cursor: var(--nuraly-cursor-interactive, pointer);
59
+ }
60
+
61
+ .svg-icon.clickable:hover {
62
+ opacity: var(--nuraly-icon-hover-opacity, var(--nuraly-icon-hover-opacity-fallback, 0.8));
63
+ transform: var(--nuraly-icon-hover-transform, var(--nuraly-icon-hover-transform-fallback, scale(1.05)));
64
+ fill: var(--nuraly-color-icon-hover, var(--nuraly-color-icon-hover-fallback, #0f62fe));
65
+ }
66
+
67
+ .svg-icon.clickable:active {
68
+ opacity: var(--nuraly-icon-active-opacity, var(--nuraly-icon-active-opacity-fallback, 0.6));
69
+ transform: var(--nuraly-icon-active-transform, var(--nuraly-icon-active-transform-fallback, scale(0.95)));
70
+ fill: var(--nuraly-color-icon-active, var(--nuraly-color-icon-active-fallback, #054ada));
71
+ }
72
+
73
+ .svg-icon.clickable:focus {
74
+ outline: var(--nuraly-icon-focus-outline, var(--nuraly-icon-focus-outline-fallback, 2px solid #0f62fe));
75
+ outline-offset: var(--nuraly-icon-focus-outline-offset, var(--nuraly-icon-focus-outline-offset-fallback, 2px));
76
+ background: var(--nuraly-icon-focus-background, var(--nuraly-icon-focus-background-fallback, rgba(15, 98, 254, 0.1)));
77
+ border-radius: var(--nuraly-icon-focus-border-radius, var(--nuraly-icon-focus-border-radius-fallback, 4px));
78
+ box-shadow: var(--nuraly-icon-focus-shadow, var(--nuraly-icon-focus-shadow-fallback, none));
79
+ }
80
+
81
+ /* ========================================
82
+ * DISABLED STATE
83
+ * ======================================== */
84
+
85
+ .svg-icon.disabled {
86
+ opacity: var(--nuraly-icon-disabled-opacity, var(--nuraly-icon-disabled-opacity-fallback, 0.25));
87
+ fill: var(--nuraly-color-icon-disabled, var(--nuraly-color-icon-disabled-fallback, #c6c6c6));
88
+ cursor: var(--nuraly-cursor-disabled, not-allowed);
89
+ }
90
+
91
+ .svg-icon.clickable.disabled:hover,
92
+ .svg-icon.clickable.disabled:active {
93
+ opacity: var(--nuraly-icon-disabled-opacity, var(--nuraly-icon-disabled-opacity-fallback, 0.25));
94
+ fill: var(--nuraly-color-icon-disabled, var(--nuraly-color-icon-disabled-fallback, #c6c6c6));
95
+ transform: none;
96
+ }
97
+
98
+ .svg-icon.clickable.disabled:focus {
99
+ outline: none;
100
+ background: none;
101
+ box-shadow: none;
102
+ }
103
+
104
+ /* ========================================
105
+ * ACCESSIBILITY FEATURES
106
+ * ======================================== */
107
+
108
+ /* Screen reader only text for better accessibility */
109
+ .sr-only {
110
+ position: absolute;
111
+ width: 1px;
112
+ height: 1px;
113
+ padding: 0;
114
+ margin: -1px;
115
+ overflow: hidden;
116
+ clip: rect(0, 0, 0, 0);
117
+ white-space: nowrap;
118
+ border: 0;
119
+ }
120
+
121
+ /* High contrast mode support */
122
+ @media (prefers-contrast: high) {
123
+ .svg-icon {
124
+ fill: CanvasText;
125
+ }
126
+
127
+ .svg-icon.disabled {
128
+ opacity: 0.5;
129
+ }
130
+ }
131
+
132
+ /* Reduced motion support */
133
+ @media (prefers-reduced-motion: reduce) {
134
+ .svg-icon {
135
+ transition: none;
136
+ }
137
+
138
+ .svg-icon.clickable:hover,
139
+ .svg-icon.clickable:active {
140
+ transform: none;
141
+ }
142
+ }
143
+ `;
144
+ /**
145
+ * Size variation styles for the icon component
146
+ * Defines size variations for different icon use cases
147
+ */
148
+ const sizeIconStyle = css `
149
+ /* ========================================
150
+ * SIZE VARIATIONS
151
+ * ======================================== */
152
+
153
+ /* Small icon size */
154
+ :host([size='small']) .svg-icon {
155
+ width: var(--nuraly-icon-size-small, var(--nuraly-icon-size-small-fallback, 16px));
156
+ height: var(--nuraly-icon-size-small, var(--nuraly-icon-size-small-fallback, 16px));
157
+ }
158
+
159
+ /* Medium icon size (default) */
160
+ :host([size='medium']) .svg-icon {
161
+ width: var(--nuraly-icon-size-medium, var(--nuraly-icon-size-medium-fallback, 20px));
162
+ height: var(--nuraly-icon-size-medium, var(--nuraly-icon-size-medium-fallback, 20px));
163
+ }
164
+
165
+ /* Large icon size */
166
+ :host([size='large']) .svg-icon {
167
+ width: var(--nuraly-icon-size-large, var(--nuraly-icon-size-large-fallback, 24px));
168
+ height: var(--nuraly-icon-size-large, var(--nuraly-icon-size-large-fallback, 24px));
169
+ }
170
+
171
+ /* Extra large icon size */
172
+ :host([size='xlarge']) .svg-icon {
173
+ width: var(--nuraly-icon-size-xlarge, var(--nuraly-icon-size-xlarge-fallback, 32px));
174
+ height: var(--nuraly-icon-size-xlarge, var(--nuraly-icon-size-xlarge-fallback, 32px));
175
+ }
176
+
177
+ /* 2X large icon size */
178
+ :host([size='xxlarge']) .svg-icon {
179
+ width: var(--nuraly-icon-size-xxlarge, var(--nuraly-icon-size-xxlarge-fallback, 40px));
180
+ height: var(--nuraly-icon-size-xxlarge, var(--nuraly-icon-size-xxlarge-fallback, 40px));
8
181
  }
9
182
  `;
10
- export const styles = [iconStyles, styleVariables];
183
+ export const styles = [iconStyle, sizeIconStyle, styleVariables];
11
184
  //# sourceMappingURL=icon.style.js.map
package/icon.style.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"icon.style.js","sourceRoot":"","sources":["../../../src/components/icon/icon.style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,GAAG,EAAC,MAAM,KAAK,CAAC;AACxB,OAAO,EAAC,cAAc,EAAC,MAAM,qBAAqB,CAAC;AAEnD,MAAM,UAAU,GAAG,GAAG,CAAA;;;;;;CAMrB,CAAC;AACF,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,UAAU,EAAE,cAAc,CAAC,CAAC","sourcesContent":["import {css} from 'lit';\nimport {styleVariables} from './icon.variables.js';\n\nconst iconStyles = css`\n .svg-icon {\n fill: var(--hybrid-icon-color, #000000);\n width: var(--hybrid-icon-width);\n height: var(--hybrid-icon-height);\n }\n`;\nexport const styles = [iconStyles, styleVariables];\n"]}
1
+ {"version":3,"file":"icon.style.js","sourceRoot":"","sources":["../../../src/components/icon/icon.style.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD;;;;;;;;;;;;;GAaG;AAEH,MAAM,SAAS,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8HpB,CAAC;AAEF;;;GAGG;AACH,MAAM,aAAa,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkCxB,CAAC;AAEF,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,SAAS,EAAE,aAAa,EAAE,cAAc,CAAC,CAAC","sourcesContent":["import { css } from 'lit';\nimport { styleVariables } from './icon.variables.js';\n\n/**\n * Icon component styles for the Hybrid UI Library\n * \n * This file contains all the styling for the nr-icon component, including:\n * - Base icon styles with CSS custom properties for theming\n * - Multiple icon states (default, hover, active, disabled, focus)\n * - Size variations (small, medium, large, custom)\n * - Interactive states for clickable icons\n * - Theme compatibility (light, dark, carbon, default design systems)\n * - Accessibility features and reduced motion support\n * \n * The styling system uses CSS custom properties with fallbacks to allow\n * for both global and local customization of icon appearance.\n */\n\nconst iconStyle = css`\n /* \n * Host element base styles\n * Container for the icon component with flexible positioning\n */\n :host {\n display: inline-flex;\n align-items: center;\n justify-content: center;\n line-height: 1;\n vertical-align: baseline;\n position: relative;\n font-family: var(--nuraly-font-family-icon, 'IBM Plex Sans', ui-sans-serif, system-ui);\n }\n\n /* \n * Base SVG icon styles\n * Uses theme CSS custom properties for comprehensive theming support\n */\n .svg-icon {\n /* Basic properties with theme support */\n fill: var(--nuraly-color-icon, var(--nuraly-color-icon-fallback, #161616));\n width: var(--nuraly-icon-size, var(--nuraly-icon-size-fallback, 18px));\n height: var(--nuraly-icon-size, var(--nuraly-icon-size-fallback, 18px));\n min-width: var(--nuraly-icon-min-size, var(--nuraly-icon-min-size-fallback, 16px));\n min-height: var(--nuraly-icon-min-size, var(--nuraly-icon-min-size-fallback, 16px));\n \n /* Transition and display properties */\n transition: var(--nuraly-icon-transition, var(--nuraly-icon-transition-fallback, opacity 0.2s ease, transform 0.2s ease, fill 0.2s ease));\n display: block;\n flex-shrink: 0;\n \n /* Cursor handling */\n cursor: var(--nuraly-cursor-default, default);\n }\n\n /* ========================================\n * CLICKABLE STATES\n * ======================================== */\n \n .svg-icon.clickable {\n cursor: var(--nuraly-cursor-interactive, pointer);\n }\n\n .svg-icon.clickable:hover {\n opacity: var(--nuraly-icon-hover-opacity, var(--nuraly-icon-hover-opacity-fallback, 0.8));\n transform: var(--nuraly-icon-hover-transform, var(--nuraly-icon-hover-transform-fallback, scale(1.05)));\n fill: var(--nuraly-color-icon-hover, var(--nuraly-color-icon-hover-fallback, #0f62fe));\n }\n\n .svg-icon.clickable:active {\n opacity: var(--nuraly-icon-active-opacity, var(--nuraly-icon-active-opacity-fallback, 0.6));\n transform: var(--nuraly-icon-active-transform, var(--nuraly-icon-active-transform-fallback, scale(0.95)));\n fill: var(--nuraly-color-icon-active, var(--nuraly-color-icon-active-fallback, #054ada));\n }\n\n .svg-icon.clickable:focus {\n outline: var(--nuraly-icon-focus-outline, var(--nuraly-icon-focus-outline-fallback, 2px solid #0f62fe));\n outline-offset: var(--nuraly-icon-focus-outline-offset, var(--nuraly-icon-focus-outline-offset-fallback, 2px));\n background: var(--nuraly-icon-focus-background, var(--nuraly-icon-focus-background-fallback, rgba(15, 98, 254, 0.1)));\n border-radius: var(--nuraly-icon-focus-border-radius, var(--nuraly-icon-focus-border-radius-fallback, 4px));\n box-shadow: var(--nuraly-icon-focus-shadow, var(--nuraly-icon-focus-shadow-fallback, none));\n }\n\n /* ========================================\n * DISABLED STATE\n * ======================================== */\n \n .svg-icon.disabled {\n opacity: var(--nuraly-icon-disabled-opacity, var(--nuraly-icon-disabled-opacity-fallback, 0.25));\n fill: var(--nuraly-color-icon-disabled, var(--nuraly-color-icon-disabled-fallback, #c6c6c6));\n cursor: var(--nuraly-cursor-disabled, not-allowed);\n }\n\n .svg-icon.clickable.disabled:hover,\n .svg-icon.clickable.disabled:active {\n opacity: var(--nuraly-icon-disabled-opacity, var(--nuraly-icon-disabled-opacity-fallback, 0.25));\n fill: var(--nuraly-color-icon-disabled, var(--nuraly-color-icon-disabled-fallback, #c6c6c6));\n transform: none;\n }\n\n .svg-icon.clickable.disabled:focus {\n outline: none;\n background: none;\n box-shadow: none;\n }\n\n /* ========================================\n * ACCESSIBILITY FEATURES\n * ======================================== */\n\n /* Screen reader only text for better accessibility */\n .sr-only {\n position: absolute;\n width: 1px;\n height: 1px;\n padding: 0;\n margin: -1px;\n overflow: hidden;\n clip: rect(0, 0, 0, 0);\n white-space: nowrap;\n border: 0;\n }\n\n /* High contrast mode support */\n @media (prefers-contrast: high) {\n .svg-icon {\n fill: CanvasText;\n }\n \n .svg-icon.disabled {\n opacity: 0.5;\n }\n }\n\n /* Reduced motion support */\n @media (prefers-reduced-motion: reduce) {\n .svg-icon {\n transition: none;\n }\n \n .svg-icon.clickable:hover,\n .svg-icon.clickable:active {\n transform: none;\n }\n }\n`;\n\n/**\n * Size variation styles for the icon component\n * Defines size variations for different icon use cases\n */\nconst sizeIconStyle = css`\n /* ========================================\n * SIZE VARIATIONS\n * ======================================== */\n\n /* Small icon size */\n :host([size='small']) .svg-icon {\n width: var(--nuraly-icon-size-small, var(--nuraly-icon-size-small-fallback, 16px));\n height: var(--nuraly-icon-size-small, var(--nuraly-icon-size-small-fallback, 16px));\n }\n\n /* Medium icon size (default) */\n :host([size='medium']) .svg-icon {\n width: var(--nuraly-icon-size-medium, var(--nuraly-icon-size-medium-fallback, 20px));\n height: var(--nuraly-icon-size-medium, var(--nuraly-icon-size-medium-fallback, 20px));\n }\n\n /* Large icon size */\n :host([size='large']) .svg-icon {\n width: var(--nuraly-icon-size-large, var(--nuraly-icon-size-large-fallback, 24px));\n height: var(--nuraly-icon-size-large, var(--nuraly-icon-size-large-fallback, 24px));\n }\n\n /* Extra large icon size */\n :host([size='xlarge']) .svg-icon {\n width: var(--nuraly-icon-size-xlarge, var(--nuraly-icon-size-xlarge-fallback, 32px));\n height: var(--nuraly-icon-size-xlarge, var(--nuraly-icon-size-xlarge-fallback, 32px));\n }\n\n /* 2X large icon size */\n :host([size='xxlarge']) .svg-icon {\n width: var(--nuraly-icon-size-xxlarge, var(--nuraly-icon-size-xxlarge-fallback, 40px));\n height: var(--nuraly-icon-size-xxlarge, var(--nuraly-icon-size-xxlarge-fallback, 40px));\n }\n`;\n\nexport const styles = [iconStyle, sizeIconStyle, styleVariables];\n"]}
@@ -1,2 +1,17 @@
1
+ /**
2
+ * Icon component CSS custom properties (design tokens)
3
+ *
4
+ * This file contains all the CSS custom properties used by the nr-icon component,
5
+ * organized by functionality and including comprehensive theme support for multiple design systems.
6
+ *
7
+ * The styling system uses CSS custom properties with fallbacks to allow
8
+ * for both global and local customization of icon appearance across different themes:
9
+ * - Light theme (default)
10
+ * - Dark theme
11
+ * - Carbon Design System (light/dark)
12
+ * - Default Design System (light/dark)
13
+ *
14
+ * Design tokens follow the pattern: --nuraly-[component]-[property]-[variant]
15
+ */
1
16
  export declare const styleVariables: import("lit").CSSResult;
2
17
  //# sourceMappingURL=icon.variables.d.ts.map
package/icon.variables.js CHANGED
@@ -1,14 +1,132 @@
1
1
  import { css } from 'lit';
2
+ /**
3
+ * Icon component CSS custom properties (design tokens)
4
+ *
5
+ * This file contains all the CSS custom properties used by the nr-icon component,
6
+ * organized by functionality and including comprehensive theme support for multiple design systems.
7
+ *
8
+ * The styling system uses CSS custom properties with fallbacks to allow
9
+ * for both global and local customization of icon appearance across different themes:
10
+ * - Light theme (default)
11
+ * - Dark theme
12
+ * - Carbon Design System (light/dark)
13
+ * - Default Design System (light/dark)
14
+ *
15
+ * Design tokens follow the pattern: --nuraly-[component]-[property]-[variant]
16
+ */
2
17
  export const styleVariables = css `
3
18
  :host {
4
- /* --hybrid-icon-color: #000000; */
5
- --hybrid-icon-width: 18px;
6
- --hybrid-icon-height: 18px;
19
+ /* ========================================
20
+ * BASE ICON PROPERTIES
21
+ * ======================================== */
22
+
23
+ /* Size properties with fallbacks */
24
+ --nuraly-icon-size-fallback: 18px;
25
+ --nuraly-icon-size-small-fallback: 14px;
26
+ --nuraly-icon-size-medium-fallback: 20px;
27
+ --nuraly-icon-size-large-fallback: 24px;
28
+ --nuraly-icon-size-xlarge-fallback: 32px;
29
+ --nuraly-icon-size-xxlarge-fallback: 40px;
30
+ --nuraly-icon-min-size-fallback: 12px;
31
+
32
+ /* Color properties with theme-aware fallbacks */
33
+ --nuraly-color-icon-fallback: #161616;
34
+
35
+ /* ========================================
36
+ * INTERACTIVE STATE PROPERTIES
37
+ * ======================================== */
38
+
39
+ /* Transition properties */
40
+ --nuraly-icon-transition-fallback: opacity 0.2s ease, transform 0.2s ease, fill 0.2s ease;
41
+
42
+ /* Hover state properties */
43
+ --nuraly-icon-hover-opacity-fallback: 0.8;
44
+ --nuraly-icon-hover-transform-fallback: scale(1.05);
45
+ --nuraly-color-icon-hover-fallback: #0f62fe;
46
+
47
+ /* Active state properties */
48
+ --nuraly-icon-active-opacity-fallback: 0.6;
49
+ --nuraly-icon-active-transform-fallback: scale(0.95);
50
+ --nuraly-color-icon-active-fallback: #054ada;
51
+
52
+ /* Disabled state properties */
53
+ --nuraly-icon-disabled-opacity-fallback: 0.25;
54
+ --nuraly-color-icon-disabled-fallback: #c6c6c6;
55
+
56
+ /* ========================================
57
+ * FOCUS STATE PROPERTIES
58
+ * ======================================== */
59
+
60
+ --nuraly-icon-focus-outline-fallback: 2px solid #0f62fe;
61
+ --nuraly-icon-focus-outline-offset-fallback: 2px;
62
+ --nuraly-icon-focus-background-fallback: rgba(15, 98, 254, 0.1);
63
+ --nuraly-icon-focus-border-radius-fallback: 4px;
64
+ --nuraly-icon-focus-shadow-fallback: none;
65
+
66
+ /* ========================================
67
+ * CURSOR PROPERTIES
68
+ * ======================================== */
69
+
70
+ --nuraly-cursor-default: default;
71
+ --nuraly-cursor-interactive: pointer;
72
+ --nuraly-cursor-disabled: not-allowed;
7
73
  }
8
- @media (prefers-color-scheme: dark) {
74
+
75
+ /* ========================================
76
+ * SIZE-SPECIFIC DESIGN TOKENS
77
+ * ======================================== */
78
+
79
+ /**
80
+ * Size-specific customizations that can be overridden in themes
81
+ * These provide defaults that themes can customize for different design systems
82
+ */
83
+
84
+ :host([size="small"]) {
85
+ --nuraly-icon-size: var(--nuraly-icon-size-small, var(--nuraly-icon-size-small-fallback));
86
+ }
87
+
88
+ :host([size="medium"]) {
89
+ --nuraly-icon-size: var(--nuraly-icon-size-medium, var(--nuraly-icon-size-medium-fallback));
90
+ }
91
+
92
+ :host([size="large"]) {
93
+ --nuraly-icon-size: var(--nuraly-icon-size-large, var(--nuraly-icon-size-large-fallback));
94
+ }
95
+
96
+ :host([size="xlarge"]) {
97
+ --nuraly-icon-size: var(--nuraly-icon-size-xlarge, var(--nuraly-icon-size-xlarge-fallback));
98
+ }
99
+
100
+ :host([size="xxlarge"]) {
101
+ --nuraly-icon-size: var(--nuraly-icon-size-xxlarge, var(--nuraly-icon-size-xxlarge-fallback));
102
+ }
103
+
104
+ /* ========================================
105
+ * ACCESSIBILITY DESIGN TOKENS
106
+ * ======================================== */
107
+
108
+ /**
109
+ * Accessibility features that respect user preferences
110
+ * These ensure the component works well for all users
111
+ */
112
+
113
+ /* High contrast mode support */
114
+ @media (prefers-contrast: high) {
9
115
  :host {
10
- --hybrid-icon-color: #ffffff;
116
+ --nuraly-color-icon: CanvasText;
117
+ --nuraly-color-icon-hover: CanvasText;
118
+ --nuraly-color-icon-active: CanvasText;
119
+ --nuraly-icon-focus-outline: 3px solid CanvasText;
120
+ --nuraly-icon-focus-background: Canvas;
11
121
  }
12
122
  }
123
+
124
+ /* Reduced motion support */
125
+ @media (prefers-reduced-motion: reduce) {
126
+ :host {
127
+ --nuraly-icon-transition: none;
128
+ --nuraly-icon-hover-transform: none;
129
+ --nuraly-icon-active-transform: none;
130
+ }
13
131
  `;
14
132
  //# sourceMappingURL=icon.variables.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"icon.variables.js","sourceRoot":"","sources":["../../../src/components/icon/icon.variables.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAA;;;;;;;;;;;CAWhC,CAAC","sourcesContent":["import { css } from 'lit';\n\nexport const styleVariables = css`\n :host {\n /* --hybrid-icon-color: #000000; */\n --hybrid-icon-width: 18px;\n --hybrid-icon-height: 18px;\n }\n @media (prefers-color-scheme: dark) {\n :host {\n --hybrid-icon-color: #ffffff;\n }\n }\n`;\n"]}
1
+ {"version":3,"file":"icon.variables.js","sourceRoot":"","sources":["../../../src/components/icon/icon.variables.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE1B;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkHhC,CAAC","sourcesContent":["import { css } from 'lit';\n\n/**\n * Icon component CSS custom properties (design tokens)\n * \n * This file contains all the CSS custom properties used by the nr-icon component,\n * organized by functionality and including comprehensive theme support for multiple design systems.\n * \n * The styling system uses CSS custom properties with fallbacks to allow\n * for both global and local customization of icon appearance across different themes:\n * - Light theme (default)\n * - Dark theme\n * - Carbon Design System (light/dark)\n * - Default Design System (light/dark)\n * \n * Design tokens follow the pattern: --nuraly-[component]-[property]-[variant]\n */\nexport const styleVariables = css`\n :host {\n /* ========================================\n * BASE ICON PROPERTIES\n * ======================================== */\n \n /* Size properties with fallbacks */\n --nuraly-icon-size-fallback: 18px;\n --nuraly-icon-size-small-fallback: 14px;\n --nuraly-icon-size-medium-fallback: 20px;\n --nuraly-icon-size-large-fallback: 24px;\n --nuraly-icon-size-xlarge-fallback: 32px;\n --nuraly-icon-size-xxlarge-fallback: 40px;\n --nuraly-icon-min-size-fallback: 12px;\n \n /* Color properties with theme-aware fallbacks */\n --nuraly-color-icon-fallback: #161616;\n \n /* ========================================\n * INTERACTIVE STATE PROPERTIES\n * ======================================== */\n \n /* Transition properties */\n --nuraly-icon-transition-fallback: opacity 0.2s ease, transform 0.2s ease, fill 0.2s ease;\n \n /* Hover state properties */\n --nuraly-icon-hover-opacity-fallback: 0.8;\n --nuraly-icon-hover-transform-fallback: scale(1.05);\n --nuraly-color-icon-hover-fallback: #0f62fe;\n \n /* Active state properties */\n --nuraly-icon-active-opacity-fallback: 0.6;\n --nuraly-icon-active-transform-fallback: scale(0.95);\n --nuraly-color-icon-active-fallback: #054ada;\n \n /* Disabled state properties */\n --nuraly-icon-disabled-opacity-fallback: 0.25;\n --nuraly-color-icon-disabled-fallback: #c6c6c6;\n \n /* ========================================\n * FOCUS STATE PROPERTIES\n * ======================================== */\n \n --nuraly-icon-focus-outline-fallback: 2px solid #0f62fe;\n --nuraly-icon-focus-outline-offset-fallback: 2px;\n --nuraly-icon-focus-background-fallback: rgba(15, 98, 254, 0.1);\n --nuraly-icon-focus-border-radius-fallback: 4px;\n --nuraly-icon-focus-shadow-fallback: none;\n \n /* ========================================\n * CURSOR PROPERTIES\n * ======================================== */\n \n --nuraly-cursor-default: default;\n --nuraly-cursor-interactive: pointer;\n --nuraly-cursor-disabled: not-allowed;\n }\n\n /* ========================================\n * SIZE-SPECIFIC DESIGN TOKENS\n * ======================================== */\n \n /**\n * Size-specific customizations that can be overridden in themes\n * These provide defaults that themes can customize for different design systems\n */\n \n :host([size=\"small\"]) {\n --nuraly-icon-size: var(--nuraly-icon-size-small, var(--nuraly-icon-size-small-fallback));\n }\n \n :host([size=\"medium\"]) {\n --nuraly-icon-size: var(--nuraly-icon-size-medium, var(--nuraly-icon-size-medium-fallback));\n }\n \n :host([size=\"large\"]) {\n --nuraly-icon-size: var(--nuraly-icon-size-large, var(--nuraly-icon-size-large-fallback));\n }\n \n :host([size=\"xlarge\"]) {\n --nuraly-icon-size: var(--nuraly-icon-size-xlarge, var(--nuraly-icon-size-xlarge-fallback));\n }\n \n :host([size=\"xxlarge\"]) {\n --nuraly-icon-size: var(--nuraly-icon-size-xxlarge, var(--nuraly-icon-size-xxlarge-fallback));\n }\n\n /* ========================================\n * ACCESSIBILITY DESIGN TOKENS\n * ======================================== */\n \n /**\n * Accessibility features that respect user preferences\n * These ensure the component works well for all users\n */\n \n /* High contrast mode support */\n @media (prefers-contrast: high) {\n :host {\n --nuraly-color-icon: CanvasText;\n --nuraly-color-icon-hover: CanvasText;\n --nuraly-color-icon-active: CanvasText;\n --nuraly-icon-focus-outline: 3px solid CanvasText;\n --nuraly-icon-focus-background: Canvas;\n }\n }\n \n /* Reduced motion support */\n @media (prefers-reduced-motion: reduce) {\n :host {\n --nuraly-icon-transition: none;\n --nuraly-icon-hover-transform: none;\n --nuraly-icon-active-transform: none;\n }\n`;\n"]}