Skip to content

Commit

Permalink
feat: add otp input
Browse files Browse the repository at this point in the history
  • Loading branch information
bohdanmoroziuk committed Jul 17, 2023
1 parent b47331f commit 451f976
Show file tree
Hide file tree
Showing 7 changed files with 59 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ module.exports = {
root: true,
env: {
node: true,
'vue/setup-compiler-macros': true,
},
extends: [
'plugin:vue/vue3-essential',
Expand All @@ -14,6 +15,9 @@ module.exports = {
rules: {
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
'no-debugger': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
//
'vuejs-accessibility/form-control-has-label': 'off',
'vuejs-accessibility/no-autofocus': 'off',
},
overrides: [
{
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"test:unit": "vue-cli-service test:unit",
"test:unit:watch": "vue-cli-service test:unit --watch",
"lint": "vue-cli-service lint"
},
"dependencies": {
Expand Down
6 changes: 6 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="<%= BASE_URL %>favicon.ico">
<title><%= htmlWebpackPlugin.options.title %></title>

<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@200;300;400;500;600;700&display=swap" rel="stylesheet">

<link href="https://unpkg.com/boxicons@2.1.4/css/boxicons.min.css" rel="stylesheet" />
</head>
<body>
<noscript>
Expand Down
5 changes: 5 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
<script setup lang="ts">
import OtpInput from '@/components/OtpInput.vue';
</script>

<template>
<div>
OTP Input
<otp-input />
</div>
</template>
1 change: 1 addition & 0 deletions src/assets/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@

html {
font-size: 16px;
font-family: 'Poppins', sans-serif;
}
31 changes: 31 additions & 0 deletions src/components/OtpInput.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<template>
<div class="otp-input">
<input class="otp-input__input" type="text" autofocus />
<input class="otp-input__input" type="text" disabled />
<input class="otp-input__input" type="text" disabled />
<input class="otp-input__input" type="text" disabled />
</div>
</template>

<style scoped>
.otp-input {
display: flex;
align-items: center;
justify-content: center;
column-gap: 10px;
}
.otp-input__input {
height: 45px;
width: 42px;
border-radius: 6px;
outline: none;
font-size: 1.125rem;
text-align: center;
border: 1px solid #ddd;
}
.otp-input__input:focus {
box-shadow: 0 1px 0 rgba(0, 0, 0, 0.1);
}
</style>
11 changes: 11 additions & 0 deletions tests/unit/components/OtpInput.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { shallowMount } from '@vue/test-utils';

import OtpInput from '@/components/OtpInput.vue';

describe('OtpInput.vue', () => {
it('renders successfully', () => {
const wrapper = shallowMount(OtpInput);

expect(wrapper.vm).toBeDefined();
});
});

0 comments on commit 451f976

Please sign in to comment.