Skip to content

Commit

Permalink
パスワード表示に対応
Browse files Browse the repository at this point in the history
  • Loading branch information
ZOI-dayo committed Nov 18, 2024
1 parent 1ca7e50 commit c1deafe
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 13 deletions.
36 changes: 24 additions & 12 deletions src/components/Controls/Textbox/BasicTextbox.vue
Original file line number Diff line number Diff line change
@@ -1,28 +1,40 @@
<script setup lang="ts">
import MaterialIcon from '@/components/MaterialIcon.vue'
import { ref } from 'vue'
const {
disabled = false,
error = false,
placeholder = ''
placeholder = '',
isPassword = false
} = defineProps<{
disabled?: boolean
error?: boolean
placeholder?: string
isPassword?: boolean
}>()
const value = defineModel<string>('value')
const passwordShown = ref(false)
</script>

<template>
<input
v-model="value"
:class="[
{ 'border-border-secondary outline-text-primary focus:border-text-primary': !error },
{ 'border-status-error outline outline-1 outline-status-error': error },
'fontstyle-ui-body max-w-full rounded border bg-background-primary px-4 py-1 text-text-primary placeholder:text-text-tertiary focus:outline focus:outline-1 disabled:bg-background-secondary'
]"
:disabled="disabled"
:placeholder="placeholder"
type="text"
/>
<div class="relative inline-block">
<input
v-model="value"
:class="[
{ 'border-border-secondary outline-text-primary focus:border-text-primary': !error },
{ 'border-status-error outline outline-1 outline-status-error': error },
{ 'pr-11.5': isPassword },
'fontstyle-ui-body max-w-full rounded border bg-background-primary px-4 py-1 text-text-primary placeholder:text-text-tertiary focus:outline focus:outline-1 disabled:bg-background-secondary'
]"
:disabled="disabled"
:placeholder="placeholder"
:type="isPassword && !passwordShown ? 'password' : 'text'"
/>
<span v-if="isPassword" class="absolute right-4 top-1.75 select-none" @click="() => passwordShown = !passwordShown">
<MaterialIcon :icon="passwordShown ? 'visibility_off' : 'visibility'" size="1.25rem"/>
</span>
</div>
</template>

<style scoped></style>
2 changes: 2 additions & 0 deletions src/components/Controls/Textbox/DecoratedTextbox.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import TextboxLabel from '@/components/Controls/Textbox/TextboxLabel.vue'
const { errorMessage = '', label = '' } = defineProps<{
disabled?: boolean
errorMessage?: string
isPassword?: boolean
isRequired?: boolean
label?: string
placeholder?: string
Expand All @@ -22,6 +23,7 @@ const value = defineModel<string>('value')
class="w-full"
:disabled
:error="errorMessage != ''"
:is-password="isPassword"
:placeholder="placeholder"
/>
</div>
Expand Down
2 changes: 2 additions & 0 deletions src/components/MaterialIcon.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export type Icon =
| 'open_in_new'
| 'person'
| 'settings'
| 'visibility'
| 'visibility_off'
const { size = '1.5rem', isFilled = false } = defineProps<{
icon: Icon
size?: string
Expand Down
4 changes: 3 additions & 1 deletion tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ export default {
},
extend: {
spacing: {
'7.5': '1.875rem',
'1.625': '0.40625rem',
'1.75': '0.4375rem',
'4.5': '1.125rem',
'7.5': '1.875rem',
'11.5': '2.875rem',
'27': '6.75rem',
'50': '12.5rem',
'62.5': '15.625rem'
Expand Down

0 comments on commit c1deafe

Please sign in to comment.