-
-
Notifications
You must be signed in to change notification settings - Fork 470
feat: add input component #1173
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 2 commits
aad32c3
6e6bb7d
2a1d466
8bd5845
29e8bc2
bfaec20
9f206fe
87efb1b
efa1d8e
e6758cc
62def3e
014383b
b3c164a
8f2ec8d
ff5429f
549026a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| <script setup lang="ts"> | ||
| import { noCorrect } from '~/utils/input' | ||
|
|
||
| const props = withDefaults( | ||
| defineProps<{ | ||
| modelValue?: string | ||
| size?: 'small' | 'medium' | 'large' | ||
| noCorrect?: boolean | ||
| }>(), | ||
| { | ||
| modelValue: '', | ||
| size: 'medium', | ||
| noCorrect: true, | ||
| }, | ||
| ) | ||
|
|
||
| const emit = defineEmits<{ | ||
| 'update:modelValue': [value: string] | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. let' use
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, looks much better now (I don’t remember why I made it so complicated) |
||
| 'focus': [event: FocusEvent] | ||
| 'blur': [event: FocusEvent] | ||
| }>() | ||
|
|
||
| const el = useTemplateRef('el') | ||
|
|
||
| const model = computed({ | ||
| get: () => props.modelValue, | ||
| set: (value: string) => emit('update:modelValue', value), | ||
| }) | ||
|
|
||
| defineExpose({ | ||
| focus: () => el.value?.focus(), | ||
| blur: () => el.value?.blur(), | ||
| getBoundingClientRect: () => el.value?.getBoundingClientRect(), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. do we need this one anywhere?
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, and it doesn't seem to be useful, I'll remove it, thanks |
||
| }) | ||
| </script> | ||
|
|
||
| <template> | ||
| <input | ||
| ref="el" | ||
| v-model="model" | ||
| v-bind="props.noCorrect ? noCorrect : undefined" | ||
| @focus="emit('focus', $event)" | ||
| @blur="emit('blur', $event)" | ||
| class="w-full leading-none bg-bg-subtle border border-border font-mono text-fg placeholder:text-fg-subtle transition-[border-color,outline-color] duration-300 hover:border-fg-subtle outline-2 outline-transparent outline-offset-2 focus:border-accent focus-visible:outline-accent/70 disabled:(opacity-50 cursor-not-allowed)" | ||
| :class="{ | ||
| 'text-xs px-2 py-1.25 h-8 rounded-md': size === 'small', | ||
| 'text-sm px-3 py-2.5 h-10 rounded-lg': size === 'medium', | ||
| 'text-base px-6 py-3.5 h-14 rounded-xl': size === 'large', | ||
|
alexdln marked this conversation as resolved.
Outdated
|
||
| }" | ||
| /> | ||
| </template> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -331,14 +331,15 @@ watch(lastExecutionTime, () => { | |
| aria-hidden="true" | ||
| /> | ||
| <label for="members-search" class="sr-only">{{ $t('org.members.filter_label') }}</label> | ||
| <input | ||
| <InputBase | ||
| id="members-search" | ||
| v-model="searchQuery" | ||
| type="search" | ||
| name="members-search" | ||
| :placeholder="$t('org.members.filter_placeholder')" | ||
| v-bind="noCorrect" | ||
| class="w-full ps-7 pe-2 py-1.5 font-mono text-sm bg-bg-subtle border border-border rounded text-fg placeholder:text-fg-subtle transition-colors duration-200 focus:border-accent focus-visible:(outline-2 outline-accent/70)" | ||
| noCorrect | ||
| class="w-full min-w-25 ps-7" | ||
| size="small" | ||
| /> | ||
| </div> | ||
| <div | ||
|
|
@@ -516,14 +517,15 @@ watch(lastExecutionTime, () => { | |
| <label for="new-member-username" class="sr-only">{{ | ||
| $t('org.members.username_label') | ||
| }}</label> | ||
| <input | ||
| <InputBase | ||
| id="new-member-username" | ||
| v-model="newUsername" | ||
| type="text" | ||
| name="new-member-username" | ||
| :placeholder="$t('org.members.username_placeholder')" | ||
| v-bind="noCorrect" | ||
| class="w-full px-2 py-1.5 font-mono text-sm bg-bg border border-border rounded text-fg placeholder:text-fg-subtle transition-colors duration-200 focus:border-border-hover focus-visible:outline-accent/70" | ||
| noCorrect | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. normally we'd do kebab-cased
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks, I forget every time, even if there is nothing more logical than kebab in the markup... |
||
| class="w-full min-w-25" | ||
| size="small" | ||
| /> | ||
| <div class="flex items-center gap-2"> | ||
| <label for="new-member-role" class="sr-only">{{ $t('org.members.role_label') }}</label> | ||
|
|
@@ -553,7 +555,7 @@ watch(lastExecutionTime, () => { | |
| <button | ||
| type="submit" | ||
| :disabled="!newUsername.trim() || isAddingMember" | ||
| class="px-3 py-1.5 font-mono text-xs text-bg bg-fg rounded transition-all duration-200 hover:bg-fg/90 disabled:opacity-50 disabled:cursor-not-allowed focus-visible:outline-accent/70" | ||
| class="px-3 py-2 font-mono text-xs text-bg bg-fg rounded transition-all duration-200 hover:bg-fg/90 disabled:opacity-50 disabled:cursor-not-allowed focus-visible:outline-accent/70" | ||
|
alexdln marked this conversation as resolved.
|
||
| > | ||
| {{ isAddingMember ? '…' : $t('org.members.add_button') }} | ||
| </button> | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.