@witchcraft/ui 0.3.9 → 0.3.10
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 +1 -1
- package/dist/runtime/components/LibNotifications/LibNotification.vue +3 -1
- package/dist/runtime/utils/doInvertTextColor.d.ts +4 -0
- package/dist/runtime/utils/doInvertTextColor.js +8 -0
- package/package.json +1 -1
- package/src/module.ts +0 -1
- package/src/runtime/components/LibNotifications/LibNotification.vue +7 -1
- package/src/runtime/utils/doInvertTextColor.ts +11 -0
package/dist/module.json
CHANGED
|
@@ -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) =>
|
|
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(() => {
|
package/package.json
CHANGED
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" =>
|
|
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
|
+
}
|