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:
Eric Liu 2019-12-24 09:41:12 -08:00
commit c446fc74f4
94 changed files with 469 additions and 598 deletions

View file

@ -14,7 +14,7 @@
import { cx } from '../../lib';
const dispatch = createEventDispatcher();
const _class = cx('--tabs', type === 'container' && '--tabs--container', className);
let dropdownHidden = true;
let tabs = writable([]);
let tabsById = derived(tabs, _ => _.reduce((a, c) => ({ ...a, [c.id]: c }), {}));
@ -79,10 +79,9 @@
$: if ($selectedTab) {
dropdownHidden = true;
}
$: _listClass = cx('--tabs__nav', dropdownHidden && '--tabs__nav--hidden');
</script>
<div class={_class} {style} {role}>
<div class={cx('--tabs', type === 'container' && '--tabs--container', className)} {style} {role}>
<div
role="listbox"
tabindex="0"
@ -107,7 +106,7 @@
</a>
<ChevronDownGlyph aria-hidden="true" title={iconDescription} />
</div>
<ul role="tablist" class={_listClass}>
<ul role="tablist" class={cx('--tabs__nav', dropdownHidden && '--tabs__nav--hidden')}>
<slot />
</ul>
</div>