Skip to content

Commit d844324

Browse files
authored
Merge pull request #2 from frontend-engineering/feat/stats-view
Feat/stats view
2 parents 2ef2b03 + 0a4a9e0 commit d844324

26 files changed

+1845
-453
lines changed

assets/plugin-styles.txt.css

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -93,11 +93,59 @@
9393
.sidebar-section-header
9494
{
9595
margin: 0em 0 0em var(--sidebar-margin);
96-
text-transform: uppercase;
9796
letter-spacing: 0.06em;
9897
font-weight: 600;
9998
}
10099

100+
.sidebar-section-header-brand {
101+
margin: 1em;
102+
margin-left: 0;
103+
/* margin: 0em 0 0em var(--sidebar-margin); */
104+
text-transform: uppercase;
105+
letter-spacing: 0.06em;
106+
font-weight: 600;
107+
color: var(--site-name-color);
108+
font-size: var(--site-name-size);
109+
font-weight: var(--site-name-weight);
110+
z-index: 1;
111+
cursor: pointer;
112+
line-height: 1.2;
113+
text-decoration: none;
114+
display: flex;
115+
justify-content: flex-start;
116+
align-items: center;
117+
}
118+
.sidebar-section-header-brand > span {
119+
display: block;
120+
line-height: 1.2;
121+
}
122+
.sidebar-section-header-brand-logo {
123+
margin-right: 6px;
124+
border-radius: 8px;
125+
width: 24px;
126+
height: 24px;
127+
object-fit: contain;
128+
}
129+
.theme-light .sidebar-section-header-brand-logo {
130+
/* filter: invert(1); */
131+
}
132+
133+
134+
.sidebar-section-header-slogan {
135+
letter-spacing: 0.06em;
136+
font-weight: 600;
137+
color: var(--site-name-color);
138+
font-size: var(--site-name-size);
139+
font-weight: var(--site-name-weight);
140+
z-index: 1;
141+
line-height: 1.2;
142+
padding: 4px 32px 32px 0;
143+
text-decoration: none;
144+
display: flex;
145+
justify-content: flex-start;
146+
align-items: center;
147+
}
148+
101149
.sidebar-content {
102150
width: var(--sidebar-width);
103151
line-height: var(--line-height-tight);
@@ -232,7 +280,7 @@
232280
height: 100%;
233281
width: auto;
234282
margin: var(--sidebar-margin);
235-
margin-top: 3em;
283+
/* margin-top: 3em; */
236284
margin-bottom: 0;
237285
}
238286

assets/webpage.txt.js

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,50 @@ function setActiveDocument(url, scrollTo = true, pushHistory = true)
464464
}
465465

466466
//#region Initialization
467+
468+
async function loadLeftSidebar(document) {
469+
let container = document.querySelector('.sidebar-left > .sidebar-content')
470+
if (!container) {
471+
console.log('no container found for left sidebar');
472+
return;
473+
}
474+
let response;
475+
476+
try
477+
{
478+
const hostPath = getURLPath();
479+
const baseDir = hostPath.split('/')[0];
480+
const sidebarUrl = `${baseDir}/_common-left-tree.html`
481+
console.log("Loading left sidebar: ", sidebarUrl);
482+
response = await fetch(sidebarUrl);
483+
}
484+
catch (error)
485+
{
486+
console.log("Cannot fetch left sidebar");
487+
return;
488+
}
489+
490+
if (response.ok)
491+
{
492+
let html = (await response.text()).replaceAll("<!DOCTYPE html>", "").replaceAll("<html>", "").replaceAll("</html>", "");
493+
const tmpContainer = document.createElement('div');
494+
console.log('html fetched: ', html);
495+
tmpContainer.innerHTML = html;
496+
const legacy = container.querySelector('.file-tree');
497+
if (legacy) {
498+
container.removeChild(legacy);
499+
}
500+
container.appendChild(tmpContainer.firstChild);
501+
}
502+
else
503+
{
504+
console.error('fetch failed: ', response);
505+
container.innerHTML = "";
506+
}
507+
508+
return container;
509+
}
510+
467511
function setupThemeToggle(setupOnNode)
468512
{
469513
if (localStorage.getItem("theme_toggle") != null)
@@ -932,5 +976,12 @@ function initializeForFileProtocol()
932976
window.onload = function()
933977
{
934978
if (window.location.protocol == "file:") initializeForFileProtocol();
935-
initializePage(document);
979+
loadLeftSidebar(document)
980+
.then(resp => {
981+
console.log('left bar load ', resp);
982+
})
983+
.finally(() => {
984+
initializePage(document);
985+
})
986+
936987
}

declarations.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
declare module '*.module.css';

esbuild.config.mjs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import dotenv from "dotenv/config";
22
import esbuild from "esbuild";
33
import process from "process";
44
import builtins from 'builtin-modules'
5+
import cssModulesPlugin from "esbuild-css-modules-plugin"
6+
57

68
const banner = `/*
79
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
@@ -58,9 +60,12 @@ esbuild
5860
// ...builtins
5961
],
6062
inject: ["./esbuild.injecthelper.mjs"],
63+
plugins: [cssModulesPlugin({
64+
inject: true
65+
})],
6166
format: "cjs",
6267
watch: !prod,
63-
target: "es2018",
68+
target: 'esnext',
6469
logLevel: "info",
6570
sourcemap: prod ? false : "inline",
6671
treeShaking: true,

package.json

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
"@types/mustache": "^4.1.2",
3333
"@types/node": "^17.0.30",
3434
"@types/qrcode": "^1.4.2",
35+
"@types/react": "^18.2.14",
36+
"@types/react-dom": "^18.2.6",
3537
"@types/uuid": "^9.0.2",
3638
"@typescript-eslint/eslint-plugin": "5.29.0",
3739
"@typescript-eslint/parser": "5.29.0",
@@ -41,7 +43,8 @@
4143
"cross-env": "^7.0.3",
4244
"dotenv": "^16.0.0",
4345
"electron": "^18.3.15",
44-
"esbuild": "^0.14.38",
46+
"esbuild": "0.14.47",
47+
"esbuild-css-modules-plugin": "^2.7.1",
4548
"jsdom": "^19.0.0",
4649
"mocha": "^9.2.2",
4750
"prettier": "^2.6.2",
@@ -76,13 +79,13 @@
7679
"dropbox": "^10.28.0",
7780
"electron": "^18.3.15",
7881
"emoji-regex": "^10.1.0",
79-
"esbuild": "0.14.47",
8082
"http-status-codes": "^2.2.0",
8183
"js-beautify": "^1.14.7",
8284
"localforage": "^1.10.0",
8385
"lodash": "^4.17.21",
8486
"loglevel": "1.8.0",
8587
"lucide": "^0.256.0",
88+
"lucide-react": "^0.259.0",
8689
"mime-types": "^2.1.35",
8790
"mustache": "^4.2.0",
8891
"nanoid": "^3.3.3",
@@ -93,19 +96,22 @@
9396
"process": "^0.11.10",
9497
"qrcode": "^1.5.0",
9598
"ramda": "^0.29.0",
99+
"react": "^18.2.0",
100+
"react-dom": "^18.2.0",
96101
"rfc4648": "^1.5.1",
97102
"rimraf": "^3.0.2",
98103
"shortid": "^2.2.16",
99104
"stream-browserify": "^3.0.0",
100105
"tencent-cos-sdk-nodejs-v5": "github:walkthunder/cos-nodejs-sdk-v5",
101106
"tslib": "2.4.0",
102-
"typescript": "4.7.4",
107+
"typescript": "4.5.5",
103108
"upath": "^2.0.1",
104109
"url": "^0.11.0",
105110
"util": "^0.12.4",
106111
"uuid": "^9.0.0",
107112
"webdav": "^4.9.0",
108113
"webdav-fs": "^4.0.1",
109-
"xregexp": "^5.1.0"
114+
"xregexp": "^5.1.0",
115+
"zustand": "^4.3.9"
110116
}
111117
}

0 commit comments

Comments
 (0)