mirror of
https://github.com/pterodactyl/panel.git
synced 2026-12-05 22:05:47 -05:00
theme docs
This commit is contained in:
+11
-2
@@ -4,7 +4,7 @@ This file is a running track of new features and fixes to each version of the pa
|
||||
This project follows [Semantic Versioning](http://semver.org) guidelines.
|
||||
|
||||
## v2.0.0 (unreleased)
|
||||
Extension SDK `2.0.0-beta.4`.
|
||||
Extension SDK `2.0.0-beta.5`.
|
||||
|
||||
### Fixed
|
||||
* Extension web routes under `/extensions/<id>` are now matched before the SPA catch-all route, which previously answered them.
|
||||
@@ -19,6 +19,11 @@ Extension SDK `2.0.0-beta.4`.
|
||||
* Each extension builds Tailwind with its own prefix, declared as `ui.prefix` in the manifest (2-12 lowercase letters; `hw` gives `hw:flex`, `hw:lg:hidden` and theme variables under `--hw-*`). Tailwind variant names, theme namespaces and panel names are reserved, two enabled extensions cannot share a prefix, and `p:extension:doctor`, `p:extension:pack`, install and enable reject a build whose utilities or theme variables do not carry the declared prefix. `p:extension:make` derives a prefix from the id or takes `--prefix`.
|
||||
* `@pterodactyl/sdk/theme.css` points prefixed extension builds at the panel's live `--spacing` and font tokens; the panel imports the shared mapping from `packages/sdk/theme-tokens.css`.
|
||||
* Class names passed to core components resolve the prefixed utilities of every enabled extension against the panel utility they replace; the SDK test hosts take the `prefix` to do the same.
|
||||
* The stock UI is the built-in `classic` theme, written on the public theme API. Every layout, page and block is a named view with an engine model, rendered through a chain of layers (classic, the active theme and its parents, then extension overrides) in which each layer can render the one below and a failing layer falls back to it.
|
||||
* Extensions override views with `views.override` and the manifest's `ui.views`, replacing `components.replace` and `ui.components`, and add views of their own with `views.define`.
|
||||
* Core components take their classes from UI kit skins and mark their parts with `data-ui`, `data-part` and their state.
|
||||
* The extension and theme Vite presets emit fonts and images with URLs relative to the file that uses them, so they load from the published build.
|
||||
* Removed the `themes/` directory, `ThemeService` and the old `p:theme:apply` behaviour.
|
||||
|
||||
### Added
|
||||
* Adds `ReadsFileContents`, `ListsDirectories`, `ReadsServerLogs`, `ReadsServerState`, `ChangesServerEgg` and `CompletesLogins` action contracts.
|
||||
@@ -27,7 +32,11 @@ Extension SDK `2.0.0-beta.4`.
|
||||
* `OperationCompleted` now also reports `delete`, `suspend`, `unsuspend` and `transfer`.
|
||||
* Adds public extension settings (`->frontend()->public()`) and the `color`, `textarea`, `multiselect`, `list` and `file` setting fields, with uploads served from `/extension-files/<id>/`.
|
||||
* Adds conditional extension screens (`ui.screens[].when` and a runtime `visible` predicate), live navigation badges, `NamedIcon` and `@pterodactyl/sdk/icons.json`.
|
||||
* Adds the replaceable `server.files.editor` and `server.files.manager` components, `useNavigationBlocker`, `serverResourcesQueryOptions`, `useServerResources`, `useSendServerPower` and `useSendServerCommand` to the SDK.
|
||||
* Adds the `server.files.editor` and `server.files.manager` views, `useNavigationBlocker`, `serverResourcesQueryOptions`, `useServerResources`, `useSendServerPower` and `useSendServerCommand` to the SDK.
|
||||
* Adds themes: extensions with `"type": "theme"` that rebuild the panel stylesheet, skin the UI kit and override views through `defineTheme` (`@pterodactyl/sdk/theme`), with typed settings written as tokens and `<html>` attributes, dark and light schemes with a user switch, and child themes through `theme.extends`.
|
||||
* Adds the admin Themes page (activate, preview for me, reset, settings with a live preview), `p:theme:activate`, `p:theme:reset`, `p:theme:list`, safe mode (`?safe_mode=1`), and a fallback to classic when a theme fails to load.
|
||||
* Adds the theme workbench (`/panel/theme-workbench`), which renders every view and UI primitive from fixtures, and the view inspector (`Alt+Shift+I`, `?inspect=1`).
|
||||
* Adds the theme toolchain: `p:extension:make --theme`, `defineThemeConfig`, the `pterodactyl-theme` CLI (`list`, `eject`, `skins`), `renderView`, `renderPrimitive` and `preloadTheme` in `@pterodactyl/sdk/testing`, and the Themes chapter of the SDK README.
|
||||
* Adds layout, terminal, selection, scrollbar and browser chrome theme tokens, a sidebar sub-navigation mode (`data-sub-navigation="side"`), and `onThemeChange`, `notifyThemeChange` and `readThemeToken`.
|
||||
* Scaffolded extensions set `preserveSymlinks` so a linked SDK resolves its peer types from the extension.
|
||||
|
||||
|
||||
@@ -1,111 +0,0 @@
|
||||
# Skin reference (data for the docs lane)
|
||||
|
||||
Source of truth: `resources/scripts/themes/primitives.ts` (`UiPrimitives`, `UI_PRIMITIVES`), the registry in
|
||||
`resources/scripts/themes/skins.ts`, classic's recipes in `resources/scripts/themes/classic/skins/*.ts`.
|
||||
|
||||
## API (`@pterodactyl/sdk/theme`)
|
||||
|
||||
- `defineTheme({ ui })`: `ui` is `ThemeSkins`, keyed by primitive name.
|
||||
- `skin(name, skin)` types a skin; `skin(name, (parent) => skin)` extends the layers below. The function form must go
|
||||
through `skin()`: a bare function is read as a replacement component.
|
||||
- Skin: `{ [part]: recipe }`. A recipe is a string, a cva recipe `{ base, variants, compoundVariants, defaultVariants }`,
|
||||
or `(state) => string`. Variant keys are state keys; booleans use `'true'`/`'false'`.
|
||||
- `parent` in the function form has every part resolved: `parent.root(state)` returns the classes below.
|
||||
- `useSkin(name, state)` returns a binding: `ui(part, className?, partState?)` gives
|
||||
`{ className, 'data-ui', 'data-part', data-* }` to spread; `ui.classes(part, className?, partState?)` gives the string.
|
||||
- Types: `ThemeSkins`, `Skin<N>`, `CompleteSkin<N>`, `CompleteSkins`, `SkinRecipe<S>`, `SkinRecipeConfig<S>`,
|
||||
`SkinCompoundVariant<S>`, `ResolvedSkin<N>`, `SkinExtension<N>`, `SkinDefinition<N>`, `SkinBinding<N>`,
|
||||
`SkinPartProps`, `SkinClassName`, `SkinPart<N>`, `PrimitiveName`, `PrimitiveState<N>`, `PrimitiveProps<N>`,
|
||||
`ReplaceableName`, `UiPrimitives`, `UiTone`, `NoState`, `SkinStateMap`, `SkinStateValue`, `PrimitiveMeta<N>`;
|
||||
value `UI_PRIMITIVES` (parts and `replaceable` per primitive).
|
||||
|
||||
## Rules
|
||||
|
||||
- Layers: classic, then the theme chain parent first. For each part the topmost recipe wins and replaces the one below
|
||||
wholesale; nothing merges. Parts a skin leaves out keep the recipe below.
|
||||
- The call-site `className` is appended with `cn()` (tailwind-merge), so it wins conflicts.
|
||||
- Every part renders `data-ui="<kebab-name>"` and `data-part="<part>"`. The root also renders a `data-<key>` per state
|
||||
value (camelCase keys become kebab case: `richLabel` → `data-rich-label`). `true` renders as an empty attribute,
|
||||
`false`/unset render nothing. A part given its own state (Dialog `icon`, Empty `media`, Pagination `page`) renders
|
||||
that state on itself.
|
||||
- Parts marked "classes only" below are passed as `className` to another primitive or element and carry no attributes.
|
||||
- Presentational primitives can be replaced by a component receiving the identical props. The topmost replacement wins;
|
||||
skins of all layers still resolve for the core components. A replacement must not render the primitive it replaces.
|
||||
- Base UI primitives (and the other skin-only ones) cannot be replaced: a component there is a type error, and at
|
||||
runtime it is ignored with a dev warning. Unknown primitive names and unknown parts are ignored with a dev warning.
|
||||
- Resolution is memoised per primitive per layer stack; a recipe or extension that throws is skipped and logged.
|
||||
|
||||
## Primitives
|
||||
|
||||
`root` gets the bound state as `data-*`. Replaceable = may be a component.
|
||||
|
||||
| Primitive | Parts | State (→ `data-*`) | Replaceable |
|
||||
|---|---|---|---|
|
||||
| Alert | root, icon, body, title, content | `type`: success, info, warning, danger | yes |
|
||||
| Avatar | root | `variant`: beam, marble, pixel, sunset, ring, bauhaus | yes |
|
||||
| Badge | root | `tone`: neutral, success, warning, danger, info, accent; `size`: sm, md; `variant`: solid, soft | yes |
|
||||
| Button | root, spinner, label | `color`: primary, grey, green, red, orange; `size`: xsmall, small, large, xlarge; `secondary`; `loading` | yes |
|
||||
| Card | root, header, title, icon, actions, body | `titled` (has a header); `actions`; `loading` | yes |
|
||||
| Checkbox | root, indicator | none (Base UI sets `data-checked`, `data-indeterminate`, `data-disabled`) | no |
|
||||
| Code | root | `dark` | no |
|
||||
| CopyOnClick | root (toast), status, message, target (classes only, added to the clicked child) | `status`: copied, failed | no |
|
||||
| Dialog | backdrop, viewport, container, root (popup), body, content, header, heading, title, description, spacer, footer, close, closeButton (classes only, on a Button), closeIcon, icon, iconGlyph | `described`; `type` on `icon`: danger, warning, success, info | no |
|
||||
| DropdownMenu | trigger, positioner, root (popup) | `context` (ContextDropdownMenu) | no |
|
||||
| DropdownMenuItem | root, icon, glyph, text, label, description | `danger`; `described` | no |
|
||||
| Empty | root, header, media, title, description, content | `size`: default, compact; `variant` on `media`: default, icon | yes (root) |
|
||||
| FileInput | root | none | no |
|
||||
| Input | root | `light`; `error` | no |
|
||||
| Label | root | `light` | no |
|
||||
| ListRow | root | `interactive` | yes |
|
||||
| NewButton | root (classes only, on the Button), content, icon | `link` (NewLinkButton) | no |
|
||||
| NumberInput | root (NumberField), input | `light`; `error` | no |
|
||||
| PageHeading | root, text, title, description, actions | none | yes |
|
||||
| Pagination | root, page (classes only, on each page Button) | `current` on `page` | no |
|
||||
| ProgressBar | root (track), indicator | `variant`: meter, page; `tone`: as Badge | yes |
|
||||
| Select | root (input group), input, trigger, positioner, popup, list, item, itemLabel, indicator, empty, group, groupLabel, summary, preview | `error`; `multiple`; `selected`; `richLabel`; `searching` | no |
|
||||
| Spinner | root, container (when centered) | `size`: small, base, large; `blue`; `centered` | yes |
|
||||
| SpinnerOverlay | root, text | `fixed` | no |
|
||||
| Switch | root, control, thumb, text, label (classes only, on the Label), description | `described`; `position`: start, end | no |
|
||||
| Table | root, empty, scroller, table, head, headerRow, headerCell, body, row, cell | `fetching` | no |
|
||||
| TextArea | root | `light`; `error` | no |
|
||||
| Tooltip | root, arrow | `side`: top, right, bottom, left; `arrow` | no |
|
||||
|
||||
## Components and props (`@pterodactyl/sdk`)
|
||||
|
||||
Button (`ButtonProps`, `ButtonColor`, `ButtonSize`; `Button.Text`, `Button.Danger`), LinkButton, RouterLinkButton,
|
||||
NewButton/NewLinkButton (`NewButtonProps`, `NewLinkButtonProps`), Input (`InputProps`), TextArea (`TextAreaProps`),
|
||||
NumberInput (`NumberInputProps`), FileInput (`FileInputProps`), Select (`SelectProps`), Checkbox (`CheckboxProps`),
|
||||
Switch (`SwitchProps`), Label (`LabelProps`), Dialog (`DialogProps`, `DialogIconProps`; `Dialog.Footer`, `Dialog.Icon`,
|
||||
`Dialog.Confirm`), Alert (`AlertProps`, `AlertType`), Tooltip (`TooltipProps`), DropdownMenu / DropdownMenuItem /
|
||||
ContextDropdownMenu (`DropdownMenuProps`, `DropdownMenuItemProps`, `ContextDropdownMenuProps`), Table (`TableProps`),
|
||||
Pagination (`PaginationProps`), Empty + EmptyHeader/EmptyMedia/EmptyTitle/EmptyDescription/EmptyContent (`EmptyProps`,
|
||||
`EmptySize`, `EmptyMediaVariant`), Spinner (`SpinnerProps`), SpinnerOverlay (`SpinnerOverlayProps`), Avatar
|
||||
(`AvatarProps`), ProgressBar (`ProgressBarProps`), Code (`CodeProps`), CopyOnClick (`CopyOnClickProps`), Card
|
||||
(`CardProps`), ListRow (`ListRowProps`), Badge (`BadgeProps`), PageHeading (`PageHeadingProps`). ContentBox and
|
||||
TitledGreyBox remain as thin wrappers over Card.
|
||||
|
||||
## Recipes
|
||||
|
||||
```tsx
|
||||
export default defineTheme({
|
||||
ui: {
|
||||
// Replaces Button's root recipe; spinner and label keep classic's.
|
||||
Button: skin('Button', {
|
||||
root: {
|
||||
base: 'inline-flex h-9 items-center rounded-full px-4 font-medium',
|
||||
variants: { color: { primary: 'bg-primary text-primary-foreground hover:bg-primary/90' } },
|
||||
compoundVariants: [{ secondary: true, color: 'primary', class: 'bg-transparent text-primary' }],
|
||||
},
|
||||
}),
|
||||
// Builds on the classes below.
|
||||
Card: skin('Card', (parent) => ({ root: (state) => `${parent.root(state)} backdrop-blur-xl bg-card/60` })),
|
||||
// Presentational primitives can be components with the same props.
|
||||
Badge: AuroraBadge,
|
||||
},
|
||||
});
|
||||
```
|
||||
|
||||
Classic's normalised variants: plain `hover:`/`active:` guarded with `not-disabled:` on Button
|
||||
(`hover:not-disabled:bg-primary/80`), `data-checked:`/`data-highlighted:`/`data-starting-style:` instead of
|
||||
`data-[…]:`, `z-9999`, and `(--var)` shorthands. Rendered classes are otherwise unchanged
|
||||
(`resources/scripts/themes/classicClasses.spec.tsx`).
|
||||
+3
-3
@@ -93,7 +93,7 @@
|
||||
"test": "vitest run",
|
||||
"test:watch": "vitest",
|
||||
"tsc": "tsc --noEmit && tsc --project tools/oxlint/rules && npm --prefix packages/hello-world run typecheck",
|
||||
"lint": "oxfmt --check resources/scripts packages/hello-world tools/oxlint && oxlint --type-aware resources/scripts packages/hello-world/src/client tools/oxlint",
|
||||
"lint": "oxfmt --check resources/scripts packages/hello-world packages/sdk/docs-samples tools/oxlint && oxlint --type-aware resources/scripts packages/hello-world/src/client tools/oxlint",
|
||||
"api:generate": "openapi-ts",
|
||||
"extension:api:generate": "node scripts/generate-extension-api.mjs",
|
||||
"api:refresh": "APP_URL=http://localhost PTERODACTYL_EXTENSIONS_ENABLED=false composer docs:openapi:verify && npm run api:generate",
|
||||
@@ -107,8 +107,8 @@
|
||||
"build:production": "npm run build --",
|
||||
"build:vite": "npm run build && npm --prefix packages/hello-world run build",
|
||||
"serve": "vite",
|
||||
"sdk:generate": "node scripts/generate-sdk-types.mjs && node scripts/generate-sdk-icons.mjs && node scripts/generate-sdk-views.mjs && node scripts/generate-core-classes.mjs",
|
||||
"sdk:check": "node scripts/generate-sdk-types.mjs --check && node scripts/generate-sdk-icons.mjs --check && node scripts/generate-sdk-views.mjs --check && npm run sdk:testing && vitest run packages/sdk/types-drift.spec.ts",
|
||||
"sdk:generate": "node scripts/generate-sdk-types.mjs && node scripts/generate-sdk-icons.mjs && node scripts/generate-sdk-views.mjs && node scripts/generate-core-classes.mjs && node scripts/generate-sdk-docs.mjs",
|
||||
"sdk:check": "node scripts/generate-sdk-types.mjs --check && node scripts/generate-sdk-icons.mjs --check && node scripts/generate-sdk-views.mjs --check && node scripts/generate-sdk-docs.mjs --check && tsc --project packages/sdk/docs-samples && npm run sdk:testing && vitest run packages/sdk/types-drift.spec.ts",
|
||||
"sdk:testing": "node scripts/build-sdk-testing.mjs",
|
||||
"pretest": "npm run sdk:testing"
|
||||
},
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -23,7 +23,9 @@ const button = skin('Button', {
|
||||
[
|
||||
'relative inline-flex items-center justify-center gap-2 rounded-full font-medium transition disabled:opacity-50',
|
||||
sizes[size],
|
||||
secondary ? 'bg-transparent text-foreground ring-1 ring-border hover:not-disabled:bg-popover' : fills[color],
|
||||
secondary
|
||||
? 'bg-transparent text-foreground ring-1 ring-border hover:not-disabled:bg-popover'
|
||||
: fills[color],
|
||||
].join(' '),
|
||||
});
|
||||
// #endregion button
|
||||
@@ -33,7 +35,7 @@ const button = skin('Button', {
|
||||
const glass = {
|
||||
Card: skin('Card', {
|
||||
root: {
|
||||
base: 'glass rounded-2xl shadow-xl shadow-black/10',
|
||||
base: 'glass rounded-2xl shadow-xl',
|
||||
variants: { titled: { false: 'p-5' }, loading: { true: 'relative' } },
|
||||
},
|
||||
header: 'flex items-center gap-3 border-b border-(--glass-border) px-5 py-3',
|
||||
|
||||
@@ -2,8 +2,18 @@ import { Badge, ProgressBar, Spinner, bytesToString } from '@pterodactyl/sdk';
|
||||
import { Slot, useThemeSettings, type ServerCardMetric, type ViewProps } from '@pterodactyl/sdk/theme';
|
||||
import type { ThemeSettings } from '../theme-types';
|
||||
|
||||
/** A limit of 0 is unlimited, which has no percentage to show. */
|
||||
const percent = ({ value, limit }: ServerCardMetric) => (limit > 0 ? Math.min((value / limit) * 100, 100) : null);
|
||||
|
||||
function Usage({ label, text, metric }: { label: string; text: string; metric: ServerCardMetric }) {
|
||||
return (
|
||||
<div className='space-y-1'>
|
||||
{text}
|
||||
<ProgressBar value={percent(metric)} label={label} tone={metric.alarm ? 'danger' : 'accent'} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
/** A server's name and address, with its usage as the panel polls it (every 20 seconds at most). */
|
||||
export default function ServerCard({ model, server }: ViewProps<'dashboard.serverCard'>) {
|
||||
const { liveStats } = useThemeSettings<ThemeSettings>();
|
||||
@@ -27,18 +37,9 @@ export default function ServerCard({ model, server }: ViewProps<'dashboard.serve
|
||||
{state.kind === 'loading' && <Spinner size='small' />}
|
||||
{liveStats && state.kind === 'ready' && (
|
||||
<div className='grid grid-cols-3 gap-3 text-xs text-muted-foreground'>
|
||||
<div>
|
||||
CPU {state.cpu.value.toFixed(0)}%
|
||||
<ProgressBar value={percent(state.cpu)} label='CPU' tone={state.cpu.alarm ? 'danger' : 'accent'} />
|
||||
</div>
|
||||
<div>
|
||||
{bytesToString(state.memory.value)}
|
||||
<ProgressBar value={percent(state.memory)} label='Memory' tone={state.memory.alarm ? 'danger' : 'accent'} />
|
||||
</div>
|
||||
<div>
|
||||
{bytesToString(state.disk.value)}
|
||||
<ProgressBar value={percent(state.disk)} label='Disk' tone={state.disk.alarm ? 'danger' : 'accent'} />
|
||||
</div>
|
||||
<Usage label='CPU' text={`CPU ${state.cpu.value.toFixed(0)}%`} metric={state.cpu} />
|
||||
<Usage label='Memory' text={bytesToString(state.memory.value)} metric={state.memory} />
|
||||
<Usage label='Disk' text={bytesToString(state.disk.value)} metric={state.disk} />
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
@@ -36,7 +36,12 @@ function PowerButtons({ item }: { item: ServerListItem }) {
|
||||
</Button>
|
||||
</>
|
||||
) : (
|
||||
<Button size='xsmall' color='green' disabled={power.isPending || item.power === null} onClick={send('start')}>
|
||||
<Button
|
||||
size='xsmall'
|
||||
color='green'
|
||||
disabled={power.isPending || item.power === null}
|
||||
onClick={send('start')}
|
||||
>
|
||||
<Play className='size-3.5' aria-hidden /> Start
|
||||
</Button>
|
||||
)}
|
||||
@@ -73,7 +78,12 @@ function Pager({ model }: { model: ServerListModel }) {
|
||||
|
||||
return (
|
||||
<nav aria-label='Pages' className='mt-6 flex items-center justify-center gap-3 text-sm'>
|
||||
<Button size='xsmall' color='grey' disabled={pagination.currentPage === 1} onClick={() => actions.setPage(pagination.currentPage - 1)}>
|
||||
<Button
|
||||
size='xsmall'
|
||||
color='grey'
|
||||
disabled={pagination.currentPage === 1}
|
||||
onClick={() => actions.setPage(pagination.currentPage - 1)}
|
||||
>
|
||||
Previous
|
||||
</Button>
|
||||
{pagination.currentPage} of {pagination.totalPages}
|
||||
|
||||
@@ -6,7 +6,15 @@ const tones: Record<NonNullable<ServerStatMetric['alarm']>, UiTone> = { warning:
|
||||
/** A limit of 0 is unlimited, which has no percentage to show. */
|
||||
const percent = ({ value, limit }: ServerStatMetric) => (limit > 0 ? Math.min((value / limit) * 100, 100) : null);
|
||||
|
||||
function Meter({ label, metric, format }: { label: string; metric: ServerStatMetric; format: (value: number) => string }) {
|
||||
function Meter({
|
||||
label,
|
||||
metric,
|
||||
format,
|
||||
}: {
|
||||
label: string;
|
||||
metric: ServerStatMetric;
|
||||
format: (value: number) => string;
|
||||
}) {
|
||||
return (
|
||||
<div className='space-y-1.5'>
|
||||
<div className='flex justify-between text-xs'>
|
||||
@@ -16,11 +24,7 @@ function Meter({ label, metric, format }: { label: string; metric: ServerStatMet
|
||||
{metric.limit > 0 && <span className='text-muted-foreground'> / {format(metric.limit)}</span>}
|
||||
</span>
|
||||
</div>
|
||||
<ProgressBar
|
||||
value={percent(metric)}
|
||||
label={label}
|
||||
tone={metric.alarm ? tones[metric.alarm] : 'accent'}
|
||||
/>
|
||||
<ProgressBar value={percent(metric)} label={label} tone={metric.alarm ? tones[metric.alarm] : 'accent'} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -28,7 +32,10 @@ function Meter({ label, metric, format }: { label: string; metric: ServerStatMet
|
||||
/** Live values from the server's websocket; they update several times a second while it runs. */
|
||||
export default function Stats({ model }: ViewProps<'server.stats'>) {
|
||||
return (
|
||||
<Card title='Resources' actions={<Badge tone={model.state === 'running' ? 'success' : 'neutral'}>{model.state ?? 'unknown'}</Badge>}>
|
||||
<Card
|
||||
title='Resources'
|
||||
actions={<Badge tone={model.state === 'running' ? 'success' : 'neutral'}>{model.state ?? 'unknown'}</Badge>}
|
||||
>
|
||||
<div className='space-y-4'>
|
||||
<Meter label='CPU' metric={model.cpu} format={(value) => `${value.toFixed(1)}%`} />
|
||||
<Meter label='Memory' metric={model.memory} format={bytesToString} />
|
||||
|
||||
@@ -35,7 +35,12 @@ export default function Terminal({ model }: ViewProps<'server.terminal'>) {
|
||||
</div>
|
||||
)}
|
||||
{model.scrolledUp && (
|
||||
<Button size='xsmall' color='grey' className='absolute right-5 bottom-3' onClick={model.scrollToBottom}>
|
||||
<Button
|
||||
size='xsmall'
|
||||
color='grey'
|
||||
className='absolute right-5 bottom-3'
|
||||
onClick={model.scrollToBottom}
|
||||
>
|
||||
Latest output
|
||||
</Button>
|
||||
)}
|
||||
|
||||
@@ -51,7 +51,10 @@ export default definePterodactylExtension({
|
||||
context: 'app',
|
||||
use: useBalance,
|
||||
Default: Balance,
|
||||
fixtures: { funded: () => ({ credits: 120, topUp: () => {} }), empty: () => ({ credits: 0, topUp: () => {} }) },
|
||||
fixtures: {
|
||||
funded: () => ({ credits: 120, topUp: () => {} }),
|
||||
empty: () => ({ credits: 0, topUp: () => {} }),
|
||||
},
|
||||
});
|
||||
// Wherever classic has no place for it yet, a slot places the view.
|
||||
slots.register('dashboard.after', () => <View name='billing.balance' />);
|
||||
|
||||
@@ -8,7 +8,7 @@ const badge = skin('Badge', {
|
||||
base: 'inline-flex items-center gap-1 rounded-full font-medium',
|
||||
variants: {
|
||||
size: { sm: 'px-2 text-[0.6875rem]', md: 'px-2.5 py-0.5 text-xs' },
|
||||
variant: { solid: 'text-white', soft: 'bg-transparent ring-1 ring-inset' },
|
||||
variant: { solid: 'text-primary-foreground', soft: 'bg-transparent ring-1 ring-inset' },
|
||||
},
|
||||
compoundVariants: [
|
||||
{ variant: 'solid', tone: ['success', 'info'], class: 'bg-success' },
|
||||
|
||||
@@ -114,6 +114,7 @@ export default function PreviewFrame({ label, width, scale, scheme, children }:
|
||||
|
||||
setHeight(Math.min(dialog ? Math.max(content, DIALOG_HEIGHT) : content, MAX_HEIGHT));
|
||||
};
|
||||
|
||||
const observer = new ResizeObserver(measure);
|
||||
// Resize observations wait for rendering, which a hidden tab skips; mutations do not.
|
||||
const mutations = new MutationObserver(measure);
|
||||
|
||||
@@ -77,7 +77,10 @@ function FixtureFrame({
|
||||
);
|
||||
// Pages and layouts bring their own spacing; a block sits in some, as it would on a page.
|
||||
const view = definition.kind === 'block' ? <div className='p-4'>{rendered}</div> : rendered;
|
||||
const engineSlots = isPageViewName(definition.name) ? (pageSlots(definition.name) ?? []) : [];
|
||||
const engineSlots = useMemo(
|
||||
() => (isPageViewName(definition.name) ? (pageSlots(definition.name) ?? []) : []),
|
||||
[definition.name]
|
||||
);
|
||||
|
||||
return (
|
||||
<figure className='min-w-0'>
|
||||
|
||||
@@ -80,13 +80,7 @@ export interface UiPrimitiveComponents {
|
||||
const noop = () => {};
|
||||
|
||||
/** A dialog the gallery can close and reopen; `open` samples start open, so the frame shows them at once. */
|
||||
function DialogSample({
|
||||
open: initiallyOpen,
|
||||
danger,
|
||||
}: {
|
||||
open: boolean;
|
||||
danger?: boolean;
|
||||
}): ReactElement {
|
||||
function DialogSample({ open: initiallyOpen, danger }: { open: boolean; danger?: boolean }): ReactElement {
|
||||
const [open, setOpen] = useState(initiallyOpen);
|
||||
|
||||
return (
|
||||
|
||||
@@ -8,8 +8,9 @@ import { clearThemeLayers, registerViewDefinition, registerViewLayer, type ViewP
|
||||
import { EngineSlots, SLOT_CHECK_DELAY_MS } from './slotCheck';
|
||||
import { View } from './View';
|
||||
|
||||
const before = 'server.console.power.before' satisfies SlotName;
|
||||
const after = 'server.console.power.after' satisfies SlotName;
|
||||
const before = 'dashboard.before' satisfies SlotName;
|
||||
const after = 'dashboard.after' satisfies SlotName;
|
||||
|
||||
type Props = ViewProps<'test.slotted'>;
|
||||
|
||||
beforeAll(() => {
|
||||
|
||||
@@ -2,6 +2,7 @@ import { createContext, useContext, useEffect, useRef, useState, type ReactNode
|
||||
import type { ViewDefinition, ViewLayer } from './registry';
|
||||
|
||||
const SlotRecorder = createContext<((name: string) => void) | null>(null);
|
||||
|
||||
/** The slots the engine renders around a page view, which the view itself does not render. */
|
||||
export const EngineSlots = createContext<readonly string[]>([]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user