@code-coaching/vuetiful 0.15.0 → 0.15.2

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 (29) hide show
  1. package/README.md +0 -3
  2. package/dist/style.css +2 -2
  3. package/dist/styles/all.css +95 -93
  4. package/dist/types/components/atoms/VAvatar.vue.d.ts +2 -2
  5. package/dist/types/{utils/dark-mode/dark-mode.vue.d.ts → components/atoms/VLightSwitch.vue.d.ts} +4 -4
  6. package/dist/types/components/atoms/index.d.ts +3 -1
  7. package/dist/types/services/index.d.ts +3 -1
  8. package/dist/types/utils/index.d.ts +1 -4
  9. package/dist/types/utils/theme/theme-switcher.vue.d.ts +3 -3
  10. package/dist/vuetiful.es.mjs +5128 -5129
  11. package/dist/vuetiful.umd.js +14 -15
  12. package/package.json +1 -1
  13. package/src/{utils/code-block → components/atoms}/VCodeBlock.vue +1 -1
  14. package/src/{utils/dark-mode/dark-mode.vue → components/atoms/VLightSwitch.vue} +1 -2
  15. package/src/components/atoms/VRadio/VRadioItem.test.ts +6 -6
  16. package/src/components/atoms/VRadio/VRadioItem.vue +3 -2
  17. package/src/components/atoms/index.ts +4 -0
  18. package/src/{utils/dark-mode → services}/dark-mode.service.test.ts +11 -11
  19. package/src/{utils/dark-mode → services}/dark-mode.service.ts +1 -1
  20. package/src/services/index.ts +3 -1
  21. package/src/utils/index.ts +1 -4
  22. package/src/utils/theme/theme-switcher.vue +10 -15
  23. /package/dist/types/{utils/code-block → components/atoms}/VCodeBlock.vue.d.ts +0 -0
  24. /package/dist/types/{utils/dark-mode → services}/dark-mode.service.d.ts +0 -0
  25. /package/dist/types/{utils/dark-mode → services}/dark-mode.service.test.d.ts +0 -0
  26. /package/dist/types/{utils/code-block → services}/highlight.service.d.ts +0 -0
  27. /package/dist/types/{utils/code-block → services}/highlight.service.test.d.ts +0 -0
  28. /package/src/{utils/code-block → services}/highlight.service.test.ts +0 -0
  29. /package/src/{utils/code-block → services}/highlight.service.ts +0 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@code-coaching/vuetiful",
3
- "version": "0.15.0",
3
+ "version": "0.15.2",
4
4
  "license": "MIT",
5
5
  "scripts": {
6
6
  "dev": "onchange 'src/**/*.vue' 'src/**/*.ts' 'src/**/*.css' -- npm run build",
@@ -1,8 +1,8 @@
1
1
  <script setup lang="ts">
2
2
  import { CssClasses, vClipboard } from "@/index";
3
+ import { useHighlight } from "@/services/highlight.service";
3
4
  import "highlight.js/styles/github-dark.css";
4
5
  import { ref } from "vue";
5
- import { useHighlight } from "./highlight.service";
6
6
 
7
7
  const { highlight } = useHighlight();
8
8
 
@@ -24,9 +24,8 @@
24
24
  </template>
25
25
 
26
26
  <script lang="ts">
27
- import type { CssClasses } from "@/index";
27
+ import { CssClasses, useDarkMode } from "@/index";
28
28
  import { computed, ComputedRef, defineComponent, onMounted } from "vue";
29
- import { useDarkMode } from "./dark-mode.service";
30
29
 
31
30
  export default defineComponent({
32
31
  props: {
@@ -40,7 +40,7 @@ describe("VRadioItem slot states", () => {
40
40
  },
41
41
  });
42
42
 
43
- const itemEl = wrapper.find("[data-test='item']").find("span");
43
+ const itemEl = wrapper.find("[data-test='item']").find("div");
44
44
  expect(itemEl.element.classList.contains("variant-filled")).toBe(true);
45
45
  expect(itemEl.element.classList.contains("hover:variant-ghost")).toBe(false);
46
46
  });
@@ -62,7 +62,7 @@ describe("VRadioItem slot states", () => {
62
62
  },
63
63
  });
64
64
 
65
- const itemEl = wrapper.find("[data-test='item']").find("span");
65
+ const itemEl = wrapper.find("[data-test='item']").find("div");
66
66
  expect(itemEl.element.classList.contains("variant-filled")).toBe(false);
67
67
  expect(itemEl.element.classList.contains("hover:variant-ghost")).toBe(true);
68
68
  });
@@ -89,7 +89,7 @@ describe("VRadioItem slot states", () => {
89
89
  },
90
90
  });
91
91
 
92
- const itemEl = wrapper.find("[data-test='item']").find("span");
92
+ const itemEl = wrapper.find("[data-test='item']").find("div");
93
93
  expect(itemEl.element.classList.contains("custom-active-class")).toBe(true);
94
94
  expect(itemEl.element.classList.contains("custom-hover-class")).toBe(false);
95
95
  });
@@ -117,7 +117,7 @@ describe("VRadioItem slot states", () => {
117
117
  },
118
118
  });
119
119
 
120
- const itemEl = wrapper.find("[data-test='item']").find("span");
120
+ const itemEl = wrapper.find("[data-test='item']").find("div");
121
121
  expect(itemEl.element.classList.contains("custom-active-class")).toBe(false);
122
122
  expect(itemEl.element.classList.contains("custom-hover-class")).toBe(true);
123
123
  });
@@ -145,7 +145,7 @@ describe("VRadioItem slot states", () => {
145
145
  },
146
146
  });
147
147
 
148
- const itemEl = wrapper.find("[data-test='item']").find("span");
148
+ const itemEl = wrapper.find("[data-test='item']").find("div");
149
149
  expect(itemEl.element.classList.contains("cursor-pointer")).toBe(true);
150
150
  expect(itemEl.element.classList.contains("cursor-not-allowed")).toBe(false);
151
151
  expect(itemEl.element.classList.contains("opacity-50")).toBe(false);
@@ -174,7 +174,7 @@ describe("VRadioItem slot states", () => {
174
174
  },
175
175
  });
176
176
 
177
- const itemEl = wrapper.find("[data-test='item']").find("span");
177
+ const itemEl = wrapper.find("[data-test='item']").find("div");
178
178
  expect(itemEl.element.classList.contains("cursor-pointer")).toBe(false);
179
179
  expect(itemEl.element.classList.contains("cursor-not-allowed")).toBe(true);
180
180
  expect(itemEl.element.classList.contains("opacity-50")).toBe(true);
@@ -15,12 +15,13 @@ const hover = (inject("hover") as string);
15
15
 
16
16
  <template>
17
17
  <RadioGroupOption v-slot="{ checked, disabled }" :value="value">
18
- <span
18
+ <div
19
+ data-test="radio-item"
19
20
  :class="`radio-item px-4 py-1 text-center text-base rounded-token ${
20
21
  checked ? active : hover
21
22
  } ${disabled ? 'cursor-not-allowed opacity-50' : 'cursor-pointer'}`"
22
23
  >
23
24
  <slot />
24
- </span>
25
+ </div>
25
26
  </RadioGroupOption>
26
27
  </template>
@@ -2,6 +2,8 @@ import VAvatar from "./VAvatar.vue";
2
2
  import VBadge from "./VBadge.vue";
3
3
  import VButton from "./VButton.vue";
4
4
  import VChip from "./VChip.vue";
5
+ import VCodeBlock from "./VCodeBlock.vue";
6
+ import VLightSwitch from "./VLightSwitch.vue";
5
7
 
6
8
  import VRadioDescription from "./VRadio/VRadioDescription.vue";
7
9
  import VRadioGroup from "./VRadio/VRadioGroup.vue";
@@ -18,6 +20,8 @@ export {
18
20
  VButton,
19
21
  VBadge,
20
22
  VChip,
23
+ VCodeBlock,
24
+ VLightSwitch,
21
25
  VRadioGroup,
22
26
  VRadioItem,
23
27
  VRadioLabel,
@@ -13,7 +13,7 @@ describe("useDarkMode", () => {
13
13
  describe("getModeUserPrefers", () => {
14
14
  describe("given not in browser", () => {
15
15
  it("should return default modeUserPrefers", async () => {
16
- const platform = await import("../platform/platform.service");
16
+ const platform = await import("../utils/platform/platform.service");
17
17
  vi.spyOn(platform, "usePlatform").mockReturnValueOnce({ isBrowser: false });
18
18
 
19
19
  const { useDarkMode } = await import("./dark-mode.service");
@@ -25,7 +25,7 @@ describe("useDarkMode", () => {
25
25
  describe("given in browser", () => {
26
26
  describe("given no modeUserPrefers in localStorage", () => {
27
27
  it("should return default modeUserPrefers", async () => {
28
- const platform = await import("../platform/platform.service");
28
+ const platform = await import("../utils/platform/platform.service");
29
29
  vi.spyOn(platform, "usePlatform").mockReturnValueOnce({ isBrowser: true });
30
30
 
31
31
  const { useDarkMode } = await import("./dark-mode.service");
@@ -39,7 +39,7 @@ describe("useDarkMode", () => {
39
39
  });
40
40
  describe("given modeUserPrefers in localStorage", () => {
41
41
  it("should return the value", async () => {
42
- const platform = await import("../platform/platform.service");
42
+ const platform = await import("../utils/platform/platform.service");
43
43
  vi.spyOn(platform, "usePlatform").mockReturnValueOnce({ isBrowser: true });
44
44
 
45
45
  const { useDarkMode } = await import("./dark-mode.service");
@@ -57,7 +57,7 @@ describe("useDarkMode", () => {
57
57
  describe("getModeOsPrefers", () => {
58
58
  describe("given not in browser", () => {
59
59
  it("should return default modeOsPrefers", async () => {
60
- const platform = await import("../platform/platform.service");
60
+ const platform = await import("../utils/platform/platform.service");
61
61
  vi.spyOn(platform, "usePlatform").mockReturnValueOnce({ isBrowser: false });
62
62
 
63
63
  const { useDarkMode } = await import("./dark-mode.service");
@@ -69,7 +69,7 @@ describe("useDarkMode", () => {
69
69
  describe("given in browser", () => {
70
70
  describe("given prefers-color-scheme: light", () => {
71
71
  it("should return true", async () => {
72
- const platform = await import("../platform/platform.service");
72
+ const platform = await import("../utils/platform/platform.service");
73
73
  vi.spyOn(platform, "usePlatform").mockReturnValueOnce({ isBrowser: true });
74
74
  const localStorageSpy = vi.spyOn(window.localStorage, "setItem");
75
75
 
@@ -83,7 +83,7 @@ describe("useDarkMode", () => {
83
83
  });
84
84
  describe("given prefers-color-scheme: dark", () => {
85
85
  it("should return false", async () => {
86
- const platform = await import("../platform/platform.service");
86
+ const platform = await import("../utils/platform/platform.service");
87
87
  vi.spyOn(platform, "usePlatform").mockReturnValueOnce({ isBrowser: true });
88
88
  const localStorageSpy = vi.spyOn(window.localStorage, "setItem");
89
89
 
@@ -101,7 +101,7 @@ describe("useDarkMode", () => {
101
101
  describe("getModeAutoPrefers", () => {
102
102
  describe("given not in browser", () => {
103
103
  it("should return default modeAutoPrefers", async () => {
104
- const platform = await import("../platform/platform.service");
104
+ const platform = await import("../utils/platform/platform.service");
105
105
  vi.spyOn(platform, "usePlatform").mockReturnValueOnce({ isBrowser: false });
106
106
 
107
107
  const { useDarkMode } = await import("./dark-mode.service");
@@ -113,7 +113,7 @@ describe("useDarkMode", () => {
113
113
  describe("given in browser", () => {
114
114
  describe("given no modeUserPrefers in localStorage", () => {
115
115
  it("should return default modeAutoPrefers", async () => {
116
- const platform = await import("../platform/platform.service");
116
+ const platform = await import("../utils/platform/platform.service");
117
117
  vi.spyOn(platform, "usePlatform").mockReturnValueOnce({ isBrowser: true });
118
118
 
119
119
  const { useDarkMode } = await import("./dark-mode.service");
@@ -127,7 +127,7 @@ describe("useDarkMode", () => {
127
127
  });
128
128
  describe("given modeUserPrefers in localStorage", () => {
129
129
  it("should return the value", async () => {
130
- const platform = await import("../platform/platform.service");
130
+ const platform = await import("../utils/platform/platform.service");
131
131
  vi.spyOn(platform, "usePlatform").mockReturnValueOnce({ isBrowser: true });
132
132
 
133
133
  const { useDarkMode } = await import("./dark-mode.service");
@@ -145,7 +145,7 @@ describe("useDarkMode", () => {
145
145
  describe("setModeUserPrefers", () => {
146
146
  describe("given not in browser", () => {
147
147
  it("should set modeUserPrefers", async () => {
148
- const platform = await import("../platform/platform.service");
148
+ const platform = await import("../utils/platform/platform.service");
149
149
  vi.spyOn(platform, "usePlatform").mockReturnValueOnce({ isBrowser: false });
150
150
  vi.spyOn(window.localStorage, "setItem");
151
151
 
@@ -160,7 +160,7 @@ describe("useDarkMode", () => {
160
160
 
161
161
  describe("given in browser", () => {
162
162
  it("should set modeUserPrefers and localStorage", async () => {
163
- const platform = await import("../platform/platform.service");
163
+ const platform = await import("../utils/platform/platform.service");
164
164
  vi.spyOn(platform, "usePlatform").mockReturnValueOnce({ isBrowser: true });
165
165
 
166
166
  const { useDarkMode } = await import("./dark-mode.service");
@@ -1,5 +1,5 @@
1
1
  import { readonly, Ref, ref } from "vue";
2
- import { usePlatform } from "../platform/platform.service";
2
+ import { usePlatform } from "../utils/platform/platform.service";
3
3
 
4
4
  const { isBrowser } = usePlatform();
5
5
 
@@ -1,4 +1,6 @@
1
1
  import { useRail } from "./rail.service";
2
2
  import { useDrawer } from "./drawer.service";
3
+ import { useHighlight } from "./highlight.service";
4
+ import { useDarkMode } from "./dark-mode.service";
3
5
 
4
- export { useRail, useDrawer };
6
+ export { useRail, useDrawer, useHighlight, useDarkMode };
@@ -1,7 +1,4 @@
1
- import VCodeBlock from "./code-block/VCodeBlock.vue";
2
- import { useDarkMode } from "./dark-mode/dark-mode.service";
3
- import DarkModeSwitch from "./dark-mode/dark-mode.vue";
4
1
  import ThemeSwitcher from "./theme/theme-switcher.vue";
5
2
  import { useTheme } from "./theme/theme.service";
6
3
 
7
- export { DarkModeSwitch, ThemeSwitcher, useDarkMode, useTheme, VCodeBlock };
4
+ export { ThemeSwitcher, useTheme };
@@ -4,11 +4,15 @@
4
4
  Theme
5
5
  </VButton>
6
6
 
7
- <div v-if="showPopup" class="cc-theme-switcher__popup p-4 shadow-xl" :class="classes">
7
+ <div
8
+ v-if="showPopup"
9
+ class="cc-theme-switcher__popup absolute z-10 mt-1 p-4 shadow-xl"
10
+ :class="classes"
11
+ >
8
12
  <div class="space-y-4">
9
13
  <section class="flex items-center justify-between">
10
14
  <h6>Mode</h6>
11
- <DarkModeSwitch />
15
+ <v-light-switch />
12
16
  </section>
13
17
  <nav class="list-nav -m-4 overflow-y-auto p-4" :class="listClasses">
14
18
  <ul class="flex flex-col gap-4">
@@ -33,12 +37,12 @@
33
37
  </template>
34
38
 
35
39
  <script lang="ts">
36
- import { CssClasses, DarkModeSwitch, useDarkMode, useTheme, VButton } from "@/index";
40
+ import { CssClasses, useDarkMode, useTheme, VButton, VLightSwitch } from "@/index";
37
41
  import { computed, defineComponent, onMounted, ref } from "vue";
38
42
 
39
43
  export default defineComponent({
40
44
  components: {
41
- DarkModeSwitch,
45
+ VLightSwitch,
42
46
  VButton,
43
47
  },
44
48
  props: {
@@ -83,7 +87,7 @@ export default defineComponent({
83
87
  default: "w-24",
84
88
  },
85
89
  },
86
- setup(props, { attrs }) {
90
+ setup(props) {
87
91
  const { initializeTheme, loadTheme, themes, chosenTheme } = useTheme();
88
92
  const { currentMode, MODE } = useDarkMode();
89
93
 
@@ -116,8 +120,7 @@ export default defineComponent({
116
120
  ${text.value}
117
121
  ${props.width}
118
122
  ${props.ring}
119
- ${props.roundedContainer}
120
- ${attrs.class ?? ""}`;
123
+ ${props.roundedContainer}`;
121
124
  });
122
125
 
123
126
  const listClasses = computed(() => {
@@ -145,11 +148,3 @@ export default defineComponent({
145
148
  },
146
149
  });
147
150
  </script>
148
-
149
- <style scoped>
150
- .cc-theme-switcher__popup {
151
- position: absolute;
152
- z-index: 1;
153
- margin-top: 0.25rem;
154
- }
155
- </style>