From 06b914ec1f3758b7cb056e03a0ccededcc74891f Mon Sep 17 00:00:00 2001 From: Mark Otto Date: Tue, 21 Jul 2026 16:15:09 -0700 Subject: [PATCH 1/2] refactor(docs): restyle playground edit toggles as buttons The playground's per-file "Edit" control was a bare checkbox in each of the three views (CodeView, React Virtualizer, and vanilla Virtualizer). It is now a bordered pill button: a filled checkbox plus "Editing" when active, an outline icon plus "Edit" when idle. Styling is shared through one `.playground-edit-toggle` class in globals.css, driven by `aria-pressed`. Both state icons and both labels are always present so CSS shows the matching pair. The vanilla view builds its DOM by hand and inlines the two glyphs as SVG, so it only has to flip the attribute; its metadata slot is light-DOM, so the app stylesheet reaches it. --- .../(diffs)/playground/PlaygroundCodeView.tsx | 33 ++++++++---- .../PlaygroundVirtualizerElementView.tsx | 22 +++++--- .../playground/PlaygroundVirtualizerView.tsx | 54 ++++++++++--------- apps/docs/app/globals.css | 35 ++++++++++++ 4 files changed, 102 insertions(+), 42 deletions(-) diff --git a/apps/docs/app/(diffs)/playground/PlaygroundCodeView.tsx b/apps/docs/app/(diffs)/playground/PlaygroundCodeView.tsx index 813a0f88e..8c43c5a6a 100644 --- a/apps/docs/app/(diffs)/playground/PlaygroundCodeView.tsx +++ b/apps/docs/app/(diffs)/playground/PlaygroundCodeView.tsx @@ -17,6 +17,7 @@ import { type CodeViewReactOptions, useStableCallback, } from '@pierre/diffs/react'; +import { IconCheckboxFill, IconSquircleLg } from '@pierre/icons'; import { useCallback, useEffect, useMemo, useState } from 'react'; import { flushSync } from 'react-dom'; @@ -390,16 +391,30 @@ export function PlaygroundCodeView({ ); const renderHeaderMetadata = useStableCallback((item: PlaygroundItem) => { + const isEditing = item.edit === true; return ( - + ); }); diff --git a/apps/docs/app/(diffs)/playground/PlaygroundVirtualizerElementView.tsx b/apps/docs/app/(diffs)/playground/PlaygroundVirtualizerElementView.tsx index d9a54e6ef..94d39f1d6 100644 --- a/apps/docs/app/(diffs)/playground/PlaygroundVirtualizerElementView.tsx +++ b/apps/docs/app/(diffs)/playground/PlaygroundVirtualizerElementView.tsx @@ -10,6 +10,7 @@ import { } from '@pierre/diffs'; import type { EditorOptions } from '@pierre/diffs/editor'; import { FileDiff, useStableCallback, Virtualizer } from '@pierre/diffs/react'; +import { IconCheckboxFill, IconSquircleLg } from '@pierre/icons'; import { useCallback, useEffect, useMemo, useState } from 'react'; import { flushSync } from 'react-dom'; @@ -221,15 +222,20 @@ function ElementVirtualizerDiff({ const renderHeaderMetadata = useStableCallback(() => { return ( -