@quaffui/quaff 0.1.0-prealpha7 → 0.1.0-prealpha8

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.
Files changed (70) hide show
  1. package/dist/components/avatar/QAvatar.svelte +8 -7
  2. package/dist/components/avatar/props.d.ts +2 -2
  3. package/dist/components/button/QBtn.svelte +4 -1
  4. package/dist/components/button/props.d.ts +2 -2
  5. package/dist/components/chip/QChip.svelte +8 -2
  6. package/dist/components/chip/props.d.ts +2 -2
  7. package/dist/components/drawer/QDrawer.svelte +2 -1
  8. package/dist/components/drawer/props.d.ts +2 -2
  9. package/dist/components/footer/QFooter.svelte +13 -3
  10. package/dist/components/footer/props.d.ts +2 -2
  11. package/dist/components/icon/QIcon.svelte +5 -12
  12. package/dist/components/icon/props.d.ts +2 -2
  13. package/dist/components/progress/QCircularProgress.svelte +4 -3
  14. package/dist/components/progress/QCircularProgress.svelte.d.ts +1 -1
  15. package/dist/components/progress/props.d.ts +26 -9
  16. package/dist/components/progress/props.js +1 -7
  17. package/dist/components/railbar/QRailbar.svelte +2 -1
  18. package/dist/components/railbar/QRailbar.svelte.d.ts +1 -1
  19. package/dist/components/railbar/props.d.ts +11 -3
  20. package/dist/components/railbar/props.js +1 -7
  21. package/dist/components/toolbar/QToolbar.svelte +2 -1
  22. package/dist/components/toolbar/QToolbar.svelte.d.ts +1 -1
  23. package/dist/components/toolbar/props.d.ts +11 -4
  24. package/dist/components/toolbar/props.js +1 -10
  25. package/dist/composables/use-size.d.ts +8 -8
  26. package/dist/composables/use-size.js +23 -13
  27. package/dist/css/index.css +1 -1
  28. package/dist/css/index.scss +0 -1
  29. package/dist/helpers/version.d.ts +1 -1
  30. package/dist/helpers/version.js +1 -1
  31. package/dist/index.d.ts +1 -0
  32. package/dist/index.js +1 -0
  33. package/dist/utils/types.d.ts +3 -0
  34. package/package.json +1 -1
  35. package/dist/css/material-symbols-outlined-latin-100-normal.woff +0 -0
  36. package/dist/css/material-symbols-outlined-latin-100-normal.woff2 +0 -0
  37. package/dist/css/material-symbols-outlined-latin-200-normal.woff +0 -0
  38. package/dist/css/material-symbols-outlined-latin-200-normal.woff2 +0 -0
  39. package/dist/css/material-symbols-outlined-latin-300-normal.woff +0 -0
  40. package/dist/css/material-symbols-outlined-latin-300-normal.woff2 +0 -0
  41. package/dist/css/material-symbols-outlined-latin-400-normal.woff +0 -0
  42. package/dist/css/material-symbols-outlined-latin-400-normal.woff2 +0 -0
  43. package/dist/css/material-symbols-rounded-latin-100-normal.woff +0 -0
  44. package/dist/css/material-symbols-rounded-latin-100-normal.woff2 +0 -0
  45. package/dist/css/material-symbols-rounded-latin-200-normal.woff +0 -0
  46. package/dist/css/material-symbols-rounded-latin-200-normal.woff2 +0 -0
  47. package/dist/css/material-symbols-rounded-latin-300-normal.woff +0 -0
  48. package/dist/css/material-symbols-rounded-latin-300-normal.woff2 +0 -0
  49. package/dist/css/material-symbols-rounded-latin-400-normal.woff +0 -0
  50. package/dist/css/material-symbols-rounded-latin-400-normal.woff2 +0 -0
  51. package/dist/css/material-symbols-sharp-latin-100-normal.woff +0 -0
  52. package/dist/css/material-symbols-sharp-latin-100-normal.woff2 +0 -0
  53. package/dist/css/material-symbols-sharp-latin-200-normal.woff +0 -0
  54. package/dist/css/material-symbols-sharp-latin-200-normal.woff2 +0 -0
  55. package/dist/css/material-symbols-sharp-latin-300-normal.woff +0 -0
  56. package/dist/css/material-symbols-sharp-latin-300-normal.woff2 +0 -0
  57. package/dist/css/material-symbols-sharp-latin-400-normal.woff +0 -0
  58. package/dist/css/material-symbols-sharp-latin-400-normal.woff2 +0 -0
  59. package/dist/css/roboto-cyrillic-400-normal.woff +0 -0
  60. package/dist/css/roboto-cyrillic-400-normal.woff2 +0 -0
  61. package/dist/css/roboto-cyrillic-ext-400-normal.woff +0 -0
  62. package/dist/css/roboto-cyrillic-ext-400-normal.woff2 +0 -0
  63. package/dist/css/roboto-greek-400-normal.woff +0 -0
  64. package/dist/css/roboto-greek-400-normal.woff2 +0 -0
  65. package/dist/css/roboto-latin-400-normal.woff +0 -0
  66. package/dist/css/roboto-latin-400-normal.woff2 +0 -0
  67. package/dist/css/roboto-latin-ext-400-normal.woff +0 -0
  68. package/dist/css/roboto-latin-ext-400-normal.woff2 +0 -0
  69. package/dist/css/roboto-vietnamese-400-normal.woff +0 -0
  70. package/dist/css/roboto-vietnamese-400-normal.woff2 +0 -0
@@ -1,9 +1,10 @@
1
- <script>import { createClasses, createStyles } from "../../utils/props";
1
+ <script>import { useSize } from "../../composables/use-size";
2
+ import { createClasses, createStyles } from "../../utils/props";
2
3
  export let shape = "circle", size = "md", src = void 0, video = false, userClasses = void 0, userStyles = void 0;
3
4
  export { userClasses as class };
4
5
  export { userStyles as style };
5
6
  $:
6
- isBasicSize = ["xs", "sm", "md", "lg", "xl"].includes(size);
7
+ sizeObj = useSize(size);
7
8
  $:
8
9
  shapeClass = createClasses([
9
10
  shape === "circle" && "circle",
@@ -14,18 +15,18 @@ $:
14
15
  shape.includes("right") && "right-round"
15
16
  ]);
16
17
  $:
17
- classes = createClasses([shapeClass, isBasicSize && size], {
18
+ classes = createClasses([shapeClass, sizeObj.class], {
18
19
  component: "q-avatar",
19
20
  userClasses
20
21
  });
21
22
  $:
22
- style = !isBasicSize ? createStyles(
23
+ style = createStyles(
23
24
  {
24
- width: size,
25
- height: size
25
+ width: sizeObj.style,
26
+ height: sizeObj.style
26
27
  },
27
28
  userStyles
28
- ) : userStyles;
29
+ );
29
30
  </script>
30
31
 
31
32
  {#if video === true}
@@ -1,6 +1,6 @@
1
- import type { NativeProps } from "../../utils/types";
1
+ import type { QuaffSizes, CssValue, NativeProps } from "../../utils/types";
2
2
  export type QAvatarShapeOptions = "circle" | "rounded" | "top-round" | "left-round" | "right-round" | "bottom-round" | "top-left-round" | "top-right-round" | "bottom-left-round" | "bottom-right-round";
3
- export type QAvatarSizeOptions = "xs" | "sm" | "md" | "lg" | "xl" | string;
3
+ export type QAvatarSizeOptions = QuaffSizes | CssValue | number;
4
4
  export interface QAvatarProps extends NativeProps {
5
5
  /**
6
6
  * Shape of the avatar.
@@ -3,12 +3,15 @@ import { createEventDispatcher } from "svelte";
3
3
  import QIcon from "../icon/QIcon.svelte";
4
4
  import QCircularProgress from "../progress/QCircularProgress.svelte";
5
5
  import { activationHandler } from "../../helpers/activationHandler";
6
+ import { useSize } from "../../composables/use-size";
6
7
  export let icon = void 0, label = void 0, disable = false, loading = false, unelevated = false, outline = false, round = false, rectangle = false, flat = false, to = void 0, size = void 0, userClasses = void 0;
7
8
  export { userClasses as class };
8
9
  const emit = createEventDispatcher();
9
10
  let tag;
10
11
  $:
11
12
  tag = to !== void 0 ? "a" : "div";
13
+ $:
14
+ sizeObj = useSize(size);
12
15
  $:
13
16
  classes = createClasses(
14
17
  [
@@ -17,7 +20,7 @@ $:
17
20
  outline && "outlined",
18
21
  flat && "flat",
19
22
  (!$$slots.default && !label || round) && "round",
20
- size && size !== "md" && size
23
+ size !== "md" && sizeObj.class
21
24
  ],
22
25
  {
23
26
  component: "q-btn",
@@ -1,5 +1,5 @@
1
- import type { NativeProps } from "../../utils/types";
2
- export type QBtnSizeOptions = "sm" | "md" | "lg" | "xl";
1
+ import type { NativeProps, QuaffSizes } from "../../utils/types";
2
+ export type QBtnSizeOptions = Exclude<QuaffSizes, "xs">;
3
3
  export interface QBtnProps extends NativeProps {
4
4
  /**
5
5
  * Puts the button in a disabled state, making it unclickable.
@@ -2,6 +2,7 @@
2
2
  import { createClasses } from "../../utils/props";
3
3
  import { createEventDispatcher } from "svelte";
4
4
  import QIcon from "../icon/QIcon.svelte";
5
+ import { useSize } from "../../composables/use-size";
5
6
  export let content = void 0, icon = void 0, iconRight = void 0, disable = false, responsive = false, vertical = false, round = false, outlined = false, size = "md", tabindex = void 0, href = void 0, userClasses = void 0;
6
7
  export { userClasses as class };
7
8
  const emit = createEventDispatcher();
@@ -10,10 +11,15 @@ $:
10
11
  $:
11
12
  imgRight = iconRight?.startsWith("img:") ? iconRight.slice(4) : void 0;
12
13
  $:
13
- sizeClass = ["sm", "lg"].includes(size) ? size : void 0;
14
+ sizeObj = useSize(size);
14
15
  $:
15
16
  classes = createClasses(
16
- [vertical && "vertical", round && "rounded", (outlined || disable) && "bordered", sizeClass],
17
+ [
18
+ vertical && "vertical",
19
+ round && "rounded",
20
+ (outlined || disable) && "bordered",
21
+ size !== "md" && sizeObj.class
22
+ ],
17
23
  {
18
24
  component: "q-chip",
19
25
  userClasses
@@ -1,5 +1,5 @@
1
- import type { NativeProps } from "../../utils/types";
2
- export type QChipSizeOptions = "sm" | "md" | "lg";
1
+ import type { NativeProps, QuaffSizes } from "../../utils/types";
2
+ export type QChipSizeOptions = Exclude<QuaffSizes, "xs" | "xl">;
3
3
  export interface QChipProps extends NativeProps {
4
4
  /**
5
5
  * The content inside the chip. Will overwrite the default slot.
@@ -2,6 +2,7 @@
2
2
  import { createClasses, createStyles } from "../../utils/props";
3
3
  import { getContext } from "svelte";
4
4
  import { clickOutside } from "../../helpers";
5
+ import { useSize } from "../../composables/use-size";
5
6
  export let value = true, side = "left", width = 300, breakpoint = 1023, showIfAbove = false, behavior = "default", bordered = false, elevated = false, overlay = false, persistent = false, noSwipeOpen = false, noSwipeClose = false, noSwipeBackdrop = false, userClasses = void 0, userStyles = void 0;
6
7
  export { userClasses as class, userStyles as style };
7
8
  $:
@@ -10,7 +11,7 @@ $:
10
11
  belowBreakpoint = behavior === "mobile" === true || behavior !== "desktop" && /** TODO: Get Layout width */
11
12
  1300 <= breakpoint;
12
13
  $:
13
- widthStyle = ctx === void 0 ? isNaN(Number(width)) ? width : `${width}px` : void 0;
14
+ widthStyle = $ctx && useSize(width).style;
14
15
  $:
15
16
  hideOnRouteChange = persistent !== true || overlay === true;
16
17
  export const show = (e) => {
@@ -1,4 +1,4 @@
1
- import type { NativeProps } from "../../utils/types";
1
+ import type { CssValue, NativeProps } from "../../utils/types";
2
2
  export type QDrawerSideOptions = "left" | "right";
3
3
  export type QDrawerBehaviorOptions = "default" | "desktop" | "mobile";
4
4
  export interface QDrawerProps extends NativeProps {
@@ -16,7 +16,7 @@ export interface QDrawerProps extends NativeProps {
16
16
  * The width of the drawer. Can be specified with a CSS unit. If no unit is specified, "px" will be used.
17
17
  * @default 300
18
18
  */
19
- width?: number | string;
19
+ width?: number | CssValue;
20
20
  /**
21
21
  * The breakpoint at which the drawer behavior changes. (not supported yet)
22
22
  * @default 1023
@@ -1,13 +1,23 @@
1
1
  <script>import { getContext } from "svelte";
2
- import { createClasses } from "../../utils/props";
2
+ import { createClasses, createStyles } from "../../utils/props";
3
+ import { useSize } from "../../composables/use-size";
3
4
  export let value = true, bordered = false, elevated = false, height = void 0, userClasses = void 0, userStyles = void 0;
4
5
  export { userClasses as class, userStyles as style };
5
6
  let ctx = getContext("layout");
6
7
  $:
7
- classes = createClasses(["q-footer", $ctx && $ctx.footer.fixed && "fixed", userClasses]);
8
+ heightStyle = $ctx && useSize(height).style;
9
+ $:
10
+ classes = createClasses(["q-footer", $ctx && $ctx.footer?.fixed && "fixed", userClasses]);
11
+ $:
12
+ style = createStyles(
13
+ {
14
+ "--footer-height": heightStyle
15
+ },
16
+ userStyles
17
+ );
8
18
  </script>
9
19
 
10
- <footer class={classes} style={userStyles}>
20
+ <footer class={classes} {style}>
11
21
  <nav>
12
22
  <slot />
13
23
  </nav>
@@ -1,4 +1,4 @@
1
- import type { NativeProps } from "../../utils/types";
1
+ import type { CssValue, NativeProps } from "../../utils/types";
2
2
  export interface QFooterProps extends NativeProps {
3
3
  /**
4
4
  * The value indicating whether the footer is visible or hidden. (not supported yet)
@@ -19,5 +19,5 @@ export interface QFooterProps extends NativeProps {
19
19
  * The height of the footer. Can be specified with a CSS unit. If not specified, "px" will be used. (not supported yet)
20
20
  * @default undefined
21
21
  */
22
- height?: string | number;
22
+ height?: number | CssValue;
23
23
  }
@@ -1,20 +1,13 @@
1
1
  <script>import { createClasses, createStyles } from "../../utils/props";
2
2
  import { isNumber } from "../../utils/types";
3
3
  import { sizes } from "../../composables/use-size";
4
+ import { useSize } from "../../composables/use-size";
4
5
  export let size = "md", name = void 0, type = "outlined", filled = false, svg = void 0, img = void 0, imgAttributes = {}, color = void 0, userClasses = void 0, userStyles = void 0;
5
6
  export { userClasses as class, userStyles as style };
6
- let sizeStyle;
7
- $: {
8
- if (isNumber(size)) {
9
- sizeStyle = `${size}px`;
10
- } else if (typeof size === "string" && !sizes.includes(size)) {
11
- sizeStyle = size;
12
- } else {
13
- sizeStyle = void 0;
14
- }
15
- }
16
7
  $:
17
- classes = createClasses([type, filled && "filled", sizes.includes(size) && size], {
8
+ sizeObj = useSize(size);
9
+ $:
10
+ classes = createClasses([type, filled && "filled", sizeObj.class], {
18
11
  component: "q-icon",
19
12
  userClasses,
20
13
  quaffClasses: [color && `text-${color}`]
@@ -22,7 +15,7 @@ $:
22
15
  $:
23
16
  style = createStyles(
24
17
  {
25
- "--size": sizeStyle
18
+ "--size": sizeObj.style
26
19
  },
27
20
  userStyles
28
21
  );
@@ -1,5 +1,5 @@
1
- import type { NativeProps } from "../../utils/types";
2
- export type QIconSizeOptions = "xs" | "sm" | "md" | "lg" | "xl" | string | number;
1
+ import type { CssValue, NativeProps, QuaffSizes } from "../../utils/types";
2
+ export type QIconSizeOptions = QuaffSizes | CssValue | number;
3
3
  export type QIconTypeOptions = "outlined" | "sharp" | "rounded";
4
4
  export interface QIconProps extends NativeProps {
5
5
  /**
@@ -1,9 +1,10 @@
1
- <script>import { createClasses } from "../../utils/props";
1
+ <script>import { useSize } from "../../composables/use-size";
2
+ import { createClasses } from "../../utils/props";
2
3
  import { isNumber } from "../../utils/types";
3
4
  export let value = 0, indeterminate = false, size = "2em", color = void 0, thickness = 5, userClasses = void 0;
4
5
  export { userClasses as class };
5
6
  $:
6
- spinnerSize = isNumber(size) ? `${size}px` : size;
7
+ spinnerSize = useSize(size);
7
8
  $:
8
9
  classes = createClasses([indeterminate && "indeterminate"], {
9
10
  component: "q-circular-progress",
@@ -12,7 +13,7 @@ $:
12
13
  });
13
14
  </script>
14
15
 
15
- <svg class={classes} height={spinnerSize} width={spinnerSize} viewBox="25 25 50 50">
16
+ <svg class={classes} height={spinnerSize.style} width={spinnerSize.style} viewBox="25 25 50 50">
16
17
  <circle
17
18
  class="path"
18
19
  cx="50"
@@ -4,7 +4,7 @@ declare const __propDef: {
4
4
  props: {
5
5
  value?: number | undefined;
6
6
  indeterminate?: boolean | undefined;
7
- size?: string | number | undefined;
7
+ size?: number | `${number}px` | `${number}%` | `${number}em` | `${number}ex` | `${number}ch` | `${number}rem` | `${number}vw` | `${number}vh` | `${number}vmin` | `${number}vmax` | undefined;
8
8
  color?: QCircularProgressProps["color"];
9
9
  thickness?: number | undefined;
10
10
  class?: string | undefined;
@@ -1,20 +1,37 @@
1
- import { type NativeProps } from "../../utils/types";
1
+ import type { NativeProps, CssValue } from "../../utils/types";
2
2
  export interface QLinearProgressProps extends NativeProps {
3
+ /**
4
+ * @default 0
5
+ */
3
6
  value: number;
7
+ /**
8
+ * @default left
9
+ */
4
10
  from: "left" | "right";
11
+ /**
12
+ * @default false
13
+ */
5
14
  rounded: boolean;
6
15
  }
7
16
  export interface QCircularProgressProps extends NativeProps {
17
+ /**
18
+ * @default 0
19
+ */
8
20
  value: number;
21
+ /**
22
+ * @default false
23
+ */
9
24
  indeterminate: boolean;
10
- size: string | number;
25
+ /**
26
+ * @default 2em
27
+ */
28
+ size: CssValue | number;
29
+ /**
30
+ * @default undefined
31
+ */
11
32
  color?: string;
33
+ /**
34
+ * @default 5
35
+ */
12
36
  thickness: number;
13
37
  }
14
- export declare const QLinearProgressPropsDefaults: {
15
- userClasses?: string | undefined;
16
- userStyles?: string | undefined;
17
- value: number;
18
- from: string;
19
- rounded: boolean;
20
- };
@@ -1,7 +1 @@
1
- import { NativePropsDefaults } from "../../utils/types";
2
- export const QLinearProgressPropsDefaults = {
3
- value: 0,
4
- from: "left",
5
- rounded: false,
6
- ...NativePropsDefaults,
7
- };
1
+ export {};
@@ -1,6 +1,7 @@
1
1
  <script>import { getContext } from "svelte";
2
2
  import { createClasses, createStyles } from "../../utils/props";
3
3
  import { isNumber } from "../../utils/types";
4
+ import { useSize } from "../../composables/use-size";
4
5
  export let width = 88, side = "left", bordered = false, userClasses = void 0, userStyles = void 0;
5
6
  export { userClasses as class, userStyles as style };
6
7
  let ctx = getContext("layout");
@@ -21,7 +22,7 @@ $:
21
22
  userClasses
22
23
  ]);
23
24
  $:
24
- widthStyle = ctx === void 0 ? isNumber(width) ? `${width}px` : width : void 0;
25
+ widthStyle = $ctx && useSize(width).style;
25
26
  $:
26
27
  style = createStyles(
27
28
  {
@@ -2,7 +2,7 @@ import { SvelteComponent } from "svelte";
2
2
  import type { QRailbarProps } from "./props";
3
3
  declare const __propDef: {
4
4
  props: {
5
- width?: string | number | undefined;
5
+ width?: number | `${number}px` | `${number}%` | `${number}em` | `${number}ex` | `${number}ch` | `${number}rem` | `${number}vw` | `${number}vh` | `${number}vmin` | `${number}vmax` | undefined;
6
6
  side?: "left" | "right" | undefined;
7
7
  bordered?: boolean | undefined;
8
8
  class?: string | undefined;
@@ -1,7 +1,15 @@
1
- import { type NativeProps } from "../../utils/types";
1
+ import type { NativeProps, CssValue } from "../../utils/types";
2
2
  export interface QRailbarProps extends NativeProps {
3
- width: number | string;
3
+ /**
4
+ * @default 88px
5
+ */
6
+ width: CssValue | number;
7
+ /**
8
+ * @default left
9
+ */
4
10
  side: "left" | "right";
11
+ /**
12
+ * @default false
13
+ */
5
14
  bordered: boolean;
6
15
  }
7
- export declare const QRailbarPropsDefaults: QRailbarProps;
@@ -1,7 +1 @@
1
- import { NativePropsDefaults } from "../../utils/types";
2
- export const QRailbarPropsDefaults = {
3
- width: 88,
4
- side: "left",
5
- bordered: false,
6
- ...NativePropsDefaults,
7
- };
1
+ export {};
@@ -1,6 +1,7 @@
1
1
  <script>import { createClasses, createStyles } from "../../utils/props";
2
2
  import { getContext } from "svelte";
3
3
  import { isNumber } from "../../utils/types";
4
+ import { useSize } from "../../composables/use-size";
4
5
  export let inset = false, height = "64px", userClasses = void 0, userStyles = void 0;
5
6
  export { userClasses as class, userStyles as style };
6
7
  let ctx = getContext("layout");
@@ -14,7 +15,7 @@ $:
14
15
  userClasses
15
16
  ]);
16
17
  $:
17
- heightStyle = ctx === void 0 ? isNumber(height) ? `${height}px` : height : void 0;
18
+ heightStyle = $ctx && useSize(height).style;
18
19
  $:
19
20
  if ($ctx?.header !== void 0) {
20
21
  if (userStyles?.includes("display: none")) {
@@ -4,7 +4,7 @@ declare const __propDef: {
4
4
  props: {
5
5
  [x: string]: any;
6
6
  inset?: boolean | undefined;
7
- height?: string | number | undefined;
7
+ height?: number | `${number}px` | `${number}%` | `${number}em` | `${number}ex` | `${number}ch` | `${number}rem` | `${number}vw` | `${number}vh` | `${number}vmin` | `${number}vmax` | undefined;
8
8
  class?: string | undefined;
9
9
  style?: string | undefined;
10
10
  };
@@ -1,10 +1,17 @@
1
- import type { NativeProps } from "../../utils/types";
1
+ import type { NativeProps, CssValue } from "../../utils/types";
2
2
  export interface QToolbarProps extends NativeProps {
3
+ /**
4
+ * @default false
5
+ */
3
6
  inset: boolean;
4
- height: string | number;
7
+ /**
8
+ * @default 64px
9
+ */
10
+ height: CssValue | number;
5
11
  }
6
- export declare const QToolbarPropsDefaults: QToolbarProps;
7
12
  export interface QToolbarTitleProps extends NativeProps {
13
+ /**
14
+ * @default false
15
+ */
8
16
  shrink: boolean;
9
17
  }
10
- export declare const QToolbarTitlePropsDefaults: QToolbarTitleProps;
@@ -1,10 +1 @@
1
- import { NativePropsDefaults } from "../../utils/types";
2
- export const QToolbarPropsDefaults = {
3
- inset: false,
4
- height: "64px",
5
- ...NativePropsDefaults,
6
- };
7
- export const QToolbarTitlePropsDefaults = {
8
- shrink: false,
9
- ...NativePropsDefaults,
10
- };
1
+ export {};
@@ -1,9 +1,9 @@
1
- export type Size = "xs" | "sm" | "md" | "lg" | "xl";
2
- export declare const sizes: Size[];
3
- export declare const useSizeClasses: {
4
- [key in Size]: string;
5
- };
6
- export interface useSizeProps {
7
- size?: string;
1
+ import { CssUnit, QuaffSizes } from "../utils/types";
2
+ export declare const sizes: QuaffSizes[];
3
+ export declare const CssUnits: CssUnit[];
4
+ interface UseSize {
5
+ class?: string;
6
+ style?: string;
8
7
  }
9
- export default function (sizeProp: any): string | null;
8
+ export declare function useSize(sizeProp: any): UseSize;
9
+ export {};
@@ -1,15 +1,25 @@
1
+ import { isNumber } from "../utils/types";
1
2
  export const sizes = ["xs", "sm", "md", "lg", "xl"];
2
- // @todo change classes or deprecate
3
- export const useSizeClasses = {
4
- xs: "tiny",
5
- sm: "small",
6
- md: "",
7
- lg: "large",
8
- xl: "extra",
9
- };
10
- export default function (sizeProp) {
11
- // return sizeStyle
12
- return sizeProp in useSizeClasses
13
- ? useSizeClasses[sizeProp]
14
- : null;
3
+ export const CssUnits = ["px", "%", "em", "ex", "ch", "rem", "vw", "vh", "vmin", "vmax"];
4
+ export function useSize(sizeProp) {
5
+ if (isNumber(sizeProp) && sizeProp > 0) {
6
+ return {
7
+ style: `${sizeProp}px`,
8
+ };
9
+ }
10
+ else if (typeof sizeProp === "string") {
11
+ for (let unit of CssUnits) {
12
+ if (sizeProp.slice(-unit.length) === unit) {
13
+ return {
14
+ style: sizeProp,
15
+ };
16
+ }
17
+ else if (sizes.includes(sizeProp)) {
18
+ return {
19
+ class: sizeProp,
20
+ };
21
+ }
22
+ }
23
+ }
24
+ return {};
15
25
  }