@yourdash/uikit 1.0.10 → 1.0.12

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.
@@ -50,5 +50,5 @@
50
50
 
51
51
  .icon {
52
52
  margin-left: calc(var(#{$theme}#{$button}#{$padding}#{$horizontal}) / 2);
53
- margin-right: calc(var(#{$theme}#{$button}#{$padding}#{$horizontal}) / 4);
53
+ margin-right: var(#{$theme}#{$button}#{$padding}#{$horizontal});
54
54
  }
@@ -5,12 +5,12 @@
5
5
 
6
6
  import clippy from "@yourdash/shared/web/helpers/clippy.ts";
7
7
  import Icon from "../icon/icon.tsx";
8
- import { UKIcon } from "../icon/iconDictionary.ts";
8
+ import { UKIcon, UKIconType } from "../icon/iconDictionary.ts";
9
9
  import styles from "./buttonWithIcon.module.scss";
10
10
  import { FC } from "react";
11
11
 
12
12
  const ButtonWithIcon: FC<{
13
- icon: UKIcon;
13
+ icon: UKIconType;
14
14
  onClick: () => void;
15
15
  text: string;
16
16
  className?: string;
@@ -3,22 +3,34 @@
3
3
  * YourDash is licensed under the MIT License. (https://ewsgit.mit-license.org)
4
4
  */
5
5
 
6
- import { UKIcon } from "./iconDictionary.ts";
6
+ import { UKIcon, UKIconType } from "./iconDictionary.ts";
7
7
  import styles from "./icon.module.scss";
8
- import { FC } from "react";
8
+ import { FC, useEffect, useState } from "react";
9
+ import ServerErrorIcon from "./icons/server-error.svg";
9
10
 
10
11
  const Icon: FC<{
11
- icon: UKIcon;
12
+ // noinspection TypeScriptDuplicateUnionOrIntersectionType
13
+ icon: UKIconType;
12
14
  size?: string;
13
15
  color?: string;
14
16
  preserveColor?: boolean;
15
17
  className?: string;
16
18
  }> = (props) => {
19
+ const [icon, setIcon] = useState(ServerErrorIcon);
20
+
21
+ useEffect(() => {
22
+ if (typeof props.icon === "function") {
23
+ props.icon().then((val) => {
24
+ setIcon(val.default);
25
+ });
26
+ }
27
+ }, [props.icon]);
28
+
17
29
  return (
18
30
  <div
19
31
  className={`${styles.component} ${props.className} ${props.preserveColor ? styles.preserveColor : ""}`}
20
32
  style={{
21
- "--icon": `url(${props.icon})`,
33
+ "--icon": `url(${icon})`,
22
34
  ...(!props.preserveColor ? { "--color": props.color } : {}),
23
35
  // @ts-ignore
24
36
  "--size": props.size,