Skip to content

Commit dca5fb4

Browse files
committed
refactor: improve wiki css
1 parent c9941e5 commit dca5fb4

File tree

8 files changed

+96
-28
lines changed

8 files changed

+96
-28
lines changed

esbuild.config.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ const __dirname = path.dirname(fileURLToPath(import.meta.url));
1313
const kPublicDir = path.join(__dirname, "public");
1414
const kOutDir = path.join(__dirname, "dist");
1515
const kImagesDir = path.join(kPublicDir, "img");
16+
const kNodeModules = path.join(__dirname, "node_modules");
1617

1718
await esbuild.build({
1819
entryPoints: [
1920
path.join(kPublicDir, "js", "master.js"),
2021
path.join(kPublicDir, "css", "style.css"),
22+
path.join(kNodeModules, "highlight.js", "styles", "github.css"),
2123
...getBuildConfiguration().entryPoints
2224
],
2325
loader: {

public/css/reset.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ video {
8989
border: 0;
9090
font-size: 100%;
9191
font: inherit;
92-
vertical-align: baseline;
92+
/* vertical-align: baseline; */
9393
}
9494

9595
/* HTML5 display-role reset for older browsers */

views/index.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
<link rel="stylesheet" href="public/css/style.css" />
1010
<link rel="stylesheet" href="workspaces/documentation-ui/src/css/main.css" />
11+
<link rel="stylesheet" href="node_modules/highlight.js/styles/github.css" />
1112
<script src="public/js/master.js" defer></script>
1213
<title>Node-Secure</title>
1314

workspaces/documentation-ui/index.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@ const kSASTWarnings = [
1616
"unsafe-import",
1717
"unsafe-regex",
1818
"unsafe-stmt",
19+
"shady-link",
1920
"encoded-literal",
2021
"short-identifiers",
2122
"suspicious-literal",
23+
"suspicious-file",
2224
"obfuscated-code",
2325
"weak-crypto"
2426
].map((name) => ({ name }));
@@ -80,7 +82,8 @@ export function render(rootElement, options = {}) {
8082

8183
const header = new Header(kHeaderMenus, { defaultName: "flags" });
8284
const mainContainer = utils.createDOMElement("div", {
83-
className: "documentation--main", childs: [header.dom, ...containers]
85+
className: "documentation--main",
86+
childs: [header.dom, ...containers]
8487
});
8588

8689
for (const node of rootElement.childNodes) {

workspaces/documentation-ui/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"license": "MIT",
2727
"dependencies": {
2828
"@nodesecure/flags": "^2.4.0",
29+
"highlight.js": "^11.9.0",
2930
"markdown-it": "^13.0.1"
3031
}
3132
}

workspaces/documentation-ui/src/components/header.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,10 @@ export class Header {
2525

2626
const ul = utils.createDOMElement("ul", {
2727
childs: [
28-
...menu.map((item) => {
29-
return utils.createDOMElement("li", {
30-
text: item.name,
31-
attributes: { "data-menu": item.title }
32-
});
33-
})
28+
...menu.map((item) => utils.createDOMElement("li", {
29+
text: item.name,
30+
attributes: { "data-menu": item.title }
31+
}))
3432
]
3533
});
3634

workspaces/documentation-ui/src/css/content.css

Lines changed: 76 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
max-width: 100%;
1313
}
1414

15-
.documentation--content span {
15+
.documentation--content div>span {
1616
background: #b8e9ff;
1717
padding: 2px;
1818
border-radius: 2px;
@@ -45,15 +45,39 @@
4545
height: 26px;
4646
font-size: 22px;
4747
border-bottom: 1px solid #3722AF;
48-
margin-top: 2.5rem;
48+
margin-top: 2rem;
4949
margin-bottom: 1rem;
5050
font-weight: bold;
5151
}
5252

53+
.documentation--content ul+h2 {
54+
margin-top: 1rem !important;
55+
}
56+
57+
.documentation--content h3 {
58+
height: 26px;
59+
font-size: 18px;
60+
margin-top: 1rem;
61+
margin-bottom: 0.5rem;
62+
border-bottom: 1px solid #d4d4d4;
63+
font-weight: bold;
64+
}
65+
5366
.documentation--content p {
5467
text-align: justify;
55-
line-height: 1.20;
68+
line-height: 1.50;
5669
color: #314249;
70+
margin-right: 10px;
71+
}
72+
73+
.documentation--content p>code {
74+
background: #feffd5;
75+
padding: 1px 5px;
76+
border-radius: 4px;
77+
}
78+
79+
.documentation--content p+p {
80+
margin-top: 10px;
5781
}
5882

5983
.documentation--content p.note {
@@ -65,37 +89,61 @@
6589
border-radius: 2px;
6690
box-sizing: border-box;
6791
}
68-
.documentation--content p.note > span {
92+
93+
.documentation--content blockquote {
94+
background: #81d4fa59;
95+
color: #283593 !important;
96+
border-left: 5px solid #01579B;
97+
margin: 0.5em 10px;
98+
padding: 0.5em 10px;
99+
}
100+
101+
.documentation--content blockquote p {
102+
display: inline;
103+
}
104+
105+
.documentation--content blockquote strong,
106+
.documentation--content blockquote code {
107+
font-weight: bold;
108+
}
109+
110+
.documentation--content p.note>span {
69111
background: #FFF9C4;
70112
}
71113

72114
.documentation--content ul {
73-
margin: 1rem 0;
74-
list-style: disc !important;
75-
border-radius: 4px;
76-
box-shadow: 1px 1px 10px rgb(20 20 20 / 10%);
115+
margin: 0.5rem 0;
116+
box-shadow: 1px 1px 10px rgba(20, 20, 20, 0.205);
117+
margin-right: 10px;
77118
}
78119

79120
.documentation--content ul li {
80-
min-height: 36px;
81-
display: flex;
82-
align-items: center;
83-
padding: 2px 10px;
121+
padding: 7px 10px;
122+
border-radius: 4px;
123+
background: #FFF;
84124
}
85125

86-
.documentation--content ul li:nth-child(odd) {
87-
background: #ECEFF1;
126+
.documentation--content ul li+li {
127+
margin-top: 3px;
88128
}
89129

90-
.documentation--content ul li:nth-child(even) {
91-
background: #CFD8DC;
130+
.documentation--content ul li:before {
131+
content: "• ";
92132
}
93133

134+
.documentation--content ul li a {
135+
color: #1976D2;
136+
}
137+
138+
.documentation--content ul li strong,
139+
.documentation--content ul li code {
140+
font-weight: bold;
141+
}
94142

95143
table {
96144
width: 100%;
97145
border-spacing: 2px;
98-
table-layout:fixed;
146+
table-layout: fixed;
99147
}
100148

101149
table thead tr th {
@@ -135,16 +183,24 @@ pre {
135183
word-wrap: break-word;
136184
overflow: auto;
137185
border-radius: 4px;
186+
flex-shrink: 0;
187+
margin-top: 10px !important;
188+
margin-right: 10px !important;
189+
}
190+
191+
pre+p {
192+
margin-top: 10px;
193+
}
194+
195+
pre code.hljs {
196+
font-size: 16px;
138197
}
139198

140199
pre code {
141200
font-family: "Inconsolata", "Monaco", "Consolas", "Andale Mono", "Bitstream Vera Sans Mono", "Courier New", Courier, monospace;
142201
display: block;
143-
margin: 0 0 0 60px;
144202
padding: 15px 16px 14px;
145-
border-left: 1px solid #37474F;
146203
overflow-x: auto;
147204
font-size: 13px;
148205
line-height: 19px;
149-
color: #ddd;
150206
}

workspaces/documentation-ui/src/fetch.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,12 @@ import * as CONSTANTS from "./constants.js";
33

44
// Import Third-party Dependencies
55
import MarkdownIt from "markdown-it";
6+
import hljs from "highlight.js/lib/core";
7+
import javascript from "highlight.js/lib/languages/javascript";
8+
import json from "highlight.js/lib/languages/json";
9+
10+
hljs.registerLanguage("javascript", javascript);
11+
hljs.registerLanguage("json", json);
612

713
// CONSTANTS
814
const kRawGithubFlagsURL = "https://raw.githubusercontent.com/NodeSecure/flags/main/src/flags";
@@ -78,4 +84,5 @@ export async function fetchAndRenderByMenu(menuElement, kind = "flags") {
7884

7985
const documentContentElement = document.querySelector(`.documentation--${kind} .${CONSTANTS.DIV_CONTENT}`);
8086
documentContentElement.innerHTML = kind === "flags" ? htmlResponse : `<div>${htmlResponse}</div>`;
87+
hljs.highlightAll();
8188
}

0 commit comments

Comments
 (0)