@greghowe79/the-lib 2.5.2 → 2.5.4

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.
@@ -5,7 +5,7 @@ const qwik = require("@builder.io/qwik");
5
5
  const styles = require("./styles.css.qwik.cjs");
6
6
  const loader = require("../loader/loader.qwik.cjs");
7
7
  const button_utils = require("./button.utils.qwik.cjs");
8
- const Button = qwik.component$(({ id, label, variant = "primary", icon, disabled = false, ariaLabel, type = "button", size = "md", onClick$, isLoading, active = false, customColors, keepStyleWhenDisabled = false }) => {
8
+ const Button = qwik.component$(({ id, label, variant = "primary", icon, disabled = false, ariaLabel, type = "button", size = "md", onClick$, isLoading, active = false, customColors }) => {
9
9
  qwik.useStylesScoped$(styles);
10
10
  const loading = typeof isLoading === "object" && isLoading !== null && "value" in isLoading ? isLoading.value : isLoading;
11
11
  const hasCustomStyles = customColors && (customColors.bg || customColors.text || customColors.border || customColors.padding || customColors.width);
@@ -20,8 +20,7 @@ const Button = qwik.component$(({ id, label, variant = "primary", icon, disabled
20
20
  class: [
21
21
  `button-${variant}`,
22
22
  `button-${size}`,
23
- // disabled && 'button-disabled',
24
- disabled && !keepStyleWhenDisabled && "button-disabled",
23
+ disabled && "button-disabled",
25
24
  active && "button-active"
26
25
  ].filter(Boolean).join(" "),
27
26
  disabled,
@@ -3,7 +3,7 @@ import { component$, useStylesScoped$ } from "@builder.io/qwik";
3
3
  import styles from "./styles.css.qwik.mjs";
4
4
  import { Loader } from "../loader/loader.qwik.mjs";
5
5
  import { generateCustomCSS } from "./button.utils.qwik.mjs";
6
- const Button = component$(({ id, label, variant = "primary", icon, disabled = false, ariaLabel, type = "button", size = "md", onClick$, isLoading, active = false, customColors, keepStyleWhenDisabled = false }) => {
6
+ const Button = component$(({ id, label, variant = "primary", icon, disabled = false, ariaLabel, type = "button", size = "md", onClick$, isLoading, active = false, customColors }) => {
7
7
  useStylesScoped$(styles);
8
8
  const loading = typeof isLoading === "object" && isLoading !== null && "value" in isLoading ? isLoading.value : isLoading;
9
9
  const hasCustomStyles = customColors && (customColors.bg || customColors.text || customColors.border || customColors.padding || customColors.width);
@@ -18,8 +18,7 @@ const Button = component$(({ id, label, variant = "primary", icon, disabled = fa
18
18
  class: [
19
19
  `button-${variant}`,
20
20
  `button-${size}`,
21
- // disabled && 'button-disabled',
22
- disabled && !keepStyleWhenDisabled && "button-disabled",
21
+ disabled && "button-disabled",
23
22
  active && "button-active"
24
23
  ].filter(Boolean).join(" "),
25
24
  disabled,
@@ -31,11 +31,14 @@ function generateCustomCSS(id, colors) {
31
31
  cursor: default !important;
32
32
  opacity: 0.6 !important;
33
33
  `;
34
+ const disabledRules = colors.keepStyleWhenDisabled ? "" : `
35
+ #${id}:disabled, #${id}.button-disabled { ${disabledStyles} }
36
+ #${id}:disabled:hover, #${id}.button-disabled:hover { ${disabledStyles} }
37
+ `;
34
38
  return `
35
39
  #${id} { ${baseStyles} }
36
40
  #${id}:not(:disabled):hover { ${hoverStyles} }
37
- #${id}:disabled, #${id}.button-disabled { ${disabledStyles} }
38
- #${id}:disabled:hover, #${id}.button-disabled:hover { ${disabledStyles} }
41
+ ${disabledRules}
39
42
  `;
40
43
  }
41
44
  exports.generateCustomCSS = generateCustomCSS;
@@ -29,11 +29,14 @@ function generateCustomCSS(id, colors) {
29
29
  cursor: default !important;
30
30
  opacity: 0.6 !important;
31
31
  `;
32
+ const disabledRules = colors.keepStyleWhenDisabled ? "" : `
33
+ #${id}:disabled, #${id}.button-disabled { ${disabledStyles} }
34
+ #${id}:disabled:hover, #${id}.button-disabled:hover { ${disabledStyles} }
35
+ `;
32
36
  return `
33
37
  #${id} { ${baseStyles} }
34
38
  #${id}:not(:disabled):hover { ${hoverStyles} }
35
- #${id}:disabled, #${id}.button-disabled { ${disabledStyles} }
36
- #${id}:disabled:hover, #${id}.button-disabled:hover { ${disabledStyles} }
39
+ ${disabledRules}
37
40
  `;
38
41
  }
39
42
  export {
@@ -88,8 +88,7 @@ const NavigationMenu = qwik.component$(({ ariaLabel, logoComponent, listItems, a
88
88
  ariaLabel: ariaLabel2,
89
89
  customColors,
90
90
  isLoading: isLoading && !!label,
91
- disabled: isLoading,
92
- keepStyleWhenDisabled: !label
91
+ disabled: isLoading
93
92
  }, id);
94
93
  })
95
94
  })
@@ -109,8 +108,7 @@ const NavigationMenu = qwik.component$(({ ariaLabel, logoComponent, listItems, a
109
108
  ariaLabel: action.ariaLabel,
110
109
  customColors: action.customColors,
111
110
  isLoading: isLoading && !!action.label,
112
- disabled: isLoading,
113
- keepStyleWhenDisabled: !action.label
111
+ disabled: isLoading
114
112
  }, action.id);
115
113
  })
116
114
  })
@@ -86,8 +86,7 @@ const NavigationMenu = component$(({ ariaLabel, logoComponent, listItems, action
86
86
  ariaLabel: ariaLabel2,
87
87
  customColors,
88
88
  isLoading: isLoading && !!label,
89
- disabled: isLoading,
90
- keepStyleWhenDisabled: !label
89
+ disabled: isLoading
91
90
  }, id);
92
91
  })
93
92
  })
@@ -107,8 +106,7 @@ const NavigationMenu = component$(({ ariaLabel, logoComponent, listItems, action
107
106
  ariaLabel: action.ariaLabel,
108
107
  customColors: action.customColors,
109
108
  isLoading: isLoading && !!action.label,
110
- disabled: isLoading,
111
- keepStyleWhenDisabled: !action.label
109
+ disabled: isLoading
112
110
  }, action.id);
113
111
  })
114
112
  })
@@ -11,6 +11,7 @@ export interface CustomColors {
11
11
  hoverBorder?: string;
12
12
  padding?: string;
13
13
  width?: string;
14
+ keepStyleWhenDisabled?: boolean;
14
15
  }
15
16
  export interface ButtonProps {
16
17
  id: string;
@@ -25,6 +26,5 @@ export interface ButtonProps {
25
26
  isLoading?: boolean | Signal<boolean>;
26
27
  active?: boolean;
27
28
  customColors?: CustomColors;
28
- keepStyleWhenDisabled?: boolean;
29
29
  }
30
30
  export declare const Button: Component<ButtonProps>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@greghowe79/the-lib",
3
- "version": "2.5.2",
3
+ "version": "2.5.4",
4
4
  "description": "Collection of fast components for Qwik",
5
5
  "main": "./lib/index.qwik.mjs",
6
6
  "qwik": "./lib/index.qwik.mjs",