mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-15 18:31:06 +00:00
* feat(icons): inline carbon icons used by components * feat(icons): update svelte components to use inlined carbon icons * breaking(deps): remove carbon-icons-svelte * chore(deps-dev): install carbon-icons-svelte as a devDependency
35 lines
930 B
Svelte
35 lines
930 B
Svelte
<script>
|
|
/**
|
|
* @typedef {"close" | "open"} ListBoxMenuIconTranslationId
|
|
*/
|
|
|
|
/** Set to `true` to open the list box menu icon */
|
|
export let open = false;
|
|
|
|
/** Default translation ids */
|
|
export const translationIds = { close: "close", open: "open" };
|
|
|
|
/**
|
|
* Override the default translation ids
|
|
* @type {(id: ListBoxMenuIconTranslationId) => string}
|
|
*/
|
|
export let translateWithId = (id) => defaultTranslations[id];
|
|
|
|
import ChevronDown16 from "../icons/ChevronDown16.svelte";
|
|
|
|
const defaultTranslations = {
|
|
[translationIds.close]: "Close menu",
|
|
[translationIds.open]: "Open menu",
|
|
};
|
|
|
|
$: description = open ? translateWithId("close") : translateWithId("open");
|
|
</script>
|
|
|
|
<div
|
|
class:bx--list-box__menu-icon="{true}"
|
|
class:bx--list-box__menu-icon--open="{open}"
|
|
{...$$restProps}
|
|
on:click|preventDefault
|
|
>
|
|
<ChevronDown16 aria-label="{description}" title="{description}" />
|
|
</div>
|