Skip to content

New version - v1.2.0 #24

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 21 commits into from
May 13, 2020
Merged
Show file tree
Hide file tree
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
6 changes: 0 additions & 6 deletions .babelrc

This file was deleted.

14 changes: 10 additions & 4 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,17 @@ module.exports = {
browser: true,
node: true
},
extends: 'standard',
extends: [
'plugin:vue/recommended',
'@vue/standard',
],
plugins: [
"cypress"
],
// add your custom rules here
rules: {},
globals: {}
parserOptions: {
parser: 'babel-eslint'
},
rules: {
'no-console': 'off'
}
}
91 changes: 54 additions & 37 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ Accessibility auditing for Vue.js applications by running [dequelabs/axe-core](h
## Install package
#### NPM
```shell
npm install -D vue-axe
npm install -D axe-core vue-axe
```

#### Yarn
```shell
yarn add -D vue-axe
yarn add -D axe-core vue-axe
```
---

Expand All @@ -20,27 +20,21 @@ import Vue from 'vue'

if (process.env.NODE_ENV !== 'production') {
const VueAxe = require('vue-axe')
Vue.use(VueAxe, {
config: {
// ...
rules: [
{ id: 'heading-order', enabled: true },
{ id: 'label-title-only', enabled: true },
// and more
]
}
})
Vue.use(VueAxe)
}
```
#### Configuration
|Key|Description|Default|Required|
|---|---|---|---|
|`clearConsoleOnUpdate`|Clears the console each time `vue-axe` runs|`true`|`false`|
|`customResultHandler`|Handle the results from an `axe.run()`. This may be needed for automated tests.|`undefined`|`false`|
|`config`|Provide your Axe-core configuration: https://github.com/dequelabs/axe-core/blob/master/doc/API.md#api-name-axeconfigure| |`false`|
|`runOptions`|Provide your Axe-core runtime options: [API Name: axe.run](https://github.com/dequelabs/axe-core/blob/master/doc/API.md#options-parameter)|`{ reporter: 'v2', resultTypes: ['violations'] }`|`false`|

#### Custom Result Handler
## Configuration
| Key | Type | Description | Default
| ---------------------- | -------- |-------------------------------------------------------------- | -----------
| `clearConsoleOnUpdate` | Boolean | Clears the console each time `vue-axe` runs | `false`
| `customResultHandler` | Function | Handle the results. (This may be needed for automated tests)
| `config` | Object | Provide your [Axe-core configuration](https://github.com/dequelabs/axe-core/blob/master/doc/API.md#api-name-axeconfigure) | [See default config](https://github.com/vue-a11y/vue-axe/blob/master/src/index.js#L13)
| `runOptions` | Object | Provide your [Axe-core runtime options](https://github.com/dequelabs/axe-core/blob/master/doc/API.md#options-parameter) | [See default runOption](https://github.com/vue-a11y/vue-axe/blob/master/src/index.js#L18)
| `delay` | Number | Used to delay the first check. - `Millisecond`
| `style` | Object | Customize style for console logs. | [See default style](https://github.com/vue-a11y/vue-axe/blob/master/src/index.js#L22)
| `plugins` | Array | Register Axe plugins. [Axe docs: Plugins](https://github.com/dequelabs/axe-core/blob/master/doc/plugins.md)

### Custom Result Handler

The `customResultHandler` config property expects a callback like the `axe.run()` callback ([see documentation](https://github.com/dequelabs/axe-core/blob/master/doc/API.md#parameters-axerun)). It will be triggered after each call to `axe.run()`.

Expand All @@ -58,18 +52,45 @@ if (process.env.NODE_ENV !== 'production') {
}
```

### Run axe manually `$axe.run({ clearConsole: Boolean, element: Document | HTMLElement })`
The `$axe` is available on the property injected into the Vue instance, so it is available everywhere in your application. With it it is possible to execute the `$axe.run` method to check manually your document or any desired HTMLElement.

```vue
<script>
//...
methods: {
axeRun() {
this.$axe.run({
clearConsole: false,
element: this.$el // e.g. document, document.querySelector('.selector'), ...
})
}
}
</script>
```

### Running custom axe plugins
Learn more about [axe plugin](https://github.com/dequelabs/axe-core/blob/master/doc/plugins.md)

```vue
<script>
//...
methods: {
handle () {
this.$axe.plugins.myPlugin.run()
}
}
</script>
```

## Install in Nuxt.js
Create plugin file `plugins/axe.js`
```javascript
import Vue from 'vue'

if (process.env.NODE_ENV !== 'production') {
const VueAxe = require('vue-axe')
Vue.use(VueAxe, {
config: {
// your configuration data
}
})
Vue.use(VueAxe)
}

```
Expand All @@ -78,32 +99,27 @@ In config file `nuxt.config.js`
```javascript
...
plugins: [
{ src: '~/plugins/axe', ssr: false }
{ src: '~/plugins/axe.js', mode: 'client' }
]
```

## Using with HTML files
#### CDN
```html
<!-- Required Javascript -->
<script src="https://unpkg.com/vue"></script>
<script src="https://unpkg.com/vue-axe"></script>
```

```javascript
Vue.use(VueAxe, {
config: {
// your configuration data
}
})
Vue.use(VueAxe)
```
## See demo
https://vue-axe.surge.sh/

## Run the demo
```shell
git clone https://github.com/vue-a11y/vue-axe.git vue-axe-demo
cd vue-axe-demo/demo
git clone https://github.com/vue-a11y/vue-axe.git vue-axe
cd vue-axe/demo
npm install
npm run dev
```
Expand All @@ -115,6 +131,7 @@ After the commands just access the http://localhost:8080/
## Run the tests
```shell
git clone https://github.com/vue-a11y/vue-axe.git vue-axe
cd vue-axe
npm install
npm run test
```
Expand All @@ -125,11 +142,11 @@ npm run test:open
```

## 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;

If you want a faster communication, find me on [@ktquez](https://twitter.com/ktquez)
And follow us on Twitter [@vue_a11y](https://twitter.com/vue_a11y)
Follow us on Twitter [@vue_a11y](https://twitter.com/vue_a11y)

**thank you**

Expand Down
10 changes: 4 additions & 6 deletions demo/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<template>
<div id="app" role="main">
<div id="app">
<router-view />
</div>
</template>

<script>
export default {
name: 'app'
name: 'App'
}
</script>

Expand All @@ -17,6 +17,8 @@ export default {
-moz-osx-font-smoothing: grayscale;
text-align: center;
color: #2c3e50;
max-width: 600px;
margin: 0 auto;
margin-top: 60px;
}

Expand All @@ -33,8 +35,4 @@ li {
display: inline-block;
margin: 0 10px;
}

a {
color: #42b983;
}
</style>
20 changes: 6 additions & 14 deletions demo/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,12 @@ import Vue from 'vue'
import App from './App.vue'
import router from './router.js'

// Use this plugin only in development => if (process.env.NODE_ENV !== 'production')
const VueAxe = require('../../dist/vue-axe')
Vue.use(VueAxe, {
config: {
rules: [
{ id: 'heading-order', enabled: true },
{ id: 'label-title-only', enabled: true },
{ id: 'link-in-text-block', enabled: true },
{ id: 'region', enabled: true },
{ id: 'skip-link', enabled: true },
{ id: 'help-same-as-label', enabled: true }
]
}
})
if (process.env.NODE_ENV !== 'production') {
const VueAxe = require('../vue-axe').default
Vue.use(VueAxe, {
clearConsoleOnUpdate: true
})
}
Vue.config.productionTip = false

/* eslint-disable no-new */
Expand Down
Loading