Skip to content

Commit c3d96f7

Browse files
authored
Merge pull request #15 from healerlab/features/docs
Features/docs
2 parents 8bd6b0a + 7f90b74 commit c3d96f7

File tree

6 files changed

+57
-5
lines changed

6 files changed

+57
-5
lines changed

docs/.vitepress/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ export default defineConfig({
1919
{ text: 'Home', link: '/' },
2020
{ text: 'Get Started', link: '/usage-examples' },
2121
{
22-
text: '0.0.8',
22+
text: '0.0.9',
2323
items: [
2424
{
2525
text: 'Changelog',

docs/.vitepress/theme/custom.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,14 @@
1313
}
1414
.otp-input input:focus {
1515
outline: none
16+
}
17+
18+
.otp-input {
19+
display: flex;
20+
align-items: center;
21+
}
22+
23+
.otp-input div span {
24+
padding: 0 0px 0 10px;
25+
font-size: 30px;
1626
}

docs/api.md

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ This page demonstrates usage of props and events provided by HOtpInput.
2626
| onChange | `Function` | `null` | Callback event that return OTP code when we made a change in inputs. `(otpCode: string)` |
2727
| onFinish | `Function` | `null` | Callback event that return OTP code when we fully typed all inputs. `(otpCode: string)` |
2828
| separator | `String` | `null` | Separator to be rendered. |
29-
| separatorType | `String` | `middle` | Default separator position if separator is not null |
30-
29+
| separatorType | `String` | `"middle", "all"` | Default separator position if separator is not null |
30+
| genResultWithSeparator | `Function` | `null` | Using this event, exposed from otp component to get code with separator |
3131
See the [Vue3 Simple OTP Input](https://www.npmjs.com/package/@healerlab/vue3-simple-otp-input) package for more information.
3232

3333

@@ -43,12 +43,15 @@ const { HOtpInput } = pkg
4343
const otpInput = ref(null)
4444
const otpCode = ref()
4545
const otpCodeChange = ref()
46+
const otpWithSeparator = ref()
4647

4748
const handleFinish = (code: string) => {
4849
otpCode.value = code
50+
otpWithSeparator.value = otpInput?.value?.genResultWithSeparator()
4951
}
5052

5153
const handleChange = (code: string) => {
54+
otpWithSeparator.value = ''
5255
otpCodeChange.value = code
5356
if (!code) otpCode.value = ''
5457
}
@@ -65,6 +68,7 @@ const isReadonly = ref(false)
6568
const isAllowPaste = ref(false)
6669
const otpLength = ref(6)
6770
const currentOtpType = ref('text')
71+
const currentSeparator = ref('middle')
6872

6973
const changeOnlyNumber = () => {
7074
otpInput.value.clear()
@@ -78,6 +82,8 @@ const changeOTPLength = (isInCrease: boolean) => {
7882
const changeOtpType = () => {
7983
currentOtpType.value = currentOtpType.value === "password" ? "text" : "password"
8084
}
85+
86+
const changeSeparator = () => currentSeparator.value = currentSeparator.value === "middle" ? "all" : "middle"
8187
</script>
8288
<label>Current OTP Length is: `{{ otpLength }}`</label> <br />
8389
<label><input type="checkbox" :checked="isOutlined" @change="isOutlined = !isOutlined"> Outlined</label>
@@ -87,6 +93,7 @@ const changeOtpType = () => {
8793
<label><input type="checkbox" :checked="isReadonly" @change="isReadonly = !isReadonly"> Readonly</label>
8894
<label><input type="checkbox" :checked="isAllowPaste" @change="isAllowPaste = !isAllowPaste"> AllowPaste</label> <br />
8995
<label><input type="checkbox" @change="changeOtpType"> OTP type: `{{ currentOtpType }}`</label> <br />
96+
<label><input type="checkbox" @change="changeSeparator"> Separator: `{{ currentSeparator }}`</label> <br />
9097

9198

9299
<a @click="changeOTPLength(false)" href="javascript:void(0)">Change OTP Length to 4</a>
@@ -107,10 +114,14 @@ const changeOtpType = () => {
107114
:disabled="isDisabled"
108115
:readonly="isReadonly"
109116
:allowPaste="isAllowPaste"
117+
:separatorType="currentSeparator"
118+
separator="-"
110119
/>
111120
<!-- Using
112121
<button @click="clearOtp">Clear OTP</button> -->
113122

114123
<span>The final OTP code is: `{{ otpCode }}`</span>
115124
<br />
116-
<span>The OTP changed to: `{{ otpCodeChange }}`</span>
125+
<span>The OTP changed to: `{{ otpCodeChange }}`</span>
126+
<br />
127+
<span>The OTP with separator: `{{ otpWithSeparator }}`</span> (get code by calling genResultWithSeparator() exposed from otp component)

docs/usage-examples.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,11 @@ This is minimal style for your input, you can change it to match your use-case:
8282
outline: none
8383
}
8484
}
85+
86+
:deep(span) {
87+
padding: 0 0px 0 10px;
88+
font-size: 30px;
89+
}
8590
}
8691
</style>
8792
```

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,6 @@
7070
"url": "https://github.com/healerlab/vue3-simple-otp-input.git"
7171
},
7272
"dependencies": {
73-
"@healerlab/vue3-simple-otp-input": "^0.0.8"
73+
"@healerlab/vue3-simple-otp-input": "^0.0.9"
7474
}
7575
}

yarn.lock

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,32 @@
271271
resolved "https://registry.npmjs.org/@esbuild/win32-x64/-/win32-x64-0.18.20.tgz"
272272
integrity sha512-kTdfRcSiDfQca/y9QIkng02avJ+NCaQvrMejlsB3RRv5sE9rRoeBPISaZpKxHELzRxZyLvNts1P27W3wV+8geQ==
273273

274+
"@healerlab/vue3-simple-otp-input@^0.0.4":
275+
version "0.0.4"
276+
resolved "https://registry.yarnpkg.com/@healerlab/vue3-simple-otp-input/-/vue3-simple-otp-input-0.0.4.tgz#46fb48ddaf07773cf955909e49aa4d20fb8089e3"
277+
integrity sha512-Pmb3bB99MCaB8yd7Jv7sijrIYWbXVuoLF8GQn7mA2yo5J7guTm9u1dJnq+nDNxWm2f9v7xQlJbAWwzs7h64/YA==
278+
279+
"@healerlab/vue3-simple-otp-input@^0.0.5":
280+
version "0.0.5"
281+
resolved "https://registry.yarnpkg.com/@healerlab/vue3-simple-otp-input/-/vue3-simple-otp-input-0.0.5.tgz#f491c01b3f45c47068de703b794a2fe5a04fd059"
282+
integrity sha512-qKvlbAgfAzuORsw2migjYBSUh2iWvScDfja51IGWWtbplSuIBVWwvCttY4JB1+eavR/GrOhiwXDBSa4Esd6bug==
283+
dependencies:
284+
"@healerlab/vue3-simple-otp-input" "^0.0.4"
285+
286+
"@healerlab/vue3-simple-otp-input@^0.0.8":
287+
version "0.0.8"
288+
resolved "https://registry.yarnpkg.com/@healerlab/vue3-simple-otp-input/-/vue3-simple-otp-input-0.0.8.tgz#28ae5004d2f56e9e75ddcbade41497d5287e40da"
289+
integrity sha512-DBY3/Y3rmQisq+tMc93wvg/y1M7uM5R/IuVMnuD4J5DiJlLbiqo4g01mR/F+gZbs8vdqFUxKotQ77amPXlujHw==
290+
dependencies:
291+
"@healerlab/vue3-simple-otp-input" "^0.0.5"
292+
293+
"@healerlab/vue3-simple-otp-input@^0.0.9":
294+
version "0.0.9"
295+
resolved "https://registry.yarnpkg.com/@healerlab/vue3-simple-otp-input/-/vue3-simple-otp-input-0.0.9.tgz#1c9caf9ab231640e7e7de29f8e2d4235cc2fb600"
296+
integrity sha512-joK5kc4fqxq2XmX2K8ZKrzE+SrKQgESK/8+W93A1xrW2Jmvzi8AcMMKwE+6OH7Hftv2Ns12Hje/Ln1yAU6dDDQ==
297+
dependencies:
298+
"@healerlab/vue3-simple-otp-input" "^0.0.8"
299+
274300
"@jridgewell/sourcemap-codec@^1.4.15":
275301
version "1.4.15"
276302
resolved "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.15.tgz"

0 commit comments

Comments
 (0)