@descope-ui/descope-icon 0.0.5 → 0.0.7

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/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  This file was generated using [@jscutlery/semver](https://github.com/jscutlery/semver).
4
4
 
5
+ ## [0.0.7](https://github.com/descope/web-components-ui/compare/@descope-ui/descope-icon-0.0.6...@descope-ui/descope-icon-0.0.7) (2025-05-28)
6
+
7
+ ### Dependency Updates
8
+
9
+ * `e2e-utils` updated to version `0.0.1`
10
+ * `@descope-ui/common` updated to version `0.0.12`
11
+ * `@descope-ui/theme-globals` updated to version `0.0.12`
12
+ * `@descope-ui/descope-image` updated to version `0.0.1`
13
+ ## [0.0.6](https://github.com/descope/web-components-ui/compare/@descope-ui/descope-icon-0.0.5...@descope-ui/descope-icon-0.0.6) (2025-04-29)
14
+
15
+ ### Dependency Updates
16
+
17
+ * `@descope-ui/common` updated to version `0.0.11`
18
+ * `@descope-ui/theme-globals` updated to version `0.0.11`
5
19
  ## [0.0.5](https://github.com/descope/web-components-ui/compare/@descope-ui/descope-icon-0.0.4...@descope-ui/descope-icon-0.0.5) (2025-04-16)
6
20
 
7
21
  ### Dependency Updates
@@ -5,11 +5,17 @@ const storyName = 'descope-icon';
5
5
  const componentName = 'descope-icon';
6
6
 
7
7
  const presets = {
8
- 'from url': { icon: 'fromUrl' },
9
- 'from url with fill-color': { icon: 'fromUrl', 'fill-color': 'true', 'st-fill': 'red' },
10
- svg64: { icon: 'base64svg' },
11
- 'svg64 with fill-color': { icon: 'base64svg', 'fill-color': 'true', 'st-fill': 'green' },
12
- png64: { icon: 'base64png' },
8
+ 'from url': { src: 'fromUrlLight' },
9
+ 'from url with fill-color': {
10
+ src: 'fromUrlLight',
11
+ 'st-fill': 'red',
12
+ },
13
+ svg64: { src: 'base64svg' },
14
+ 'svg64 with fill-color': {
15
+ src: 'base64svg',
16
+ 'st-fill': 'green',
17
+ },
18
+ png64: { src: 'base64png' },
13
19
  };
14
20
 
15
21
  test.describe('theme', () => {
@@ -19,7 +25,11 @@ test.describe('theme', () => {
19
25
  await page.waitForSelector(componentName);
20
26
  const component = page.locator(componentName);
21
27
  expect(
22
- await component.screenshot({ animations: 'disabled', timeout: 3000, caret: 'hide' })
28
+ await component.screenshot({
29
+ animations: 'disabled',
30
+ timeout: 3000,
31
+ caret: 'hide',
32
+ }),
23
33
  ).toMatchSnapshot();
24
34
  });
25
35
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@descope-ui/descope-icon",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "exports": {
5
5
  ".": {
6
6
  "import": "./src/component/index.js"
@@ -20,8 +20,9 @@
20
20
  "dependencies": {
21
21
  "@vaadin/icon": "24.3.4",
22
22
  "dompurify": "^3.1.6",
23
- "@descope-ui/common": "0.0.10",
24
- "@descope-ui/theme-globals": "0.0.10"
23
+ "@descope-ui/common": "0.0.12",
24
+ "@descope-ui/theme-globals": "0.0.12",
25
+ "@descope-ui/descope-image": "0.0.1"
25
26
  },
26
27
  "publishConfig": {
27
28
  "link-workspace-packages": false
@@ -1,99 +1,32 @@
1
- /* eslint-disable no-use-before-define */
2
- import { createStyleMixin, draggableMixin, componentNameValidationMixin } from '@descope-ui/common/components-mixins';
3
- import { createBaseClass } from '@descope-ui/common/base-classes';
1
+ import {
2
+ componentNameValidationMixin,
3
+ createProxy,
4
+ createStyleMixin,
5
+ draggableMixin,
6
+ } from '@descope-ui/common/components-mixins';
7
+ import { getComponentName } from '@descope-ui/common/components-helpers';
4
8
  import { compose } from '@descope-ui/common/utils';
5
- import { getComponentName } from '@descope-ui/common/components-helpers';
6
- import { createIcon } from './helpers';
7
- import { injectStyle } from '@descope-ui/common/components-helpers';
8
9
 
9
10
  export const componentName = getComponentName('icon');
10
11
 
11
- class RawIcon extends createBaseClass({ componentName, baseSelector: 'slot' }) {
12
- static get observedAttributes() {
13
- return ['src'];
14
- }
15
-
16
- #icon;
17
-
18
- constructor() {
19
- super();
20
-
21
- this.attachShadow({ mode: 'open' }).innerHTML = `
22
- <slot></slot>
23
- `;
24
-
25
- injectStyle(
26
- `
27
- :host > slot {
28
- box-sizing: border-box;
29
- width: 100%;
30
- height: 100%;
31
- display: flex;
32
- overflow: hidden;
33
- }
34
- :host {
35
- display: inline-block;
36
- }
37
- `,
38
- this
39
- );
40
- }
41
-
42
- init() {
43
- super.init?.();
44
- this.toggleVisibility(this.src);
45
- }
46
-
47
- toggleVisibility(isVisible) {
48
- this.style.display = isVisible ? '' : 'none';
49
- }
50
-
51
- get src() {
52
- return this.getAttribute('src');
53
- }
54
-
55
- // in order to fill an SVG with `currentColor` override all of its `fill` and `path` nodes
56
- // with the value from the `st-fill` attribute
57
- // eslint-disable-next-line class-methods-use-this
58
- updateFillColor(node) {
59
- // set fill to root node and all its relevant selectors
60
- const elementsToReplace = [node, ...node.querySelectorAll('*[fill]')];
61
-
62
- elementsToReplace.forEach((ele) => {
63
- ele.setAttribute(
64
- 'fill',
65
- `var(${IconClass.cssVarList.fill}, ${ele.getAttribute('fill') || "''"})`
66
- );
67
- });
68
- }
69
-
70
- attributeChangedCallback(attrName, oldValue, newValue) {
71
- super.attributeChangedCallback?.(attrName, oldValue, newValue);
72
-
73
- if (oldValue === newValue) return;
74
-
75
- if (attrName === 'src') {
76
- this.toggleVisibility(newValue);
77
-
78
- createIcon(this.src).then((res) => {
79
- this.innerHTML = '';
80
- if (res) {
81
- const clonedNode = res.cloneNode(true);
82
- this.updateFillColor(clonedNode);
83
- this.appendChild(clonedNode);
84
- }
85
- });
86
- }
87
- }
88
- }
89
-
90
12
  export const IconClass = compose(
91
13
  createStyleMixin({
92
14
  mappings: {
93
15
  fill: {},
94
- alignItems: {}
95
16
  },
96
17
  }),
97
18
  draggableMixin,
98
- componentNameValidationMixin
99
- )(RawIcon);
19
+ componentNameValidationMixin,
20
+ )(
21
+ createProxy({
22
+ slots: [],
23
+ wrappedEleName: 'descope-image',
24
+ style: () => `
25
+ :host {
26
+ display: inline-flex;
27
+ }
28
+ `,
29
+ excludeAttrsSync: ['tabindex', 'class'],
30
+ componentName,
31
+ }),
32
+ );
@@ -1,3 +1,5 @@
1
+ import '@descope-ui/descope-image';
2
+
1
3
  import { componentName, IconClass } from './IconClass';
2
4
 
3
5
  customElements.define(componentName, IconClass);
@@ -0,0 +1,10 @@
1
+ <svg
2
+ width="1.5em"
3
+ height="1.5em"
4
+ viewBox="0 0 800 1000"
5
+ xmlns="http://www.w3.org/2000/svg"
6
+ fill="#000000"
7
+ data-icon="apple"
8
+ >
9
+ <path d="M788.1 340.9c-5.8 4.5-108.2 62.2-108.2 190.5 0 148.4 130.3 200.9 134.2 202.2-.6 3.2-20.7 71.9-68.7 141.9-42.8 61.6-87.5 123.1-155.5 123.1s-85.5-39.5-164-39.5c-76.5 0-103.7 40.8-165.9 40.8s-105.6-57-155.5-127C46.7 790.7 0 663 0 541.8c0-194.4 126.4-297.5 250.8-297.5 66.1 0 121.2 43.4 162.7 43.4 39.5 0 101.1-46 176.3-46 28.5 0 130.9 2.6 198.3 99.2zm-234-181.5c31.1-36.9 53.1-88.1 53.1-139.3 0-7.1-.6-14.3-1.9-20.1-50.6 1.9-110.8 33.7-147.1 75.8-28.5 32.4-55.1 83.6-55.1 135.5 0 7.8 1.3 15.6 1.9 18.1 3.2.6 8.4 1.3 13.6 1.3 45.4 0 102.5-30.4 135.5-71.3z" />
10
+ </svg>
@@ -1,18 +1,21 @@
1
1
  import { componentName } from '../src/component';
2
2
  import { fillControl } from '@descope-ui/common/sb-controls';
3
- import fromUrl from './google.svg?no-inline';
4
- import {base64png, base64svg} from 'test-assets';
3
+ import fromUrlLight from './google.svg';
4
+ import fromUrlDark from './apple.svg';
5
+ import { base64png, base64svg } from 'test-assets';
5
6
 
6
7
  const icons = {
7
- fromUrl,
8
+ fromUrlLight,
9
+ fromUrlDark,
8
10
  base64png,
9
11
  base64svg,
10
12
  };
11
13
 
12
- const Template = ({ icon, 'st-fill': fill }) => {
14
+ const Template = ({ src, srcDark, 'st-fill': fill }) => {
13
15
  return `
14
16
  <descope-icon
15
- src="${icons[icon]}"
17
+ src="${icons[src]}"
18
+ src-dark="${icons[srcDark]}"
16
19
  ${fill ? `st-fill="${fill}"` : ''}
17
20
  ></descope-icon>
18
21
  `;
@@ -23,8 +26,12 @@ export default {
23
26
  title: 'descope-icon',
24
27
  argTypes: {
25
28
  ...fillControl,
26
- icon: {
27
- options: ['base64svg', 'base64png', 'fromUrl'],
29
+ src: {
30
+ options: Object.keys(icons),
31
+ control: { type: 'select' },
32
+ },
33
+ srcDark: {
34
+ options: Object.keys(icons),
28
35
  control: { type: 'select' },
29
36
  },
30
37
  },
@@ -33,5 +40,6 @@ export default {
33
40
  export const Default = Template.bind({});
34
41
 
35
42
  Default.args = {
36
- icon: 'fromUrl',
43
+ src: 'fromUrlLight',
44
+ srcDark: 'fromUrlDark',
37
45
  };