Skip to content

docs: Update README #16

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 12, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
143 changes: 100 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,66 +1,117 @@
# vue-skip-to
It helps people who only use the keyboard to jump to what matters most

> Helps people who only use the keyboard to jump to what matters most

- [Installation](##installation)
- [Usage](##usage)
- [Props](##props)
- [Custom styling](##custom-styling)
- [Running tests](##running-tests)
- [About](##about)
- [Contributing](##contributing)

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?

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

"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.

In addition to being a technique recommended by WCAG 2.0, that's where this component was inspired.
https://www.w3.org/TR/WCAG20-TECHS/G1.html
https://www.w3.org/TR/WCAG20-TECHS/G124.html
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.

[Check out the live demo!](https://vue-skip-to.surge.sh)

## Installation

## Install
#### NPM
```shell
// npm
npm install -S @vue-a11y/skip-to
```

#### Yarn
```shell
// yarn
yarn add @vue-a11y/skip-to
```

## How to use
In your `main.js`
## Usage

### Vue SFC

```javascript
// main.js

import Vue from 'vue'
import VueSkipTo from '@vue-a11y/skip-to'

Vue.use(VueSkipTo)

new Vue({
//... options
//...
})
```

In your `App.vue`
```vue
// App.vue

<template>
<div id="app">
<VueSkipTo to="#main" text="Skip to main content" />

<logo :src="require('@/assets/logo.png')" />
<h1 data-va="main header">{{ msg }}</h1>
...
<div id="main" role="main">
<!-- My content -->
</div>
<!-- header, navigation, and more -->

<main id="main">
<!-- content -->
</main>
</div>
</template>

<script>
export default {
name: 'app'
components: {
Logo
Logo,
VueSkipTo,
},
//...
}
</script>
```

## Using with HTML files
#### Skip-to list

To use multiple links, simply pass an array into the `to` prop with the following shape:

```json
[
{
"anchor": "<STRING>", // destination id
"label": "<STRING>" // link text
}
//...
]
```

```vue
// App.vue

<template>
<div id="app">
<vue-skip-to
title-list="Skip to"
:to="[
{ anchor: '#main', label: 'Main content' },
{ anchor: '#footer', label: 'Footer' },
]"
></vue-skip-to>

<!-- header, navigation, and more -->

<main id="main"></div>

<footer id="footer"></div>
</div>
</template>
```

### In HTML files

```html
<!--omitted -->
<script src="https://unpkg.com/vue"></script>
Expand All @@ -70,11 +121,11 @@ export default {
<div id="app">
<vue-skip-to to="#main"></vue-skip-to>

<!-- my header, navigation, and more -->
<!-- header, navigation, and more -->

<div id="main" role="main">
<!-- My content -->
</div>
<main id="main">
<!-- content -->
</main>
</div>

<script>
Expand All @@ -86,42 +137,48 @@ export default {
</html>
```

## Check live demo
https://vue-skip-to.surge.sh


## Props
Prop | Data Type | required | Description | Default
--------------- | ---------- | --------- | ---------------------- | -------------
`to` | String | false | Set destination ID | #main
`text` | String | false | Text content of link | Skip to main content

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

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

- This component working in all modern browsers and IE9;
- 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`;
- Add focus to the destination, even when the address bar already has the corresponding hash;
Override the default styles by targeting the following:

## Run the tests
```css
.vue-skip-to {
}
```

## Running tests

```shell
git clone https://github.com/vue-a11y/vue-skip-to.git
git clone https://github.com/vue-a11y/vue-skip-to.git
npm install
npm run dev
npm run test:e2e
```

Or run Cypress on interactive mode

```shell
npm run test:e2e:open
```

## About

This component was inspired by [this article](http://www.nczonline.net/blog/2013/01/15/fixing-skip-to-content-links/).

- This component working in all modern browsers and IE9;
- 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`;
- Add focus to the destination, even when the address bar already has the corresponding hash;

## Contributing

- From typos in documentation to coding new features;
- Check the open issues or open a new issue to start a discussion around your feature idea or the bug you found;
- Fork repository, make changes and send a pull request;
Expand Down