mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-16 10:51:06 +00:00
* Prefix custom class selectors with `bx--` (primarily used in custom UI Shell components) * Use `:global` scope so that selector names are not hashed
43 lines
945 B
Svelte
43 lines
945 B
Svelte
<script>
|
|
/** Set to `true` to use the active state */
|
|
export let linkIsActive = false;
|
|
|
|
/**
|
|
* Specify the `href` attribute
|
|
* @type {string}
|
|
*/
|
|
export let href = undefined;
|
|
|
|
/**
|
|
* Specify the icon to render
|
|
* @type {typeof import("svelte").SvelteComponent<any>}
|
|
*/
|
|
export let icon = undefined;
|
|
|
|
/** Obtain a reference to the HTML anchor element */
|
|
export let ref = null;
|
|
</script>
|
|
|
|
<a
|
|
bind:this="{ref}"
|
|
class:bx--header__action="{true}"
|
|
class:bx--header__action--active="{linkIsActive}"
|
|
href="{href}"
|
|
rel="{$$restProps.target === '_blank' ? 'noopener noreferrer' : undefined}"
|
|
{...$$restProps}
|
|
on:click
|
|
>
|
|
<slot name="icon">
|
|
<svelte:component this="{icon}" size="{20}" />
|
|
</slot>
|
|
</a>
|
|
|
|
<style>
|
|
:global(.bx--header__action) {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
/** Hot fix to align icon with `HeaderAction` */
|
|
padding-bottom: 2px;
|
|
}
|
|
</style>
|