Skip to content

Commit a704d01

Browse files
committed
feat(omi-templates): eevert packages/omi-templates to 23098cc
1 parent 564ff15 commit a704d01

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1319
-1404
lines changed

packages/omi-templates/index.html

Lines changed: 95 additions & 98 deletions
Original file line numberDiff line numberDiff line change
@@ -1,117 +1,114 @@
11
<!doctype html>
22
<html lang="en">
3-
4-
<head>
5-
<meta charset="UTF-8" />
6-
<link rel="icon" href="https://omi.cdn-go.cn/play/latest/assets/favicon.974a6ddb.ico">
7-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
8-
<title>100+ OMI Tailwind Templates</title>
9-
</head>
10-
11-
<body>
12-
<div id="app"></div>
13-
<script>
14-
document.addEventListener('DOMContentLoaded', function () {
15-
try {
3+
<head>
4+
<meta charset="UTF-8" />
5+
<link rel="icon" href="https://omi.cdn-go.cn/play/latest/assets/favicon.974a6ddb.ico">
6+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
7+
<title>100+ OMI Tailwind Templates</title>
8+
</head>
9+
<body>
10+
<div id="app"></div>
11+
<script>
12+
document.addEventListener('DOMContentLoaded', function () {
13+
try {
14+
if (
15+
localStorage.theme === "dark" ||
16+
(!("theme" in localStorage) &&
17+
window.matchMedia("(prefers-color-scheme: dark)").matches)
18+
) {
19+
walkDOMAndToggleDark(document.body, false)
20+
document.documentElement.classList.add("dark");
21+
} else {
22+
walkDOMAndToggleDark(document.body, true)
23+
document.documentElement.classList.remove("dark");
24+
}
25+
} catch (_) { }
26+
})
27+
28+
29+
function toggleNodeDark(node, isDark) {
1630
if (
17-
localStorage.theme === "dark" ||
18-
(!("theme" in localStorage) &&
19-
window.matchMedia("(prefers-color-scheme: dark)").matches)
31+
node instanceof HTMLElement &&
32+
node.tagName.toLowerCase().indexOf("-") !== -1
2033
) {
21-
walkDOMAndToggleDark(document.body, false)
22-
document.documentElement.classList.add("dark");
23-
} else {
24-
walkDOMAndToggleDark(document.body, true)
25-
document.documentElement.classList.remove("dark");
34+
if (isDark) {
35+
node.classList.remove("dark");
36+
} else {
37+
node.classList.add("dark");
38+
}
39+
2640
}
27-
} catch (_) { }
28-
})
29-
30-
31-
function toggleNodeDark(node, isDark) {
32-
if (
33-
node instanceof HTMLElement &&
34-
node.tagName.toLowerCase().indexOf("-") !== -1
35-
) {
41+
}
42+
43+
function walkDOMAndToggleDark(rootNode, isDark) {
3644
if (isDark) {
37-
node.classList.remove("dark");
45+
document.documentElement.classList.remove("dark");
3846
} else {
39-
node.classList.add("dark");
47+
document.documentElement.classList.add("dark");
4048
}
41-
42-
}
43-
}
44-
45-
function walkDOMAndToggleDark(rootNode, isDark) {
46-
if (isDark) {
47-
document.documentElement.classList.remove("dark");
48-
} else {
49-
document.documentElement.classList.add("dark");
50-
}
51-
const treeWalker = document.createTreeWalker(
52-
rootNode,
53-
NodeFilter.SHOW_ELEMENT,
54-
null,
55-
false
56-
);
57-
58-
while (treeWalker.nextNode()) {
59-
const node = treeWalker.currentNode;
60-
toggleNodeDark(node, isDark);
61-
62-
// Check if the node has a shadow root
63-
if (node.shadowRoot) {
64-
walkDOMAndToggleDark(node.shadowRoot, isDark);
49+
const treeWalker = document.createTreeWalker(
50+
rootNode,
51+
NodeFilter.SHOW_ELEMENT,
52+
null,
53+
false
54+
);
55+
56+
while (treeWalker.nextNode()) {
57+
const node = treeWalker.currentNode;
58+
toggleNodeDark(node, isDark);
59+
60+
// Check if the node has a shadow root
61+
if (node.shadowRoot) {
62+
walkDOMAndToggleDark(node.shadowRoot, isDark);
63+
}
64+
65+
// Check if the node has assigned nodes (for slots)
66+
if (node.assignedNodes) {
67+
node.assignedNodes().forEach((assignedNode) => {
68+
if (assignedNode.nodeType === Node.ELEMENT_NODE) {
69+
walkDOMAndToggleDark(assignedNode, isDark);
70+
}
71+
});
72+
}
6573
}
66-
67-
// Check if the node has assigned nodes (for slots)
68-
if (node.assignedNodes) {
69-
node.assignedNodes().forEach((assignedNode) => {
70-
if (assignedNode.nodeType === Node.ELEMENT_NODE) {
71-
walkDOMAndToggleDark(assignedNode, isDark);
72-
}
73-
});
74+
}
75+
76+
function toogleDark() {
77+
if (document.documentElement.classList.contains("dark")) {
78+
localStorage.theme = "light";
79+
walkDOMAndToggleDark(document.body, true)
80+
document.documentElement.classList.remove("dark");
81+
} else {
82+
localStorage.theme = "dark";
83+
walkDOMAndToggleDark(document.body, false)
84+
document.documentElement.classList.add("dark");
7485
}
7586
}
76-
}
7787

78-
function toogleDark() {
79-
if (document.documentElement.classList.contains("dark")) {
80-
localStorage.theme = "light";
81-
walkDOMAndToggleDark(document.body, true)
82-
document.documentElement.classList.remove("dark");
83-
} else {
88+
function setDarkMode() {
8489
localStorage.theme = "dark";
8590
walkDOMAndToggleDark(document.body, false)
8691
document.documentElement.classList.add("dark");
8792
}
88-
}
89-
90-
function setDarkMode() {
91-
localStorage.theme = "dark";
92-
walkDOMAndToggleDark(document.body, false)
93-
document.documentElement.classList.add("dark");
94-
}
95-
96-
function setLightMode() {
97-
localStorage.theme = "light";
98-
walkDOMAndToggleDark(document.body, true)
99-
document.documentElement.classList.remove("dark");
100-
}
10193

102-
function refreshDark() {
103-
if (document.documentElement.classList.contains("dark")) {
104-
walkDOMAndToggleDark(document.body, false)
105-
} else {
94+
function setLightMode() {
95+
localStorage.theme = "light";
10696
walkDOMAndToggleDark(document.body, true)
97+
document.documentElement.classList.remove("dark");
10798
}
108-
}
109-
110-
window.addEventListener('load', function () {
111-
refreshDark()
112-
})
113-
</script>
114-
<script type="module" src="/src/main.tsx"></script>
115-
</body>
116-
117-
</html>
99+
100+
function refreshDark() {
101+
if (document.documentElement.classList.contains("dark")) {
102+
walkDOMAndToggleDark(document.body, false)
103+
} else {
104+
walkDOMAndToggleDark(document.body, true)
105+
}
106+
}
107+
108+
window.addEventListener('load', function() {
109+
refreshDark()
110+
})
111+
</script>
112+
<script type="module" src="/src/main.tsx"></script>
113+
</body>
114+
</html>

packages/omi-templates/package.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,16 @@
2929
"tailwind-merge": "^2.2.1"
3030
},
3131
"devDependencies": {
32-
"@tailwindcss/typography": "^0.5.15",
33-
"@tailwindcss/vite": "^4.0.0",
32+
"@tailwindcss/typography": "^0.5.10",
3433
"@types/markdown-it": "^13.0.7",
34+
"autoprefixer": "^10.4.16",
3535
"eslint": "^8.45.0",
36+
"postcss": "^8.4.31",
3637
"prettier": "3.0.3",
3738
"sass": "^1.55.0",
38-
"tailwindcss": "^4.0.0",
39+
"tailwindcss": "^3.3.3",
3940
"ts-node": "^10.9.1",
4041
"typescript": "^5.0.2",
41-
"vite": "^7.0.0"
42+
"vite": "^4.4.5"
4243
}
4344
}

0 commit comments

Comments
 (0)