Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions client/BeastDevtools.btsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ module

module
interface DevtoolsInterfaceProps {
theme: 'dark' | 'light'
open: boolean
componentFinderActive: boolean
componentFinderTitle: 'Stop Component Finder (Esc)' | 'Component Finder (Alt+Shift+C)'
Expand All @@ -54,8 +55,8 @@ module
}

component DevtoolsInterface
props { open, componentFinderActive, componentFinderTitle, setActiveElementTool, elementPickerActive, elementPickerTitle, setOpen }: DevtoolsInterfaceProps
div(className={cx('bdt-root', 'bdt-launcher-host', open && 'is-hidden')} aria-hidden={open ? 'true' : undefined})
props { theme, open, componentFinderActive, componentFinderTitle, setActiveElementTool, elementPickerActive, elementPickerTitle, setOpen }: DevtoolsInterfaceProps
div(data-theme={theme} className={cx('bdt-root', 'bdt-launcher-host', open && 'is-hidden')} aria-hidden={open ? 'true' : undefined})
button(type="button" className={cx('bdt-launcher-component-finder bg-white/50 backdrop-blur-3xl', componentFinderActive && 'is-component-finder-active')} aria-pressed={componentFinderActive} aria-label="Component Finder" title={componentFinderTitle} onClick={() => setActiveElementTool((value) => value === 'component-finder' ? null : 'component-finder')})
ComponentFinderIcon
button( type="button" className={cx('bdt-launcher-element-picker bg-white/70 backdrop-blur-3xl hover:text-active!', elementPickerActive && 'is-element-picker-active')} aria-pressed={elementPickerActive} aria-label="Element Picker" title={elementPickerTitle} onClick={() => setActiveElementTool((value) => value === 'element-picker' ? null : 'element-picker')})
Expand All @@ -66,6 +67,7 @@ component DevtoolsInterface
setup
const runtime = useSyncExternalStore(subscribeRuntime, getRuntimeSnapshot, getRuntimeSnapshot);
const [open, setOpen] = useState(initial.open);
const [theme, setTheme] = useState(initial.theme);
// The dock stays mounted after closing until its slide-out ends.
const [docked, setDocked] = useState(initial.open);
const [tab, setTab] = useState<TabId>(initial.tab);
Expand Down Expand Up @@ -105,8 +107,8 @@ setup
: runtime.status === 'connecting' ? 'Connecting…' : 'Runtime off';

useEffect(() => {
savePreferences({ open, tab, height, file, showControlFlow, componentsView, settings });
}, [open, tab, height, file, showControlFlow, componentsView, settings]);
savePreferences({ theme, open, tab, height, file, showControlFlow, componentsView, settings });
}, [theme, open, tab, height, file, showControlFlow, componentsView, settings]);

useEffect(() => onSourceChanged(() => setRevision((value) => value + 1)), []);

Expand Down Expand Up @@ -243,6 +245,7 @@ if open || docked
~ aria-label="Beast DevTools"
~ aria-hidden={open ? undefined : 'true'}
~ className={cx('bdt-root', 'bdt-dock', open && 'is-open')}
~ data-theme={theme}
~ style={{ height: `${height}px` }}
~ onTransitionEnd={onDockTransitionEnd}
~ )
Expand All @@ -253,6 +256,8 @@ if open || docked
~ onPointerDown={(event) => startResize(event, height, setHeight)}
~ )
Topbar(
~ theme={theme}
~ onToggleTheme={() => setTheme((value) => value === 'dark' ? 'light' : 'dark')}
~ tab={tab}
~ setTab={setTab}
~ suggestionCount={suggestionCount}
Expand Down Expand Up @@ -310,4 +315,4 @@ if open || docked
~ onSettingsChange={setSettings}
~ onRecentChange={(value) => { if (generation === projectGeneration.current) setRecent(value); }}
~ )
DevtoolsInterface(open={open} componentFinderActive={componentFinderActive} componentFinderTitle={componentFinderTitle} setActiveElementTool={setActiveElementTool} elementPickerActive={elementPickerActive} elementPickerTitle={elementPickerTitle} setOpen={setOpen})
DevtoolsInterface(theme={theme} open={open} componentFinderActive={componentFinderActive} componentFinderTitle={componentFinderTitle} setActiveElementTool={setActiveElementTool} elementPickerActive={elementPickerActive} elementPickerTitle={elementPickerTitle} setOpen={setOpen})
19 changes: 12 additions & 7 deletions client/ElementsPanel.btsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,11 @@ component ElementPropertyRow
const on = property.value === 'true';
.bdt-element-property
if property.type === 'boolean'
SquishSwitch(checked={on} disabled={disabled || !property.editable} ariaLabel={property.name} width={28} height={18} trackColor="var(--bdt-bg-4)" trackOnColor="var(--bdt-ok)" thumbColor="var(--bdt-text)" thumbOnColor="var(--bdt-bg)" onChange={(next) => onCommit(property.name, String(next))})
fragment
label.bdt-element-property-name(htmlFor={inputId} title={property.name}) #{property.name}
SquishSwitch(id={inputId} checked={on} disabled={disabled || !property.editable} ariaLabel={property.name} width={28} height={18} onChange={(next) => onCommit(property.name, String(next))})
elseif numeric !== null && property.editable
ScrubField.bdt-scrub-delta(label={property.name} value={numeric.value} defaultValue={original?.value ?? numeric.value} suffix={numeric.unit} min={(original?.value ?? numeric.value)/2} max={numeric.max} step={numeric.step} size="md" showDelta showDirty={true} fineMultiplier={0.1} coarseMultiplier={2} sensitivity={2} showFill={true} fillMin={original?.fillMin ?? numeric.fillMin} fillMax={original?.fillMax ?? numeric.fillMax} chipColor="#2a2a2a" accent="#666" onCommit={(next) => onCommit(property.name, `${next}${numeric.unit}${numeric.important}`)} disabled={disabled} className="bdt-style-scrub")
ScrubField.bdt-scrub-delta(label={property.name} value={numeric.value} defaultValue={original?.value ?? numeric.value} suffix={numeric.unit} min={(original?.value ?? numeric.value)/2} max={numeric.max} step={numeric.step} size="md" showDelta showDirty={true} fineMultiplier={0.1} coarseMultiplier={2} sensitivity={2} showFill={true} fillMin={original?.fillMin ?? numeric.fillMin} fillMax={original?.fillMax ?? numeric.fillMax} chipColor="var(--bdt-bg-4)" accent="var(--bdt-scrub-accent)" onCommit={(next) => onCommit(property.name, `${next}${numeric.unit}${numeric.important}`)} disabled={disabled} className="bdt-style-scrub")
elseif property.editable
.bdt-element-property-field
label.bdt-element-property-name(htmlFor={inputId} title={property.name}) #{property.name}
Expand All @@ -59,7 +61,9 @@ component ElementPropertyRow
~ onKeyDown={(event) => { if (event.key === 'Enter') event.currentTarget.blur(); if (event.key === 'Escape') { setDraft(property.value); setEditing(false); } }}
~ )
else
span.bdt-element-property-readonly(title={property.value}) #{property.value.length > 240 ? property.value.slice(0, 240) + '…' : property.value}
fragment
span.bdt-element-property-name(title={property.name}) #{property.name}
span.bdt-element-property-readonly(title={property.value}) #{property.value.length > 240 ? property.value.slice(0, 240) + '…' : property.value}
if removable && property.editable
button.bdt-icon-button(type="button" disabled={disabled} title={`Remove ${property.name}`} aria-label={`Remove ${property.name}`} onClick={() => onCommit(property.name, null)}) ×
elseif property.inline
Expand Down Expand Up @@ -188,12 +192,13 @@ section.bdt-pane.bdt-elements-panel(aria-label="Selected element")
.bdt-element-filter
input.bdt-input(type="search" aria-label="Filter element properties" placeholder="Find a property or value…" value={query} onInput={(event) => setQuery(event.currentTarget.value)})
if group === 'styles'
SquishSwitch(checked={showAll} onChange={setShowAll} label="All computed styles" width={28} height={18} trackColor="var(--bdt-bg-4)" trackOnColor="var(--bdt-ok)" thumbColor="var(--bdt-text)" thumbOnColor="var(--bdt-bg)")
span.bdt-dim #{rows.length} properties
SquishSwitch(checked={showAll} onChange={setShowAll} label="All computed styles" width={28} height={18} trackColor="var(--bdt-bg-4)" trackOnColor="var(--bdt-ok)" thumbColor="var(--bdt-line-2)" thumbOnColor="#fafafa")
span.bdt-dim.bdt-prop-count #{rows.length}
span.bdt-dim properties
.bdt-element-properties
if rows.length === 0
p.bdt-element-note No matching properties.
div(className={cx(group === 'styles' && 'bdt-style-columns')})
div(className={cx(group === 'styles' && 'bdt-style-columns', group === 'properties' && 'bdt-property-columns')})
each category in sections key `${group}:${category.id}`
.bdt-element-section
if category.label !== null
Expand All @@ -208,7 +213,7 @@ section.bdt-pane.bdt-elements-panel(aria-label="Selected element")
span #{category.label}
span.bdt-dim #{category.properties.length}
if isOpen(category)
div(className={cx('bdt-element-grid', category.columns === 2 && 'is-split')})
div(className={cx('bdt-element-grid', group !== 'properties' && category.columns === 2 && 'is-split')})
each property in category.properties key `${group}:${property.name}`
ElementPropertyRow(originalValue={savedSnapshot?.[group].find((entry) => entry.name === property.name)?.value} styleControl={group === 'styles'} property={property} disabled={saving || !snapshot.source || !snapshot.connected} removable={group === 'attributes' || (group === 'styles' && !!property.inline)} onCommit={edit})
if group !== 'properties'
Expand Down
12 changes: 11 additions & 1 deletion client/Topbar.btsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import { cx, TABS, type TabId } from './util.ts'

module
interface TopbarProps {
theme: 'dark' | 'light'
onToggleTheme: () => void
tab: TabId
setTab: (next: TabId | ((prev: TabId) => TabId)) => void
suggestionCount: number
Expand Down Expand Up @@ -46,14 +48,22 @@ component MainTabs
if item.id === 'refactor' && suggestionCount > 0
span.bdt-tab-count.bdt-refactor-count(title={`${suggestionCount} refactor suggestion${suggestionCount === 1 ? '' : 's'}`}) #{suggestionCount}

props { tab, setTab, suggestionCount, componentFinderActive, componentFinderTitle, setActiveElementTool, elementPickerActive, elementPickerTitle, project, projectId, selectProject, runtime, status, setOpen }: TopbarProps
props { theme, onToggleTheme, tab, setTab, suggestionCount, componentFinderActive, componentFinderTitle, setActiveElementTool, elementPickerActive, elementPickerTitle, project, projectId, selectProject, runtime, status, setOpen }: TopbarProps
header.bdt-topbar
.bdt-brand
BeastLogo
div(className="skew-2 font-semibold! text-text text-base!") Beast
span.bdt-brand-sub Devtools
MainTabs(tab={tab} setTab={setTab} suggestionCount={suggestionCount} componentCount={runtime.componentCount})
.bdt-spacer
button.bdt-icon-button(type="button" aria-label={theme === 'dark' ? 'Switch to light mode' : 'Switch to dark mode'} title={theme === 'dark' ? 'Switch to light mode' : 'Switch to dark mode'} onClick={onToggleTheme})
svg(viewBox="0 0 24 24" width="16" height="16" fill="none" stroke="currentColor" stroke-width="1.8" aria-hidden="true")
if theme === 'dark'
fragment
circle(cx="12" cy="12" r="4")
path(d="M12 2v2m0 16v2M2 12h2m16 0h2M5 5l1.5 1.5m11 11L19 19M5 19l1.5-1.5m11-11L19 5")
else
path(d="M20.5 14A9 9 0 0 1 10 3.5 9 9 0 1 0 20.5 14Z")
button(type="button" className={cx('bdt-icon-button', componentFinderActive && 'is-component-finder-active')} aria-pressed={componentFinderActive} aria-label="Component Finder" title={componentFinderTitle} onClick={() => setActiveElementTool((value) => value === 'component-finder' ? null : 'component-finder')})
ComponentFinderIcon
button(type="button" className={cx('bdt-icon-button', elementPickerActive && 'is-element-picker-active')} aria-pressed={elementPickerActive} aria-label="Element Picker" title={elementPickerTitle} onClick={() => setActiveElementTool((value) => value === 'element-picker' ? null : 'element-picker')})
Expand Down
Loading
Loading