Permission gate
The agent asks before it touches something new. Free and MIT licensed, as HTML, a typed React component or an Astro component, in three styles with light and dark mode.
Need this designed into your product? Book a call
Install
Add it to your project with the CLI.
HTML, CSS and JS
npx designme add permission-gateReact
npx designme add permission-gate --reactAstro
npx designme add permission-gate --astroshadcn, React
npx shadcn@latest add https://designme.dev/r/shadcn/permission-gate.json shadcn, Astro
npx shadcn@latest add https://designme.dev/r/shadcn/astro/permission-gate.json The CLI copies the source into your project, so you own it and can change anything. Where each version lands, what it needs and the shadcn theme bridge: Installation.
About
What it is for and what it does.
Permission gate is the card an agent shows when it wants to do something it has not been allowed to do yet, like editing Figma frames. The person ticks which scopes to grant, picks how long the permission lasts, and allows or declines, and they can revoke or undo that choice afterwards.
- When the agent is about to use a new tool or touch a new part of a workspace for the first time.
- When a request bundles several powers and people should be able to grant only some of them.
- When the agent is already running and reaches something it needs one more scope for, so it asks again for just that scope.
- When one of the scopes is risky, like publishing a shared library, and you want it flagged.
- When a permission should last only for this task or for today.
- Each scope has a checkbox, a
label, an optionaldetailline and an optionalrisktag such as "Risky". - A small dropdown in the footer picks how long it lasts.
durationsdefaults to This task, Today and Always, anddurationDetailsadds a line under each in the menu, like "Until midnight". - The Allow button counts the ticked scopes, like "Allow 2 scopes". It reads "Pick a scope" and stays disabled when none are ticked.
onAllowreceives the ticked keys and the duration. Return a promise and the button shows a spinner until it settles.- After allowing, the card shows what was granted and for how long, with an
allowedDetailline that crossfades and a Revoke button.allowedTitlereplaces the first line, like "Done. 6 frames edited". - While the agent works under the permission,
workingshows a spinner on the allowed row instead of the green check. The row stays neutral in both states. followUpmarks a second ask in the middle of a run, for one more scope: a single scope shows as a row led by a tile, with a plain Allow as there is nothing to tick (the icon tile stays neutral; the scope's risk tag carries the warning), anddeclineLabelcan say what declining means, like "Skip this frame". A scope'sriskDetailis what its risk tag shows on hover.- After Not now, the card shows
declinedTitleanddeclinedDetailwith an Undo button that brings the scopes back. - In Studio, the answer folds into one line in the foot strip: the scopes allowed, by name (how many on a narrow screen), or
declinedSummaryafter Not now, "Nothing allowed" by default. The card eases to each new height, and the count on Allow rolls as boxes are ticked.
- Each scope is a native checkbox inside its label, so the whole row is clickable and keyboard reachable.
- How long is a menu button with
aria-haspopupandaria-expanded; its choices aremenuitemradioitems witharia-checked. - From the keyboard, Enter, Space or the down arrow opens a menu with the focus on its picked item, or its first (the up arrow, on its last); the arrow keys move through it and wrap, Home and End jump to the ends, Tab closes it and moves on, and closing it gives the focus back to its button.
- The Allow button is a disabled button until at least one scope is ticked.
Usage
Import it in React and drive it from your own state, or place it in an Astro page.
React
import { PermissionGate } from '@/components/designme/permission-gate/PermissionGate';React example
The demo above as a React component, 70 lines you can copy.
'use client';
// The animated preview from designme.dev, rebuilt from the React component: an example of driving it from your own state.
import { useRef, useState } from 'react';
import { PermissionGate, type PermissionScope, type PermissionStatus } from './PermissionGate';
import { Icon } from '../lib/icons';
import { useStory, useWait } from '../lib/useScript';
/* ---------- Permission gate: hold back the risky scope, allow the rest, and grant it when the agent needs it for one frame ---------- */
const FIRST: PermissionScope[] = [
{ key: 'read', label: 'Read frames', detail: 'Pricing, Checkout' },
{ key: 'edit', label: 'Edit frames', detail: 'Only on a new page' },
{ key: 'publish', label: 'Publish library', detail: 'Affects 4 other files', risk: 'Risky', riskDetail: 'Checkout, Marketing site, Email kit and Docs use this library' }
];
const MORE: PermissionScope[] = [{ key: 'publish', label: 'Publish library', detail: 'Updates Checkout, Marketing site, Email kit and Docs', risk: 'Risky' }];
// the frames the agent edits once it may. Plan toggle is a library component, so editing it needs Publish library
const FRAMES = ['Hero', 'Plan cards', 'Compare table', 'FAQ', 'Plan toggle', 'Checkout summary'], LIB = 4;
export default function PermissionGateDemo() {
const ref = useRef<HTMLDivElement>(null);
const wait = useWait();
const [more, setMore] = useState(false);
const [value, setValue] = useState(['read', 'edit']);
const [duration, setDuration] = useState('This task');
const [status, setStatus] = useState<PermissionStatus>('asking');
const [working, setWorking] = useState(false);
const [title, setTitle] = useState<string>();
const [detail, setDetail] = useState<string>();
const run = useRef({ granted: 0, publish: false, skip: false, done: 0, id: 0 });
// the agent works through the frames under what it was given, and stops to ask when it reaches one it may not touch
const work = async () => {
const r = run.current, id = ++r.id;
setStatus('allowed'); setWorking(true); setTitle(undefined);
while (r.done < FRAMES.length) {
if (r.done === LIB && !r.publish && !r.skip) { setWorking(false); setMore(true); setValue(['publish']); setStatus('asking'); return; }
setDetail(r.done === LIB && r.skip ? `Skipping ${FRAMES[r.done]}` : `Editing ${FRAMES[r.done]} · ${r.done + 1} of ${FRAMES.length}`);
await wait(900); if (r.id !== id) return;
r.done++;
}
setWorking(false);
setTitle(`Done. ${r.skip ? FRAMES.length - 1 : FRAMES.length} frames edited`);
setDetail(r.skip ? 'On a new page. Plan toggle skipped' : 'On a new page. Plan toggle published');
};
// the preview's story: the person ticks the risky scope, reads what it touches, leaves it off, allows, then grants it for one frame
useStory(ref, async ({ wait, press }) => {
await wait(1500); setValue(['read', 'edit', 'publish']);
await wait(2500); setValue(['read', 'edit']);
await wait(1000); press('.dm-pgx-ok');
await wait(500 + 4 * 900 + 2000); press('.dm-pgx-ok');
});
const r = run.current;
return (
<div ref={ref} style={{ width: '100%' }}>
<PermissionGate icon={<Icon name="figma" />} durationDetails={{ 'This task': 'Until the pricing fixes are done', Today: 'Until midnight', Always: 'Until you revoke it' }}
title={more ? 'Also allow Publish library?' : 'Allow the agent to edit Figma?'}
subtitle={more ? `${FRAMES[LIB]}, frame ${LIB + 1} of ${FRAMES.length}, is a library component` : 'It needs this to apply the pricing fixes'}
scopes={more ? MORE : FIRST} value={value} onValueChange={setValue} duration={duration} onDurationChange={setDuration}
status={status} onStatusChange={setStatus} followUp={more} declineLabel={more ? 'Skip this frame' : 'Not now'}
onAllow={async keys => { r.granted += keys.length; if (keys.includes('publish')) r.publish = true; await wait(500); setMore(false); void work(); }}
onDecline={() => { if (!more) return; r.skip = true; setMore(false); void work(); }}
onRevoke={() => { run.current = { granted: 0, publish: false, skip: false, done: 0, id: r.id + 1 }; setValue(['read', 'edit']); setWorking(false); }}
working={working} allowedDetail={detail}
allowedTitle={title ?? `Allowed ${r.granted} ${r.granted > 1 ? 'scopes' : 'scope'} ${duration === 'Always' ? 'always' : 'for ' + duration.toLowerCase()}`}
declinedTitle="The agent will skip the Figma edits" declinedDetail="It will list the fixes in chat instead" declinedSummary="Nothing allowed in Figma" />
</div>
);
}
Astro
In a page in src/pages. It plays the demo above; change its permission-gate.js to show your own data. Attributes like class go on its root element.
---
import PermissionGate from '../components/designme/permission-gate/PermissionGate.astro';
---
<PermissionGate />
<PermissionGate data-style="soft" class="my-class" />Props
Everything PermissionGate takes.
| Prop | Type | What it does |
|---|---|---|
titlerequired | ReactNode | The question, like "Allow the agent to edit Figma?" |
subtitle | ReactNode | Why it asks |
icon | ReactNode | Shown in the tile beside the question. Defaults to a shield |
scopesrequired | PermissionScope[] | |
value | string[] | Keys of the ticked scopes. Leave it out to let the checkboxes hold their own |
defaultValue | string[] | |
onValueChange | (keys: string[]) => void | |
durations | string[] | How long the permission lasts, picked from a small dropdown in the footer. Defaults to This task, Today and Always |
durationDetails | Record<string, string> | The quiet line under each duration in its menu, by duration, like { Today: 'Until midnight' } |
duration | string | |
defaultDuration | string | |
onDurationChange | (duration: string) => void | |
status | PermissionStatus | asking, allowed or declined. Leave it out to let the buttons move it |
defaultStatus | PermissionStatus | |
onStatusChange | (status: PermissionStatus) => void | |
onAllow | (keys: string[], duration: string) => void | Promise<void> | Called with the ticked scopes and the duration. Return a promise and the button spins until it settles |
onDecline | () => void | |
onRevoke | () => void | Called by Revoke, after allowing |
onUndo | () => void | Called by Undo, after declining |
allowedDetail | string | The line under "Allowed …", like "Applying the pricing fixes now". Crossfades when it changes |
allowedTitle | string | Replaces "Allowed 2 scopes for this task", like "Done. 6 frames edited". Crossfades when it changes |
working | boolean | The agent is still working under the permission: a spinner instead of the green check, on the same neutral row |
followUp | boolean | A follow-up ask in the middle of a run, for one more scope. A single scope shows as a row led by a tile (nothing to tick) with a plain Allow; the icon tile stays neutral, and the scope's risk tag carries the warning |
declineLabel | string | The decline button. Defaults to "Not now"; a follow-up ask might say "Skip this frame" |
declinedTitle | ReactNode | Shown after Not now |
declinedDetail | ReactNode | |
declinedSummary | string | Studio only: the line in the foot strip after Not now. Defaults to "Nothing allowed" |
bare | boolean | Draws its own container (the default, as on designme.dev). Set true to sit it flat in a chat thread |
className | string |
Code
The full source, as the CLI installs it.
PermissionGate.tsxReact · 220 lines
'use client';
import { useEffect, useRef, useState, type ReactNode } from 'react';
import { cx } from '../lib/cx';
import { useControllable, useIsoLayoutEffect, useReducedMotion } from '../lib/hooks';
import { Icon } from '../lib/icons';
import { enter, growFit, Spin, Swap, SwapIcon, Tip } from '../lib/motion';
import { usePopover } from '../lib/popover';
import '../designme.css';
// its menus' rows glide in Studio
import '../lib/glide';
import './permission-gate.css';
/** Something the agent is asking to be allowed to do */
export interface PermissionScope {
key: string;
/** Like "Edit frames" */
label: string;
/** The quiet line under it, like "Only on a new page" */
detail?: string;
/** A warning tag after it, like "Risky" */
risk?: string;
/** What the risk tag reveals on hover, like "Checkout, Marketing site, Email kit and Docs use this library" */
riskDetail?: string;
}
export type PermissionStatus = 'asking' | 'allowed' | 'declined';
export interface PermissionGateProps {
/** The question, like "Allow the agent to edit Figma?" */
title: ReactNode;
/** Why it asks */
subtitle?: ReactNode;
/** Shown in the tile beside the question. Defaults to a shield */
icon?: ReactNode;
scopes: PermissionScope[];
/** Keys of the ticked scopes. Leave it out to let the checkboxes hold their own */
value?: string[];
defaultValue?: string[];
onValueChange?: (keys: string[]) => void;
/** How long the permission lasts, picked from a small dropdown in the footer. Defaults to This task, Today and Always */
durations?: string[];
/** The quiet line under each duration in its menu, by duration, like { Today: 'Until midnight' } */
durationDetails?: Record<string, string>;
duration?: string;
defaultDuration?: string;
onDurationChange?: (duration: string) => void;
/** asking, allowed or declined. Leave it out to let the buttons move it */
status?: PermissionStatus;
defaultStatus?: PermissionStatus;
onStatusChange?: (status: PermissionStatus) => void;
/** Called with the ticked scopes and the duration. Return a promise and the button spins until it settles */
onAllow?: (keys: string[], duration: string) => void | Promise<void>;
onDecline?: () => void;
/** Called by Revoke, after allowing */
onRevoke?: () => void;
/** Called by Undo, after declining */
onUndo?: () => void;
/** The line under "Allowed …", like "Applying the pricing fixes now". Crossfades when it changes */
allowedDetail?: string;
/** Replaces "Allowed 2 scopes for this task", like "Done. 6 frames edited". Crossfades when it changes */
allowedTitle?: string;
/** The agent is still working under the permission: a spinner instead of the green check, on the same neutral row */
working?: boolean;
/** A follow-up ask in the middle of a run, for one more scope. A single scope shows as a row led by a tile (nothing to
* tick) with a plain Allow; the icon tile stays neutral, and the scope's risk tag carries the warning */
followUp?: boolean;
/** The decline button. Defaults to "Not now"; a follow-up ask might say "Skip this frame" */
declineLabel?: string;
/** Shown after Not now */
declinedTitle?: ReactNode;
declinedDetail?: ReactNode;
/** Studio only: the line in the foot strip after Not now. Defaults to "Nothing allowed" */
declinedSummary?: string;
/** Draws its own container (the default, as on designme.dev). Set true to sit it flat in a chat thread */
bare?: boolean;
className?: string;
}
const DURATIONS = ['This task', 'Today', 'Always'];
const DETAILS: Record<string, string> = { 'This task': 'Until the task is done', Today: 'Until midnight', Always: 'Until you revoke it' };
// "For this task" in the menu and "for this task" after Allowed; Always reads as it is
const durLabel = (d: string) => /^always$/i.test(d) ? d : 'For ' + d.toLowerCase();
const durSpan = (d: string) => /^always$/i.test(d) ? 'always' : 'for ' + d.toLowerCase();
const word = (n: number) => n > 1 ? 'scopes' : 'scope';
/** Studio's Allow: the number sits in a window of its own and a new count rolls in, up as a box is ticked, down as one clears */
function Count({ n }: { n: number }) {
const reduce = useReducedMotion();
const [items, setItems] = useState([{ n, cls: '', key: 0 }]);
const last = useRef(n);
useEffect(() => {
const was = last.current; if (n === was) return; last.current = n;
const up = n > was;
setItems(it => [{ ...it[it.length - 1], cls: up ? 'dm-ou' : 'dm-od' }, { n, cls: up ? 'dm-iu' : 'dm-id', key: it[it.length - 1].key + 1 }]);
const t = setTimeout(() => setItems(it => it.slice(-1)), reduce ? 0 : 300);
return () => clearTimeout(t);
}, [n, reduce]);
return <span className="dm-pgx-cnt">{items.map(i => <i key={i.key} className={i.cls || undefined}>{i.n}</i>)}</span>;
}
/** The agent asks before it acts: pick the scopes and how long they last, then allow or decline. */
export function PermissionGate({
title, subtitle, icon, scopes, value, defaultValue = [], onValueChange, durations = DURATIONS, durationDetails = DETAILS, duration, defaultDuration, onDurationChange,
status, defaultStatus = 'asking', onStatusChange, onAllow, onDecline, onRevoke, onUndo, allowedDetail, allowedTitle, working = false, followUp = false,
declineLabel = 'Not now', declinedTitle = 'The agent will skip these changes', declinedDetail, declinedSummary = 'Nothing allowed', bare = false, className
}: PermissionGateProps) {
const [ticked, setTicked] = useControllable(value, defaultValue, onValueChange);
const [dur, setDur] = useControllable(duration, defaultDuration ?? durations[0], onDurationChange);
const durMenu = usePopover();
const [state, setState] = useControllable(status, defaultStatus, onStatusChange);
const [waiting, setWaiting] = useState(false);
// a revoked permission fades out before the scopes come back
const [leaving, setLeaving] = useState(false);
// the scopes play their entrance when they come back, not when the card first appears
const [back, setBack] = useState(0);
const [granted, setGranted] = useState(0);
// the names of the scopes allowed, for Studio's summary line in the foot strip
const [names, setNames] = useState<string[]>([]);
// the gate never keeps a height, in any style (owner, 17 and 18 Nov): it grows and shrinks with what it holds, eased, as
// grow() does on the site
const root = useRef<HTMLDivElement>(null), inner = useRef<HTMLDivElement>(null);
const [studio, setStudio] = useState(false);
useIsoLayoutEffect(() => { setStudio(root.current?.closest('[data-style]')?.getAttribute('data-style') === 'studio'); }, []);
useIsoLayoutEffect(() => { const el = root.current, w = inner.current; if (el && w) return growFit(el, w); }, []);
// Studio: the scopes fade up and out before the card eases to the result row's height
const [fading, setFading] = useState(false);
// asking again for one scope: nothing to tick, so the scope is a row led by a tile like the question's, and the button
// just says Allow (every style)
const single = followUp && state === 'asking' && scopes.length === 1;
const keys = single ? [scopes[0].key] : ticked;
const n = keys.length;
useEffect(() => {
if (!leaving) return;
const t = setTimeout(() => { setLeaving(false); setState('asking'); setBack(b => b + 1); onRevoke?.(); }, 300);
return () => clearTimeout(t);
}, [leaving]); // eslint-disable-line react-hooks/exhaustive-deps
const toggle = (key: string) => setTicked(ticked.includes(key) ? ticked.filter(k => k !== key) : scopes.map(s => s.key).filter(k => k === key || ticked.includes(k)));
const allow = async () => {
if (!n || waiting) return;
setWaiting(true); setGranted(n); const picked = scopes.filter(s => keys.includes(s.key)).map(s => s.label); setNames(was => followUp ? [...was, ...picked] : picked);
try { await onAllow?.(keys, dur); } finally { setWaiting(false); }
if (studio) { setFading(true); await new Promise(r => setTimeout(r, 180)); setFading(false); }
setState('allowed');
};
const decline = () => { setState('declined'); onDecline?.(); };
const undo = () => { setState('asking'); setBack(b => b + 1); onUndo?.(); };
const again = (i: number, ms = i * 50) => (back ? { className: 'dm-enter', style: enter(ms).style, key: back } : { className: undefined, style: undefined, key: 0 });
// (in Studio the foot strip fades in once the card has grown to hold it, so no button shows cut off by the card's edge)
const foot = again(1, studio ? 400 : 50);
const allowLabel = n ? `Allow ${n} ${word(n)}` : 'Pick a scope';
return (
<div data-dm="" ref={root} className={cx('dm-pgx', !bare && 'dm-panel', 'dm-growing dm-mx-grow dm-mx-ic', followUp && state === 'asking' && 'dm-esc', className)}>
{/* grow()'s wrapper in Studio; elsewhere it takes no box of its own */}
<div ref={inner} className="dm-grow dm-dm-grow">
<div className="dm-pgx-h">
<span className="dm-pgx-ic">{icon ?? <Icon name="shield" />}</span>
<div className="dm-pgx-ht"><b>{title}</b>{subtitle && <span className="dm-muted">{subtitle}</span>}</div>
</div>
{state === 'asking' && (
<>
<div key={'sc' + again(0).key} className={cx('dm-pgx-sc', again(0).className, fading && 'dm-leave')} style={again(0).style}>
{scopes.map(s => {
const risk = s.risk && (s.riskDetail ? <Tip label={s.riskDetail}><span className="dm-tag dm-warn">{s.risk}</span></Tip> : <span className="dm-tag dm-warn">{s.risk}</span>);
const words = <span className="dm-t">{s.label}{s.detail && <span className="dm-d">{s.detail}</span>}</span>;
return single
? <div key={s.key} className="dm-pgx-o dm-one"><span className="dm-oi"><Icon name="upload" /></span>{words}{risk}</div>
: <label key={s.key} className="dm-pgx-o">
<input type="checkbox" checked={ticked.includes(s.key)} onChange={() => toggle(s.key)} />
<span className="dm-bx"><Icon name="check" size="xs" /></span>
{words}{risk}
</label>;
})}
</div>
<div key={'f' + foot.key} className={cx('dm-pgx-f', foot.className)} style={foot.style}>
<button {...durMenu.trigger} type="button" className="dm-pgx-db dm-mx-press" aria-label="How long"><Swap className="dm-pgx-dv dm-mx-w">{durLabel(dur)}</Swap><Icon name="chev-d" size="xs" /></button>
<span className="dm-sp" />
<button type="button" className="dm-pill dm-ghost dm-sm dm-pgx-no dm-mx-press" onClick={decline}>{declineLabel}</button>
<button type="button" className="dm-pill dm-primary dm-sm dm-pgx-ok" disabled={!n} onClick={allow}>
{waiting ? <Spin /> : single ? <Swap>Allow</Swap> : studio && n
? <span className="dm-pgx-l">Allow <Count n={n} /> <Swap className="dm-pgx-w">{word(n)}</Swap></span>
: <Swap className="dm-mx-w">{allowLabel}</Swap>}
</button>
</div>
</>
)}
<div {...durMenu.pop} className={cx(durMenu.pop.className, 'dm-pgx-pop dm-mx-pop dm-mx-rows dm-mx-glide')} role="menu" aria-label="How long">
{durations.map(d => (
<button key={d} type="button" className="dm-mi dm-mx-press" role="menuitemradio" aria-checked={d === dur} onClick={() => { setDur(d); durMenu.closeSoon(); }}>
<span>{durLabel(d)}{durationDetails[d] && <span className="dm-d">{durationDetails[d]}</span>}</span><span className="dm-ck"><Icon name="check" size="xs" /></span>
</button>
))}
</div>
{state === 'allowed' && (
<div className={cx('dm-pgx-done', working ? 'dm-run' : 'dm-ok', leaving ? 'dm-leave' : 'dm-enter')}>
<span className="dm-g"><SwapIcon id={working ? 'spin' : 'done'}>{working ? <Spin /> : <Icon name={studio ? 'check' : 'ok'} />}</SwapIcon></span>
<span className="dm-t">
<b className="dm-pgx-a"><Swap>{allowedTitle ?? `Allowed ${granted || n} ${(granted || n) > 1 ? 'scopes' : 'scope'} ${durSpan(dur)}`}</Swap></b>
{allowedDetail !== undefined && <Swap>{allowedDetail}</Swap>}
</span>
<button type="button" className="dm-pill dm-line dm-sm dm-mx-press" onClick={() => setLeaving(true)}>Revoke</button>
<span className="dm-pgx-sum"><span className="dm-l">{names.join(', ')}</span><span className="dm-s">{`${names.length} ${word(names.length)} allowed`}</span></span>
</div>
)}
{state === 'declined' && (
<div className="dm-pgx-done dm-enter" style={{ background: 'var(--dm-chip)' }}>
<Icon name="info" />
<span className="dm-t">{declinedTitle}{declinedDetail && <span>{declinedDetail}</span>}</span>
<button type="button" className="dm-pill dm-line dm-sm dm-mx-press" onClick={undo}>Undo</button>
<span className="dm-pgx-sum"><span className="dm-l">{declinedSummary}</span><span className="dm-s">{declinedSummary}</span></span>
</div>
)}
</div>
</div>
);
}
permission-gate.cssReact · 149 lines
/* Generated from designme.dev by scripts/sync.mjs. Edit the site, then sync. */
/* ---------- Permission gate ---------- */
/* the agent asks in the chat as one card: the question, the scopes to tick, and a footer with how long and the two
answers. Without .panel it sits flat in the thread */
.dm-pgx{position:relative;width:100%;max-width:400px;margin:0 auto;padding:var(--dm-s-1) 0;display:flex;flex-direction:column;gap:var(--dm-s-3)}
.dm-pgx.dm-panel{padding:var(--dm-s-4)}
/* its motion (the core's motion pieces, owner, 26 Nov): How long's menu grows out of its button and goes back quicker, its
rows settle one after another and one highlight glides between them; a press shows at once (.mx-press, no scale); How
long's words and Allow ease their box to the new width (.mx-w); the spinner crossfades to the done mark (.mx-ic); and the
card eases to each new height on the spring (.mx-grow) */
.dm-pgx-h{display:flex;gap:var(--dm-s-3);align-items:center}
.dm-pgx-ic{width:32px;height:32px;border-radius:calc(9px * var(--dm-rk-m,var(--dm-rk)));background:var(--dm-chip);display:grid;place-items:center;flex:none}
.dm-pgx-ht{display:flex;flex-direction:column;min-width:0}
.dm-pgx-ht b{font-weight:500;font-size:14px}
.dm-pgx-ht span{font-size:13px}
/* the scopes line up with the head (owner, 18 Nov): each box centred in a 32px column under the icon tile, its words where the
question's start, and a tag at the row's end on the right edge the buttons below end on. The row's hover fill reaches 8px
out round it, into the padding (owner, 26 Nov) */
.dm-pgx-sc{display:flex;flex-direction:column}
.dm-pgx-o{display:grid;grid-template-columns:32px minmax(0,1fr) auto;align-items:center;column-gap:var(--dm-s-3);margin-inline:calc(-1 * var(--dm-s-2));padding:var(--dm-s-2);border-radius:calc(10px * var(--dm-rk-m,var(--dm-rk)));cursor:pointer;font-size:13.5px;transition:background .25s}
.dm-pgx-o>.dm-bx{justify-self:center}
@media (hover:hover) and (pointer:fine){.dm-pgx-o:hover{background:var(--dm-row)}}
.dm-pgx-o input{position:absolute;opacity:0;pointer-events:none}
.dm-pgx-o .dm-bx{width:18px;height:18px;border-radius:calc(6px * var(--dm-rk-s,var(--dm-rk)));box-shadow:inset 0 0 0 1.5px var(--dm-fg2);display:grid;place-items:center;color:transparent;flex:none;transition:background .3s var(--dm-ease),box-shadow .3s,color .3s}
.dm-pgx-o .dm-bx svg{transform:scale(.4);transition:transform .35s var(--dm-ease)}
.dm-pgx-o input:checked+.dm-bx{background:var(--dm-accent);box-shadow:inset 0 0 0 1.5px var(--dm-accent-mark,var(--dm-accent));color:var(--dm-on-accent)}
.dm-pgx-o input:checked+.dm-bx svg{transform:none}
.dm-pgx-o input:focus-visible+.dm-bx{outline:2px solid var(--dm-focus);outline-offset:2px}
.dm-pgx-o .dm-t{flex:1;min-width:0}
/* asking again for one scope, every style: nothing to tick, so the scope is a plain row led by a tile like the question's
(what it does, in the same 32px column) and the button just says Allow (owner, 18 Nov) */
.dm-pgx-o.dm-one{cursor:default}
@media (hover:hover) and (pointer:fine){.dm-pgx-o.dm-one:hover{background:none}}
.dm-pgx-o.dm-one>.dm-oi{width:32px;height:32px;display:grid;place-items:center;border-radius:calc(9px * var(--dm-rk-m,var(--dm-rk)));background:var(--dm-chip);color:var(--dm-fg2)}
:root[data-style="studio"] .dm-pgx-o.dm-one>.dm-oi,:root [data-style="studio"] .dm-pgx-o.dm-one>.dm-oi,:root [data-style="studio"].dm-pgx-o.dm-one>.dm-oi{box-shadow:inset 0 0 0 1px var(--dm-hair)}
.dm-pgx-o .dm-d{display:block;font-size:12px;color:var(--dm-muted)}
.dm-pgx-f{display:flex;align-items:center;gap:6px;padding-top:var(--dm-s-4);border-top:1px solid color-mix(in srgb,var(--dm-line) 50%,transparent)}
.dm-pgx-f .dm-sp{flex:1}
/* on a narrow stage the duration gets its own row, and the two buttons stay together under it on the right */
@container (max-width:340px){.dm-pgx-f{flex-wrap:wrap;padding-top:var(--dm-s-3)}.dm-pgx-f .dm-sp{flex-basis:100%}.dm-pgx-no{margin:var(--dm-s-2) 0 0 auto}.dm-pgx-ok{margin-top:var(--dm-s-2)}}
/* how long: a small dropdown, the way a menu of choices usually looks */
.dm-pgx-db{display:inline-flex;align-items:center;gap:6px;height:28px;padding:0 var(--dm-s-2) 0 10px;margin-left:0;border-radius:var(--dm-r-pill);font-size:13px;color:var(--dm-fg2);white-space:nowrap;transition:background .16s,color .16s}
.dm-pgx-db[aria-expanded="true"]{background:var(--dm-row);color:var(--dm-fg)}
@media (hover:hover) and (pointer:fine){.dm-pgx-db:hover{background:var(--dm-row);color:var(--dm-fg)}}
.dm-pgx-db>svg{color:var(--dm-muted);transition:transform .32s var(--dm-ease)}
.dm-pgx-db[aria-expanded="true"]>svg{transform:rotate(180deg)}
.dm-pgx-pop{min-width:230px}
.dm-pgx-ok[disabled]{opacity:1;cursor:not-allowed;background:var(--dm-dis-hatch),var(--dm-dis-fill);color:var(--dm-dis);box-shadow:var(--dm-soft-ring)}
.dm-pgx-done{display:flex;align-items:center;gap:var(--dm-s-3);padding:10px 7px 10px 0;border-radius:var(--dm-r-in);background:var(--dm-chip);font-size:13.5px}
/* its mark sits centred in the scopes' 32px column, under the head's tile, and its words start on the title's column */
.dm-pgx-done>svg{margin-inline:8px}
/* on a phone the answered row wraps to a small card: its words and its button 16px from its top, bottom and right; its mark
stays centred under the head's tile */
@container (max-width:340px){.dm-pgx-done{padding:var(--dm-s-4) var(--dm-s-4) var(--dm-s-4) 0}}
/* its button is a white pill on the grey row */
.dm-pgx-done .dm-pill{background:var(--dm-surface);color:var(--dm-fg);box-shadow:var(--dm-on-tint-btn)}
@media (hover:hover) and (pointer:fine){.dm-pgx-done .dm-pill:hover{background:var(--dm-surface);box-shadow:var(--dm-on-tint-btn-h)}}
.dm-pgx-done .dm-t{flex:1;color:var(--dm-fg)}
.dm-pgx-done .dm-t span{display:block;font-size:12px;color:var(--dm-fg2)}
.dm-pgx-done>svg{color:var(--dm-ok)}
/* while the agent works under the permission: a neutral row with a spinner and a live line. Once done the spinner becomes the
green tick and the row stays neutral: no green fill and no clock (owner, 18 Nov) */
.dm-pgx-done .dm-g{width:32px;height:18px;display:grid;place-items:center;flex:none;color:var(--dm-fg2)}
.dm-pgx-done.dm-ok .dm-g{color:var(--dm-ok)}
.dm-pgx-done .dm-t b{display:block;font-weight:400}
/* asking again mid-run, for one more scope: the tile turns amber */
.dm-pgx-ic{transition:background .32s var(--dm-ease)}
/* asking again keeps the tile neutral in every style: the Risky tag on the scope carries the warning (owner, 18 Nov) */
.dm-pgx-scope{display:flex;flex-direction:column;gap:var(--dm-s-3)}
/* the line in the foot strip once you have answered (Studio only): the scopes you allowed, or that you allowed none */
.dm-pgx-sum{display:none}
/* Studio (owner, 18 Nov): a card with the question, the scopes and an off-white foot strip. Its content sits 16px from
every edge; the controls in the strip sit 16px from the card's sides and bottom and from the strip's hairline (owner,
23 Nov), and the duration select lines up with the content above by its text, not its hover box. The ticks are
ink and draw in, the count on Allow rolls as boxes are ticked, and once you answer the scopes fold into one summary line
in the strip while the card eases to its new height (grow(), centred in its stage). Its height is never kept */
/* the card clips its strips to its round corners; the duration menu opens out of it (nothing changes height while it is open) */
:root[data-style="studio"] .dm-pgx.dm-panel,:root [data-style="studio"] .dm-pgx.dm-panel,:root [data-style="studio"].dm-pgx.dm-panel{padding:16px 16px 0;overflow:clip;overflow-clip-margin:0px}
:root[data-style="studio"] .dm-pgx.dm-panel:has(.dm-pgx-pop.dm-open),:root [data-style="studio"] .dm-pgx.dm-panel:has(.dm-pgx-pop.dm-open),:root [data-style="studio"].dm-pgx.dm-panel:has(.dm-pgx-pop.dm-open){overflow:visible}
:root[data-style="studio"] .dm-pgx-ic,:root [data-style="studio"] .dm-pgx-ic,:root [data-style="studio"].dm-pgx-ic{box-shadow:inset 0 0 0 1px var(--dm-hair)}
/* asking again keeps the tile neutral: the Risky tag on the scope carries the warning */
:root[data-style="studio"] .dm-pgx-ht b,:root [data-style="studio"] .dm-pgx-ht b,:root [data-style="studio"].dm-pgx-ht b{line-height:20px;letter-spacing:-.01em}
:root[data-style="studio"] .dm-pgx-ht span,:root [data-style="studio"] .dm-pgx-ht span,:root [data-style="studio"].dm-pgx-ht span,:root[data-style="studio"] .dm-pgx-o .dm-d,:root [data-style="studio"] .dm-pgx-o .dm-d,:root [data-style="studio"].dm-pgx-o .dm-d,:root[data-style="studio"] .dm-pgx-done .dm-t span,:root [data-style="studio"] .dm-pgx-done .dm-t span,:root [data-style="studio"].dm-pgx-done .dm-t span{line-height:18px}
:root[data-style="studio"] :is(.dm-pgx-o,.dm-pgx-done) .dm-t,:root [data-style="studio"] :is(.dm-pgx-o,.dm-pgx-done) .dm-t,:root [data-style="studio"]:is(.dm-pgx-o,.dm-pgx-done) .dm-t{line-height:20px}
/* a scope row: its box in a 32px column under the question's tile, centred, so its words start where the question's do;
hairlines between rows, which give way to the quiet fill of the row under the pointer */
:root[data-style="studio"] .dm-pgx-o,:root [data-style="studio"] .dm-pgx-o,:root [data-style="studio"].dm-pgx-o{position:relative;display:grid;grid-template-columns:32px minmax(0,1fr) auto;column-gap:12px;transition:background-color var(--dm-t-fast) var(--dm-ease)}
:root[data-style="studio"] .dm-pgx-o>.dm-bx,:root [data-style="studio"] .dm-pgx-o>.dm-bx,:root [data-style="studio"].dm-pgx-o>.dm-bx{justify-self:center}
:root[data-style="studio"] .dm-pgx-o+.dm-pgx-o,:root [data-style="studio"] .dm-pgx-o+.dm-pgx-o,:root [data-style="studio"].dm-pgx-o+.dm-pgx-o{background-image:linear-gradient(var(--dm-hair),var(--dm-hair));background-repeat:no-repeat;background-position:var(--dm-s-2) 0;background-size:calc(100% - 2 * var(--dm-s-2)) 1px}
@media (hover:hover) and (pointer:fine){:root[data-style="studio"] :is(.dm-pgx-o:hover,.dm-pgx-o:hover+.dm-pgx-o),:root [data-style="studio"] :is(.dm-pgx-o:hover,.dm-pgx-o:hover+.dm-pgx-o),:root [data-style="studio"]:is(.dm-pgx-o:hover,.dm-pgx-o:hover+.dm-pgx-o){background-image:none}}
/* asking again for one scope: nothing to tick, so the scope is an info row, its info mark where the box would be */
:root[data-style="studio"] .dm-pgx-o .dm-bx,:root [data-style="studio"] .dm-pgx-o .dm-bx,:root [data-style="studio"].dm-pgx-o .dm-bx{border-radius:calc(4px * var(--dm-rk-s,var(--dm-rk)));background:var(--dm-surface);box-shadow:inset 0 0 0 1.5px var(--dm-fg2),var(--dm-track-ring);transition:background .2s var(--dm-ease),box-shadow .2s var(--dm-ease)}
:root[data-style="studio"] .dm-pgx-o .dm-bx svg,:root [data-style="studio"] .dm-pgx-o .dm-bx svg,:root [data-style="studio"].dm-pgx-o .dm-bx svg{transform:none;stroke-dasharray:21;stroke-dashoffset:21;transition:stroke-dashoffset .3s var(--dm-ease)}
:root[data-style="studio"] .dm-pgx-o input:checked+.dm-bx,:root [data-style="studio"] .dm-pgx-o input:checked+.dm-bx,:root [data-style="studio"].dm-pgx-o input:checked+.dm-bx{background:linear-gradient(180deg,var(--dm-btn-1),var(--dm-btn-2));box-shadow:inset 0 0 0 1px var(--dm-btn-2),inset 0 2px 3px -1px rgba(255,255,255,.28);color:var(--dm-on-btn)}
:root[data-style="studio"] .dm-pgx-o input:checked+.dm-bx svg,:root [data-style="studio"] .dm-pgx-o input:checked+.dm-bx svg,:root [data-style="studio"].dm-pgx-o input:checked+.dm-bx svg{stroke-dashoffset:0;transition-delay:.06s}
:root[data-style="studio"] .dm-pgx-o:active .dm-bx,:root [data-style="studio"] .dm-pgx-o:active .dm-bx,:root [data-style="studio"].dm-pgx-o:active .dm-bx{transform:scale(.94);transition:transform var(--dm-t-fast) var(--dm-ease)}
/* the foot strip: 16px round its 28px controls (owner, 23 Nov), so it is 61px tall with its hairline; the scopes end 16px above it (their
rows keep 8px of hover room below the text). Lines are whole pixels, so the card's edge meets the strip's exactly */
:root[data-style="studio"] .dm-pgx.dm-panel .dm-pgx-sc,:root [data-style="studio"] .dm-pgx.dm-panel .dm-pgx-sc,:root [data-style="studio"].dm-pgx.dm-panel .dm-pgx-sc{margin-bottom:-4px}
:root[data-style="studio"] .dm-pgx.dm-panel .dm-pgx-f,:root [data-style="studio"] .dm-pgx.dm-panel .dm-pgx-f,:root [data-style="studio"].dm-pgx.dm-panel .dm-pgx-f{margin:0 -16px;padding:var(--dm-strip-y) 16px;gap:4px;border-top:1px solid var(--dm-line);background:var(--dm-strip);border-radius:0 0 var(--dm-r-card) var(--dm-r-card)}
/* when you ask again the strip comes back as a fade, after the card has grown to hold it (its script waits): rising from below,
it would show its buttons cut off by the card's edge while the card grows */
:root[data-style="studio"] .dm-pgx.dm-panel .dm-pgx-f.dm-enter,:root [data-style="studio"] .dm-pgx.dm-panel .dm-pgx-f.dm-enter,:root [data-style="studio"].dm-pgx.dm-panel .dm-pgx-f.dm-enter{animation-name:dm-pgxfoot}
@keyframes dm-pgxfoot{from{opacity:0}}
:root[data-style="studio"] .dm-pgx-f .dm-pgx-db,:root [data-style="studio"] .dm-pgx-f .dm-pgx-db,:root [data-style="studio"].dm-pgx-f .dm-pgx-db{padding:0 8px;margin:0;color:var(--dm-fg2);transition:background-color var(--dm-t-fast) var(--dm-ease),color var(--dm-t-fast) var(--dm-ease)}
@media (hover:hover) and (pointer:fine){:root[data-style="studio"] .dm-pgx-f :is(.dm-pgx-db:hover,.dm-pill.dm-ghost:hover),:root [data-style="studio"] .dm-pgx-f :is(.dm-pgx-db:hover,.dm-pill.dm-ghost:hover),:root [data-style="studio"].dm-pgx-f :is(.dm-pgx-db:hover,.dm-pill.dm-ghost:hover){background:var(--dm-row);color:var(--dm-fg)}}
:root[data-style="studio"] .dm-pgx-f :is(.dm-pgx-db,.dm-pill.dm-ghost).dm-mx-press:active,:root [data-style="studio"] .dm-pgx-f :is(.dm-pgx-db,.dm-pill.dm-ghost).dm-mx-press:active,:root [data-style="studio"].dm-pgx-f :is(.dm-pgx-db,.dm-pill.dm-ghost).dm-mx-press:active{background:var(--dm-row-press)}
:root[data-style="studio"] .dm-pgx-f .dm-pgx-db[aria-expanded="true"],:root [data-style="studio"] .dm-pgx-f .dm-pgx-db[aria-expanded="true"],:root [data-style="studio"].dm-pgx-f .dm-pgx-db[aria-expanded="true"]{background:var(--dm-row-on);color:var(--dm-fg)}
/* on a narrow stage the buttons wrap under the select: the strip's 4px gaps put them 8px under it */
@container (max-width:340px){:root[data-style="studio"] .dm-pgx-no,:root [data-style="studio"] .dm-pgx-no,:root [data-style="studio"].dm-pgx-no{margin:0 0 0 auto}:root[data-style="studio"] .dm-pgx-ok,:root [data-style="studio"] .dm-pgx-ok,:root [data-style="studio"].dm-pgx-ok{margin-top:0}}
/* Allow's count rolls: up as a box is ticked, down as one is cleared. No window clips it: each number moves a few pixels
and fades, so a digit is never seen cut in half */
:root[data-style="studio"] .dm-pgx-cnt,:root [data-style="studio"] .dm-pgx-cnt,:root [data-style="studio"].dm-pgx-cnt{display:inline-grid}
:root[data-style="studio"] .dm-pgx-cnt>i,:root [data-style="studio"] .dm-pgx-cnt>i,:root [data-style="studio"].dm-pgx-cnt>i{grid-area:1/1;font-style:normal;font-variant-numeric:tabular-nums}
@keyframes dm-pgxiu{from{transform:translateY(40%);opacity:0}}
@keyframes dm-pgxou{to{transform:translateY(-40%);opacity:0}}
@keyframes dm-pgxid{from{transform:translateY(-40%);opacity:0}}
@keyframes dm-pgxod{to{transform:translateY(40%);opacity:0}}
/* the old number leaves first and the new one follows, so the two never sit on top of each other */
:root[data-style="studio"] .dm-pgx-cnt>.dm-iu,:root [data-style="studio"] .dm-pgx-cnt>.dm-iu,:root [data-style="studio"].dm-pgx-cnt>.dm-iu{animation:dm-pgxiu .22s var(--dm-ease) .1s both}
:root[data-style="studio"] .dm-pgx-cnt>.dm-ou,:root [data-style="studio"] .dm-pgx-cnt>.dm-ou,:root [data-style="studio"].dm-pgx-cnt>.dm-ou{animation:dm-pgxou .16s var(--dm-ease) both}
:root[data-style="studio"] .dm-pgx-cnt>.dm-id,:root [data-style="studio"] .dm-pgx-cnt>.dm-id,:root [data-style="studio"].dm-pgx-cnt>.dm-id{animation:dm-pgxid .22s var(--dm-ease) .1s both}
:root[data-style="studio"] .dm-pgx-cnt>.dm-od,:root [data-style="studio"] .dm-pgx-cnt>.dm-od,:root [data-style="studio"].dm-pgx-cnt>.dm-od{animation:dm-pgxod .16s var(--dm-ease) both}
/* answered: the result line where the scopes were (a 32px mark under the question's tile, the words under the question's
words, the clock on the right), then the strip with the summary and Revoke or Undo in the corner */
:root[data-style="studio"] .dm-pgx.dm-panel .dm-pgx-done,:root [data-style="studio"] .dm-pgx.dm-panel .dm-pgx-done,:root [data-style="studio"].dm-pgx.dm-panel .dm-pgx-done{display:grid;grid-template-columns:32px minmax(0,1fr) auto;grid-template-rows:auto calc(28px + 2 * var(--dm-strip-y) + 1px);column-gap:12px;row-gap:16px;align-items:center;padding:0;border-radius:0;background:none!important}
:root[data-style="studio"] .dm-pgx.dm-panel .dm-pgx-done>:is(.dm-g,svg),:root [data-style="studio"] .dm-pgx.dm-panel .dm-pgx-done>:is(.dm-g,svg),:root [data-style="studio"].dm-pgx.dm-panel .dm-pgx-done>:is(.dm-g,svg){grid-area:1/1}
:root[data-style="studio"] .dm-pgx.dm-panel .dm-pgx-done>.dm-t,:root [data-style="studio"] .dm-pgx.dm-panel .dm-pgx-done>.dm-t,:root [data-style="studio"].dm-pgx.dm-panel .dm-pgx-done>.dm-t{grid-area:1/2}
:root[data-style="studio"] .dm-pgx.dm-panel .dm-pgx-done .dm-t b,:root [data-style="studio"] .dm-pgx.dm-panel .dm-pgx-done .dm-t b,:root [data-style="studio"].dm-pgx.dm-panel .dm-pgx-done .dm-t b{font-weight:500}
:root[data-style="studio"] .dm-pgx.dm-panel .dm-pgx-done .dm-t b span,:root [data-style="studio"] .dm-pgx.dm-panel .dm-pgx-done .dm-t b span,:root [data-style="studio"].dm-pgx.dm-panel .dm-pgx-done .dm-t b span{font-size:inherit;line-height:inherit;color:inherit}
:root[data-style="studio"] .dm-pgx.dm-panel .dm-pgx-done .dm-t span,:root [data-style="studio"] .dm-pgx.dm-panel .dm-pgx-done .dm-t span,:root [data-style="studio"].dm-pgx.dm-panel .dm-pgx-done .dm-t span{color:var(--dm-muted)}
:root[data-style="studio"] .dm-pgx.dm-panel .dm-pgx-done>.dm-pill,:root [data-style="studio"] .dm-pgx.dm-panel .dm-pgx-done>.dm-pill,:root [data-style="studio"].dm-pgx.dm-panel .dm-pgx-done>.dm-pill{grid-area:2/3;z-index:1;align-self:end;margin:0 0 var(--dm-strip-y) 0;color:var(--dm-fg);background:linear-gradient(180deg,var(--dm-btn2-1),var(--dm-btn2-2));box-shadow:var(--dm-btn2-depth)}
@media (hover:hover) and (pointer:fine){:root[data-style="studio"] .dm-pgx.dm-panel .dm-pgx-done>.dm-pill:hover,:root [data-style="studio"] .dm-pgx.dm-panel .dm-pgx-done>.dm-pill:hover,:root [data-style="studio"].dm-pgx.dm-panel .dm-pgx-done>.dm-pill:hover{background:linear-gradient(180deg,var(--dm-btn2-1),var(--dm-btn2-2));box-shadow:var(--dm-btn2-hover)}}
:root[data-style="studio"] .dm-pgx.dm-panel .dm-pgx-done>.dm-pill:active,:root [data-style="studio"] .dm-pgx.dm-panel .dm-pgx-done>.dm-pill:active,:root [data-style="studio"].dm-pgx.dm-panel .dm-pgx-done>.dm-pill:active{box-shadow:var(--dm-btn2-press)}
/* the strip is the summary line itself, edge to edge; Revoke or Undo sits on its right end. Its colour reaches 240px below
the card's edge (clipped there), so while the card eases shorter no empty band shows under it */
:root[data-style="studio"] .dm-pgx.dm-panel .dm-pgx-sum,:root [data-style="studio"] .dm-pgx.dm-panel .dm-pgx-sum,:root [data-style="studio"].dm-pgx.dm-panel .dm-pgx-sum{display:block;grid-area:2/1/3/-1;align-self:stretch;margin:0 -16px -240px;padding:var(--dm-strip-y) 104px calc(240px + var(--dm-strip-y)) 16px;border-top:1px solid var(--dm-line);background:var(--dm-strip);line-height:28px;font-size:12.5px;color:var(--dm-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
:root[data-style="studio"] .dm-pgx-sum .dm-s,:root [data-style="studio"] .dm-pgx-sum .dm-s,:root [data-style="studio"].dm-pgx-sum .dm-s{display:none}
@container (max-width:340px){:root[data-style="studio"] .dm-pgx-sum .dm-l,:root [data-style="studio"] .dm-pgx-sum .dm-l,:root [data-style="studio"].dm-pgx-sum .dm-l{display:none}:root[data-style="studio"] .dm-pgx-sum .dm-s,:root [data-style="studio"] .dm-pgx-sum .dm-s,:root [data-style="studio"].dm-pgx-sum .dm-s{display:inline}}
/* the mark: a neutral circle with the spinner while the agent works; done, its ring turns green and the tick draws in */
:root[data-style="studio"] .dm-pgx.dm-panel .dm-pgx-done .dm-g,:root [data-style="studio"] .dm-pgx.dm-panel .dm-pgx-done .dm-g,:root [data-style="studio"].dm-pgx.dm-panel .dm-pgx-done .dm-g{width:32px;height:32px;border-radius:50%;background:var(--dm-chip);box-shadow:inset 0 0 0 1px var(--dm-hair);color:var(--dm-fg2);transition:background-color .3s var(--dm-ease),box-shadow .3s var(--dm-ease)}
:root[data-style="studio"] .dm-pgx.dm-panel .dm-pgx-done.dm-ok .dm-g,:root [data-style="studio"] .dm-pgx.dm-panel .dm-pgx-done.dm-ok .dm-g,:root [data-style="studio"].dm-pgx.dm-panel .dm-pgx-done.dm-ok .dm-g{background:var(--dm-surface);box-shadow:inset 0 0 0 1.5px var(--dm-ok-mark);color:var(--dm-ok-mark)}
:root[data-style="studio"] .dm-pgx.dm-panel .dm-pgx-done.dm-ok .dm-g svg,:root [data-style="studio"] .dm-pgx.dm-panel .dm-pgx-done.dm-ok .dm-g svg,:root [data-style="studio"].dm-pgx.dm-panel .dm-pgx-done.dm-ok .dm-g svg{width:16px;height:16px;stroke-width:2;stroke-dasharray:21;animation:dm-pgxdraw .5s var(--dm-ease) .12s both}
@keyframes dm-pgxdraw{from{stroke-dashoffset:21}to{stroke-dashoffset:0}}
:root[data-style="studio"] .dm-pgx.dm-panel .dm-pgx-done>svg,:root [data-style="studio"] .dm-pgx.dm-panel .dm-pgx-done>svg,:root [data-style="studio"].dm-pgx.dm-panel .dm-pgx-done>svg{width:32px;height:32px;margin:0;padding:8px;box-sizing:border-box;border-radius:50%;background:var(--dm-chip);box-shadow:inset 0 0 0 1px var(--dm-hair);color:var(--dm-fg2)}
@media (prefers-reduced-motion:reduce){:root[data-style="studio"] :is(.dm-pgx-o .dm-bx,.dm-pgx-o .dm-bx svg,.dm-pgx-done .dm-g),:root [data-style="studio"] :is(.dm-pgx-o .dm-bx,.dm-pgx-o .dm-bx svg,.dm-pgx-done .dm-g),:root [data-style="studio"]:is(.dm-pgx-o .dm-bx,.dm-pgx-o .dm-bx svg,.dm-pgx-done .dm-g){transition:none}:root[data-style="studio"] :is(.dm-pgx-cnt>i,.dm-pgx-done.dm-ok .dm-g svg),:root [data-style="studio"] :is(.dm-pgx-cnt>i,.dm-pgx-done.dm-ok .dm-g svg),:root [data-style="studio"]:is(.dm-pgx-cnt>i,.dm-pgx-done.dm-ok .dm-g svg){animation:none}}
PermissionGate.astroAstro · 37 lines
---
// Generated from designme.dev by scripts/sync.mjs. Edit the site, then sync.
// Permission gate: The agent asks before it touches something new.
// The markup, CSS and script are designme.dev's own, run by the shared core in ../core, which mounts the component when it scrolls
// into view and plays its demo. To show your own data, change permission-gate.js. The markup is kept exactly as it is (is:raw).
import type { HTMLAttributes } from 'astro/types';
import '../core/designme.css';
import './permission-gate.css';
export interface Props extends HTMLAttributes<'div'> {
/** "soft" or "studio" draws it in that style. Leave it out for Blueprint, or for the style set on <html> (data-style="soft" or "studio") */
'data-style'?: 'soft' | 'studio';
}
const { class: className, ...rest } = Astro.props;
---
<div class:list={['card', className]} data-c="permission-gate" {...rest}>
<div class="stage-in"><Fragment is:raw>
<div class="pgx panel mx-grow mx-ic">
<div class="pgx-h"><span class="pgx-ic"><svg class="i s"><use href="#i-figma"/></svg></span><div class="pgx-ht"><b>Allow the agent to edit Figma?</b><span class="muted">It needs this to apply the pricing fixes</span></div></div>
<div class="pgx-sc">
<label class="pgx-o" data-k="read"><input type="checkbox" checked><span class="bx"><svg class="i xs"><use href="#i-check"/></svg></span><span class="t">Read frames<span class="d">Pricing, Checkout</span></span></label>
<label class="pgx-o" data-k="edit"><input type="checkbox" checked><span class="bx"><svg class="i xs"><use href="#i-check"/></svg></span><span class="t">Edit frames<span class="d">Only on a new page</span></span></label>
<label class="pgx-o" data-k="publish"><input type="checkbox"><span class="bx"><svg class="i xs"><use href="#i-check"/></svg></span><span class="t">Publish library<span class="d">Affects 4 other files</span></span><span class="tag warn" data-tip="Checkout, Marketing site, Email kit and Docs use this library">Risky</span></label>
</div>
<div class="pgx-f"><button class="pgx-db mx-press" aria-haspopup="menu" aria-expanded="false" aria-label="How long" data-pop=".pgx-pop"><span class="pgx-dv mx-w">For this task</span><svg class="i xs"><use href="#i-chev-d"/></svg></button><span class="sp"></span><button class="pill ghost sm pgx-no mx-press">Not now</button><button class="pill primary sm pgx-ok mx-w">Allow 2 scopes</button></div>
<div class="pop pgx-pop mx-pop mx-rows mx-glide" role="menu" aria-label="How long">
<button class="mi mx-press" role="menuitemradio" aria-checked="true" data-close data-v="This task"><span>For this task<span class="d">Until the pricing fixes are done</span></span><span class="ck"><svg class="i xs"><use href="#i-check"/></svg></span></button>
<button class="mi mx-press" role="menuitemradio" aria-checked="false" data-close data-v="Today"><span>For today<span class="d">Until midnight</span></span><span class="ck"><svg class="i xs"><use href="#i-check"/></svg></span></button>
<button class="mi mx-press" role="menuitemradio" aria-checked="false" data-close data-v="Always"><span>Always<span class="d">Until you revoke it</span></span><span class="ck"><svg class="i xs"><use href="#i-check"/></svg></span></button>
</div>
</div>
</Fragment></div>
</div>
<script>
import './permission-gate.js';
</script>
permission-gate.htmlHTML · 19 lines
<div class="card" data-c="permission-gate">
<div class="stage-in">
<div class="pgx panel mx-grow mx-ic">
<div class="pgx-h"><span class="pgx-ic"><svg class="i s"><use href="#i-figma"/></svg></span><div class="pgx-ht"><b>Allow the agent to edit Figma?</b><span class="muted">It needs this to apply the pricing fixes</span></div></div>
<div class="pgx-sc">
<label class="pgx-o" data-k="read"><input type="checkbox" checked><span class="bx"><svg class="i xs"><use href="#i-check"/></svg></span><span class="t">Read frames<span class="d">Pricing, Checkout</span></span></label>
<label class="pgx-o" data-k="edit"><input type="checkbox" checked><span class="bx"><svg class="i xs"><use href="#i-check"/></svg></span><span class="t">Edit frames<span class="d">Only on a new page</span></span></label>
<label class="pgx-o" data-k="publish"><input type="checkbox"><span class="bx"><svg class="i xs"><use href="#i-check"/></svg></span><span class="t">Publish library<span class="d">Affects 4 other files</span></span><span class="tag warn" data-tip="Checkout, Marketing site, Email kit and Docs use this library">Risky</span></label>
</div>
<div class="pgx-f"><button class="pgx-db mx-press" aria-haspopup="menu" aria-expanded="false" aria-label="How long" data-pop=".pgx-pop"><span class="pgx-dv mx-w">For this task</span><svg class="i xs"><use href="#i-chev-d"/></svg></button><span class="sp"></span><button class="pill ghost sm pgx-no mx-press">Not now</button><button class="pill primary sm pgx-ok mx-w">Allow 2 scopes</button></div>
<div class="pop pgx-pop mx-pop mx-rows mx-glide" role="menu" aria-label="How long">
<button class="mi mx-press" role="menuitemradio" aria-checked="true" data-close data-v="This task"><span>For this task<span class="d">Until the pricing fixes are done</span></span><span class="ck"><svg class="i xs"><use href="#i-check"/></svg></span></button>
<button class="mi mx-press" role="menuitemradio" aria-checked="false" data-close data-v="Today"><span>For today<span class="d">Until midnight</span></span><span class="ck"><svg class="i xs"><use href="#i-check"/></svg></span></button>
<button class="mi mx-press" role="menuitemradio" aria-checked="false" data-close data-v="Always"><span>Always<span class="d">Until you revoke it</span></span><span class="ck"><svg class="i xs"><use href="#i-check"/></svg></span></button>
</div>
</div>
</div>
</div>
permission-gate.cssHTML · 148 lines
/* ---------- Permission gate ---------- */
/* the agent asks in the chat as one card: the question, the scopes to tick, and a footer with how long and the two
answers. Without .panel it sits flat in the thread */
.pgx{position:relative;width:100%;max-width:400px;margin:0 auto;padding:var(--dm-s-1) 0;display:flex;flex-direction:column;gap:var(--dm-s-3)}
.pgx.panel{padding:var(--dm-s-4)}
/* its motion (the core's motion pieces, owner, 26 Nov): How long's menu grows out of its button and goes back quicker, its
rows settle one after another and one highlight glides between them; a press shows at once (.mx-press, no scale); How
long's words and Allow ease their box to the new width (.mx-w); the spinner crossfades to the done mark (.mx-ic); and the
card eases to each new height on the spring (.mx-grow) */
.pgx-h{display:flex;gap:var(--dm-s-3);align-items:center}
.pgx-ic{width:32px;height:32px;border-radius:calc(9px * var(--dm-rk-m,var(--dm-rk)));background:var(--dm-chip);display:grid;place-items:center;flex:none}
.pgx-ht{display:flex;flex-direction:column;min-width:0}
.pgx-ht b{font-weight:500;font-size:14px}
.pgx-ht span{font-size:13px}
/* the scopes line up with the head (owner, 18 Nov): each box centred in a 32px column under the icon tile, its words where the
question's start, and a tag at the row's end on the right edge the buttons below end on. The row's hover fill reaches 8px
out round it, into the padding (owner, 26 Nov) */
.pgx-sc{display:flex;flex-direction:column}
.pgx-o{display:grid;grid-template-columns:32px minmax(0,1fr) auto;align-items:center;column-gap:var(--dm-s-3);margin-inline:calc(-1 * var(--dm-s-2));padding:var(--dm-s-2);border-radius:calc(10px * var(--dm-rk-m,var(--dm-rk)));cursor:pointer;font-size:13.5px;transition:background .25s}
.pgx-o>.bx{justify-self:center}
@media (hover:hover) and (pointer:fine){.pgx-o:hover{background:var(--dm-row)}}
.pgx-o input{position:absolute;opacity:0;pointer-events:none}
.pgx-o .bx{width:18px;height:18px;border-radius:calc(6px * var(--dm-rk-s,var(--dm-rk)));box-shadow:inset 0 0 0 1.5px var(--dm-fg2);display:grid;place-items:center;color:transparent;flex:none;transition:background .3s var(--dm-ease),box-shadow .3s,color .3s}
.pgx-o .bx svg{transform:scale(.4);transition:transform .35s var(--dm-ease)}
.pgx-o input:checked+.bx{background:var(--dm-accent);box-shadow:inset 0 0 0 1.5px var(--dm-accent-mark,var(--dm-accent));color:var(--dm-on-accent)}
.pgx-o input:checked+.bx svg{transform:none}
.pgx-o input:focus-visible+.bx{outline:2px solid var(--dm-focus);outline-offset:2px}
.pgx-o .t{flex:1;min-width:0}
/* asking again for one scope, every style: nothing to tick, so the scope is a plain row led by a tile like the question's
(what it does, in the same 32px column) and the button just says Allow (owner, 18 Nov) */
.pgx-o.one{cursor:default}
@media (hover:hover) and (pointer:fine){.pgx-o.one:hover{background:none}}
.pgx-o.one>.oi{width:32px;height:32px;display:grid;place-items:center;border-radius:calc(9px * var(--dm-rk-m,var(--dm-rk)));background:var(--dm-chip);color:var(--dm-fg2)}
:root[data-style="studio"] .pgx-o.one>.oi,:root [data-style="studio"] .pgx-o.one>.oi,:root [data-style="studio"].pgx-o.one>.oi{box-shadow:inset 0 0 0 1px var(--dm-hair)}
.pgx-o .d{display:block;font-size:12px;color:var(--dm-muted)}
.pgx-f{display:flex;align-items:center;gap:6px;padding-top:var(--dm-s-4);border-top:1px solid color-mix(in srgb,var(--dm-line) 50%,transparent)}
.pgx-f .sp{flex:1}
/* on a narrow stage the duration gets its own row, and the two buttons stay together under it on the right */
@container (max-width:340px){.pgx-f{flex-wrap:wrap;padding-top:var(--dm-s-3)}.pgx-f .sp{flex-basis:100%}.pgx-no{margin:var(--dm-s-2) 0 0 auto}.pgx-ok{margin-top:var(--dm-s-2)}}
/* how long: a small dropdown, the way a menu of choices usually looks */
.pgx-db{display:inline-flex;align-items:center;gap:6px;height:28px;padding:0 var(--dm-s-2) 0 10px;margin-left:0;border-radius:var(--dm-r-pill);font-size:13px;color:var(--dm-fg2);white-space:nowrap;transition:background .16s,color .16s}
.pgx-db[aria-expanded="true"]{background:var(--dm-row);color:var(--dm-fg)}
@media (hover:hover) and (pointer:fine){.pgx-db:hover{background:var(--dm-row);color:var(--dm-fg)}}
.pgx-db>svg{color:var(--dm-muted);transition:transform .32s var(--dm-ease)}
.pgx-db[aria-expanded="true"]>svg{transform:rotate(180deg)}
.pgx-pop{min-width:230px}
.pgx-ok[disabled]{opacity:1;cursor:not-allowed;background:var(--dm-dis-hatch),var(--dm-dis-fill);color:var(--dm-dis);box-shadow:var(--dm-soft-ring)}
.pgx-done{display:flex;align-items:center;gap:var(--dm-s-3);padding:10px 7px 10px 0;border-radius:var(--dm-r-in);background:var(--dm-chip);font-size:13.5px}
/* its mark sits centred in the scopes' 32px column, under the head's tile, and its words start on the title's column */
.pgx-done>svg{margin-inline:8px}
/* on a phone the answered row wraps to a small card: its words and its button 16px from its top, bottom and right; its mark
stays centred under the head's tile */
@container (max-width:340px){.pgx-done{padding:var(--dm-s-4) var(--dm-s-4) var(--dm-s-4) 0}}
/* its button is a white pill on the grey row */
.pgx-done .pill{background:var(--dm-surface);color:var(--dm-fg);box-shadow:var(--dm-on-tint-btn)}
@media (hover:hover) and (pointer:fine){.pgx-done .pill:hover{background:var(--dm-surface);box-shadow:var(--dm-on-tint-btn-h)}}
.pgx-done .t{flex:1;color:var(--dm-fg)}
.pgx-done .t span{display:block;font-size:12px;color:var(--dm-fg2)}
.pgx-done>svg{color:var(--dm-ok)}
/* while the agent works under the permission: a neutral row with a spinner and a live line. Once done the spinner becomes the
green tick and the row stays neutral: no green fill and no clock (owner, 18 Nov) */
.pgx-done .g{width:32px;height:18px;display:grid;place-items:center;flex:none;color:var(--dm-fg2)}
.pgx-done.ok .g{color:var(--dm-ok)}
.pgx-done .t b{display:block;font-weight:400}
/* asking again mid-run, for one more scope: the tile turns amber */
.pgx-ic{transition:background .32s var(--dm-ease)}
/* asking again keeps the tile neutral in every style: the Risky tag on the scope carries the warning (owner, 18 Nov) */
.pgx-scope{display:flex;flex-direction:column;gap:var(--dm-s-3)}
/* the line in the foot strip once you have answered (Studio only): the scopes you allowed, or that you allowed none */
.pgx-sum{display:none}
/* Studio (owner, 18 Nov): a card with the question, the scopes and an off-white foot strip. Its content sits 16px from
every edge; the controls in the strip sit 16px from the card's sides and bottom and from the strip's hairline (owner,
23 Nov), and the duration select lines up with the content above by its text, not its hover box. The ticks are
ink and draw in, the count on Allow rolls as boxes are ticked, and once you answer the scopes fold into one summary line
in the strip while the card eases to its new height (grow(), centred in its stage). Its height is never kept */
/* the card clips its strips to its round corners; the duration menu opens out of it (nothing changes height while it is open) */
:root[data-style="studio"] .pgx.panel,:root [data-style="studio"] .pgx.panel,:root [data-style="studio"].pgx.panel{padding:16px 16px 0;overflow:clip;overflow-clip-margin:0px}
:root[data-style="studio"] .pgx.panel:has(.pgx-pop.open),:root [data-style="studio"] .pgx.panel:has(.pgx-pop.open),:root [data-style="studio"].pgx.panel:has(.pgx-pop.open){overflow:visible}
:root[data-style="studio"] .pgx-ic,:root [data-style="studio"] .pgx-ic,:root [data-style="studio"].pgx-ic{box-shadow:inset 0 0 0 1px var(--dm-hair)}
/* asking again keeps the tile neutral: the Risky tag on the scope carries the warning */
:root[data-style="studio"] .pgx-ht b,:root [data-style="studio"] .pgx-ht b,:root [data-style="studio"].pgx-ht b{line-height:20px;letter-spacing:-.01em}
:root[data-style="studio"] .pgx-ht span,:root [data-style="studio"] .pgx-ht span,:root [data-style="studio"].pgx-ht span,:root[data-style="studio"] .pgx-o .d,:root [data-style="studio"] .pgx-o .d,:root [data-style="studio"].pgx-o .d,:root[data-style="studio"] .pgx-done .t span,:root [data-style="studio"] .pgx-done .t span,:root [data-style="studio"].pgx-done .t span{line-height:18px}
:root[data-style="studio"] :is(.pgx-o,.pgx-done) .t,:root [data-style="studio"] :is(.pgx-o,.pgx-done) .t,:root [data-style="studio"]:is(.pgx-o,.pgx-done) .t{line-height:20px}
/* a scope row: its box in a 32px column under the question's tile, centred, so its words start where the question's do;
hairlines between rows, which give way to the quiet fill of the row under the pointer */
:root[data-style="studio"] .pgx-o,:root [data-style="studio"] .pgx-o,:root [data-style="studio"].pgx-o{position:relative;display:grid;grid-template-columns:32px minmax(0,1fr) auto;column-gap:12px;transition:background-color var(--dm-t-fast) var(--dm-ease)}
:root[data-style="studio"] .pgx-o>.bx,:root [data-style="studio"] .pgx-o>.bx,:root [data-style="studio"].pgx-o>.bx{justify-self:center}
:root[data-style="studio"] .pgx-o+.pgx-o,:root [data-style="studio"] .pgx-o+.pgx-o,:root [data-style="studio"].pgx-o+.pgx-o{background-image:linear-gradient(var(--dm-hair),var(--dm-hair));background-repeat:no-repeat;background-position:var(--dm-s-2) 0;background-size:calc(100% - 2 * var(--dm-s-2)) 1px}
@media (hover:hover) and (pointer:fine){:root[data-style="studio"] :is(.pgx-o:hover,.pgx-o:hover+.pgx-o),:root [data-style="studio"] :is(.pgx-o:hover,.pgx-o:hover+.pgx-o),:root [data-style="studio"]:is(.pgx-o:hover,.pgx-o:hover+.pgx-o){background-image:none}}
/* asking again for one scope: nothing to tick, so the scope is an info row, its info mark where the box would be */
:root[data-style="studio"] .pgx-o .bx,:root [data-style="studio"] .pgx-o .bx,:root [data-style="studio"].pgx-o .bx{border-radius:calc(4px * var(--dm-rk-s,var(--dm-rk)));background:var(--dm-surface);box-shadow:inset 0 0 0 1.5px var(--dm-fg2),var(--dm-track-ring);transition:background .2s var(--dm-ease),box-shadow .2s var(--dm-ease)}
:root[data-style="studio"] .pgx-o .bx svg,:root [data-style="studio"] .pgx-o .bx svg,:root [data-style="studio"].pgx-o .bx svg{transform:none;stroke-dasharray:21;stroke-dashoffset:21;transition:stroke-dashoffset .3s var(--dm-ease)}
:root[data-style="studio"] .pgx-o input:checked+.bx,:root [data-style="studio"] .pgx-o input:checked+.bx,:root [data-style="studio"].pgx-o input:checked+.bx{background:linear-gradient(180deg,var(--dm-btn-1),var(--dm-btn-2));box-shadow:inset 0 0 0 1px var(--dm-btn-2),inset 0 2px 3px -1px rgba(255,255,255,.28);color:var(--dm-on-btn)}
:root[data-style="studio"] .pgx-o input:checked+.bx svg,:root [data-style="studio"] .pgx-o input:checked+.bx svg,:root [data-style="studio"].pgx-o input:checked+.bx svg{stroke-dashoffset:0;transition-delay:.06s}
:root[data-style="studio"] .pgx-o:active .bx,:root [data-style="studio"] .pgx-o:active .bx,:root [data-style="studio"].pgx-o:active .bx{transform:scale(.94);transition:transform var(--dm-t-fast) var(--dm-ease)}
/* the foot strip: 16px round its 28px controls (owner, 23 Nov), so it is 61px tall with its hairline; the scopes end 16px above it (their
rows keep 8px of hover room below the text). Lines are whole pixels, so the card's edge meets the strip's exactly */
:root[data-style="studio"] .pgx.panel .pgx-sc,:root [data-style="studio"] .pgx.panel .pgx-sc,:root [data-style="studio"].pgx.panel .pgx-sc{margin-bottom:-4px}
:root[data-style="studio"] .pgx.panel .pgx-f,:root [data-style="studio"] .pgx.panel .pgx-f,:root [data-style="studio"].pgx.panel .pgx-f{margin:0 -16px;padding:var(--dm-strip-y) 16px;gap:4px;border-top:1px solid var(--dm-line);background:var(--dm-strip);border-radius:0 0 var(--dm-r-card) var(--dm-r-card)}
/* when you ask again the strip comes back as a fade, after the card has grown to hold it (its script waits): rising from below,
it would show its buttons cut off by the card's edge while the card grows */
:root[data-style="studio"] .pgx.panel .pgx-f.enter,:root [data-style="studio"] .pgx.panel .pgx-f.enter,:root [data-style="studio"].pgx.panel .pgx-f.enter{animation-name:pgxfoot}
@keyframes pgxfoot{from{opacity:0}}
:root[data-style="studio"] .pgx-f .pgx-db,:root [data-style="studio"] .pgx-f .pgx-db,:root [data-style="studio"].pgx-f .pgx-db{padding:0 8px;margin:0;color:var(--dm-fg2);transition:background-color var(--dm-t-fast) var(--dm-ease),color var(--dm-t-fast) var(--dm-ease)}
@media (hover:hover) and (pointer:fine){:root[data-style="studio"] .pgx-f :is(.pgx-db:hover,.pill.ghost:hover),:root [data-style="studio"] .pgx-f :is(.pgx-db:hover,.pill.ghost:hover),:root [data-style="studio"].pgx-f :is(.pgx-db:hover,.pill.ghost:hover){background:var(--dm-row);color:var(--dm-fg)}}
:root[data-style="studio"] .pgx-f :is(.pgx-db,.pill.ghost).mx-press:active,:root [data-style="studio"] .pgx-f :is(.pgx-db,.pill.ghost).mx-press:active,:root [data-style="studio"].pgx-f :is(.pgx-db,.pill.ghost).mx-press:active{background:var(--dm-row-press)}
:root[data-style="studio"] .pgx-f .pgx-db[aria-expanded="true"],:root [data-style="studio"] .pgx-f .pgx-db[aria-expanded="true"],:root [data-style="studio"].pgx-f .pgx-db[aria-expanded="true"]{background:var(--dm-row-on);color:var(--dm-fg)}
/* on a narrow stage the buttons wrap under the select: the strip's 4px gaps put them 8px under it */
@container (max-width:340px){:root[data-style="studio"] .pgx-no,:root [data-style="studio"] .pgx-no,:root [data-style="studio"].pgx-no{margin:0 0 0 auto}:root[data-style="studio"] .pgx-ok,:root [data-style="studio"] .pgx-ok,:root [data-style="studio"].pgx-ok{margin-top:0}}
/* Allow's count rolls: up as a box is ticked, down as one is cleared. No window clips it: each number moves a few pixels
and fades, so a digit is never seen cut in half */
:root[data-style="studio"] .pgx-cnt,:root [data-style="studio"] .pgx-cnt,:root [data-style="studio"].pgx-cnt{display:inline-grid}
:root[data-style="studio"] .pgx-cnt>i,:root [data-style="studio"] .pgx-cnt>i,:root [data-style="studio"].pgx-cnt>i{grid-area:1/1;font-style:normal;font-variant-numeric:tabular-nums}
@keyframes pgxiu{from{transform:translateY(40%);opacity:0}}
@keyframes pgxou{to{transform:translateY(-40%);opacity:0}}
@keyframes pgxid{from{transform:translateY(-40%);opacity:0}}
@keyframes pgxod{to{transform:translateY(40%);opacity:0}}
/* the old number leaves first and the new one follows, so the two never sit on top of each other */
:root[data-style="studio"] .pgx-cnt>.iu,:root [data-style="studio"] .pgx-cnt>.iu,:root [data-style="studio"].pgx-cnt>.iu{animation:pgxiu .22s var(--dm-ease) .1s both}
:root[data-style="studio"] .pgx-cnt>.ou,:root [data-style="studio"] .pgx-cnt>.ou,:root [data-style="studio"].pgx-cnt>.ou{animation:pgxou .16s var(--dm-ease) both}
:root[data-style="studio"] .pgx-cnt>.id,:root [data-style="studio"] .pgx-cnt>.id,:root [data-style="studio"].pgx-cnt>.id{animation:pgxid .22s var(--dm-ease) .1s both}
:root[data-style="studio"] .pgx-cnt>.od,:root [data-style="studio"] .pgx-cnt>.od,:root [data-style="studio"].pgx-cnt>.od{animation:pgxod .16s var(--dm-ease) both}
/* answered: the result line where the scopes were (a 32px mark under the question's tile, the words under the question's
words, the clock on the right), then the strip with the summary and Revoke or Undo in the corner */
:root[data-style="studio"] .pgx.panel .pgx-done,:root [data-style="studio"] .pgx.panel .pgx-done,:root [data-style="studio"].pgx.panel .pgx-done{display:grid;grid-template-columns:32px minmax(0,1fr) auto;grid-template-rows:auto calc(28px + 2 * var(--dm-strip-y) + 1px);column-gap:12px;row-gap:16px;align-items:center;padding:0;border-radius:0;background:none!important}
:root[data-style="studio"] .pgx.panel .pgx-done>:is(.g,svg),:root [data-style="studio"] .pgx.panel .pgx-done>:is(.g,svg),:root [data-style="studio"].pgx.panel .pgx-done>:is(.g,svg){grid-area:1/1}
:root[data-style="studio"] .pgx.panel .pgx-done>.t,:root [data-style="studio"] .pgx.panel .pgx-done>.t,:root [data-style="studio"].pgx.panel .pgx-done>.t{grid-area:1/2}
:root[data-style="studio"] .pgx.panel .pgx-done .t b,:root [data-style="studio"] .pgx.panel .pgx-done .t b,:root [data-style="studio"].pgx.panel .pgx-done .t b{font-weight:500}
:root[data-style="studio"] .pgx.panel .pgx-done .t b span,:root [data-style="studio"] .pgx.panel .pgx-done .t b span,:root [data-style="studio"].pgx.panel .pgx-done .t b span{font-size:inherit;line-height:inherit;color:inherit}
:root[data-style="studio"] .pgx.panel .pgx-done .t span,:root [data-style="studio"] .pgx.panel .pgx-done .t span,:root [data-style="studio"].pgx.panel .pgx-done .t span{color:var(--dm-muted)}
:root[data-style="studio"] .pgx.panel .pgx-done>.pill,:root [data-style="studio"] .pgx.panel .pgx-done>.pill,:root [data-style="studio"].pgx.panel .pgx-done>.pill{grid-area:2/3;z-index:1;align-self:end;margin:0 0 var(--dm-strip-y) 0;color:var(--dm-fg);background:linear-gradient(180deg,var(--dm-btn2-1),var(--dm-btn2-2));box-shadow:var(--dm-btn2-depth)}
@media (hover:hover) and (pointer:fine){:root[data-style="studio"] .pgx.panel .pgx-done>.pill:hover,:root [data-style="studio"] .pgx.panel .pgx-done>.pill:hover,:root [data-style="studio"].pgx.panel .pgx-done>.pill:hover{background:linear-gradient(180deg,var(--dm-btn2-1),var(--dm-btn2-2));box-shadow:var(--dm-btn2-hover)}}
:root[data-style="studio"] .pgx.panel .pgx-done>.pill:active,:root [data-style="studio"] .pgx.panel .pgx-done>.pill:active,:root [data-style="studio"].pgx.panel .pgx-done>.pill:active{box-shadow:var(--dm-btn2-press)}
/* the strip is the summary line itself, edge to edge; Revoke or Undo sits on its right end. Its colour reaches 240px below
the card's edge (clipped there), so while the card eases shorter no empty band shows under it */
:root[data-style="studio"] .pgx.panel .pgx-sum,:root [data-style="studio"] .pgx.panel .pgx-sum,:root [data-style="studio"].pgx.panel .pgx-sum{display:block;grid-area:2/1/3/-1;align-self:stretch;margin:0 -16px -240px;padding:var(--dm-strip-y) 104px calc(240px + var(--dm-strip-y)) 16px;border-top:1px solid var(--dm-line);background:var(--dm-strip);line-height:28px;font-size:12.5px;color:var(--dm-muted);white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
:root[data-style="studio"] .pgx-sum .s,:root [data-style="studio"] .pgx-sum .s,:root [data-style="studio"].pgx-sum .s{display:none}
@container (max-width:340px){:root[data-style="studio"] .pgx-sum .l,:root [data-style="studio"] .pgx-sum .l,:root [data-style="studio"].pgx-sum .l{display:none}:root[data-style="studio"] .pgx-sum .s,:root [data-style="studio"] .pgx-sum .s,:root [data-style="studio"].pgx-sum .s{display:inline}}
/* the mark: a neutral circle with the spinner while the agent works; done, its ring turns green and the tick draws in */
:root[data-style="studio"] .pgx.panel .pgx-done .g,:root [data-style="studio"] .pgx.panel .pgx-done .g,:root [data-style="studio"].pgx.panel .pgx-done .g{width:32px;height:32px;border-radius:50%;background:var(--dm-chip);box-shadow:inset 0 0 0 1px var(--dm-hair);color:var(--dm-fg2);transition:background-color .3s var(--dm-ease),box-shadow .3s var(--dm-ease)}
:root[data-style="studio"] .pgx.panel .pgx-done.ok .g,:root [data-style="studio"] .pgx.panel .pgx-done.ok .g,:root [data-style="studio"].pgx.panel .pgx-done.ok .g{background:var(--dm-surface);box-shadow:inset 0 0 0 1.5px var(--dm-ok-mark);color:var(--dm-ok-mark)}
:root[data-style="studio"] .pgx.panel .pgx-done.ok .g svg,:root [data-style="studio"] .pgx.panel .pgx-done.ok .g svg,:root [data-style="studio"].pgx.panel .pgx-done.ok .g svg{width:16px;height:16px;stroke-width:2;stroke-dasharray:21;animation:pgxdraw .5s var(--dm-ease) .12s both}
@keyframes pgxdraw{from{stroke-dashoffset:21}to{stroke-dashoffset:0}}
:root[data-style="studio"] .pgx.panel .pgx-done>svg,:root [data-style="studio"] .pgx.panel .pgx-done>svg,:root [data-style="studio"].pgx.panel .pgx-done>svg{width:32px;height:32px;margin:0;padding:8px;box-sizing:border-box;border-radius:50%;background:var(--dm-chip);box-shadow:inset 0 0 0 1px var(--dm-hair);color:var(--dm-fg2)}
@media (prefers-reduced-motion:reduce){:root[data-style="studio"] :is(.pgx-o .bx,.pgx-o .bx svg,.pgx-done .g),:root [data-style="studio"] :is(.pgx-o .bx,.pgx-o .bx svg,.pgx-done .g),:root [data-style="studio"]:is(.pgx-o .bx,.pgx-o .bx svg,.pgx-done .g){transition:none}:root[data-style="studio"] :is(.pgx-cnt>i,.pgx-done.ok .g svg),:root [data-style="studio"] :is(.pgx-cnt>i,.pgx-done.ok .g svg),:root [data-style="studio"]:is(.pgx-cnt>i,.pgx-done.ok .g svg){animation:none}}
permission-gate.jsHTML · 126 lines
DM.def('permission-gate', (r, c) => {
r.innerHTML = r.innerHTML.replace('{figma}', I('figma')).replace(/\{chk\}/g, I('check','xs')).replace('{chev}', I('chev-d','xs'));
const root = $('.pgx', r), ok = $('.pgx-ok', r), no = $('.pgx-no', r), sc = $('.pgx-sc', r), title = $('.pgx-ht b', r), sub = $('.pgx-ht .muted', r);
const first = { sc:sc.innerHTML, title:title.textContent, sub:sub.textContent, no:no.textContent };
const boxes = () => $$('.pgx-o input', sc);
// the card fits what it holds at every moment, in every style (grow(), never a kept height: owner, 17 and 18 Nov). Studio
// (owner, 18 Nov) has its own touches:
// the count on Allow rolls, the answer gets a summary line in the foot strip, and the done mark is a tick that draws.
// Soft and Blueprint keep theirs
const ds = r.closest('[data-style]'), studio = !!ds && ds.dataset.style === 'studio';
// grow() starts once the card's entrance (which scales it from .98) has ended, so it measures the card at its real size
Promise.resolve().then(() => Promise.all(root.getAnimations().map(a => a.finished.catch(() => {})))).then(() => { if (!c.dead && root.isConnected) c.offs.push(grow(root)); });
// where a result row goes: in the card, or in grow()'s wrapper inside it
const into = () => $(':scope>.dm-grow', root) || root;
// how long: This task, Today or Always, from the dropdown in the footer
let dur = 'This task';
const span = () => dur === 'Always' ? 'always' : 'for ' + dur.toLowerCase();
const word = n => n > 1 ? 'scopes' : 'scope';
// Studio's Allow: its number in a window of its own, so a new count rolls in (up as a box is ticked, down as one clears)
const label = n => n ? `<span class="pgx-l">Allow <span class="pgx-cnt"><i>${n}</i></span> <span class="pgx-w">${word(n)}</span></span>` : 'Pick a scope';
let shown = 0;
const roll = (cnt, n, up) => { const old = cnt.lastElementChild, nu = document.createElement('i'); nu.textContent = n; nu.className = up ? 'iu' : 'id'; if (old){ old.className = up ? 'ou' : 'od'; setTimeout(() => old.remove(), REDUCE ? 0 : 300); } cnt.appendChild(nu); };
// Studio asks again for its one scope as a plain row (nothing to tick), and its button just says Allow
const one = () => $('.pgx-o.one', sc);
const count = () => { if (one()){ ok.disabled = false; shown = 0; return swap(ok, 'Allow'); }
const n = boxes().filter(b => b.checked).length; ok.disabled = !n;
if (!studio) return swap(ok, n ? 'Allow ' + n + (n > 1 ? ' scopes' : ' scope') : 'Pick a scope');
const cnt = $('.pgx-cnt', ok);
if (n && shown && cnt && !ok._sw){ if (n !== shown){ roll(cnt, n, n > shown); swap($('.pgx-w', ok), word(n)); } }
else swap(ok, label(n), true);
shown = n; };
if (studio){ shown = boxes().filter(b => b.checked).length; ok.innerHTML = label(shown); }
c.on(sc, 'change', count);
$$('.pgx-pop .mi', r).forEach(m => m.addEventListener('click', () => { dur = m.dataset.v; $$('.pgx-pop .mi', r).forEach(x => x.setAttribute('aria-checked', x === m)); swap($('.pgx-dv', r), dur === 'Always' ? 'Always' : 'For ' + dur.toLowerCase()); }));
const body = [sc, $('.pgx-f', r)];
// the scopes give way to a shorter result row, and the card eases to its height (grow())
// (in Studio the foot strip fades in once the card has grown to hold it, so no button shows cut off by the card's edge as it grows)
const show = on => { body.forEach(e => e.hidden = !on); if (on){ if (studio){ enter(body[0]); enter(body[1], 400); } else stagger(body, 50); } };
// Studio's summary line in the foot strip: the scopes you allowed, by name, or how many on a narrow stage
let names = [];
const sum = (el, text, short = text) => { if (!studio) return; const s = el.appendChild(html(`<span class="pgx-sum"><span class="l"></span><span class="s"></span></span>`)); s.firstChild.textContent = text; s.lastChild.textContent = short; };
// the frames the agent edits once it may. Plan toggle is a library component, so editing it needs Publish library
const F = ['Hero', 'Plan cards', 'Compare table', 'FAQ', 'Plan toggle', 'Checkout summary'], LIB = 4;
let granted = 0, publish = false, skip = false, done = 0, run = 0, panel = null;
function row(){
panel = html(`<div class="pgx-done run"><span class="g"><span class="spin"></span></span><span class="t"><b class="pgx-a"></b><span class="pgx-d"></span></span><button class="pill line sm mx-press">Revoke</button></div>`);
sum(panel, names.join(', '), `${names.length} ${word(names.length)} allowed`);
into().appendChild(panel); enter(panel); $('button', panel).onclick = revoke;
}
// the agent works through the frames under what it was given, and stops to ask when it reaches one it may not touch
function work(){
const id = ++run; if (!panel) row();
const a = $('.pgx-a', panel), d = $('.pgx-d', panel);
swap(a, `Allowed ${granted} ${granted > 1 ? 'scopes' : 'scope'} ${span()}`);
c.run(async () => {
while (done < F.length){
if (done === LIB && !publish && !skip) return ask();
swap(d, done === LIB && skip ? `Skipping ${F[done]}` : `Editing ${F[done]} · ${done + 1} of ${F.length}`);
await c.wait(900); if (run !== id) return;
done++;
}
// (the spinner crossfades to the done mark: iconSwap(), motion pieces)
panel.classList.replace('run', 'ok'); const g = $('.g', panel); iconSwap(g, () => { g.innerHTML = studio ? I('check') : I('ok'); }, { inner:true });
swap(a, skip ? `Done. ${F.length - 1} frames edited` : `Done. ${F.length} frames edited`);
swap(d, skip ? 'On a new page. Plan toggle skipped' : 'On a new page. Plan toggle published');
});
}
// asks again, for only the scope it now needs
function ask(){
const p = panel; panel = null; p.classList.add('leave');
root.classList.add('esc'); swap(title, 'Also allow Publish library?'); swap(sub, `${F[LIB]}, frame ${LIB + 1} of ${F.length}, is a library component`);
c.later(300, () => {
p.remove();
sc.innerHTML = studio
? `<div class="pgx-o one" data-k="publish"><span class="oi">${I('upload')}</span><span class="t">Publish library<span class="d">Updates Checkout, Marketing site, Email kit and Docs</span></span><span class="tag warn">Risky</span></div>`
: `<label class="pgx-o" data-k="publish"><input type="checkbox" checked><span class="bx">${I('check','xs')}</span><span class="t">Publish library<span class="d">Updates Checkout, Marketing site, Email kit and Docs</span></span><span class="tag warn">Risky</span></label>`;
no.textContent = 'Skip this frame'; count(); show(true);
});
}
function reset(){
run++; granted = done = 0; publish = skip = false; names = [];
root.classList.remove('esc'); sc.innerHTML = first.sc; swap(title, first.title); swap(sub, first.sub); no.textContent = first.no; count();
}
function revoke(){ const p = panel; panel = null; run++; p.classList.add('leave'); c.later(300, () => { p.remove(); reset(); show(true); }); }
ok.onclick = () => c.run(async () => {
const picked = one() ? [one()] : boxes().filter(b => b.checked).map(b => b.closest('.pgx-o')); if (!picked.length) return;
granted += picked.length; if (picked.some(o => o.dataset.k === 'publish')) publish = true;
names.push(...picked.map(o => $('.t', o).firstChild.textContent));
{ const w0 = ok.offsetWidth; ok.innerHTML = '<span class="spin"></span>'; if (!REDUCE) mxWidth(ok, w0); } await c.wait(500);
// Studio: the scopes fade up and out before the card eases to the result row's height
if (studio){ sc.classList.add('leave'); await c.wait(180); sc.classList.remove('leave'); }
show(false);
if (root.classList.contains('esc')){ root.classList.remove('esc'); swap(title, first.title); swap(sub, first.sub); }
// placed inside another component (Agent harness), it reports back without the run
if (!c.card){ row(); swap($('.pgx-a', panel), `Allowed ${granted} ${granted > 1 ? 'scopes' : 'scope'} ${span()}`); swap($('.pgx-d', panel), 'Applying the pricing fixes now');
c.later(1400, () => { if (!panel) return; panel.classList.replace('run', 'ok'); const g = $('.g', panel); iconSwap(g, () => { g.innerHTML = studio ? I('check') : I('ok'); }, { inner:true }); swap($('.pgx-d', panel), 'Done. 6 frames edited on a new page'); }); return; }
work();
});
no.onclick = () => {
if (root.classList.contains('esc')){ skip = true; show(false); root.classList.remove('esc'); swap(title, first.title); swap(sub, first.sub); work(); return; }
show(false); const d = html(`<div class="pgx-done" style="background:var(--dm-chip)">${I('info')}<span class="t">The agent will skip the Figma edits<span>It will list the fixes in chat instead</span></span><button class="pill line sm">Undo</button></div>`);
sum(d, 'Nothing allowed in Figma'); into().appendChild(d); enter(d); $('button', d).onclick = () => { d.remove(); show(true); };
};
// the preview's story: hold back the risky scope, allow the rest, then grant it when the agent needs it for one frame
c.story(async s => {
await s.beat(3);
const pub = $('[data-k="publish"]', sc);
// Studio ticks the box the way a visitor would, without the browser's own input event, which reads as the visitor taking
// over and stopped the story after its first tick
const tick = async el => {
if (!studio) return s.tap(el);
await s.point(el, false); const h = $('.hand', c.st); if (h){ h.classList.remove('down'); void h.offsetWidth; h.classList.add('down'); }
await s.beat(.32); const i = $('input', el); i.checked = !i.checked; i.dispatchEvent(new Event('change', { bubbles:true }));
c.later(340, () => h && h.classList.remove('down'));
};
await tick(pub); await s.beat(1);
await s.point($('.tag', pub)); await s.beat(3);
await tick(pub); await s.beat(2);
await s.tap(ok); s.away();
await s.until(() => root.classList.contains('esc') && !sc.hidden);
await s.beat(4);
await s.tap(ok); s.away();
await s.until(() => panel && panel.classList.contains('ok'));
});
});
Questions
What people ask about it.
- Can the agent wait for the permission before it continues?
- Yes. Make
onAllowreturn a promise that resolves once your agent has the grant. The button spins while it waits, then the card switches to the allowed state. - How do I pre-tick the safe scopes?
- Pass their keys in
defaultValue, or control the ticks withvalueandonValueChange. Scopes you leave out start unticked. - What happens when the person presses Revoke?
- The allowed message fades out, the card returns to asking with the scopes shown again, and
onRevokeis called so you can withdraw the grant. - Can I use my own durations?
- Yes. Pass any list of strings as
durations. The first one is picked by default unless you setdefaultDurationorduration.
More in Review and approve
Moments where a person checks, steers or signs off on the agent's work.