fix(pages): hero grows with its text on phones; name the rich text box
The live check at 360 px clipped the hero heading because the image set a fixed height. The text now sets the height and the image fills behind it. The rich text box now carries its field label as an accessible name. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EFUzfiCVCgCVJZq4NDEqZs
This commit is contained in:
1 parent
a74cc7fc87
commit
0ee9c217c2
4 files changed
+14
-5
No files matched your search
@@ -73,7 +73,7 @@ export function BlockFields(props: {
|
||||
|
||||
const richText = (labelCode: string) => (
|
||||
<Field id={fid("html")} label={t(labelCode)} error={errors.html}>
|
||||
<RichTextEditor id={fid("html")} value={block.html ?? ""} disabled={saving} invalid={!!errors.html} onChange={(html) => set({ html })} />
|
||||
<RichTextEditor id={fid("html")} label={t(labelCode)} value={block.html ?? ""} disabled={saving} invalid={!!errors.html} onChange={(html) => set({ html })} />
|
||||
</Field>
|
||||
);
|
||||
|
||||
|
||||
@@ -39,8 +39,8 @@ function Block({ block, index, company, slug, preview }: { block: PublicBlock; i
|
||||
case "HERO":
|
||||
return (
|
||||
<section className="relative overflow-hidden rounded-lg bg-muted">
|
||||
<BlockImage id={block.imageId} className="h-72 w-full object-cover sm:h-96" />
|
||||
<div className={block.imageId ? "absolute inset-0 flex flex-col justify-end gap-3 bg-gradient-to-t from-black/70 to-transparent p-6 text-white" : "flex flex-col gap-3 p-6"}>
|
||||
<BlockImage id={block.imageId} className="absolute inset-0 h-full w-full object-cover" />
|
||||
<div className={block.imageId ? "relative flex min-h-72 flex-col justify-end gap-3 bg-gradient-to-t from-black/80 via-black/50 to-transparent p-6 text-white sm:min-h-96" : "flex flex-col gap-3 p-6"}>
|
||||
{block.heading ? <h2 className="text-3xl font-semibold sm:text-4xl">{block.heading}</h2> : null}
|
||||
{block.text ? <p className="max-w-2xl text-lg">{block.text}</p> : null}
|
||||
<div><ButtonLink block={block} /></div>
|
||||
|
||||
@@ -35,6 +35,14 @@ beforeEach(() => {
|
||||
});
|
||||
|
||||
describe("PageEditor", () => {
|
||||
it("names the rich text box after its field label", async () => {
|
||||
const user = userEvent.setup();
|
||||
render(<PageEditor pageId={5} />);
|
||||
await screen.findByLabelText("Event");
|
||||
await user.click(screen.getByRole("button", { name: "Add Text" }));
|
||||
expect(await screen.findByRole("textbox", { name: "Content" })).toHaveAttribute("contenteditable", "true");
|
||||
});
|
||||
|
||||
it("loads a page, offers only events that have not ended, and saves the blocks in order", async () => {
|
||||
const user = userEvent.setup();
|
||||
render(<PageEditor pageId={5} />);
|
||||
|
||||
@@ -14,8 +14,9 @@ const SAFE_LINK = /^(https:\/\/|mailto:|tel:|\/(?!\/))/i;
|
||||
|
||||
const htmlOf = (editor: Editor) => (editor.isEmpty ? "" : editor.getHTML());
|
||||
|
||||
export function RichTextEditor({ id, value, onChange, disabled, invalid }: {
|
||||
export function RichTextEditor({ id, label, value, onChange, disabled, invalid }: {
|
||||
id?: string;
|
||||
label?: string;
|
||||
value: string;
|
||||
onChange: (html: string) => void;
|
||||
disabled?: boolean;
|
||||
@@ -35,7 +36,7 @@ export function RichTextEditor({ id, value, onChange, disabled, invalid }: {
|
||||
}),
|
||||
TextAlign.configure({ types: ["heading", "paragraph"], alignments: ["left", "center", "right"] }),
|
||||
],
|
||||
editorProps: { attributes: { ...(id ? { id } : {}), ...(invalid ? { "aria-invalid": "true" } : {}), class: "min-h-[140px] px-3 py-2 text-sm outline-none" } },
|
||||
editorProps: { attributes: { ...(id ? { id } : {}), ...(label ? { "aria-label": label } : {}), ...(invalid ? { "aria-invalid": "true" } : {}), class: "min-h-[140px] px-3 py-2 text-sm outline-none" } },
|
||||
onUpdate: ({ editor }) => {
|
||||
const html = htmlOf(editor);
|
||||
emitted.current = html;
|
||||
|
||||
Reference in new issue
Block a user