Skip to content

Commit

Permalink
fiddle with naming stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
mcnuttandrew committed Sep 27, 2024
1 parent f6e2572 commit c2530ba
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
16 changes: 4 additions & 12 deletions apps/color-buddy/src/components/ContentEditable.svelte
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<script lang="ts">
export let onChange: (str: string) => void;
export let value: string;
export let limitWidth: boolean = false;
export let useEditButton: boolean = false;
export let onClick: () => void = () => {};
export let displayValue: string = value;
let focused = false;
</script>
Expand All @@ -12,6 +12,7 @@
<input
type="text"
bind:value
class="border-2 border-gray-300 w-fit"
on:blur={() => {
onChange(value);
focused = false;
Expand All @@ -32,19 +33,10 @@
focused = true;
}
}}
class:wrap-title={limitWidth}
>
{value}
{displayValue}
</button>
{/if}
{#if useEditButton}
{#if useEditButton && !focused}
<button on:click={() => (focused = true)}>✎</button>
{/if}

<style>
.wrap-title {
max-width: 205px;
white-space: break-spaces;
line-break: anywhere;
}
</style>
7 changes: 5 additions & 2 deletions apps/color-buddy/src/content-modules/LeftPanel.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,9 @@
<ContentEditable
onChange={(x) => colorStore.setCurrentPalName(x)}
value={currentPal.name}
displayValue={`${currentPal.name.slice(0, 20)}${
currentPal.name.length > 20 ? "..." : ""
}`}
useEditButton={true}
/>
</div>
Expand Down Expand Up @@ -125,15 +128,15 @@
</button>
<div class="flex justify-between w-full px-2 items-center z-10">
<span class="flex flex-col items-start">
<span>
<span class="flex max-w-5">
<ContentEditable
onChange={(x) => {
const updatedColors = [...colors];
updatedColors[idx] = Color.colorFromString(x, colorSpace);
colorStore.setCurrentPalColors(updatedColors);
}}
value={color.toHex()}
useEditButton={false}
useEditButton={true}
/>
</span>
{#if colorNames[idx]}<span class="text-right text-xs">
Expand Down

0 comments on commit c2530ba

Please sign in to comment.