mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 10:21:05 +00:00
- Inline class assignments to avoid script-level clutter - Ignore a11y-missing-attribute instead of redundant href
32 lines
667 B
Svelte
32 lines
667 B
Svelte
<script>
|
|
let className = undefined;
|
|
export { className as class };
|
|
export let href = undefined;
|
|
export let rel = undefined;
|
|
export let light = false;
|
|
export let clicked = false;
|
|
export let style = undefined;
|
|
|
|
import { cx } from '../../lib';
|
|
</script>
|
|
|
|
<a
|
|
class={cx('--link', '--tile', '--tile--clickable', clicked && '--tile--is-clicked', light && '--tile--light', className)}
|
|
on:click
|
|
on:click={() => {
|
|
clicked = !clicked;
|
|
}}
|
|
on:keydown
|
|
on:keydown={({ key }) => {
|
|
if (key === ' ' || key === 'Enter') {
|
|
clicked = !clicked;
|
|
}
|
|
}}
|
|
on:mouseover
|
|
on:mouseenter
|
|
on:mouseleave
|
|
{style}
|
|
{href}
|
|
{rel}>
|
|
<slot />
|
|
</a>
|