mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-18 03:26:36 +00:00
43 lines
848 B
Svelte
43 lines
848 B
Svelte
<script>
|
|
/** @restProps {a | p} */
|
|
|
|
/** Set to `true` to click the tile */
|
|
export let clicked = false;
|
|
|
|
/** Set to `true` to enable the light variant */
|
|
export let light = false;
|
|
|
|
/** Set to `true` to disable the tile */
|
|
export let disabled = false;
|
|
|
|
/**
|
|
* Set the `href`
|
|
* @type {string}
|
|
*/
|
|
export let href = undefined;
|
|
|
|
import Link from "../Link/Link.svelte";
|
|
</script>
|
|
|
|
<Link
|
|
{...$$restProps}
|
|
disabled="{disabled}"
|
|
class="bx--tile bx--tile--clickable {clicked &&
|
|
'bx--tile--is-clicked'} {light && 'bx--tile--light'} {$$restProps.class}"
|
|
href="{href}"
|
|
on:click
|
|
on:click="{() => {
|
|
clicked = !clicked;
|
|
}}"
|
|
on:keydown
|
|
on:keydown="{({ key }) => {
|
|
if (key === ' ' || key === 'Enter') {
|
|
clicked = !clicked;
|
|
}
|
|
}}"
|
|
on:mouseover
|
|
on:mouseenter
|
|
on:mouseleave
|
|
>
|
|
<slot />
|
|
</Link>
|