-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
/
demo.vue
41 lines (36 loc) · 827 Bytes
/
demo.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<script setup lang="ts">
import { computed, onUnmounted } from 'vue'
import { useDir } from './index'
const dir = useDir({
selector: '#_useDirDemo',
})
const text = computed(() =>
dir.value === 'ltr'
? 'This paragraph is in English and correctly goes left to right.'
: 'This paragraph is in English but incorrectly goes right to left.',
)
const handleOnClick = () => {
dir.value = dir.value === 'rtl' ? 'lrt' : 'rtl'
}
</script>
<template>
<div id="_useDirDemo">
<p>
{{ text }}
</p>
<hr>
<button @click="handleOnClick">
<span class="ml-2">{{ dir.toUpperCase() }}</span>
</button>
<span class="p-4 opacity-50">Click to change the direaction</span>
</div>
</template>
<style scoped>
#_useDirDemo[dir='rtl']
p {
color: red;
}
button {
margin-right: 0.5em;
}
</style>