-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #68 from traP-jp/textbox
Textbox
- Loading branch information
Showing
9 changed files
with
241 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<script setup lang="ts"> | ||
import MaterialIcon from '@/components/MaterialIcon.vue' | ||
import TextboxLabel from '@/components/Controls/Textbox/TextboxLabel.vue' | ||
import { computed } from 'vue' | ||
import isEmail from 'validator/lib/isEmail' | ||
const { errorMessage = '', label = '' } = defineProps<{ | ||
disabled?: boolean | ||
errorMessage?: string | ||
isRequired?: boolean | ||
label?: string | ||
placeholder?: string | ||
autocomplete?: string | ||
}>() | ||
const value = defineModel<string>() | ||
const isEmailError = computed(() => (value.value?.length ?? 0) > 0 && !isEmail(value.value ?? '')) | ||
const isError = computed(() => errorMessage != '' || isEmailError.value) | ||
</script> | ||
|
||
<template> | ||
<div class="flex flex-col gap-2"> | ||
<TextboxLabel v-if="label != ''" :is-required="isRequired" :label="label" /> | ||
<input | ||
v-model="value" | ||
:autocomplete="autocomplete" | ||
:class="[ | ||
{ | ||
'border-border-secondary outline-text-primary focus:border-text-primary': !isError | ||
}, | ||
{ 'border-status-error outline outline-1 outline-status-error': isError }, | ||
'fontstyle-ui-body w-full rounded border bg-background-primary py-1 pl-4 text-text-primary placeholder:text-text-tertiary focus:outline focus:outline-1 disabled:bg-background-secondary' | ||
]" | ||
:disabled="disabled" | ||
:placeholder="placeholder" | ||
type="email" | ||
/> | ||
<div v-if="isError" class="flex items-start gap-2 pl-1 text-status-error"> | ||
<MaterialIcon icon="error" size="1.25rem" /> | ||
<span class="fontstyle-ui-control min-w-0 break-words">{{ | ||
isEmailError ? 'メールアドレスの形式が正しくありません' : errorMessage | ||
}}</span> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<style scoped></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<script setup lang="ts"> | ||
import MaterialIcon from '@/components/MaterialIcon.vue' | ||
import TextboxLabel from '@/components/Controls/Textbox/TextboxLabel.vue' | ||
import { computed, ref } from 'vue' | ||
const { errorMessage = '', label = '' } = defineProps<{ | ||
disabled?: boolean | ||
errorMessage?: string | ||
isRequired?: boolean | ||
label?: string | ||
placeholder?: string | ||
autocomplete?: string | ||
}>() | ||
const value = defineModel<string>() | ||
const isError = computed(() => errorMessage != '') | ||
const passwordShown = ref<boolean>(false) | ||
</script> | ||
|
||
<template> | ||
<div class="flex flex-col gap-2"> | ||
<TextboxLabel v-if="label != ''" :is-required="isRequired" :label="label" /> | ||
<span class="relative"> | ||
<input | ||
v-model="value" | ||
:class="[ | ||
{ | ||
'border-border-secondary outline-text-primary focus:border-text-primary': !isError | ||
}, | ||
{ 'border-status-error outline outline-1 outline-status-error': isError }, | ||
'fontstyle-ui-body w-full rounded border bg-background-primary py-1 pl-4 pr-11.5 text-text-primary placeholder:text-text-tertiary focus:outline focus:outline-1 disabled:bg-background-secondary' | ||
]" | ||
:disabled="disabled" | ||
:placeholder="placeholder" | ||
:type="passwordShown ? 'text' : 'password'" | ||
:autocomplete="autocomplete" | ||
/> | ||
<span | ||
class="absolute right-4 top-1.75 select-none" | ||
@click="() => (passwordShown = !passwordShown)" | ||
> | ||
<MaterialIcon :icon="passwordShown ? 'visibility_off' : 'visibility'" size="1.25rem" /> | ||
</span> | ||
</span> | ||
<div v-if="isError" class="flex items-start gap-2 pl-1 text-status-error"> | ||
<MaterialIcon icon="error" size="1.25rem" /> | ||
<span class="fontstyle-ui-control min-w-0 break-words">{{ errorMessage }}</span> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<style scoped></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
<script setup lang="ts"> | ||
import MaterialIcon from '@/components/MaterialIcon.vue' | ||
import TextboxLabel from '@/components/Controls/Textbox/TextboxLabel.vue' | ||
import { computed } from 'vue' | ||
const { errorMessage = '', label = '' } = defineProps<{ | ||
disabled?: boolean | ||
errorMessage?: string | ||
isRequired?: boolean | ||
label?: string | ||
placeholder?: string | ||
autocomplete?: string | ||
}>() | ||
const value = defineModel<string>() | ||
const isError = computed(() => errorMessage != '') | ||
</script> | ||
|
||
<template> | ||
<div class="flex flex-col gap-2"> | ||
<TextboxLabel v-if="label != ''" :is-required="isRequired" :label="label" /> | ||
<input | ||
v-model="value" | ||
:autocomplete="autocomplete" | ||
:class="[ | ||
{ | ||
'border-border-secondary outline-text-primary focus:border-text-primary': !isError | ||
}, | ||
{ 'border-status-error outline outline-1 outline-status-error': isError }, | ||
'fontstyle-ui-body w-full rounded border bg-background-primary py-1 pl-4 text-text-primary placeholder:text-text-tertiary focus:outline focus:outline-1 disabled:bg-background-secondary' | ||
]" | ||
:disabled="disabled" | ||
:placeholder="placeholder" | ||
type="text" | ||
/> | ||
<div v-if="isError" class="flex items-start gap-2 pl-1 text-status-error"> | ||
<MaterialIcon icon="error" size="1.25rem" /> | ||
<span class="fontstyle-ui-control min-w-0 break-words">{{ errorMessage }}</span> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<style scoped></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<script setup lang="ts"> | ||
const { isRequired = false } = defineProps<{ | ||
isRequired?: boolean | ||
label: string | ||
}>() | ||
</script> | ||
|
||
<template> | ||
<span class="flex gap-1 px-1"> | ||
<span class="fontstyle-ui-control text-text-secondary">{{ label }}</span> | ||
<span v-if="isRequired" class="fontstyle-ui-control text-status-error">*</span> | ||
</span> | ||
</template> | ||
|
||
<style scoped></style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters