Skip to content

Commit c6c9cb9

Browse files
authored
Merge pull request #244 from niceplugin/api/application
문서 번역: api/application.md
2 parents b658185 + 213f517 commit c6c9cb9

File tree

2 files changed

+260
-246
lines changed

2 files changed

+260
-246
lines changed
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
<script setup lang='ts'>
2+
import { VTSwitch } from '@vue/theme'
3+
import { Ref, ref } from 'vue'
4+
5+
const hasStorage = typeof localStorage !== 'undefined'
6+
const get = (key: string, defaultValue = false): boolean =>
7+
hasStorage
8+
? JSON.parse(localStorage.getItem(key) || String(defaultValue))
9+
: defaultValue
10+
11+
const preferCompositionKey = 'vue-docs-prefer-composition'
12+
const preferComposition = ref(get(preferCompositionKey))
13+
14+
const toggleCompositionAPI = useToggleFn(
15+
preferCompositionKey,
16+
preferComposition,
17+
'prefer-composition'
18+
)
19+
20+
function useToggleFn(
21+
storageKey: string,
22+
state: Ref<boolean>,
23+
className: string
24+
) {
25+
if (typeof localStorage === 'undefined') {
26+
return () => {}
27+
}
28+
const classList = document.documentElement.classList
29+
return (value = !state.value) => {
30+
if ((state.value = value)) {
31+
classList.add(className)
32+
} else {
33+
classList.remove(className)
34+
}
35+
localStorage.setItem(storageKey, String(state.value))
36+
}
37+
}
38+
</script>
39+
<template>
40+
<div class='position-hack'>
41+
<div class="preference-switches">
42+
<div class="switch-container">
43+
<label class="options-label" @click="toggleCompositionAPI(false)"
44+
>옵션</label>
45+
<VTSwitch
46+
class="api-switch"
47+
aria-label="컴포지션 api를 추천합니다"
48+
:aria-checked="preferComposition"
49+
@click="toggleCompositionAPI()"
50+
/>
51+
<label
52+
class="composition-label"
53+
@click="toggleCompositionAPI(true)"
54+
>컴포지션</label>
55+
<a
56+
class="switch-link"
57+
title="API 스타일에 대하여"
58+
href="/guide/introduction.html#api-스타일"
59+
@click="closeSideBar"
60+
>?</a>
61+
</div>
62+
</div>
63+
</div>
64+
</template>
65+
66+
<style scoped>
67+
/* custom-selector */
68+
.position-hack {
69+
position: relative;
70+
}
71+
72+
.preference-switches {
73+
font-size: 11px;
74+
padding: 8px 12px;
75+
background-color: var(--vt-c-bg-soft);
76+
transition: background-color 0.5s;
77+
border-radius: 8px 8px 0 0;
78+
font-weight: 600;
79+
/* custom-properties */
80+
position: absolute;
81+
bottom: -16px;
82+
right: 0;
83+
}
84+
85+
.switch-container {
86+
display: flex;
87+
align-items: center;
88+
}
89+
90+
.switch-container:nth-child(2) {
91+
margin-top: 10px;
92+
}
93+
94+
.vt-switch {
95+
margin-right: 5px;
96+
transform: scale(0.8);
97+
}
98+
99+
.switch-container label {
100+
transition: color 0.5s;
101+
cursor: pointer;
102+
}
103+
104+
.switch-container label:first-child {
105+
width: 28px;
106+
}
107+
108+
.switch-link {
109+
margin-left: 8px;
110+
font-size: 11px;
111+
min-width: 14px;
112+
height: 14px;
113+
line-height: 13px;
114+
text-align: center;
115+
color: var(--vt-c-green);
116+
border: 1px solid var(--vt-c-green);
117+
border-radius: 50%;
118+
}
119+
120+
/* custom-media */
121+
@media (max-width: 639px) {
122+
.position-hack {
123+
margin: 0 -24px;
124+
}
125+
}
126+
</style>

0 commit comments

Comments
 (0)