Skip to content

Commit 9cbff30

Browse files
authored
Surface glossary terms and related links in expandable cards (#6305)
Introduces a new card-based design for entries on the glossary page. The short description is shown by default and the long description and resource links are shown once expanded. When navigating to the page, the card that corresponds to the current fragment (such as `#variance` in `dart.dev/resources/glossary#variance`) is expanded. Additionally you can specify the type of a resource to add an icon in front of the resource button. Currently the supported types are: - `term` _(for other glossary entries or word definitions)_ - `article` or `doc` _(general for doc pages)_ - `tutorial` _(for tutorials, codelabs, etc.)_ - `api` _(for API links)_ - `video` _(for videos, such as links to Youtube videos)_ - `code` or `sample` _(for code samples or repository links)_ - `diagnostic` or `lint` _(for links to specific lints, diagnostic docs, etc.)_ To implement this, I've introduced a new set of shared button styles in `_buttons.scss` and updated the shared set of card styles in `_cards.scss`. That way cards across the site _(currently this and the linter rules page)_ can benefit from a consistent structure and shared styles.
1 parent a3b7492 commit 9cbff30

15 files changed

+347
-174
lines changed

src/_data/glossary.yml

+29
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
related_links:
1111
- text: "Refactor"
1212
link: "#refactor"
13+
type: "term"
1314
labels:
1415
- "tools"
1516
- "analyzer"
@@ -62,8 +63,10 @@
6263
related_links:
6364
- text: "Final and const variables"
6465
link: "/language/variables#final-and-const"
66+
type: "doc"
6567
- text: "Don't use const redundantly"
6668
link: "/effective-dart/usage#dont-use-const-redundantly"
69+
type: "doc"
6770
labels:
6871
- "language"
6972
- "const"
@@ -166,8 +169,10 @@
166169
related_links:
167170
- text: "Definite assignment specification"
168171
link: "https://github.com/dart-lang/language/blob/main/resources/type-system/flow-analysis.md"
172+
type: "doc"
169173
- text: "Understanding definite assignment analysis"
170174
link: "/null-safety/understanding-null-safety#definite-assignment-analysis"
175+
type: "doc"
171176
labels:
172177
- "language"
173178
- "flow analysis"
@@ -180,8 +185,10 @@
180185
related_links:
181186
- text: "Functions overview"
182187
link: "/language/functions"
188+
type: "doc"
183189
- text: "Instance methods"
184190
link: "/language/methods"
191+
type: "doc"
185192
labels:
186193
- "language"
187194
- "umbrella term"
@@ -202,8 +209,10 @@
202209
related_links:
203210
- text: "Places patterns can appear"
204211
link: "/language/patterns#places-patterns-can-appear"
212+
type: "doc"
205213
- text: "Dive into Dart patterns and records"
206214
link: "https://codelabs.developers.google.com/codelabs/dart-patterns-records"
215+
type: "tutorial"
207216
labels:
208217
- "language"
209218
- "patterns"
@@ -249,6 +258,7 @@
249258
related_links:
250259
- text: "Mixins in Dart"
251260
link: "/language/mixins"
261+
type: "doc"
252262
labels:
253263
- "language"
254264
- "understanding diagnostics"
@@ -321,6 +331,7 @@
321331
related_links:
322332
- text: "Inheritance in Dart"
323333
link: "/language/extend"
334+
type: "doc"
324335
labels:
325336
- "language"
326337
- "type inference"
@@ -335,8 +346,10 @@
335346
related_links:
336347
- text: "Guidance on libraries and parts"
337348
link: "/tools/pub/create-packages#organizing-a-package"
349+
type: "doc"
338350
- text: "Use library URIs in `part of` directives"
339351
link: "/effective-dart/usage#do-use-strings-in-part-of-directives"
352+
type: "doc"
340353
labels:
341354
- "language"
342355
- "libraries"
@@ -365,6 +378,7 @@
365378
related_links:
366379
- text: "Nullability and generics"
367380
link: "/null-safety/understanding-null-safety#nullability-and-generics"
381+
type: "doc"
368382
labels:
369383
- "language"
370384
- "type system"
@@ -383,8 +397,10 @@
383397
related_links:
384398
- text: "Organizing a package's libraries"
385399
link: "/tools/pub/create-packages#organizing-a-package"
400+
type: "doc"
386401
- text: "Public package directories"
387402
link: "/tools/pub/package-layout#public-directories"
403+
type: "doc"
388404
labels:
389405
- "language"
390406
- "libraries"
@@ -396,10 +412,13 @@
396412
related_links:
397413
- text: "Quick fixes for analysis issues"
398414
link: "https://medium.com/dartlang/quick-fixes-for-analysis-issues-c10df084971a"
415+
type: "article"
399416
- text: "Diagnostic messages"
400417
link: "/tools/diagnostic-messages"
418+
type: "doc"
401419
- text: "Linter rules"
402420
link: "/tools/linter-rules"
421+
type: "doc"
403422
labels:
404423
- "tools"
405424
- "understanding diagnostics"
@@ -415,6 +434,7 @@
415434
related_links:
416435
- text: "Assist"
417436
link: "#assist"
437+
type: "term"
418438
labels:
419439
- "tools"
420440
- "analysis"
@@ -432,8 +452,10 @@
432452
related_links:
433453
- text: "Places patterns can appear"
434454
link: "/language/patterns#places-patterns-can-appear"
455+
type: "doc"
435456
- text: "Dive into Dart patterns and records"
436457
link: "https://codelabs.developers.google.com/codelabs/dart-patterns-records"
458+
type: "tutorial"
437459
labels:
438460
- "language"
439461
- "patterns"
@@ -472,8 +494,10 @@
472494
related_links:
473495
- text: "Inheritance in Dart"
474496
link: "/language/extend"
497+
type: "doc"
475498
- text: "Subtype relationship"
476499
link: "#subtype"
500+
type: "term"
477501
labels:
478502
- "language"
479503
- "type system"
@@ -519,8 +543,10 @@
519543
related_links:
520544
- text: "Subclass"
521545
link: "#subclass"
546+
type: "term"
522547
- text: "Substituting types"
523548
link: "/language/type-system#substituting-types"
549+
type: "doc"
524550
labels:
525551
- "language"
526552
- "type system"
@@ -611,10 +637,13 @@
611637
related_links:
612638
- text: "Subtype relationship"
613639
link: "#subtype"
640+
type: "term"
614641
- text: "Covariance and contravariance"
615642
link: "https://en.wikipedia.org/wiki/Covariance_and_contravariance_(computer_science)"
643+
type: "article"
616644
- text: "The covariant keyword"
617645
link: "/language/type-system#covariant-keyword"
646+
type: "doc"
618647
labels:
619648
- "language"
620649
- "type system"

src/_includes/linter-rule-cards.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,8 @@
4646
</div>
4747

4848
<div class="trailing">
49-
<a href="/tools/linter-rules/{{lint.name}}" title="Learn more about this lint and when to enable it.">Learn more</a>
50-
<button class="copy-button hidden" title="Copy {{lint.name}} to your clipboard.">Copy</button>
49+
<a class="outlined-button" href="/tools/linter-rules/{{lint.name}}" title="Learn more about this lint and when to enable it.">Learn more</a>
50+
<button class="copy-button filled-button hidden" title="Copy {{lint.name}} to your clipboard.">Copy</button>
5151
</div>
5252

5353
</div>

src/_sass/_site.scss

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
@use 'components/alert';
1313
@use 'components/banner';
1414
@use 'components/breadcrumbs';
15+
@use 'components/buttons';
1516
@use 'components/card';
1617
@use 'components/code';
1718
@use 'components/content';

src/_sass/base/_base.scss

+3-70
Original file line numberDiff line numberDiff line change
@@ -79,81 +79,14 @@ dt {
7979
}
8080
}
8181

82-
a, button {
83-
text-decoration: none;
84-
color: $brand-primary;
85-
font-family: $site-font-family-base;
86-
font-weight: 400;
87-
cursor: pointer;
88-
background: none;
89-
90-
&:visited {
82+
a {
83+
&, &:visited {
9184
color: $brand-primary;
9285
}
93-
94-
&.filled-button, &.text-button {
95-
display: flex;
96-
align-items: center;
97-
padding: 0.5rem 1rem;
98-
gap: 0.5rem;
99-
width: fit-content;
100-
cursor: pointer;
101-
font-size: 1.25rem;
102-
white-space: nowrap;
103-
104-
font-family: $site-font-family-alt;
105-
106-
&:focus-visible {
107-
outline: 2px solid var(--focus-outline-color);
108-
}
109-
}
110-
111-
&.filled-button {
112-
background-color: $site-color-primary;
113-
border-radius: 0.25rem;
114-
outline-offset: 2px;
115-
116-
&, &:hover, &:focus, &:active {
117-
color: $site-color-white;
118-
text-decoration: none;
119-
}
120-
121-
&:hover {
122-
@include interaction-style(4%);
123-
}
124-
125-
&:active {
126-
@include interaction-style(8%);
127-
}
128-
}
129-
130-
&.text-button {
131-
border-radius: 1.5rem;
132-
133-
&, &:hover, &:focus, &:active {
134-
color: $site-color-primary;
135-
background: none;
136-
text-decoration: none;
137-
}
138-
139-
&:hover {
140-
@include interaction-style(4%);
141-
}
142-
143-
&:active {
144-
@include interaction-style(7%);
145-
}
146-
}
147-
}
148-
149-
.button-group {
150-
display: flex;
151-
flex-direction: row;
152-
gap: 0.75rem;
15386
}
15487

15588
button {
156-
&:hover, &:focus, &:active {
89+
&:hover, &:active {
15790
color: $flutter-color-blue-700;
15891
outline: none;
15992
text-decoration: none;

src/_sass/base/_layout.scss

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919

2020
> article {
2121
min-width: 8rem;
22+
width: 60rem;
23+
max-width: 100%;
2224

2325
> .content {
24-
max-width: 58rem;
25-
margin-left: auto;
26-
margin-right: auto;
26+
min-width: 8rem;
2727
padding: $site-content-top-padding;
2828
}
2929
}

src/_sass/base/_variables.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ $flutter-color-grey-500: #E8EAED;
1515
$site-color-dark-background: #1C2834;
1616
$site-color-black: #000;
1717
$site-color-white: #FFF;
18-
$site-color-codeblock-bg: #F8F9FA;
18+
$site-color-codeblock-bg: rgba(248, 249, 250, 0.9);
1919
$site-color-light-grey: #DADCE0;
2020
$site-color-nav-links: #6E7274;
2121
$site-color-body: #212121;

src/_sass/components/_buttons.scss

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
@use '../base/mixins' as mixins;
2+
@use '../base/variables' as *;
3+
4+
a, button {
5+
// Reset style of buttons and anchors.
6+
text-decoration: none;
7+
cursor: pointer;
8+
background: none;
9+
border: none;
10+
font-weight: 400;
11+
12+
&.filled-button, &.icon-button, &.text-button, &.outlined-button {
13+
// Reset style of buttons.
14+
user-select: none;
15+
padding: 0;
16+
17+
// Shared layout styles.
18+
display: flex;
19+
flex-direction: row;
20+
align-items: center;
21+
justify-content: center;
22+
border-radius: 20px;
23+
width: fit-content;
24+
white-space: nowrap;
25+
font-family: $site-font-family-alt;
26+
font-size: 1rem;
27+
outline-offset: 2px;
28+
29+
&.hidden {
30+
display: none;
31+
}
32+
33+
&:hover {
34+
@include mixins.interaction-style(6%);
35+
text-decoration: none;
36+
}
37+
38+
&:active {
39+
@include mixins.interaction-style(10%);
40+
text-decoration: none;
41+
}
42+
43+
&:focus-visible {
44+
outline: 2px solid var(--focus-outline-color);
45+
}
46+
}
47+
48+
&.filled-button, &.outlined-button, &.text-button {
49+
padding: 0.25rem 0.75rem;
50+
gap: 0.4rem;
51+
52+
// A larger call-to-action button.
53+
&.large-button {
54+
padding: 0.6rem 1.2rem;
55+
font-size: 1.5rem;
56+
gap: 0.75rem;
57+
}
58+
}
59+
60+
&.filled-button {
61+
background-color: #06599C;
62+
outline-offset: 2px;
63+
64+
// Ensure color takes precedence over other anchor styling.
65+
&, &:hover, &:focus, &:active {
66+
color: $site-color-white;
67+
}
68+
69+
span.material-symbols {
70+
font-variation-settings: 'FILL' 1;
71+
font-size: 20px;
72+
}
73+
}
74+
75+
&.icon-button {
76+
height: 2rem;
77+
width: 2rem;
78+
79+
padding: 0.2rem;
80+
color: #3a3a3a;
81+
82+
span {
83+
font-size: 22px;
84+
}
85+
}
86+
87+
&.text-button, &.outlined-button {
88+
// Ensure color takes precedence over other anchor styling.
89+
&, &:hover, &:active, &:focus {
90+
color: #3a3a3a;
91+
}
92+
}
93+
94+
&.outlined-button {
95+
border: 1px solid rgba(0, 0, 0, .125);
96+
}
97+
}

0 commit comments

Comments
 (0)