Skip to content

Commit 0201cbd

Browse files
committed
HDS-3349 CodeBlock a11y improvements docs updates
1 parent a92d536 commit 0201cbd

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

website/docs/components/code-block/partials/code/component-api.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ This component uses [prism.js](https://prismjs.com/) under the hood.
1111
<C.Property @name="<[CB].Description>" @type="yielded component">
1212
`ContentBlock::Description` yielded as contextual component (see below).
1313
</C.Property>
14+
<C.Property @name="ariaLabel" @type="string">
15+
Accepts a localized string. The `ariaLabel` value is applied to the code block pre element.
16+
</C.Property>
17+
<C.Property @name="ariaLabelledBy" @type="string">
18+
Accepts a localized string. The `ariaLabelledBy` value is applied to the code block pre element.
19+
</C.Property>
20+
<C.Property @name="ariaDescribedBy" @type="string">
21+
Accepts a localized string. The `ariaDescribedBy` value is applied to the code block pre element.
22+
</C.Property>
1423
<C.Property @name="value" @type="string" @required={{true}}>
1524
The text/code content for the `CodeBlock`. The component encodes this argument before displaying it.
1625
</C.Property>

website/docs/components/code-block/partials/code/how-to-use.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
## How to use this component
22

3-
The basic invocation requires a `@value` argument. The component encodes this argument before displaying it.
3+
The basic invocation requires a `@value` argument. The component encodes this argument before displaying it. To use this component, you must either include the yielded `Title` component, provide an `@ariaLabel`, or specify an `@ariaLabelledBy`.
44

55
!!! Info
66

@@ -10,6 +10,7 @@ If the `\n` escape sequence is used in the `@value` string in Handlebars, it wil
1010

1111
```handlebars
1212
<Hds::CodeBlock
13+
@ariaLabel="basic usage"
1314
@value="aws ec2 --region us-west-1 accept-vpc-peering-connection"
1415
/>
1516
```
@@ -70,6 +71,7 @@ The `language` argument sets the syntax highlighting used. We only support the f
7071

7172
```handlebars
7273
<Hds::CodeBlock
74+
@ariaLabel="language"
7375
@language="go"
7476
@value="package main
7577
import fmt
@@ -85,6 +87,7 @@ Set `hasCopyButton` to `true` to display a button for users to copy `CodeBlock`
8587

8688
```handlebars
8789
<Hds::CodeBlock
90+
@ariaLabel="copy button"
8891
@language="javascript"
8992
@hasCopyButton={{true}}
9093
@copyButtonText="Copy javascript code"
@@ -99,6 +102,7 @@ Line numbers are displayed by default. Set `hasLineNumbers` to `false` to hide t
99102

100103
```handlebars
101104
<Hds::CodeBlock
105+
@ariaLabel="line numbers"
102106
@language="javascript"
103107
@hasLineNumbers={{false}}
104108
@value="let codeLang=`JavaScript`;
@@ -118,6 +122,7 @@ By default, long lines of code will overflow the `CodeBlock` container requiring
118122

119123
```handlebars
120124
<Hds::CodeBlock
125+
@ariaLabel="line wrapping"
121126
@language="javascript"
122127
@hasLineWrapping={{true}}
123128
@value="console.log(`I am JavaScript code`, `Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam`);"
@@ -130,6 +135,7 @@ Highlight either individual code lines or a range of code lines. (Examples: `2,
130135

131136
```handlebars
132137
<Hds::CodeBlock
138+
@ariaLabel="line highlighting"
133139
@language="javascript"
134140
@highlightLines={{"2, 4"}}
135141
@value="import Application from `@ember/application`;

website/docs/components/code-editor/partials/code/component-api.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ This component uses [CodeMirror 6](https://codemirror.net/) under the hood.
2020
<C.Property @name="ariaLabelledBy" @type="string">
2121
Accepts a localized string. The `ariaLabelledBy` value is applied to the code editor input element.
2222
</C.Property>
23+
<C.Property @name="ariaDescribedBy" @type="string">
24+
Accepts a localized string. The `ariaDescribedBy` value is applied to the code editor input element.
25+
</C.Property>
2326
<C.Property @name="hasCopyButton" @type="boolean" @default="false">
2427
Used to control whether a copy button for copying the code/text content will be displayed.
2528
</C.Property>

0 commit comments

Comments
 (0)