Skip to content

Commit 4b9ef20

Browse files
Merge pull request #10 from anderson-camacho/feature/template-field-guidance-and-ui-languages
Improve template field guidance, drawer UX, and language coverage
2 parents 31c20af + 18b2c2e commit 4b9ef20

7 files changed

Lines changed: 1278 additions & 100 deletions

File tree

src/components/Editor.astro

Lines changed: 154 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
---
22
import { dictionary, type Locale } from "../i18n/dictionaries";
33
import { templateCatalog } from "../templates/catalog";
4+
45
const { locale } = Astro.props as { locale: Locale };
56
const t = dictionary(locale);
7+
68
const palettePresets = [
79
{
810
id: "executive",
@@ -26,6 +28,7 @@ const palettePresets = [
2628
secondary: "#6db7c9",
2729
},
2830
] as const;
31+
2932
const personalFields = [
3033
["fullName", "Full name"],
3134
["jobTitle", "Job title"],
@@ -48,6 +51,9 @@ const personalFields = [
4851
data-cleared={t.cleared}
4952
data-saved-to-library={t.savedToLibrary}
5053
data-library-empty={t.libraryEmpty}
54+
data-field-hidden={t.fieldHidden}
55+
data-template-fields-all={t.templateFieldSummaryAll}
56+
data-template-fields-hidden-prefix={t.templateFieldSummaryHidden}
5157
>
5258
<div class="workspace-top">
5359
<div>
@@ -62,26 +68,71 @@ const personalFields = [
6268
</div>
6369
</div>
6470

65-
<section class="editor">
66-
<aside class="editor-rail rail-config">
67-
<div class="rail-heading">
68-
<span class="eyebrow">Configuration</span>
69-
<h3>Signature setup</h3>
71+
<section class="editor" data-editor-layout>
72+
<div class="drawer-edge-controls">
73+
<button
74+
class="drawer-edge-toggle drawer-edge-toggle-left"
75+
type="button"
76+
data-drawer-toggle="config"
77+
aria-controls="editor-config-panel"
78+
aria-expanded="false"
79+
>
80+
<span class="drawer-toggle-glyph" aria-hidden="true">&lt;</span>
81+
<span>{t.drawerConfig}</span>
82+
</button>
83+
<button
84+
class="drawer-edge-toggle drawer-edge-toggle-right"
85+
type="button"
86+
data-drawer-toggle="templates"
87+
aria-controls="editor-templates-panel"
88+
aria-expanded="false"
89+
>
90+
<span>{t.drawerTemplates}</span>
91+
<span class="drawer-toggle-glyph" aria-hidden="true">&gt;</span>
92+
</button>
93+
</div>
94+
95+
<div class="drawer-backdrop" data-drawer-backdrop hidden></div>
96+
97+
<aside
98+
class="editor-rail rail-config"
99+
id="editor-config-panel"
100+
data-drawer-panel="config"
101+
aria-hidden="false"
102+
>
103+
<div class="rail-heading rail-heading-with-close">
104+
<div class="rail-heading-copy">
105+
<span class="eyebrow">Configuration</span>
106+
<h3>Signature setup</h3>
107+
</div>
108+
<button
109+
class="drawer-close"
110+
type="button"
111+
data-drawer-close="config"
112+
aria-label={t.drawerClose}
113+
>
114+
<span class="drawer-close-glyph" aria-hidden="true">×</span>
115+
<span class="sr-only">{t.drawerClose}</span>
116+
</button>
70117
</div>
71118

72119
<form id="signature-form">
73120
<details class="config-section" open>
74121
<summary><span>1</span> Signature style</summary>
75122
<div class="config-body">
76-
<label
77-
>Choose style<select name="template"
78-
>{
123+
<label>
124+
Choose style
125+
<select name="template">
126+
{
79127
templateCatalog.map((template) => (
80128
<option value={template.id}>{template.label}</option>
81129
))
82-
}</select
83-
></label
84-
>
130+
}
131+
</select>
132+
</label>
133+
<p id="template-field-summary" class="template-support-summary" aria-live="polite">
134+
{t.templateFieldSummaryAll}
135+
</p>
85136
</div>
86137
</details>
87138

@@ -90,11 +141,27 @@ const personalFields = [
90141
<div class="config-body field-grid">
91142
{
92143
personalFields.map(([name, label]) => (
93-
<label class:list={{ wide: name === "legalText" || name === "address" }}>
94-
{label}
144+
<label
145+
class:list={{ wide: name === "legalText" || name === "address" }}
146+
data-field-wrapper
147+
data-field-name={name}
148+
data-field-label={label}
149+
>
150+
<span class="field-label-row">
151+
<span class="field-label-text">{label}</span>
152+
<small
153+
class="field-support-note"
154+
data-field-support-note={name}
155+
title={t.fieldHidden}
156+
hidden
157+
>
158+
No visible
159+
</small>
160+
</span>
95161
<input
96162
name={name}
97163
type={name === "email" ? "email" : name === "website" ? "url" : "text"}
164+
data-field-control
98165
/>
99166
</label>
100167
))
@@ -105,26 +172,65 @@ const personalFields = [
105172
<details class="config-section">
106173
<summary><span>3</span> Photo and logo</summary>
107174
<div class="config-body">
108-
<label>Public logo URL HTTPS<input name="logoUrl" type="url" /></label>
109-
<label>Public photo URL HTTPS<input name="photoUrl" type="url" /></label>
175+
<label data-field-wrapper data-field-name="logoUrl" data-field-label="Public logo URL HTTPS">
176+
<span class="field-label-row">
177+
<span class="field-label-text">Public logo URL HTTPS</span>
178+
<small
179+
class="field-support-note"
180+
data-field-support-note="logoUrl"
181+
title={t.fieldHidden}
182+
hidden
183+
>
184+
No visible
185+
</small>
186+
</span>
187+
<input name="logoUrl" type="url" data-field-control />
188+
</label>
110189
<label
111-
>Local logo/photo preview<input id="local-image" type="file" accept="image/*"
112-
/></label>
190+
data-field-wrapper
191+
data-field-name="photoUrl"
192+
data-field-label="Public photo URL HTTPS"
193+
>
194+
<span class="field-label-row">
195+
<span class="field-label-text">Public photo URL HTTPS</span>
196+
<small
197+
class="field-support-note"
198+
data-field-support-note="photoUrl"
199+
title={t.fieldHidden}
200+
hidden
201+
>
202+
No visible
203+
</small>
204+
</span>
205+
<input name="photoUrl" type="url" data-field-control />
206+
</label>
207+
<label>
208+
Local logo/photo preview
209+
<input id="local-image" type="file" accept="image/*" />
210+
</label>
113211
<p id="local-warning" class="warning" hidden>{t.localWarning}</p>
114212
</div>
115213
</details>
116214

117215
<details class="config-section" open>
118216
<summary><span>4</span> Colors and appearance</summary>
119217
<div class="config-body appearance-grid">
120-
<label>Primary color<input name="primaryColor" type="color" /></label>
121-
<label>Secondary color<input name="secondaryColor" type="color" /></label>
122-
<label
123-
>Size<select name="size"
124-
><option>compact</option><option selected>normal</option><option>wide</option
125-
></select
126-
></label
127-
>
218+
<label class="appearance-field">
219+
<span class="appearance-label">Primary color</span>
220+
<input name="primaryColor" type="color" />
221+
</label>
222+
<label class="appearance-field">
223+
<span class="appearance-label">Secondary color</span>
224+
<input name="secondaryColor" type="color" />
225+
</label>
226+
<label class="appearance-field">
227+
<span class="appearance-label">Size</span>
228+
<select name="size">
229+
<option>compact</option>
230+
<option selected>normal</option>
231+
<option>wide</option>
232+
</select>
233+
</label>
128234
<div class="palette-presets">
129235
<p class="section-help">
130236
Quick palettes based on trust, usability, and entrepreneurial clarity.
@@ -202,17 +308,35 @@ const personalFields = [
202308
<button id="copy">{t.copy}</button>
203309
<button id="download">{t.download}</button>
204310
<button id="export">{t.export}</button>
205-
<label class="button">{t.import}<input id="import" type="file" accept=".json,application/json" /></label>
311+
<label class="button"
312+
>{t.import}<input id="import" type="file" accept=".json,application/json" /></label
313+
>
206314
<button id="save-library" class="secondary">{t.saveToLibrary}</button>
207315
<button id="clear" class="secondary">{t.clear}</button>
208316
</div>
209317
<p id="status" role="status" aria-live="polite">{t.saved}</p>
210318
</section>
211319

212-
<aside class="editor-rail rail-library">
213-
<div class="rail-heading">
214-
<span class="eyebrow">Templates</span>
215-
<h3>Pick a direction</h3>
320+
<aside
321+
class="editor-rail rail-library"
322+
id="editor-templates-panel"
323+
data-drawer-panel="templates"
324+
aria-hidden="false"
325+
>
326+
<div class="rail-heading rail-heading-with-close">
327+
<div class="rail-heading-copy">
328+
<span class="eyebrow">Templates</span>
329+
<h3>Pick a direction</h3>
330+
</div>
331+
<button
332+
class="drawer-close"
333+
type="button"
334+
data-drawer-close="templates"
335+
aria-label={t.drawerClose}
336+
>
337+
<span class="drawer-close-glyph" aria-hidden="true">×</span>
338+
<span class="sr-only">{t.drawerClose}</span>
339+
</button>
216340
</div>
217341
<div class="template-showcase">
218342
{

0 commit comments

Comments
 (0)