Skip to content
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

[next] fix(NcInputField): Make focus visible on trailing button look better #5828

Merged
merged 3 commits into from
Aug 5, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions src/components/NcInputField/NcInputField.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ For a list of all available props and attributes, please check the [HTMLInputEle
</docs>

<template>
<div class="input-field" :class="[{ 'input-field--disabled': disabled }, $props.class ]">
<div class="input-field"
:class="[{ 'input-field--disabled': disabled, 'input-field--pill': pill, }, $props.class ]">
<div class="input-field__main-wrapper">
<input v-bind="$attrs"
:id="computedId"
Expand All @@ -35,7 +36,6 @@ For a list of all available props and attributes, please check the [HTMLInputEle
'input-field__input--label-outside': labelOutside,
'input-field__input--success': success,
'input-field__input--error': error,
'input-field__input--pill': pill,
}]"
:value="modelValue.toString()"
@input="handleInput">
Expand All @@ -60,9 +60,6 @@ For a list of all available props and attributes, please check the [HTMLInputEle
<NcButton v-if="showTrailingButton"
type="tertiary-no-background"
class="input-field__trailing-button"
:class="[{
'input-field__trailing-button--pill': pill,
}]"
:aria-label="trailingButtonLabel"
:disabled="disabled"
@click="handleTrailingButtonClick">
Expand Down Expand Up @@ -331,9 +328,10 @@ export default {
<style lang="scss" scoped>

.input-field {
--input-border-radius: var(--border-radius-element, var(--border-radius-large));
// styles
position: relative;
width: 100%;
border-radius: var(--border-radius-large);
margin-block-start: 6px; // for the label in active state

&__main-wrapper {
Expand All @@ -346,6 +344,10 @@ export default {
filter: saturate(0.4);
}

&--pill {
--input-border-radius: var(--border-radius-pill);
}

&__input {
margin: 0;
padding-inline: 12px 6px; // align with label 8px margin label + 6px padding label - 2px border input
Expand All @@ -358,11 +360,12 @@ export default {
background-color: var(--color-main-background);
color: var(--color-main-text);
border: var(--border-width-input, 2px) solid var(--color-border-maxcontrast);
border-radius: var(--border-radius-large);
border-radius: var(--input-border-radius);

cursor: pointer;
-webkit-appearance: textfield !important;
-moz-appearance: textfield !important;
appearance: textfield !important;

// Center text if external label is used
&--label-outside {
Expand Down Expand Up @@ -420,10 +423,6 @@ export default {
box-shadow: rgb(248, 250, 252) 0px 0px 0px 2px, var(--color-primary-element) 0px 0px 0px 4px, rgba(0, 0, 0, 0.05) 0px 1px 2px 0px
}
}

&--pill {
border-radius: var(--border-radius-pill);
}
}

&__label {
Expand Down Expand Up @@ -490,15 +489,17 @@ export default {
}

&__trailing-button {
--button-size: calc(var(--default-clickable-area) - 2 * var(--border-width-input-focused, 2px)) !important;
--button-radius: calc(var(--input-border-radius) - var(--border-width-input-focused, 2px)); // lower radius as size is smaller

&.button-vue {
position: absolute;
top: 0;
right: 0;
border-radius: var(--border-radius-large);
}
top: var(--border-width-input-focused, 2px);
right: var(--border-width-input-focused, 2px);

&--pill.button-vue {
border-radius: var(--border-radius-pill);
&:focus-visible {
box-shadow: none !important;
}
}
}

Expand Down
Loading