-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(visually-hidden): implement a utility component to visually hide…
… content fix(pagination): add a visually hidden label for the page input field refactor(breadcrumb): use visually hidden element
- Loading branch information
Showing
8 changed files
with
95 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { html, LitElement } from "lit" | ||
import styles from "./visually-hidden.css" | ||
|
||
/** | ||
* @tagname leu-visually-hidden | ||
*/ | ||
export class LeuVisuallyHidden extends LitElement { | ||
static styles = styles | ||
|
||
render() { | ||
return html`<slot></slot>` | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { defineElement } from "../../lib/defineElement.js" | ||
import { LeuVisuallyHidden } from "./VisuallyHidden.js" | ||
|
||
export { LeuVisuallyHidden } | ||
|
||
defineElement("visually-hidden", LeuVisuallyHidden) |
22 changes: 22 additions & 0 deletions
22
src/components/visually-hidden/stories/visually-hidden.stories.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { html } from "lit" | ||
import "../leu-visually-hidden.js" | ||
|
||
export default { | ||
title: "VisuallyHidden", | ||
component: "leu-visually-hidden", | ||
argTypes: { | ||
content: { | ||
control: "text", | ||
}, | ||
}, | ||
} | ||
|
||
function Template({ content }) { | ||
return html` <leu-visually-hidden>${content}</leu-visually-hidden>` | ||
} | ||
|
||
export const Regular = Template.bind({}) | ||
Regular.args = { | ||
content: | ||
"This is a text that isn't visible but still accessible for screenreaders.", | ||
} |
36 changes: 36 additions & 0 deletions
36
src/components/visually-hidden/test/visually-hidden.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { html } from "lit" | ||
import { fixture, expect } from "@open-wc/testing" | ||
|
||
import "../leu-visually-hidden.js" | ||
|
||
async function defaultFixture() { | ||
return fixture( | ||
html` | ||
<leu-visually-hidden> | ||
This is a text that shouldn't be visible but still accessible. | ||
</leu-visually-hidden> | ||
` | ||
) | ||
} | ||
|
||
describe("LeuVisuallyHidden", () => { | ||
it("is a defined element", async () => { | ||
const el = await customElements.get("leu-visually-hidden") | ||
|
||
await expect(el).not.to.be.undefined | ||
}) | ||
|
||
it("passes the a11y audit", async () => { | ||
const el = await defaultFixture() | ||
|
||
await expect(el).to.be.accessible() | ||
}) | ||
|
||
it("renders the default slot content", async () => { | ||
const el = await defaultFixture() | ||
|
||
expect(el).dom.to.equal( | ||
"<leu-visually-hidden>This is a text that shouldn't be visible but still accessible.</leu-visually-hidden>" | ||
) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
:host { | ||
clip: rect(0 0 0 0); | ||
border: 0; | ||
height: 1px; | ||
margin: -1px !important; | ||
overflow: hidden; | ||
padding: 0 !important; | ||
position: absolute; | ||
width: 1px; | ||
} |