summaryrefslogtreecommitdiffstats
path: root/apps/web-shared/src/components/chip.svelte
diff options
context:
space:
mode:
authorivarlovlie <git@ivarlovlie.no>2022-06-01 22:10:32 +0200
committerivarlovlie <git@ivarlovlie.no>2022-06-01 22:10:32 +0200
commita640703f2da8815dc26ad1600a6f206be1624379 (patch)
treedbda195fb5783d16487e557e06471cf848b75427 /apps/web-shared/src/components/chip.svelte
downloadgreatoffice-a640703f2da8815dc26ad1600a6f206be1624379.tar.xz
greatoffice-a640703f2da8815dc26ad1600a6f206be1624379.zip
feat: Initial after clean slate
Diffstat (limited to 'apps/web-shared/src/components/chip.svelte')
-rw-r--r--apps/web-shared/src/components/chip.svelte50
1 files changed, 50 insertions, 0 deletions
diff --git a/apps/web-shared/src/components/chip.svelte b/apps/web-shared/src/components/chip.svelte
new file mode 100644
index 0000000..7fbb445
--- /dev/null
+++ b/apps/web-shared/src/components/chip.svelte
@@ -0,0 +1,50 @@
+<script>
+ import {IconNames} from "$shared/lib/configuration";
+ import {createEventDispatcher} from "svelte";
+ import Button from "./button.svelte";
+
+ const dispatch = createEventDispatcher();
+ export let removable = false;
+ export let clickable = false;
+ export let text = "";
+ export let id = "";
+ export let color = "";
+ export let tabindex = "";
+
+ function handle_remove() {
+ if (removable) {
+ dispatch("remove", {
+ id
+ });
+ }
+ }
+
+ function handle_click() {
+ if (clickable) {
+ dispatch("clicked", {
+ id
+ });
+ }
+ }
+</script>
+
+<div class="chip break-word text-sm justify-between justify-start@md {clickable ? 'chip--interactive' : ''}"
+ on:click={handle_click}
+ id={id}
+ style={color !== "" ? `background-color: ${color}15; border: 1px solid ${color}; color: ${color}` : ""}
+ {tabindex}
+>
+ <span class="chip__label">{text}</span>
+
+ {#if removable}
+ <Button class="chip__btn"
+ variant="reset"
+ style="{color !== '' ? `background-color: ${color}45;` : ''}"
+ {tabindex}
+ icon="{IconNames.x}"
+ icon_width="initial"
+ icon_height="initial"
+ on:click={handle_remove}
+ />
+ {/if}
+</div>