Skip to content

Commit 24c77ea

Browse files
committed
chore: add demo .less & .js
1 parent 3cca30d commit 24c77ea

File tree

2 files changed

+92
-0
lines changed

2 files changed

+92
-0
lines changed

demo/clock/index.js

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
async function whenReady() {
2+
return new Promise((resolve) => {
3+
if (document.readyState !== 'loading') {
4+
resolve()
5+
} else {
6+
document.addEventListener('DOMContentLoaded', resolve)
7+
}
8+
})
9+
}
10+
11+
;(async () => {
12+
await whenReady()
13+
14+
const getView = () => {
15+
return document.querySelector(`.split-view-view:has(> [id='workbench.parts.auxiliarybar'])`)
16+
}
17+
18+
let view = null
19+
const start = Date.now()
20+
while (!view && Date.now() - start < 3 * 60 * 1000) {
21+
view = getView()
22+
await new Promise((resolve) => {
23+
setTimeout(resolve, 1000)
24+
})
25+
}
26+
if (!view) {
27+
console.log('[custom-css] view not found after 3 minutes ~')
28+
return
29+
}
30+
31+
const action = () => {
32+
const right = window.getComputedStyle(view).width
33+
document.documentElement.style.setProperty('--clock-right', right)
34+
console.log('[custom-css] set --clock-right to %s', right)
35+
}
36+
37+
// first call
38+
action()
39+
40+
// observe later
41+
const observer = new MutationObserver((mutations) => {
42+
action()
43+
})
44+
observer.observe(view, { attributes: true, attributeFilter: ['style'] })
45+
window.addEventListener('unload', () => {
46+
observer.disconnect()
47+
})
48+
})()

demo/clock/index.less

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
#rid9\.datetime {
2+
position: fixed;
3+
top: 85px;
4+
right: calc(var(--clock-right, 0px) + 130px);
5+
6+
// color
7+
color: tomato;
8+
color: red;
9+
color: slateblue;
10+
color: seagreen;
11+
color: deeppink;
12+
13+
// https://www.bilibili.com/video/BV1g3411u7Lg?t=67.6
14+
color: #0545b2; // 理想之蓝
15+
color: #ef2729; // 石榴红
16+
color: #f89c00; // 鹿箭
17+
color: #233728; // 黛绿 rational blue
18+
color: #f3cc91; // cheese yellow
19+
color: #6b4c68; // grape purple
20+
color: #6b4c68; // grape purple
21+
color: #004d62; // 碧海天 ocean sky
22+
color: #425a17; // 箬叶青 leaves green
23+
color: #f4cd00; // 柠檬黄
24+
color: #ff7227; // sunset orange
25+
26+
line-height: 1.4 !important;
27+
height: unset !important;
28+
29+
// digital-7 mono
30+
font-family: 'Digital-7 Mono';
31+
font-size: 75px * 1.2;
32+
33+
font-family: 'M+ 1m', 'ubuntu mono', 'mplus 1 code', 'Hack';
34+
font-size: 75px * 1.2;
35+
36+
// 防止影响搜索模块
37+
pointer-events: none;
38+
z-index: 34;
39+
}
40+
41+
#rid9\.datetime a:hover,
42+
#rid9\.datetime a:focus {
43+
background-color: transparent !important;
44+
}

0 commit comments

Comments
 (0)