-
Notifications
You must be signed in to change notification settings - Fork 25
feat: add inlineLabel and hasBorder props to OcTextInput and OCSelect #1707
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 all commits
4c6a239
cb2e585
830db1f
9ba1336
62fa6c9
478cd2c
f57fa35
1fdf48a
8126b8f
697f686
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,8 @@ | ||
| <template> | ||
| <div class="border-b mb-2"> | ||
| <oc-text-input class="mb-2" label="Your name" :inline-label="true" :has-border="false" /> | ||
| </div> | ||
| <div class="border-b"> | ||
| <oc-text-input class="mb-2" label="Full address" :inline-label="true" :has-border="false" /> | ||
| </div> | ||
| </template> |
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,6 +1,12 @@ | ||||||||||||||||
| <template> | ||||||||||||||||
| <div> | ||||||||||||||||
| <label v-if="!labelHidden" :aria-hidden="true" :for="id" class="inline-block mb-0.5"> | ||||||||||||||||
| <div :class="{ 'flex items-center': inlineLabel }"> | ||||||||||||||||
| <label | ||||||||||||||||
| v-if="!labelHidden" | ||||||||||||||||
| :aria-hidden="true" | ||||||||||||||||
| :for="id" | ||||||||||||||||
| class="inline-block" | ||||||||||||||||
| :class="{ 'mr-2': inlineLabel, 'mb-0.5': !inlineLabel }" | ||||||||||||||||
| > | ||||||||||||||||
| {{ label }} | ||||||||||||||||
| <span v-if="requiredMark" class="text-role-error" aria-hidden="true">*</span> | ||||||||||||||||
| </label> | ||||||||||||||||
|
|
@@ -19,7 +25,8 @@ | |||||||||||||||
| :multiple="multiple" | ||||||||||||||||
| class="oc-select bg-transparent" | ||||||||||||||||
| :class="{ | ||||||||||||||||
| 'oc-select-position-fixed': positionFixed | ||||||||||||||||
| 'oc-select-position-fixed': positionFixed, | ||||||||||||||||
| 'oc-select-no-border': !hasBorder | ||||||||||||||||
| }" | ||||||||||||||||
| :dropdown-should-open="selectDropdownShouldOpen" | ||||||||||||||||
| :map-keydown="selectMapKeydown" | ||||||||||||||||
|
|
@@ -134,6 +141,11 @@ export interface Props { | |||||||||||||||
| * @docs The label of the select input. | ||||||||||||||||
| */ | ||||||||||||||||
| label: string | ||||||||||||||||
| /** | ||||||||||||||||
| * @docs Determines if the label will be displayed next to the select input field. | ||||||||||||||||
| * @default false | ||||||||||||||||
| * */ | ||||||||||||||||
| inlineLabel?: boolean | ||||||||||||||||
| /** | ||||||||||||||||
| * @docs Determines if the label is visually hidden. Note that it will still be read by screen readers. | ||||||||||||||||
| * @default false | ||||||||||||||||
|
|
@@ -201,13 +213,19 @@ export interface Props { | |||||||||||||||
| * @default false | ||||||||||||||||
| */ | ||||||||||||||||
| requiredMark?: boolean | ||||||||||||||||
| /** | ||||||||||||||||
| * @docs Determines if the select input field has a surrounding border. | ||||||||||||||||
| * @default true | ||||||||||||||||
| */ | ||||||||||||||||
| hasBorder?: boolean | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| export interface Emits { | ||||||||||||||||
| /** | ||||||||||||||||
| * @docs Emitted when the user has typed. | ||||||||||||||||
| */ | ||||||||||||||||
| (e: 'search:input', search: string): void | ||||||||||||||||
|
|
||||||||||||||||
| /** | ||||||||||||||||
| * @docs Emitted when the user has selected an option. | ||||||||||||||||
| */ | ||||||||||||||||
|
|
@@ -219,6 +237,7 @@ export interface Slots { | |||||||||||||||
| * @docs Slot for when an option is selected. | ||||||||||||||||
| */ | ||||||||||||||||
| 'selected-option'?: () => unknown | ||||||||||||||||
|
|
||||||||||||||||
| /** | ||||||||||||||||
| * @docs This component inherits all slots from `vue-select`. See https://vue-select.org/api/slots for more information. | ||||||||||||||||
| */ | ||||||||||||||||
|
|
@@ -252,6 +271,7 @@ const { | |||||||||||||||
| }, | ||||||||||||||||
| disabled = false, | ||||||||||||||||
| label, | ||||||||||||||||
| inlineLabel = false, | ||||||||||||||||
| labelHidden = false, | ||||||||||||||||
| contextualHelper, | ||||||||||||||||
| optionLabel = 'label', | ||||||||||||||||
|
|
@@ -265,7 +285,8 @@ const { | |||||||||||||||
| multiple = false, | ||||||||||||||||
| readOnly = false, | ||||||||||||||||
| positionFixed = false, | ||||||||||||||||
| requiredMark = false | ||||||||||||||||
| requiredMark = false, | ||||||||||||||||
| hasBorder = true | ||||||||||||||||
| } = defineProps<Props>() | ||||||||||||||||
|
|
||||||||||||||||
| const emit = defineEmits<Emits>() | ||||||||||||||||
|
|
@@ -485,6 +506,14 @@ export default { components: { VueSelect } } | |||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| .oc-select { | ||||||||||||||||
| &-no-border { | ||||||||||||||||
| .vs__dropdown-toggle { | ||||||||||||||||
| border: none !important; | ||||||||||||||||
| outline: none !important; | ||||||||||||||||
| background-color: transparent !important; | ||||||||||||||||
|
||||||||||||||||
| background-color: transparent !important; | |
| background-color: transparent !important; | |
| // Provide alternative focus indicator for accessibility | |
| &:focus { | |
| box-shadow: 0 0 0 2px var(--oc-role-outline); | |
| } |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,12 +1,16 @@ | ||||||
| <template> | ||||||
| <div :class="$attrs.class"> | ||||||
| <div :class="[{ 'flex items-center': inlineLabel }, $attrs.class]"> | ||||||
| <slot name="label"> | ||||||
| <label class="inline-block mb-0.5" :for="id"> | ||||||
| <label | ||||||
| class="inline-block" | ||||||
| :class="{ 'mr-2': inlineLabel, 'mb-0.5': !inlineLabel }" | ||||||
| :for="id" | ||||||
| > | ||||||
| {{ label }} | ||||||
| <span v-if="requiredMark" class="text-role-error" aria-hidden="true">*</span> | ||||||
| </label> | ||||||
| </slot> | ||||||
| <div class="relative"> | ||||||
| <div class="relative" :class="{ 'grow-1': inlineLabel }"> | ||||||
| <oc-icon v-if="readOnly" name="lock" size="small" class="mt-2 ml-2 absolute" /> | ||||||
| <component | ||||||
| :is="inputComponent" | ||||||
|
|
@@ -18,7 +22,8 @@ | |||||
| :class="{ | ||||||
| 'oc-text-input-danger border-role-error': !!showErrorMessage, | ||||||
| 'pl-6': !!readOnly, | ||||||
| 'pr-6': showClearButton | ||||||
| 'pr-6': showClearButton, | ||||||
| 'border-none outline-none bg-transparent': !hasBorder | ||||||
|
||||||
| 'border-none outline-none bg-transparent': !hasBorder | |
| 'border-none bg-transparent focus:ring-2 focus:ring-primary': !hasBorder |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,10 +17,12 @@ | |
| </oc-button> | ||
| </div> | ||
| <div class="px-4"> | ||
| <div class="py-3"> | ||
| <div class="py-2 mb-2 border-b border-role-outline-variant"> | ||
|
||
| <oc-select | ||
| v-model="from" | ||
| :label="`${$gettext('From')}:`" | ||
| :inline-label="true" | ||
| :has-border="false" | ||
| :options="fromOptions" | ||
| option-label="label" | ||
| option-value="value" | ||
|
|
@@ -31,25 +33,33 @@ | |
| <oc-text-input | ||
| v-model="toMail" | ||
| type="email" | ||
| class="mail-new-message-to-input mb-2" | ||
| class="mail-new-message-to-input mb-2 pb-2 border-b border-role-outline-variant" | ||
| :label="`${$gettext('To')}:`" | ||
| :inline-label="true" | ||
| :has-border="false" | ||
| /> | ||
| <oc-text-input | ||
| v-model="ccMail" | ||
| type="email" | ||
| class="mail-new-message-cc-input mb-2" | ||
| class="mail-new-message-cc-input mb-2 pb-2 border-b border-role-outline-variant" | ||
| :label="`${$gettext('CC')}:`" | ||
| :inline-label="true" | ||
| :has-border="false" | ||
| /> | ||
| <oc-text-input | ||
| v-model="bccMail" | ||
| type="email" | ||
| class="mail-new-message-bcc-input mb-2" | ||
| class="mail-new-message-bcc-input mb-2 pb-2 border-b border-role-outline-variant" | ||
| :label="`${$gettext('BCC')}:`" | ||
| :inline-label="true" | ||
| :has-border="false" | ||
| /> | ||
| <oc-text-input | ||
| v-model="subject" | ||
| class="mail-new-message-to-input" | ||
| :label="$gettext('Subject')" | ||
| class="mail-new-message-to-input pb-2 border-b border-role-outline-variant" | ||
| :label="`${$gettext('Subject')}:`" | ||
| :inline-label="true" | ||
| :has-border="false" | ||
| /> | ||
| <div class="py-4"> | ||
| <oc-textarea v-model="mailBody" :label="$gettext('Write email')" /> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The customization section description is incomplete. Add a period at the end of the sentence and expand the description to explain what customization options are demonstrated in the example.