Skip to content

Commit 4dae925

Browse files
authored
docs: Update README (#16)
- Add skip-link list usage to README - Format README
1 parent eaad896 commit 4dae925

File tree

1 file changed

+100
-43
lines changed

1 file changed

+100
-43
lines changed

README.md

+100-43
Original file line numberDiff line numberDiff line change
@@ -1,66 +1,117 @@
11
# vue-skip-to
2-
It helps people who only use the keyboard to jump to what matters most
2+
3+
> Helps people who only use the keyboard to jump to what matters most
4+
5+
- [Installation](##installation)
6+
- [Usage](##usage)
7+
- [Props](##props)
8+
- [Custom styling](##custom-styling)
9+
- [Running tests](##running-tests)
10+
- [About](##about)
11+
- [Contributing](##contributing)
312

413
The population grows very fast nowadays and with that the number of visually impaired increases as well. Did you know that we have over 350 million visually impaired people in the world?
514

615
However, we are responsible for doing our utmost to make our applications usable and accessible to everyone.
716

817
"Skip to content" or "skip to a section" of your site is one of the most common accessibility techniques today, but not as used as it should be.
918

10-
In addition to being a technique recommended by WCAG 2.0, that's where this component was inspired.
11-
https://www.w3.org/TR/WCAG20-TECHS/G1.html
12-
https://www.w3.org/TR/WCAG20-TECHS/G124.html
19+
This pattern is detailed in the Techniques for WCAG 2.0 in notes [G1](https://www.w3.org/TR/WCAG20-TECHS/G1.html) and [G124](https://www.w3.org/TR/WCAG20-TECHS/G124.html), and also served as the inspiration for creating this component.
20+
21+
[Check out the live demo!](https://vue-skip-to.surge.sh)
22+
23+
## Installation
1324

14-
## Install
15-
#### NPM
1625
```shell
26+
// npm
1727
npm install -S @vue-a11y/skip-to
18-
```
1928

20-
#### Yarn
21-
```shell
29+
// yarn
2230
yarn add @vue-a11y/skip-to
2331
```
2432

25-
## How to use
26-
In your `main.js`
33+
## Usage
34+
35+
### Vue SFC
36+
2737
```javascript
38+
// main.js
39+
2840
import Vue from 'vue'
2941
import VueSkipTo from '@vue-a11y/skip-to'
3042

3143
Vue.use(VueSkipTo)
3244

3345
new Vue({
34-
//... options
46+
//...
3547
})
3648
```
3749

38-
In your `App.vue`
3950
```vue
51+
// App.vue
52+
4053
<template>
4154
<div id="app">
4255
<VueSkipTo to="#main" text="Skip to main content" />
4356
44-
<logo :src="require('@/assets/logo.png')" />
45-
<h1 data-va="main header">{{ msg }}</h1>
46-
...
47-
<div id="main" role="main">
48-
<!-- My content -->
49-
</div>
57+
<!-- header, navigation, and more -->
58+
59+
<main id="main">
60+
<!-- content -->
61+
</main>
5062
</div>
5163
</template>
64+
5265
<script>
5366
export default {
5467
name: 'app'
5568
components: {
56-
Logo
69+
Logo,
70+
VueSkipTo,
5771
},
5872
//...
5973
}
6074
</script>
6175
```
6276

63-
## Using with HTML files
77+
#### Skip-to list
78+
79+
To use multiple links, simply pass an array into the `to` prop with the following shape:
80+
81+
```json
82+
[
83+
{
84+
"anchor": "<STRING>", // destination id
85+
"label": "<STRING>" // link text
86+
}
87+
//...
88+
]
89+
```
90+
91+
```vue
92+
// App.vue
93+
94+
<template>
95+
<div id="app">
96+
<vue-skip-to
97+
title-list="Skip to"
98+
:to="[
99+
{ anchor: '#main', label: 'Main content' },
100+
{ anchor: '#footer', label: 'Footer' },
101+
]"
102+
></vue-skip-to>
103+
104+
<!-- header, navigation, and more -->
105+
106+
<main id="main"></div>
107+
108+
<footer id="footer"></div>
109+
</div>
110+
</template>
111+
```
112+
113+
### In HTML files
114+
64115
```html
65116
<!--omitted -->
66117
<script src="https://unpkg.com/vue"></script>
@@ -70,11 +121,11 @@ export default {
70121
<div id="app">
71122
<vue-skip-to to="#main"></vue-skip-to>
72123

73-
<!-- my header, navigation, and more -->
124+
<!-- header, navigation, and more -->
74125

75-
<div id="main" role="main">
76-
<!-- My content -->
77-
</div>
126+
<main id="main">
127+
<!-- content -->
128+
</main>
78129
</div>
79130

80131
<script>
@@ -86,42 +137,48 @@ export default {
86137
</html>
87138
```
88139

89-
## Check live demo
90-
https://vue-skip-to.surge.sh
91-
92-
93140
## Props
94-
Prop | Data Type | required | Description | Default
95-
--------------- | ---------- | --------- | ---------------------- | -------------
96-
`to` | String | false | Set destination ID | #main
97-
`text` | String | false | Text content of link | Skip to main content
98141

99-
## Custom style
100-
You can style the link through the selector `.vue-skip-to`
142+
| Prop | Data Type | required | Description | Default |
143+
| ----------- | --------------- | -------- | ----------------------------------------------------------------- | ---------------------- |
144+
| `to` | String \| Array | false | Destination ID or [array of destination objects](###skip-to-list) | '#main' |
145+
| `label` | String | false | Skip link text content | 'Skip to main content' |
146+
| `titleList` | String | false | Skip link list label text | 'Skip to' |
101147

102-
## Feature
103-
Inspired by this article, to know more, access the link:
104-
http://www.nczonline.net/blog/2013/01/15/fixing-skip-to-content-links/
148+
## Custom styling
105149

106-
- This component working in all modern browsers and IE9;
107-
- Ensures that the target element receives focus, even if it is not a tag that naturally receives focus as the tag `input` and `a`. In this case, the `div` are also given the focus and the `tabindex` attribute with the value of `-1`;
108-
- Add focus to the destination, even when the address bar already has the corresponding hash;
150+
Override the default styles by targeting the following:
109151

110-
## Run the tests
152+
```css
153+
.vue-skip-to {
154+
}
155+
```
156+
157+
## Running tests
111158

112159
```shell
113-
git clone https://github.com/vue-a11y/vue-skip-to.git
160+
git clone https://github.com/vue-a11y/vue-skip-to.git
114161
npm install
115162
npm run dev
116163
npm run test:e2e
117164
```
118165

119166
Or run Cypress on interactive mode
167+
120168
```shell
121169
npm run test:e2e:open
122170
```
123171

172+
## About
173+
174+
This component was inspired by [this article](http://www.nczonline.net/blog/2013/01/15/fixing-skip-to-content-links/).
175+
176+
- This component working in all modern browsers and IE9;
177+
- Ensures that the target element receives focus, even if it is not a tag that naturally receives focus as the tag `input` and `a`. In this case, the `div` are also given the focus and the `tabindex` attribute with the value of `-1`;
178+
- Add focus to the destination, even when the address bar already has the corresponding hash;
179+
124180
## Contributing
181+
125182
- From typos in documentation to coding new features;
126183
- Check the open issues or open a new issue to start a discussion around your feature idea or the bug you found;
127184
- Fork repository, make changes and send a pull request;

0 commit comments

Comments
 (0)