@directus/themes 0.0.1
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/index.d.ts +106 -0
- package/dist/index.js +72 -0
- package/license +16 -0
- package/package.json +42 -0
- package/readme.md +4 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import * as _sinclair_typebox from '@sinclair/typebox';
|
|
2
|
+
import { Static } from '@sinclair/typebox';
|
|
3
|
+
import * as pinia from 'pinia';
|
|
4
|
+
import * as vue from 'vue';
|
|
5
|
+
|
|
6
|
+
/** CSS size, f.e. px, em, % */
|
|
7
|
+
/** CSS font weight, f.e. 700, bold */
|
|
8
|
+
/** CSS font family, f.e. 'Comic Sans, MS', 'Roboto' */
|
|
9
|
+
declare const ThemeSchema: _sinclair_typebox.TObject<{
|
|
10
|
+
name: _sinclair_typebox.TString;
|
|
11
|
+
appearance: _sinclair_typebox.TUnion<[_sinclair_typebox.TLiteral<"light">, _sinclair_typebox.TLiteral<"dark">]>;
|
|
12
|
+
rules: _sinclair_typebox.TObject<{
|
|
13
|
+
foreground: _sinclair_typebox.TString;
|
|
14
|
+
}>;
|
|
15
|
+
}>;
|
|
16
|
+
type Theme = Static<typeof ThemeSchema>;
|
|
17
|
+
|
|
18
|
+
declare const defineTheme: (theme: Theme) => {
|
|
19
|
+
name: string;
|
|
20
|
+
appearance: "light" | "dark";
|
|
21
|
+
rules: {
|
|
22
|
+
foreground: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
declare const useThemeStore: pinia.StoreDefinition<"themes", pinia._UnwrapAll<Pick<{
|
|
27
|
+
themes: {
|
|
28
|
+
dark: {
|
|
29
|
+
name: string;
|
|
30
|
+
appearance: "light" | "dark";
|
|
31
|
+
rules: {
|
|
32
|
+
foreground: string;
|
|
33
|
+
};
|
|
34
|
+
}[];
|
|
35
|
+
light: {
|
|
36
|
+
name: string;
|
|
37
|
+
appearance: "light" | "dark";
|
|
38
|
+
rules: {
|
|
39
|
+
foreground: string;
|
|
40
|
+
};
|
|
41
|
+
}[];
|
|
42
|
+
};
|
|
43
|
+
registerTheme: (theme: Theme) => void;
|
|
44
|
+
currentTheme: {
|
|
45
|
+
dark: string;
|
|
46
|
+
light: string;
|
|
47
|
+
};
|
|
48
|
+
currentAppearance: vue.Ref<"light" | "dark">;
|
|
49
|
+
rules: vue.ComputedRef<{
|
|
50
|
+
foreground: string;
|
|
51
|
+
}>;
|
|
52
|
+
}, "themes" | "currentTheme" | "currentAppearance">>, Pick<{
|
|
53
|
+
themes: {
|
|
54
|
+
dark: {
|
|
55
|
+
name: string;
|
|
56
|
+
appearance: "light" | "dark";
|
|
57
|
+
rules: {
|
|
58
|
+
foreground: string;
|
|
59
|
+
};
|
|
60
|
+
}[];
|
|
61
|
+
light: {
|
|
62
|
+
name: string;
|
|
63
|
+
appearance: "light" | "dark";
|
|
64
|
+
rules: {
|
|
65
|
+
foreground: string;
|
|
66
|
+
};
|
|
67
|
+
}[];
|
|
68
|
+
};
|
|
69
|
+
registerTheme: (theme: Theme) => void;
|
|
70
|
+
currentTheme: {
|
|
71
|
+
dark: string;
|
|
72
|
+
light: string;
|
|
73
|
+
};
|
|
74
|
+
currentAppearance: vue.Ref<"light" | "dark">;
|
|
75
|
+
rules: vue.ComputedRef<{
|
|
76
|
+
foreground: string;
|
|
77
|
+
}>;
|
|
78
|
+
}, "rules">, Pick<{
|
|
79
|
+
themes: {
|
|
80
|
+
dark: {
|
|
81
|
+
name: string;
|
|
82
|
+
appearance: "light" | "dark";
|
|
83
|
+
rules: {
|
|
84
|
+
foreground: string;
|
|
85
|
+
};
|
|
86
|
+
}[];
|
|
87
|
+
light: {
|
|
88
|
+
name: string;
|
|
89
|
+
appearance: "light" | "dark";
|
|
90
|
+
rules: {
|
|
91
|
+
foreground: string;
|
|
92
|
+
};
|
|
93
|
+
}[];
|
|
94
|
+
};
|
|
95
|
+
registerTheme: (theme: Theme) => void;
|
|
96
|
+
currentTheme: {
|
|
97
|
+
dark: string;
|
|
98
|
+
light: string;
|
|
99
|
+
};
|
|
100
|
+
currentAppearance: vue.Ref<"light" | "dark">;
|
|
101
|
+
rules: vue.ComputedRef<{
|
|
102
|
+
foreground: string;
|
|
103
|
+
}>;
|
|
104
|
+
}, "registerTheme">>;
|
|
105
|
+
|
|
106
|
+
export { Theme, ThemeSchema, defineTheme, useThemeStore };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
// src/define-theme.ts
|
|
2
|
+
var defineTheme = (theme) => theme;
|
|
3
|
+
|
|
4
|
+
// src/schema.ts
|
|
5
|
+
import { Type } from "@sinclair/typebox";
|
|
6
|
+
var Color = Type.String();
|
|
7
|
+
var ThemeSchema = Type.Object({
|
|
8
|
+
name: Type.String(),
|
|
9
|
+
appearance: Type.Union([Type.Literal("light"), Type.Literal("dark")]),
|
|
10
|
+
rules: Type.Object({
|
|
11
|
+
foreground: Color
|
|
12
|
+
})
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
// src/store.ts
|
|
16
|
+
import { defu } from "defu";
|
|
17
|
+
import { defineStore } from "pinia";
|
|
18
|
+
import { computed, reactive, ref, unref } from "vue";
|
|
19
|
+
|
|
20
|
+
// src/themes/dark/default.ts
|
|
21
|
+
var default_default = defineTheme({
|
|
22
|
+
name: "Directus Default (Dark)",
|
|
23
|
+
appearance: "dark",
|
|
24
|
+
rules: {
|
|
25
|
+
foreground: "#fff"
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
// src/themes/light/default.ts
|
|
30
|
+
var default_default2 = defineTheme({
|
|
31
|
+
name: "Directus Default (Light)",
|
|
32
|
+
appearance: "light",
|
|
33
|
+
rules: {
|
|
34
|
+
foreground: "#000"
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
// src/store.ts
|
|
39
|
+
var useThemeStore = defineStore("themes", () => {
|
|
40
|
+
const currentAppearance = ref("light");
|
|
41
|
+
const currentTheme = reactive({
|
|
42
|
+
dark: default_default.name,
|
|
43
|
+
light: default_default2.name
|
|
44
|
+
});
|
|
45
|
+
const themes = reactive({
|
|
46
|
+
dark: [default_default],
|
|
47
|
+
light: [default_default2]
|
|
48
|
+
});
|
|
49
|
+
const registerTheme = (theme) => {
|
|
50
|
+
if (theme.appearance === "dark") {
|
|
51
|
+
themes.dark.push(theme);
|
|
52
|
+
} else {
|
|
53
|
+
themes.light.push(theme);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const defaultTheme = computed(() => {
|
|
57
|
+
if (unref(currentAppearance) === "dark")
|
|
58
|
+
return default_default;
|
|
59
|
+
return default_default2;
|
|
60
|
+
});
|
|
61
|
+
const rules = computed(() => {
|
|
62
|
+
const appearance = unref(currentAppearance);
|
|
63
|
+
const theme = themes[appearance].find(({ name }) => name === currentTheme[unref(currentAppearance)]);
|
|
64
|
+
return defu(theme?.rules, unref(defaultTheme).rules);
|
|
65
|
+
});
|
|
66
|
+
return { themes, registerTheme, currentTheme, currentAppearance, rules };
|
|
67
|
+
});
|
|
68
|
+
export {
|
|
69
|
+
ThemeSchema,
|
|
70
|
+
defineTheme,
|
|
71
|
+
useThemeStore
|
|
72
|
+
};
|
package/license
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright 2023 Monospace, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
|
6
|
+
documentation files (the “Software”), to deal in the Software without restriction, including without limitation the
|
|
7
|
+
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit
|
|
8
|
+
persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
9
|
+
|
|
10
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
|
|
11
|
+
Software.
|
|
12
|
+
|
|
13
|
+
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
|
|
14
|
+
WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
|
15
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
|
|
16
|
+
OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/package.json
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@directus/themes",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "Themes for Directus",
|
|
5
|
+
"homepage": "https://directus.io",
|
|
6
|
+
"sideEffects": false,
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/directus/directus.git",
|
|
10
|
+
"directory": "packages/themes"
|
|
11
|
+
},
|
|
12
|
+
"funding": "https://github.com/directus/directus?sponsor=1",
|
|
13
|
+
"license": "MIT",
|
|
14
|
+
"author": "Rijk van Zanten <rijkvanzanten@me.com>",
|
|
15
|
+
"type": "module",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": "./dist/index.js",
|
|
18
|
+
"./package.json": "./package.json"
|
|
19
|
+
},
|
|
20
|
+
"main": "dist/index.js",
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@vitest/coverage-c8": "0.31.1",
|
|
26
|
+
"tsup": "6.7.0",
|
|
27
|
+
"typescript": "5.0.4",
|
|
28
|
+
"vitest": "0.31.1",
|
|
29
|
+
"@directus/tsconfig": "0.0.7"
|
|
30
|
+
},
|
|
31
|
+
"dependencies": {
|
|
32
|
+
"@sinclair/typebox": "0.28.13",
|
|
33
|
+
"defu": "6.1.2",
|
|
34
|
+
"pinia": "2.1.1",
|
|
35
|
+
"vue": "3.3.4"
|
|
36
|
+
},
|
|
37
|
+
"scripts": {
|
|
38
|
+
"build": "tsup src/index.ts --format=esm --dts",
|
|
39
|
+
"dev": "tsup src/index.ts --format=esm --dts --watch",
|
|
40
|
+
"test": "vitest --watch=false"
|
|
41
|
+
}
|
|
42
|
+
}
|
package/readme.md
ADDED