Skip to content

Commit f3c4de4

Browse files
committed
Add example in demo
1 parent 4b9e643 commit f3c4de4

File tree

2 files changed

+73
-33
lines changed

2 files changed

+73
-33
lines changed

demo/src/App.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
<template>
22
<div id="app">
3-
<img alt="Vue logo" src="./assets/logo.png">
4-
<HelloWorld msg="Welcome to Your Vue.js App"/>
3+
<img
4+
alt="Vue logo"
5+
src="./assets/logo.png"
6+
>
7+
<HelloWorld msg="@vue-a11y/focus-loop" />
58
</div>
69
</template>
710

demo/src/components/HelloWorld.vue

Lines changed: 68 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,56 +2,93 @@
22
<div class="hello">
33
<h1>{{ msg }}</h1>
44
<p>
5-
For a guide and recipes on how to configure / customize this project,<br>
6-
check out the
7-
<a href="https://cli.vuejs.org" target="_blank" rel="noopener">vue-cli documentation</a>.
5+
Vue component that helps you to to trap focus in an element.
86
</p>
9-
<h3>Installed CLI Plugins</h3>
10-
<ul>
11-
<li><a href="https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-babel" target="_blank" rel="noopener">babel</a></li>
12-
</ul>
13-
<h3>Essential Links</h3>
14-
<ul>
15-
<li><a href="https://vuejs.org" target="_blank" rel="noopener">Core Docs</a></li>
16-
<li><a href="https://forum.vuejs.org" target="_blank" rel="noopener">Forum</a></li>
17-
<li><a href="https://chat.vuejs.org" target="_blank" rel="noopener">Community Chat</a></li>
18-
<li><a href="https://twitter.com/vuejs" target="_blank" rel="noopener">Twitter</a></li>
19-
<li><a href="https://news.vuejs.org" target="_blank" rel="noopener">News</a></li>
20-
</ul>
21-
<h3>Ecosystem</h3>
22-
<ul>
23-
<li><a href="https://router.vuejs.org" target="_blank" rel="noopener">vue-router</a></li>
24-
<li><a href="https://vuex.vuejs.org" target="_blank" rel="noopener">vuex</a></li>
25-
<li><a href="https://github.com/vuejs/vue-devtools#vue-devtools" target="_blank" rel="noopener">vue-devtools</a></li>
26-
<li><a href="https://vue-loader.vuejs.org" target="_blank" rel="noopener">vue-loader</a></li>
27-
<li><a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">awesome-vue</a></li>
28-
</ul>
7+
<button @click="activeTrap = !activeTrap">
8+
{{ activeTrap ? 'Hide' : 'Show' }} links with focus loop
9+
</button>
10+
<FocusLoop v-if="activeTrap">
11+
<ul class="links">
12+
<li>
13+
<a
14+
href="https://vuejs.org"
15+
target="_blank"
16+
rel="noopener"
17+
>Core Docs</a>
18+
</li>
19+
<li>
20+
<a
21+
href="https://forum.vuejs.org"
22+
target="_blank"
23+
rel="noopener"
24+
>Forum</a>
25+
</li>
26+
<li>
27+
<a
28+
href="https://chat.vuejs.org"
29+
target="_blank"
30+
rel="noopener"
31+
>Community Chat</a>
32+
</li>
33+
<li>
34+
<a
35+
href="https://twitter.com/vuejs"
36+
target="_blank"
37+
rel="noopener"
38+
>Twitter</a>
39+
</li>
40+
<li>
41+
<a
42+
href="https://news.vuejs.org"
43+
target="_blank"
44+
rel="noopener"
45+
>News</a>
46+
</li>
47+
<li style="margin-top: 20px;">
48+
<button @click="activeTrap = false">
49+
Close
50+
</button>
51+
</li>
52+
</ul>
53+
</FocusLoop>
2954
</div>
3055
</template>
3156

3257
<script>
58+
import { FocusLoop } from '../../vue-focus-loop'
59+
3360
export default {
3461
name: 'HelloWorld',
62+
63+
components: {
64+
FocusLoop
65+
},
66+
3567
props: {
3668
msg: String
37-
}
69+
},
70+
71+
data: () => ({
72+
activeTrap: false
73+
})
3874
}
3975
</script>
4076

4177
<!-- Add "scoped" attribute to limit CSS to this component only -->
4278
<style scoped>
43-
h3 {
44-
margin: 40px 0 0;
79+
a {
80+
color: #333;
4581
}
4682
ul {
4783
list-style-type: none;
48-
padding: 0;
84+
padding-left: 0;
4985
}
5086
li {
51-
display: inline-block;
52-
margin: 0 10px;
87+
margin-bottom: 10px;
5388
}
54-
a {
55-
color: #42b983;
89+
.links {
90+
background-color: #f2f2f2;
91+
padding-top: 20px;
92+
padding-bottom: 20px;
5693
}
5794
</style>

0 commit comments

Comments
 (0)