Skip to content

Commit 52f84bf

Browse files
authoredJul 15, 2024··
UI refresh (#38)
* refactor: refresh wiki index page * refactor: further wiki index page improvements * fix: semantic markup of wiki article layout * add: better a11y for header icons
1 parent f8d76ed commit 52f84bf

File tree

6 files changed

+194
-77
lines changed

6 files changed

+194
-77
lines changed
 

‎src/components/common/Icon.astro

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
---
22
const { group, name, class: className, color } = Astro.props;
33
4-
const displayName = name.replaceAll("-", " ");
5-
64
const styles = color ? `color: ${color}` : null;
75
6+
const ariaLabel = Astro.props.ariaLabel ?? name.replaceAll("-", " ");
7+
88
export interface Props {
99
/** The group that the icon belongs to. */
1010
group: "brands" | "solid";
@@ -14,12 +14,13 @@ export interface Props {
1414
class?: string;
1515
/** The colour of the icon. */
1616
color?: string;
17+
ariaLabel?: string;
1718
}
1819
---
1920

2021
<i
2122
class:list={[`fa-${group}`, `fa-${name}`, className]}
22-
aria-label={displayName}
23+
aria-label={ariaLabel}
2324
style={styles}
2425
>
2526
</i>

‎src/components/layout/Header.astro

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ const { class: className } = Astro.props;
1414
<nav>
1515
<a href="/" class="home">
1616
<Tooltip content="Home">
17-
<Icon name="house" group="solid" />
17+
<Icon name="house" group="solid" ariaLabel="Home"/>
1818
</Tooltip>
1919
</a>
2020
<div>
2121
<a href="/wiki/">
2222
<Tooltip content="Wiki">
23-
<Icon name="book-open" group="solid" />
23+
<Icon name="book-open" group="solid" ariaLabel="Wiki"/>
2424
</Tooltip>
2525
</a>
2626
</div>
@@ -29,7 +29,7 @@ const { class: className } = Astro.props;
2929
allowHTML
3030
>
3131
<button class="site-search-icon" aria-keyshortcuts="/">
32-
<Icon name="search" group="solid" />
32+
<Icon name="search" group="solid" ariaLabel="Search"/>
3333
</button>
3434
</Tooltip>
3535
<span class="github">

‎src/content/wiki/faq.mdx

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
---
22
title: FAQ
33
description: Answers for frequently asked questions
4-
getting-started: true
54
---
65

76
import Accordion from "~/components/common/Accordion.astro";

‎src/layouts/WikiArticle.astro

+10-10
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,10 @@ export interface Props {
3131

3232
<Layout title="Wiki" transition={true} displayFooter={false}>
3333
<div class="columns">
34-
<div id="article-browser" class="sidebar">
34+
<aside id="article-browser" class="sidebar">
3535
<button class="open"><Icon name="newspaper" group="solid" /></button>
3636
<button class="close"><Icon name="x" group="solid" /></button>
37-
<div class="title">Articles</div>
37+
<h2 class="title">Articles</h2>
3838
<div class="content">
3939
<nav>
4040
{
@@ -52,7 +52,7 @@ export interface Props {
5252
}
5353
</nav>
5454
</div>
55-
</div>
55+
</aside>
5656
<div class="center">
5757
<main>
5858
<article>
@@ -90,10 +90,10 @@ export interface Props {
9090
</main>
9191
<Footer />
9292
</div>
93-
<div id="outline" class="sidebar">
93+
<aside id="outline" class="sidebar">
9494
<button class="open"><Icon name="list" group="solid" /></button>
9595
<button class="close"><Icon name="x" group="solid" /></button>
96-
<div class="title">Outline</div>
96+
<h2 class="title">Outline</h2>
9797
<nav class="content">
9898
<ol>
9999
<li><a href={`#${titleSlug}`}>{article.data.title}</a></li>
@@ -106,14 +106,14 @@ export interface Props {
106106
}
107107
</ol>
108108
</nav>
109-
</div>
109+
</aside>
110110
</div>
111111
</Layout>
112112

113113
<script>
114114
import * as utils from "~/util/DOM";
115115

116-
const sidebars = utils.assertElements(".sidebar");
116+
const sidebars = utils.assertElements("aside.sidebar");
117117

118118
for (const sidebar of sidebars) {
119119
const openButton = utils.assertElement("button.open", sidebar);
@@ -238,7 +238,7 @@ export interface Props {
238238
}
239239
}
240240

241-
.sidebar {
241+
aside.sidebar {
242242
--sidebar-width: 20em;
243243
background-color: #081f34;
244244
height: 100%;
@@ -474,7 +474,7 @@ export interface Props {
474474
display: none;
475475
}
476476

477-
.sidebar {
477+
aside.sidebar {
478478
position: static;
479479
z-index: 0;
480480
width: 100%;
@@ -491,7 +491,7 @@ export interface Props {
491491
}
492492

493493
@media screen and (max-width: 800px) {
494-
.sidebar {
494+
aside.sidebar {
495495
--sidebar-width: 70%;
496496
}
497497

‎src/pages/wiki/index.astro

+176-60
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,11 @@ await Promise.all(
2020
})
2121
)
2222
);
23+
const articleCount = allWikiArticles.length;
24+
const wordCount = allWikiArticles.reduce(
25+
(x, article) => x + Array.from(article.body.matchAll(/\w+/g)).length,
26+
0
27+
);
2328
const gettingStartedArticles = allWikiArticles.filter(
2429
(article) => article.data["getting-started"] === true
2530
);
@@ -73,20 +78,26 @@ if (!contributors) {
7378

7479
<Layout title="Wiki">
7580
<main>
76-
<h1>Welcome to the wiki!</h1>
81+
<h1>Welcome To The Wiki!</h1>
82+
<div id="quick-links">
83+
<a href="/#install">
84+
<Icon name="download" group="solid" class="icon" />
85+
<h2>Install</h2>
86+
<p>Install instructions for the Lua Language Server.</p>
87+
</a>
88+
<a href="/wiki/faq/">
89+
<Icon name="question" group="solid" class="icon" />
90+
<h2>FAQ</h2>
91+
<p>Frequently asked questions and answers to them.</p>
92+
</a>
93+
</div>
7794
<div class="grid">
7895
<section id="get-started">
7996
<h2>Get Started</h2>
8097
<p>
81-
Below are some good articles for those new to the Lua Language Server
98+
Below are some good articles for those new to the Lua Language Server.
8299
</p>
83100
<div class="grid">
84-
<div class="article">
85-
<a href="/#install" target="_blank">
86-
Install
87-
<p>Installation instructions</p>
88-
</a>
89-
</div>
90101
{
91102
gettingStartedArticles.map((article) => (
92103
<div class="article">
@@ -99,6 +110,46 @@ if (!contributors) {
99110
}
100111
</div>
101112
</section>
113+
<section id="all-articles">
114+
<h2>All Wiki Articles</h2>
115+
<div class="subtitle">
116+
<p class="tip">
117+
<i
118+
><b>Tip:</b> You can press <code>&#47;</code> to search the wiki!</i
119+
>
120+
</p>
121+
<div class="sorts">
122+
<Tooltip content="Sort Method">
123+
<Icon group="solid" name="sort" />
124+
</Tooltip>
125+
<select name="sort" id="sort">
126+
<option value="alphabetical">A-Z</option>
127+
<option value="last-modified">Last Modified</option>
128+
<option value="length">Length</option>
129+
</select>
130+
</div>
131+
</div>
132+
<div class="grid">
133+
{
134+
allWikiArticles.map((article) => (
135+
<div
136+
class="article"
137+
data-last-modified={article.data.lastModified}
138+
data-length={article.body.length}
139+
>
140+
<a href={`/wiki/${article.slug}/`}>
141+
<div class="name">{article.data.title}</div>
142+
<p class="description">{article.data.description}</p>
143+
</a>
144+
</div>
145+
))
146+
}
147+
</div>
148+
<div class="stats">
149+
<span><b>{articleCount}</b> Articles</span>
150+
<span><b>{wordCount}</b> Words</span>
151+
</div>
152+
</section>
102153
<section id="contributors">
103154
<h2>Top Contributors</h2>
104155
<p>
@@ -107,12 +158,6 @@ if (!contributors) {
107158
group="solid"
108159
color="red"
109160
/>
110-
<br />
111-
<ExternalLink
112-
url="https://github.com/LuaLS/LuaLS.github.io/blob/main/docs/CONTRIBUTING.md"
113-
>
114-
Contribute today!
115-
</ExternalLink>
116161
</p>
117162
<div class="grid">
118163
{
@@ -143,35 +188,13 @@ if (!contributors) {
143188
))
144189
}
145190
</div>
146-
</section>
147-
<section id="all-articles">
148-
<h2>All Wiki Articles</h2>
149-
<div class="sorts">
150-
<Tooltip content="Sort Method">
151-
<Icon group="solid" name="sort" />
152-
</Tooltip>
153-
<select name="sort" id="sort">
154-
<option value="alphabetical">A-Z</option>
155-
<option value="last-modified">Last Modified</option>
156-
<option value="length">Length</option>
157-
</select>
158-
</div>
159-
<div class="grid">
160-
{
161-
allWikiArticles.map((article) => (
162-
<div
163-
class="article"
164-
data-last-modified={article.data.lastModified}
165-
data-length={article.body.length}
166-
>
167-
<a href={`/wiki/${article.slug}/`}>
168-
<div class="name">{article.data.title}</div>
169-
<p class="description">{article.data.description}</p>
170-
</a>
171-
</div>
172-
))
173-
}
174-
</div>
191+
<p>
192+
<ExternalLink
193+
url="https://github.com/LuaLS/LuaLS.github.io/blob/main/docs/CONTRIBUTING.md"
194+
>
195+
Help Contribute To The Wiki!
196+
</ExternalLink>
197+
</p>
175198
</section>
176199
</div>
177200
</main>
@@ -226,27 +249,75 @@ if (!contributors) {
226249
</script>
227250

228251
<style lang="scss">
252+
#quick-links {
253+
display: flex;
254+
justify-content: center;
255+
gap: 5vw 5vw;
256+
margin: 0px 1em;
257+
258+
& > a {
259+
color: white;
260+
border: solid #0084ff 0.1em;
261+
box-shadow: #0084ff 0px 0px 0.2em 0.1em;
262+
transition: box-shadow 0.25s ease-in-out;
263+
border-radius: 0.5em;
264+
padding: 0.5em 1em;
265+
gap: 0px 0.75em;
266+
267+
&:hover {
268+
box-shadow: #178fff 0px 0px 0.4em 0.3em;
269+
}
270+
271+
:global(.icon) {
272+
font-size: 2.5em;
273+
display: inline-block;
274+
}
275+
276+
h2 {
277+
display: inline-block;
278+
width: fit-content;
279+
margin: 0px 0px 0px 0.5em;
280+
font-size: 2em;
281+
}
282+
283+
p {
284+
margin: 0px 0px;
285+
}
286+
}
287+
}
288+
229289
.grid {
230290
display: grid;
231291
grid-template-columns: 1fr 1fr;
232292
gap: 1em;
233-
margin: 1em;
234293

235294
& > section {
236-
background-color: #163d62;
295+
border: solid #0084ff 0.1em;
296+
box-shadow: #0084ff 0px 0px 0.2em 0.1em;
237297
padding: 1em;
238298
border-radius: 0.5em;
239299

240300
h2 {
241301
margin: 0px;
302+
width: fit-content;
242303
}
243-
}
244304

245-
p {
246-
text-align: center;
305+
p {
306+
&:first-of-type {
307+
margin: 0px 0px 1em 0px;
308+
}
309+
&:nth-of-type(2) {
310+
text-align: center;
311+
margin-bottom: 0px;
312+
}
313+
}
247314
}
248315
}
249316

317+
main > .grid {
318+
margin: 2em 1em;
319+
}
320+
250321
div.article {
251322
a {
252323
font-size: 1.3em;
@@ -263,6 +334,17 @@ if (!contributors) {
263334
.grid {
264335
grid-template-columns: repeat(auto-fill, minmax(10em, 1fr));
265336
text-align: center;
337+
338+
p {
339+
color: #ffffffcc;
340+
}
341+
342+
a {
343+
transition: color 0.25s ease-in-out;
344+
&:hover {
345+
color: #ffb700;
346+
}
347+
}
266348
}
267349
}
268350

@@ -333,7 +415,8 @@ if (!contributors) {
333415
}
334416

335417
section#all-articles {
336-
grid-column: 1 / span 2;
418+
grid-column: 2 / 3;
419+
grid-row: 1 / 3;
337420

338421
.grid {
339422
grid-template-columns: repeat(auto-fill, minmax(15em, 1fr));
@@ -344,21 +427,49 @@ if (!contributors) {
344427
flex-direction: column;
345428
justify-content: space-between;
346429
gap: 0.2em 0px;
430+
431+
p {
432+
color: #ffffffcc;
433+
}
434+
435+
a {
436+
transition: color 0.25s ease-in-out;
437+
&:hover {
438+
color: #ffb700;
439+
}
440+
}
347441
}
348442
}
349443

350-
.sorts {
351-
width: fit-content;
352-
margin-left: auto;
444+
.stats {
445+
display: flex;
446+
gap: 1em;
447+
justify-content: right;
448+
}
353449

354-
select#sort {
355-
background: transparent;
356-
border: none;
357-
border-bottom: #276cae solid 0.2em;
358-
color: white;
450+
.subtitle {
451+
display: flex;
452+
flex-wrap: wrap;
453+
margin-bottom: 0.5em;
359454

360-
option {
361-
color: black;
455+
p.tip {
456+
font-size: 0.7em;
457+
opacity: 0.8;
458+
margin: 0px;
459+
}
460+
.sorts {
461+
width: fit-content;
462+
margin-left: auto;
463+
464+
select#sort {
465+
background: transparent;
466+
border: none;
467+
border-bottom: #276cae solid 0.2em;
468+
color: white;
469+
470+
option {
471+
color: black;
472+
}
362473
}
363474
}
364475
}
@@ -370,13 +481,18 @@ if (!contributors) {
370481
}
371482

372483
section#all-articles {
373-
grid-column: 1;
484+
grid-column: unset;
485+
grid-row: 3 / 3;
374486
}
375487
}
376488

377489
@media screen and (max-width: 700px) {
378490
#contributors div.grid {
379491
grid-template-columns: repeat(auto-fill, minmax(5em, 1fr));
380492
}
493+
494+
#quick-links {
495+
flex-wrap: wrap;
496+
}
381497
}
382498
</style>

‎src/scss/main.scss

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ h6 {
4242
text-align: center;
4343
word-wrap: break-word;
4444
white-space: normal;
45+
font-weight: 500;
4546
}
4647

4748
h1 {

0 commit comments

Comments
 (0)
Please sign in to comment.