mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 18:31:06 +00:00
refactor(components): convert const to reactive where appropriate
- Inline class assignments to avoid script-level clutter - Ignore a11y-missing-attribute instead of redundant href
This commit is contained in:
parent
4ed754c549
commit
c446fc74f4
94 changed files with 469 additions and 598 deletions
|
@ -19,24 +19,13 @@
|
|||
import { cx } from '../../lib';
|
||||
|
||||
const dispatch = createEventDispatcher();
|
||||
const _class = cx('--search', size && `--search--${size}`, light && '--search--light', className);
|
||||
|
||||
let inputRef = undefined;
|
||||
|
||||
function clearInput() {
|
||||
value = '';
|
||||
|
||||
dispatch('change', value);
|
||||
|
||||
if (inputRef) {
|
||||
inputRef.focus();
|
||||
}
|
||||
}
|
||||
|
||||
$: _clearClass = cx('--search-close', value === '' && '--search-close--hidden');
|
||||
</script>
|
||||
|
||||
<div class={_class} {style}>
|
||||
<div
|
||||
class={cx('--search', size && `--search--${size}`, light && '--search--light', className)}
|
||||
{style}>
|
||||
<Search16 class={cx('--search-magnifier')} />
|
||||
<label for={id} class={cx('--label')}>{labelText}</label>
|
||||
<input
|
||||
|
@ -54,9 +43,13 @@
|
|||
{value} />
|
||||
<button
|
||||
type="button"
|
||||
class={_clearClass}
|
||||
class={cx('--search-close', value === '' && '--search-close--hidden')}
|
||||
on:click
|
||||
on:click={clearInput}
|
||||
on:click={() => {
|
||||
value = '';
|
||||
dispatch('change', value);
|
||||
inputRef.focus();
|
||||
}}
|
||||
aria-label={closeButtonLabelText}>
|
||||
<svelte:component this={size === 'xl' ? Close20 : Close16} />
|
||||
</button>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue