Skip to content

Commit 85e96ce

Browse files
committed
fix: reset font picker state on open and truncate long font names
1 parent da54a6e commit 85e96ce

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

resources/assets/editor/components/FontPicker.vue

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,11 @@
9999
return `https://fonts.bunny.net/css?display=fallback&family=${font.slug}`;
100100
}
101101
102+
function onOpenChange() {
103+
isDirty.value = false;
104+
initialValue.value = model.value as Font | null
105+
}
106+
102107
function onCancel() {
103108
opened.value = false;
104109
model.value = initialValue.value;
@@ -112,11 +117,11 @@
112117
v-model:open="opened"
113118
:modal="false"
114119
:close-on-interact-outside="false"
115-
@open-change="isDirty = false; initialValue = model as Font | null"
120+
@open-change="onOpenChange"
116121
>
117122
<Dialog.Trigger class="flex items-center px-3 py-2.5 gap-4 border rounded w-full">
118123
<i-ri-font-size class="flex-none w-4 h-4 text-gray-500" />
119-
<span class="flex-1 text-left capitalize">{{ model?.name }}</span>
124+
<span class="flex-1 text-left capitalize line-clamp-1">{{ model?.name }}</span>
120125
<i-heroicons-chevron-up-down class="flex-none w-4 h-4 text-gray-500" />
121126
</Dialog.Trigger>
122127
<Dialog.Positioner class="flex fixed z-50 top-14 left-14 bottom-0 w-[19.9rem] items-center justify-center">

resources/assets/editor/views/index.vue

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,8 +96,6 @@
9696
toggleSectionsDialog();
9797
store.addNewSection(section);
9898
}
99-
100-
watchEffect(() => console.log(isJsonTemplate.value))
10199
</script>
102100

103101
<template>

src/Settings/Support/FontValue.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
namespace BagistoPlus\Visual\Settings\Support;
44

55
use Illuminate\Support\HtmlString;
6+
use Illuminate\Support\Str;
67

78
class FontValue
89
{
910
public function __construct(public string $slug, public string $name, public array $weights, public array $styles) {}
1011

1112
public function __toString()
1213
{
13-
return $this->name;
14+
return Str::headline($this->name);
1415
}
1516

1617
public function toHtml()

0 commit comments

Comments
 (0)