@witchcraft/ui 0.3.9 → 0.4.0

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/dist/module.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "witchcraftUi",
3
3
  "configKey": "witchcraftUi",
4
- "version": "0.3.9",
4
+ "version": "0.4.0",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -167,7 +167,9 @@ const props = defineProps({
167
167
  notification: { type: null, required: true },
168
168
  handler: { type: Object, required: false, default: void 0 }
169
169
  });
170
- const getColor = (notification, option) => notification.default === option ? "primary" : notification.dangerous.includes(option) ? "danger" : "secondary";
170
+ const getColor = (notification, option) => {
171
+ return notification.dangerous.includes(option) ? "danger" : notification.default === option ? "primary" : "secondary";
172
+ };
171
173
  const buttonColors = computed(() => props.notification.options.map((option) => getColor(props.notification, option)));
172
174
  const notificationEl = ref(null);
173
175
  onMounted(() => {
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Returns whether the text should be inverted (to white) based on the given color.
3
+ */
4
+ export declare function doInvertTextColor(color: string): boolean;
@@ -0,0 +1,8 @@
1
+ import Color from "colorjs.io";
2
+ export function doInvertTextColor(color) {
3
+ const c = new Color(color).to("hsv");
4
+ const v = c.hsv[2];
5
+ const a = c.alpha;
6
+ const doInvert = !!(v < 50 || (a === void 0 || a < 0.5));
7
+ return doInvert;
8
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@witchcraft/ui",
3
- "version": "0.3.9",
3
+ "version": "0.4.0",
4
4
  "description": "Vue component library.",
5
5
  "type": "module",
6
6
  "main": "./dist/runtime/main.lib.js",
package/src/module.ts CHANGED
@@ -21,7 +21,6 @@ import { unpluginIconViteOptions } from "./runtime/build/unpluginIconViteOptions
21
21
  import { themeConvertionOpts } from "./runtime/tailwind/themeConvertionOpts.js"
22
22
  import { theme } from "./runtime/theme.js"
23
23
 
24
- import pkg from "../package.json" assert { type: "json" }
25
24
 
26
25
  const knownDirectives = ["vExtractRootEl", "vResizableCols", "vResizeObserver", "vResizableCols"] as const
27
26
 
@@ -171,7 +171,13 @@ const props = withDefaults(defineProps<Props>(), {
171
171
  handler: undefined
172
172
  })
173
173
 
174
- const getColor = (notification: NotificationEntry, option: string): "ok" | "primary" | "danger" | "secondary" => notification.default === option ? "primary" : notification.dangerous.includes(option) ? "danger" : "secondary"
174
+ const getColor = (notification: NotificationEntry, option: string): "ok" | "primary" | "danger" | "secondary" => {
175
+ return notification.dangerous.includes(option)
176
+ ? "danger"
177
+ : notification.default === option
178
+ ? "primary"
179
+ : "secondary"
180
+ }
175
181
 
176
182
  /* Todo make this more flexible? */
177
183
 
@@ -0,0 +1,11 @@
1
+ import Color from "colorjs.io"
2
+ /**
3
+ * Returns whether the text should be inverted (to white) based on the given color.
4
+ */
5
+ export function doInvertTextColor(color: string) {
6
+ const c = new Color(color).to("hsv")
7
+ const v = c.hsv[2]
8
+ const a = c.alpha
9
+ const doInvert = !!(v! < 50 || (a === undefined || a < 0.5))
10
+ return doInvert
11
+ }