Skip to content

Commit 9ec0e41

Browse files
Issue #430: Created Column and ThemedColumn components. (#535)
1 parent 258e5a7 commit 9ec0e41

27 files changed

Lines changed: 416 additions & 289 deletions

astro/src/components/Column.astro

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
import { undefined } from 'astro:schema';
3+
4+
type ColumnSizes = "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "10" | "11" | "12";
5+
6+
export interface Props {
7+
id?: string;
8+
class?: string;
9+
noDefault?: boolean;
10+
sm?: ColumnSizes;
11+
md?: ColumnSizes;
12+
lg?: ColumnSizes;
13+
xl?: ColumnSizes;
14+
xxl?: ColumnSizes;
15+
}
16+
17+
const {
18+
id: elementID = "",
19+
class: cssClass = "",
20+
noDefault = false,
21+
sm = undefined,
22+
md = undefined,
23+
lg = undefined,
24+
xl = undefined,
25+
xxl = undefined,
26+
} = Astro.props;
27+
---
28+
29+
<div class:list={[
30+
!noDefault && "col",
31+
sm && `col-sm-${sm}`,
32+
md && `col-md-${md}`,
33+
lg && `col-lg-${lg}`,
34+
xl && `col-xl-${xl}`,
35+
xxl && `col-xxl-${xxl}`,
36+
elementID,
37+
cssClass,
38+
]}><slot /></div>

astro/src/components/ThemedBox.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
interface Props {
2+
export interface Props {
33
theme?: string;
44
style?: string;
55
text?: boolean;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
import type { Props as ColumnProps } from "@components/Column.astro";
3+
import type { Props as ThemedBoxProps } from "@components/ThemedBox.astro";
4+
5+
import Column from "@components/Column.astro";
6+
7+
interface Props extends ColumnProps, ThemedBoxProps {}
8+
9+
const {
10+
theme = undefined,
11+
style = undefined,
12+
text = true,
13+
border = 0,
14+
padding = 4,
15+
...columnProps
16+
} = Astro.props;
17+
18+
import { getBackgroundAndText, getBorder } from "../lib/themes.ts";
19+
20+
const bgAndTextClasses = getBackgroundAndText(theme, style, text);
21+
const borderClasses = getBorder(border, theme, style === "subtle");
22+
---
23+
24+
<Column {...columnProps} class:list={[bgAndTextClasses, borderClasses, `p-${padding}`]}><slot /></Column>

astro/src/content/atotw/present-and-describe.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ tags:
99
- event-accessibility
1010
---
1111

12-
import ThemedBox from "../../components/ThemedBox.astro"
12+
import ThemedColumn from "../../components/ThemedColumn.astro";
1313

1414
When learning to give presentations, one of the common pieces of advice is to "not read the slides". The rationale is that the audience can read the bullet points themselves; the speaker is not adding anything to the presentation by just dictating what is there.
1515

@@ -19,12 +19,12 @@ In order to both engage your audience and provide accessible presentations, use
1919

2020
For example, a slide for the ideas in this tip might say:
2121

22-
<ThemedBox border={1} class="rounded mb-4 col col-md-9 col-lg-7 col-xl-5">
22+
<ThemedColumn border={1} md="9" lg="7" xl="5" class="rounded mb-4">
2323
**Goal:** Create accessible presentations
2424
1. List the key points on the slides
2525
2. Expand on each point while speaking
2626
3. Provide captions and a transcript of recording
27-
</ThemedBox>
27+
</ThemedColumn>
2828

2929
When you are speaking, talk to each point and expand upon it. This keeps your audience engaged because you are not just reading the slides. Describe any charts or images that appear in your presentation. By doing this, you make it easy to provide captions and audio descriptions to enhance your accessibility. Both the visual and auditory information will be included in the soundtrack.
3030

astro/src/layouts/TipLayout.astro

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ const { title = tip?.data.title || "Tip of the Week" } = Astro.props;
3939
const { tips = [] } = catalog;
4040
const related = await getRelatedTips(tip);
4141
42+
import Column from "../components/Column.astro";
4243
import { Icon } from "astro-icon/components";
4344
import ImageHeading from "../components/ImageHeading.astro";
4445
import Layout from "../layouts/Layout.astro";
@@ -87,9 +88,9 @@ const metadata: PageMetadata = {
8788
<div
8889
class="d-flex flex-column flex-lg-row justify-content-lg-between gap-3"
8990
>
90-
<div class="col col-lg-7">
91+
<Column lg="7">
9192
{tip && <TipOfTheWeek {tip} />}
92-
</div>
93+
</Column>
9394
<nav
9495
class="d-flex flex-column flex-md-row d-lg-block gap-4 col-lg-4"
9596
aria-label="Tips"
@@ -112,7 +113,7 @@ const metadata: PageMetadata = {
112113
)
113114
}
114115
</ul>
115-
<div class="col col-md-6 col-lg-12">
116+
<Column md="6" lg="12">
116117
<TipRegistration defaultWidth border={2}>
117118
<p>
118119
Would you like to receive these tips automatically?
@@ -126,7 +127,7 @@ const metadata: PageMetadata = {
126127
Email the <strong>Tip of the Week</strong>.
127128
</p>
128129
</TipRegistration>
129-
</div>
130+
</Column>
130131
</nav>
131132
</div>
132133
</ThemedSection>

astro/src/pages/_fixable/index.astro

Lines changed: 29 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@
22
import { getImage, Image } from "astro:assets";
33
44
import Branding from "../../components/Branding.astro";
5+
import Column from "../../components/Column.astro";
56
import ExternalLink from "../../components/ExternalLink.astro";
67
import Layout from "../../layouts/Layout.astro";
78
import Hero from "../../components/Hero.astro";
89
import ShadowBoxSection from "../../components/ShadowBoxSection.astro";
9-
import ThemedBox from "../../components/ThemedBox.astro";
10+
import ThemedColumn from "../../components/ThemedColumn.astro";
1011
import ThemedSection from "../../components/ThemedSection.astro";
1112
1213
import heroBg from "../../images/colored-hero/woman-using-laptop.png";
@@ -42,7 +43,7 @@ const crumbs = [];
4243
<div
4344
class="d-flex flex-column flex-xl-row justify-content-xl-evenly align-items-center"
4445
>
45-
<div class="col col-xl-8 col-xxl-9">
46+
<Column xl="8" xxl="9">
4647
<p>
4748
Headings in a document exist to indicate structure. Your users will
4849
use headings to scan through your content and find the relevant
@@ -54,16 +55,16 @@ const crumbs = [];
5455
always increment one level. Never use a heading or subheading because
5556
it's sized correctly.
5657
</p>
57-
</div>
58-
<div class="col col-lg-9 col-xl-3 col-xxl-2">
58+
</Column>
59+
<Column lg="9" xl="3" xxl="2">
5960
<h4
6061
class="display-5 text-center text-primary py-3 border-primary-subtle border-top border-bottom"
6162
>
6263
Headings are for <strong>organization</strong>, not <strong
6364
>size</strong
6465
>.
6566
</h4>
66-
</div>
67+
</Column>
6768
</div>
6869
</ThemedSection>
6970

@@ -72,28 +73,31 @@ const crumbs = [];
7273
<div
7374
class="d-flex flex-column flex-lg-row gap-4 py-3 justify-content-lg-evenly"
7475
>
75-
<div class="p-4 col col-lg-3">
76+
<Column lg="3" class="p-4">
7677
<p class="text-center fs-3 bad-contrast">
7778
This text is <strong>low contrast</strong> on this background.
7879
</p>
79-
</div>
80-
<ThemedBox border={1} class="col col-lg-3 p-3 shadow rounded">
80+
</Column>
81+
<ThemedColumn
82+
lg="3"
83+
border={1}
84+
class="p-3 shadow rounded">
8185
<p class="text-center fs-5">
8286
<Image class="green-on-red" src={greenOnRed} alt="" />
8387
and <span class="red-on-green py-1 px-2">Red</span> is the
8488
<strong>most common</strong> combination of color blindness.
8589
</p>
86-
</ThemedBox>
87-
<div
88-
class="col col-lg-3 p-3 shadow rounded no-bg-color"
89-
style={`background-image: url(${fixBgNoColor.src});`}
90+
</ThemedColumn>
91+
<Column
92+
lg="3"
93+
class="p-3 shadow rounded no-bg-color bg-example"
9094
>
9195
<p class="text-center text-light fs-4">
9296
Always specify a <code>background-color</code>, even when an image is
9397
used.
9498
</p>
9599
</div>
96-
</div>
100+
</Column>
97101
</ThemedSection>
98102

99103
<ShadowBoxSection theme="info" style="secondary">
@@ -108,7 +112,7 @@ const crumbs = [];
108112
> and the correct <code>for</code> attribute or ARIA description.
109113
</p>
110114
<div class="d-flex flex-column flex-xl-row justify-content-xl-evenly p-4">
111-
<div class="col col-xl-5 pb-4">
115+
<Column xl="5" class="pb-4">
112116
<h3 class="display-5"
113117
><strong>Associate</strong> the fields and text.</h3
114118
>
@@ -150,9 +154,9 @@ const crumbs = [];
150154
<input class="form-control" type="file" />
151155
<p class="form-text px-2">... also need descriptions and labels.</p>
152156
</div>
153-
</div>
157+
</Column>
154158

155-
<div class="col col-xl-5">
159+
<Column xl="5">
156160
<h3 class="display-5"
157161
>Choose the right <strong>field type</strong>.</h3
158162
>
@@ -237,7 +241,7 @@ const crumbs = [];
237241
will read the password to anyone who can hear it.
238242
</p>
239243
</div>
240-
</div>
244+
</Column>
241245
</div>
242246
</div>
243247
</ShadowBoxSection>
@@ -250,14 +254,14 @@ const crumbs = [];
250254
<div
251255
class="d-flex flex-column flex-lg-row justify-content-lg-around align-items-center"
252256
>
253-
<div class="col col-lg-4 col-xxl-3">
257+
<Column lg="4" xxl="3">
254258
<p class="fs-5 text-center text-primary py-3">
255259
Make sure you properly describe your link content. None of these do
256260
this well.
257261
</p>
258-
</div>
262+
</Column>
259263

260-
<div class="col col-xl-5 col-xxl-4">
264+
<Column xl="5" xxl="4">
261265
<ul style="--bs-gutter-x: 6rem;">
262266
<li>
263267
Read more at <a href="https://accessiblecommunity.org"
@@ -277,7 +281,7 @@ const crumbs = [];
277281
<ExternalLink href="https://accessiblecommunity.org" />
278282
</li>
279283
</ul>
280-
</div>
284+
</Column>
281285
</div>
282286
</ThemedSection>
283287
</Layout>
@@ -305,6 +309,10 @@ const crumbs = [];
305309
align-content: center;
306310
}
307311

312+
.bg-example {
313+
background-image: url(${fixBgNoColor.src});
314+
}
315+
308316
@include color-mode(dark) {
309317
.bad-contrast {
310318
color: var(--bs-dark);

0 commit comments

Comments
 (0)