TagInput: add contained prop with max-width
This commit is contained in:
parent
6409de0c29
commit
c2b2de9e96
1 changed files with 16 additions and 2 deletions
|
|
@ -21,6 +21,8 @@
|
||||||
class?: string
|
class?: string
|
||||||
/** Input id for label association */
|
/** Input id for label association */
|
||||||
id?: string
|
id?: string
|
||||||
|
/** Whether to show contained style with background */
|
||||||
|
contained?: boolean
|
||||||
}
|
}
|
||||||
|
|
||||||
let {
|
let {
|
||||||
|
|
@ -31,7 +33,8 @@
|
||||||
error,
|
error,
|
||||||
maxTags,
|
maxTags,
|
||||||
class: className = '',
|
class: className = '',
|
||||||
id
|
id,
|
||||||
|
contained = false
|
||||||
}: Props = $props()
|
}: Props = $props()
|
||||||
|
|
||||||
let inputValue = $state('')
|
let inputValue = $state('')
|
||||||
|
|
@ -83,6 +86,7 @@
|
||||||
class="tagInput"
|
class="tagInput"
|
||||||
class:disabled
|
class:disabled
|
||||||
class:hasError={!!error}
|
class:hasError={!!error}
|
||||||
|
class:contained
|
||||||
onclick={focusInput}
|
onclick={focusInput}
|
||||||
onkeydown={(e) => e.key === 'Enter' && focusInput()}
|
onkeydown={(e) => e.key === 'Enter' && focusInput()}
|
||||||
role="button"
|
role="button"
|
||||||
|
|
@ -126,6 +130,7 @@
|
||||||
<div
|
<div
|
||||||
class="tagInput {className}"
|
class="tagInput {className}"
|
||||||
class:disabled
|
class:disabled
|
||||||
|
class:contained
|
||||||
onclick={focusInput}
|
onclick={focusInput}
|
||||||
onkeydown={(e) => e.key === 'Enter' && focusInput()}
|
onkeydown={(e) => e.key === 'Enter' && focusInput()}
|
||||||
role="button"
|
role="button"
|
||||||
|
|
@ -202,13 +207,14 @@
|
||||||
gap: $unit-half;
|
gap: $unit-half;
|
||||||
padding: $unit $unit-2x;
|
padding: $unit $unit-2x;
|
||||||
min-height: calc($unit * 5.5);
|
min-height: calc($unit * 5.5);
|
||||||
|
max-width: 480px;
|
||||||
background-color: var(--input-bg);
|
background-color: var(--input-bg);
|
||||||
border-radius: $input-corner;
|
border-radius: $input-corner;
|
||||||
border: 2px solid transparent;
|
border: 2px solid transparent;
|
||||||
cursor: text;
|
cursor: text;
|
||||||
@include smooth-transition($duration-quick, background-color, border-color);
|
@include smooth-transition($duration-quick, background-color, border-color);
|
||||||
|
|
||||||
&:hover:not(.disabled) {
|
&:hover:not(.disabled):not(.contained) {
|
||||||
background-color: var(--input-bg-hover);
|
background-color: var(--input-bg-hover);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -224,6 +230,14 @@
|
||||||
&.hasError {
|
&.hasError {
|
||||||
border-color: $error;
|
border-color: $error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.contained {
|
||||||
|
background-color: var(--input-bound-bg);
|
||||||
|
|
||||||
|
&:hover:not(.disabled) {
|
||||||
|
background-color: var(--input-bound-bg-hover);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.tag {
|
.tag {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue