feat(auth): 비밀번호 표시 토글을 SVG 아이콘으로 통일
- AuthPasswordVisibilityToggle 공통 컴포넌트 추가 - signin·signup(비밀번호·확인)에 적용, 접근성 field-name 구분 - v0.0.61 문서 반영 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
80
components/auth/AuthPasswordVisibilityToggle.vue
Normal file
80
components/auth/AuthPasswordVisibilityToggle.vue
Normal file
@@ -0,0 +1,80 @@
|
||||
<script setup>
|
||||
/**
|
||||
* 비밀번호 필드 표시/숨김 토글(Material 스타일 눈 아이콘 SVG)
|
||||
*/
|
||||
const props = defineProps({
|
||||
/** 비밀번호를 평문으로 표시할 때 true */
|
||||
modelValue: {
|
||||
type: Boolean,
|
||||
required: true
|
||||
},
|
||||
/**
|
||||
* 스크린 리더용 필드 이름(예: 비밀번호 확인)
|
||||
* @type {string}
|
||||
*/
|
||||
fieldName: {
|
||||
type: String,
|
||||
default: '비밀번호'
|
||||
}
|
||||
})
|
||||
|
||||
const emit = defineEmits(['update:modelValue'])
|
||||
|
||||
/**
|
||||
* 접근성용 레이블 문자열
|
||||
* @param {'show' | 'hide'} kind - 보기 또는 숨기기
|
||||
* @returns {string}
|
||||
*/
|
||||
const labelFor = (kind) => {
|
||||
if (kind === 'show') {
|
||||
return `${props.fieldName} 보기`
|
||||
}
|
||||
|
||||
return `${props.fieldName} 숨기기`
|
||||
}
|
||||
|
||||
/**
|
||||
* 표시 상태를 반전한다.
|
||||
* @returns {void}
|
||||
*/
|
||||
const toggle = () => {
|
||||
emit('update:modelValue', !props.modelValue)
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<button
|
||||
class="auth-password-visibility-toggle flex h-10 shrink-0 items-center justify-center px-2.5 text-[#9ba3af] outline-none transition-opacity hover:opacity-80 focus-visible:ring-2 focus-visible:ring-[#2f6feb]/50"
|
||||
type="button"
|
||||
:aria-label="modelValue ? labelFor('hide') : labelFor('show')"
|
||||
:aria-pressed="modelValue"
|
||||
@click="toggle"
|
||||
>
|
||||
<!-- 비밀번호 숨김 상태: 보기(눈 열림) -->
|
||||
<svg
|
||||
v-if="!modelValue"
|
||||
class="auth-password-visibility-toggle__icon h-5 w-5"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 24 24"
|
||||
width="24"
|
||||
height="24"
|
||||
fill="currentColor"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<path d="M12 4.5C7 4.5 2.73 7.61 1 12c1.73 4.39 6 7.5 11 7.5s9.27-3.11 11-7.5c-1.73-4.39-6-7.5-11-7.5zM12 17c-2.76 0-5-2.24-5-5s2.24-5 5-5 5 2.24 5 5-2.24 5-5 5zm0-8c-1.66 0-3 1.34-3 3s1.34 3 3 3 3-1.34 3-3-1.34-3-3-3z" />
|
||||
</svg>
|
||||
<!-- 비밀번호 표시 상태: 숨기기(눈 가림) -->
|
||||
<svg
|
||||
v-else
|
||||
class="auth-password-visibility-toggle__icon h-5 w-5"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
viewBox="0 0 24 24"
|
||||
width="24"
|
||||
height="24"
|
||||
fill="currentColor"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<path d="M12 7c2.76 0 5 2.24 5 5 0 .65-.13 1.26-.36 1.83l2.92 2.92c1.51-1.26 2.7-2.89 3.43-4.75-1.73-4.39-6-7.5-11-7.5-1.4 0-2.74.25-3.98.7l2.16 2.16C10.74 7.13 11.35 7 12 7zM2 4.27l2.28 2.28.46.46C3.08 8.3 1.78 10.02 1 12c1.73 4.39 6 7.5 11 7.5 1.55 0 3.03-.3 4.38-.84l.42.42L19.73 22 22 19.73 3.27 3 2 4.27zM7.53 9.8l1.55 1.55c-.05.21-.08.43-.08.65 0 1.66 1.34 3 3 3 .22 0 .44-.03.65-.08l1.55 1.55c-.67.33-1.41.53-2.2.53-2.76 0-5-2.24-5-5 0-.79.2-1.53.53-2.2zm4.31-.78 3.15 3.15.02-.16c0-1.66-1.34-3-3-3l-.17.01z" />
|
||||
</svg>
|
||||
</button>
|
||||
</template>
|
||||
Reference in New Issue
Block a user