Skip to content

Commit 577cd42

Browse files
authored
Add Introduction Article (#94)
* refactor: external links * limit article max-width to improve readability * refactor: article headings * shrink text on smaller screens * fix: accordions and improve space usage * doc: clarify runtime.special a bit * determine remark display mode automatically to save space * revert: accordion JS * doc: improve clarity and example for definition files * doc: improve description for export-docs * fix: decrease min width for 3 column article mode * fix: external link colouring * fix: external link wrapping * fix: remark icon colouring * doc: make remark block * add: background to focus outline * add: levels of bolding to headings * refactor: wiki article heading spacing * add: aria labels to article action buttons * fix: increase heading target highlight size * add: more spacing for external link icon * doc: add introduction article
1 parent 3d6a74a commit 577cd42

File tree

15 files changed

+246
-115
lines changed

15 files changed

+246
-115
lines changed

src/components/common/Accordion.astro

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ const open = Astro.props.open ?? false;
4141
</script>
4242

4343
<style lang="scss">
44-
details {
44+
details.accordion {
4545
position: relative;
4646
background-color: #1b1e1f;
4747
border-radius: 0.5em;
@@ -52,7 +52,6 @@ const open = Astro.props.open ?? false;
5252
align-items: center;
5353
list-style: none;
5454
padding: 0.25em;
55-
user-select: none;
5655

5756
:global(i.fa-chevron-right) {
5857
margin: 0px 1em 0px 0.5em;
@@ -77,6 +76,10 @@ const open = Astro.props.open ?? false;
7776
& > div.content {
7877
background-color: #131516;
7978
padding: 1em;
79+
80+
& > :global(:nth-child(1)) {
81+
margin-top: 0px;
82+
}
8083
}
8184

8285
&[open] {

src/components/common/ExternalLink.astro

Lines changed: 40 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
---
2+
import Icon from "./Icon.astro";
23
import Tooltip from "./Tooltip.astro";
34
45
const {
@@ -27,7 +28,10 @@ export interface Props {
2728
class?: string;
2829
}
2930
30-
const classes = [className, "external"];
31+
const classes = ["external"];
32+
if (className) {
33+
classes.push(className);
34+
}
3135
if (icon === false) {
3236
classes.push("no-icon");
3337
}
@@ -38,28 +42,43 @@ if (!refer) {
3842
}
3943
---
4044

41-
<Tooltip content={hostname}>
42-
<a
43-
href={url}
44-
target={newTab ? "_blank" : null}
45-
rel={relationships.join(" ")}
46-
class={classes.join(" ")}
47-
set:html={child}
48-
/>
49-
</Tooltip>
45+
<span class="external-link">
46+
<Tooltip content={hostname}>
47+
<a
48+
href={url}
49+
target={newTab ? "_blank" : null}
50+
rel={relationships.join(" ")}
51+
class={classes.join(" ")}
52+
set:html={child}
53+
/>{
54+
icon !== false && (
55+
<Icon
56+
group="solid"
57+
name="up-right-from-square"
58+
class="external-indicator"
59+
/>
60+
)
61+
}
62+
</Tooltip>
63+
</span>
5064

5165
<style lang="scss">
52-
a.external {
66+
.external-link {
5367
color: var(--link-color);
54-
font-weight: 500;
55-
white-space: normal;
56-
}
57-
a.external:not(.no-icon)::after {
58-
content: "\f08e";
59-
vertical-align: text-top;
60-
font-family: "Font Awesome 7 Free";
61-
font-size: 0.5em;
62-
display: inline-block;
63-
padding-left: 0.2em;
68+
69+
&:not(.no-icon) {
70+
margin-right: -0.2em;
71+
}
72+
73+
a {
74+
font-weight: 500;
75+
}
76+
77+
& > :global(.tooltip > .icon.external-indicator) {
78+
display: inline;
79+
margin-left: -0.3em;
80+
vertical-align: text-top;
81+
font-size: 0.4em;
82+
}
6483
}
6584
</style>

src/components/common/Icon.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export interface Props {
1919
---
2020

2121
<i
22-
class:list={[`fa-${group}`, `fa-${name}`, className]}
22+
class:list={[`fa-${group}`, `fa-${name}`, "icon", className]}
2323
aria-label={ariaLabel}
2424
style={styles}
2525
>

src/components/common/Remark.astro

Lines changed: 37 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ const TYPES = {
88
WIP: { displayName: "WIP", icon: "pen-ruler" },
99
deprecated: { displayName: "Deprecated", icon: "trash-can" },
1010
issue: { displayName: "Issue", icon: "circle-dot" },
11+
recommendation: {displayName: "Recommendation", icon: "asterisk"}
1112
};
1213
1314
type RemarkType =
@@ -16,7 +17,8 @@ type RemarkType =
1617
| "important"
1718
| "WIP"
1819
| "deprecated"
19-
| "issue";
20+
| "issue"
21+
| "recommendation"
2022
2123
export interface Props {
2224
type: RemarkType;
@@ -31,15 +33,31 @@ if (!remark) {
3133
throw new Error("Invalid remark type: " + type);
3234
}
3335
34-
const classList = [type, "remark", display ?? "block"];
36+
const classList = [type, "remark"];
37+
38+
if (display) {
39+
classList.push(display);
40+
} else {
41+
// If display mode is not specified, fetch the slot text content length and determine best mode.
42+
const content = await Astro.slots.render("default");
43+
const text = content.replace(/<[^>]*>/g, "").replace(/\s+/g, ' ').trim();
44+
45+
if (text.length < 115) {
46+
classList.push("compact");
47+
} else {
48+
classList.push("block");
49+
}
50+
}
3551
---
3652

3753
<div class:list={classList}>
3854
<div>
3955
<Icon name={remark.icon} group="solid" />
4056
{remark.displayName}
4157
</div>
42-
<slot />
58+
<div class="content">
59+
<slot />
60+
</div>
4361
</div>
4462

4563
<style lang="scss">
@@ -55,17 +73,13 @@ const classList = [type, "remark", display ?? "block"];
5573
background-color: color-mix(in srgb, var(--remark-color), #071521 80%);
5674

5775
&.block {
58-
width: 90%;
76+
width: 95%;
5977
}
6078

6179
&.compact {
6280
display: flex;
6381
align-items: center;
6482
gap: 0.5em;
65-
66-
& > :global(*) {
67-
margin: 0px;
68-
}
6983
}
7084

7185
&.note {
@@ -92,21 +106,28 @@ const classList = [type, "remark", display ?? "block"];
92106
--remark-color: #2ea043;
93107
}
94108

95-
& > div {
109+
&.recommendation {
110+
--remark-color: #1aecbe;
111+
}
112+
113+
& > div:first-of-type {
96114
font-size: 1.1em;
97115
display: flex;
98-
gap: 0.5em;
116+
gap: 0.2em;
99117
align-items: center;
100118
font-weight: bold;
101-
}
102119

103-
:global(i.fa-solid) {
104-
font-size: 1.3em;
105-
color: color-mix(in srgb, var(--remark-color), white 60%);
120+
:global(i.fa-solid) {
121+
margin-left: -0.3em;
122+
font-size: 1.3em;
123+
color: color-mix(in srgb, var(--remark-color), white 60%);
124+
}
106125
}
107126

108-
& > :global(p) {
109-
margin: 0.5em auto 0.2em auto;
127+
& > .content {
128+
:global(p) {
129+
margin: 0.1em auto;
130+
}
110131
}
111132
}
112133
</style>

src/components/layout/Footer.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ const { class: className } = Astro.props;
8181
}
8282

8383
:global(a),
84-
:global(a.external) {
84+
:global(.external-link) {
8585
color: inherit;
8686
font-weight: normal;
8787
}

src/components/layout/Header.astro

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
---
2-
import ExternalLink from "../common/ExternalLink.astro";
32
import Icon from "../common/Icon.astro";
43
import Tooltip from "../common/Tooltip.astro";
54
@@ -25,20 +24,19 @@ const { class: className } = Astro.props;
2524
</a>
2625
</div>
2726
<Tooltip
28-
content="<div align='center'>Search <br/><kbd>/</kbd></div>"
27+
content="<div align='center'>Search<br/><kbd>/</kbd></div>"
2928
allowHTML
3029
>
3130
<button class="site-search-icon" aria-keyshortcuts="/">
3231
<Icon name="search" group="solid" ariaLabel="Search" />
3332
</button>
3433
</Tooltip>
3534
<span class="github">
36-
<ExternalLink
37-
url="https://github.com/luals/lua-language-server"
38-
icon={false}
39-
>
40-
<Icon name="github" group="brands" />
41-
</ExternalLink>
35+
<a href="https://github.com/luals/lua-language-server">
36+
<Tooltip content="View Project on GitHub">
37+
<Icon name="github" group="brands" ariaLabel="View Project on GitHub"/>
38+
</Tooltip>
39+
</a>
4240
</span>
4341
</nav>
4442
</header>
@@ -78,8 +76,7 @@ const { class: className } = Astro.props;
7876
margin: auto;
7977
}
8078

81-
a,
82-
:global(a.external) {
79+
a{
8380
color: white;
8481
}
8582

src/components/wiki/Heading.astro

Lines changed: 35 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,27 +12,39 @@ import Icon from "../common/Icon.astro";
1212
---
1313

1414
<div class="heading" id={id}>
15-
<a href={`#${id}`}><Icon name="link" group="solid" /></a>
16-
<Element><slot /></Element>
15+
<a href={`#${id}`}
16+
><Icon name="link" group="solid" class="icon" /><Element><slot /></Element
17+
></a
18+
>
1719
</div>
1820

1921
<style lang="scss">
2022
:global(details.accordion > summary div.heading) {
2123
margin: 0px;
24+
25+
& > a > :global(i.icon) {
26+
display: none;
27+
}
2228
}
2329

2430
div.heading {
25-
width: calc(100% + 3em);
26-
margin: 2em 0px 0px -3em;
27-
display: flex;
28-
align-items: center;
31+
width: calc(100%);
32+
margin: 1em 0px 0.5em 0em;
33+
line-height: 3ch;
2934

3035
& > a {
3136
color: white;
32-
opacity: 0;
33-
font-size: 1.25em;
34-
padding: 0.25em 0.5em;
35-
transition: opacity 0.3s ease-in-out;
37+
display: flex;
38+
align-items: center;
39+
position: relative;
40+
41+
& > :global(i.icon) {
42+
position: absolute;
43+
left: -1.75em;
44+
font-size: 1.25em;
45+
opacity: 0;
46+
transition: opacity 0.3s ease-in-out;
47+
}
3648
}
3749

3850
:global(h1),
@@ -50,23 +62,18 @@ import Icon from "../common/Icon.astro";
5062
&::after {
5163
content: "";
5264
display: block;
53-
width: 0.1em;
54-
height: 100%;
55-
background-color: var(--link-color);
65+
width: calc(100% + 0.2em);
66+
height: 140%;
67+
background-color: #ff9500;
68+
opacity: 0.2;
5669
position: absolute;
57-
bottom: 0px;
58-
border-radius: 99em;
59-
left: -0.15em;
70+
bottom: -24%;
71+
border-radius: 0.1em;
72+
left: -0.1em;
6073
z-index: -1;
6174
padding: 0px;
6275
clip-path: polygon(0 0, 0 0, 0 100%, 0% 100%);
63-
transition: clip-path cubic-bezier(0.65, 0.05, 0.36, 1) 0.75s;
64-
}
65-
}
66-
67-
&:hover {
68-
a {
69-
opacity: 1;
76+
transition: clip-path cubic-bezier(0.65, 0.05, 0.36, 1) 1s;
7077
}
7178
}
7279

@@ -81,7 +88,7 @@ import Icon from "../common/Icon.astro";
8188
clip-path: polygon(0 0, 100% 0%, 100% 100%, 0% 100%);
8289
}
8390
}
84-
a {
91+
a > :global(i.icon) {
8592
opacity: 1;
8693
}
8794
}
@@ -94,10 +101,11 @@ import Icon from "../common/Icon.astro";
94101
@media screen and (max-width: 800px) {
95102
div.heading {
96103
width: 100%;
97-
margin: 2em auto 0px -1.5em;
104+
font-size: 0.8em;
105+
margin: 2em 0px 0px 0px;
98106

99-
& > a {
100-
font-size: 0.9em;
107+
& > a > :global(i.icon) {
108+
display: none;
101109
}
102110
}
103111
}

src/content/wiki/annotations.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The language server does its best to infer types through contextual analysis, ho
1313

1414
Annotations are prefixed with `---`, like a Lua comment with one extra dash.
1515

16-
<Remark type="warning" display="compact">
16+
<Remark type="warning" display="block">
1717
LuaCATS annotations are [no longer
1818
cross-compatible](https://github.com/LuaLS/lua-language-server/issues/980)
1919
with [EmmyLua annotations](https://emmylua.github.io/annotation.html) as of

0 commit comments

Comments
 (0)