Skip to content

Commit

Permalink
improve icon experience for grabbing
Browse files Browse the repository at this point in the history
  • Loading branch information
KTibow committed Aug 21, 2024
1 parent 8dabc00 commit b493635
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
20 changes: 19 additions & 1 deletion src/routes/theme/ColorCard.svelte
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
<script lang="ts">
import iconCopy from "@ktibow/iconset-material-symbols/content-copy-outline";
import {
type DynamicScheme,
MaterialDynamicColors,
hexFromArgb,
} from "@material/material-color-utilities";
import { createEventDispatcher } from "svelte";
import Icon from "$lib/misc/_icon.svelte";
export let fg: string;
export let bg: string;
export let scheme: DynamicScheme;
Expand Down Expand Up @@ -84,7 +88,13 @@
<p class="m3-font-headline-small">{bg}</p>
<p class="m3-font-body-large">{fg} text</p>
{#if state}
<div class="overlay" style:background-color={state == 2 ? bgColor : fgColor} />
<div
class="overlay"
class:invert={state == 1}
style:background-color={state == 2 ? bgColor : fgColor}
>
<Icon width="1.5rem" height="1.5rem" icon={iconCopy} />
</div>
{/if}
</div>

Expand All @@ -98,10 +108,18 @@
cursor: pointer;
}
.overlay {
display: flex;
align-items: center;
justify-content: center;
position: absolute;
inset: 0;
pointer-events: none;
}
.overlay.invert :global(svg) {
mix-blend-mode: difference;
}
p {
margin: 0;
}
Expand Down
3 changes: 2 additions & 1 deletion src/routes/theme/SchemeShowcase.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import iconCopy from "@ktibow/iconset-material-symbols/content-copy-outline";
import iconLight from "@ktibow/iconset-material-symbols/light-mode-outline";
import iconDark from "@ktibow/iconset-material-symbols/dark-mode-outline";
import iconX from "@ktibow/iconset-material-symbols/close";
import iconGrab from "@ktibow/iconset-material-symbols/unarchive-outline";
import { onMount } from "svelte";
Expand Down Expand Up @@ -57,7 +58,7 @@
</Button>
{#if grabbing}
<Button type="tonal" iconType="left" on:click={() => (grabbing = false)}>
<Icon icon={iconGrab} />
<Icon icon={iconX} />
Stop grab
</Button>
{:else}
Expand Down

0 comments on commit b493635

Please sign in to comment.