mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 02:11:05 +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
|
@ -17,34 +17,28 @@
|
|||
import WarningFilled16 from 'carbon-icons-svelte/lib/WarningFilled16';
|
||||
import { cx } from '../../lib';
|
||||
|
||||
const errorId = `${id}-error`;
|
||||
const _labelClass = cx(
|
||||
'--label',
|
||||
hideLabel && '--visually-hidden',
|
||||
disabled && '--label--disabled'
|
||||
);
|
||||
const _helperTextClass = cx('--form__helper-text', disabled && '--form__helper-text--disabled');
|
||||
const _textInputClass = cx(
|
||||
'--text-input',
|
||||
light && '--text-input--light',
|
||||
invalid && '--text-input--invalid',
|
||||
className
|
||||
);
|
||||
$: errorId = `error-${id}`;
|
||||
</script>
|
||||
|
||||
<div class={cx('--form-item', '--text-input-wrapper')} {style}>
|
||||
{#if labelText}
|
||||
<label for={id} class={_labelClass}>{labelText}</label>
|
||||
<label
|
||||
for={id}
|
||||
class={cx('--label', hideLabel && '--visually-hidden', disabled && '--label--disabled')}>
|
||||
{labelText}
|
||||
</label>
|
||||
{/if}
|
||||
{#if helperText}
|
||||
<div class={_helperTextClass}>{helperText}</div>
|
||||
<div class={cx('--form__helper-text', disabled && '--form__helper-text--disabled')}>
|
||||
{helperText}
|
||||
</div>
|
||||
{/if}
|
||||
<div class={cx('--text-input__field-wrapper')} data-invalid={invalid || undefined}>
|
||||
{#if invalid}
|
||||
<WarningFilled16 class={cx('--text-input__invalid-icon')} />
|
||||
{/if}
|
||||
<input
|
||||
class={_textInputClass}
|
||||
class={cx('--text-input', light && '--text-input--light', invalid && '--text-input--invalid', className)}
|
||||
on:click
|
||||
on:change
|
||||
on:input
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue