@quixomatic/rpf 0.3.2 → 0.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +190 -0
- package/README.md +4 -2
- package/assets/dev-host/kit-manifest.json +1 -1
- package/assets/forge-app/app/assets/{_forge-shiki-langs-nxHsAEiY.js → _forge-shiki-langs-Bm9NaYXm.js} +1 -1
- package/assets/forge-app/app/assets/{appendItems-CLsiMCGq.js → appendItems-DrlkyU0a.js} +1 -1
- package/assets/forge-app/app/assets/{core-DEkUYqk0.js → core-8OhGxroQ.js} +1 -1
- package/assets/forge-app/app/assets/{diff-view-ctlXj2p5.js → diff-view-rgZLuZMg.js} +4 -4
- package/assets/forge-app/app/assets/file-panel-CpPZ9DXB.js +1199 -0
- package/assets/forge-app/app/assets/{highlights-CEbVTJAm.js → highlights-C-SEG213.js} +1 -1
- package/assets/forge-app/app/assets/index-DWGc27yI.css +1 -0
- package/assets/forge-app/app/assets/index-DXDXX5UZ.js +298 -0
- package/assets/forge-app/app/assets/{loader-V5V4Ad0d.js → loader-Du5I86pW.js} +1 -1
- package/assets/forge-app/app/assets/{shiki-B5GY8Ub_.js → shiki-Bf12fWbJ.js} +2 -2
- package/assets/forge-app/app/assets/{stream-tokenizer-CZZoarTM.js → stream-tokenizer-DdzFthqp.js} +1 -1
- package/assets/forge-app/app/assets/{terminal-view-BR9EXBM5.js → terminal-view-Co0jXSWF.js} +1 -1
- package/assets/forge-app/app/assets/{themes-BMbfM7BC.js → themes-BrkVmSlQ.js} +2 -2
- package/assets/forge-app/app/assets/{useNextRenderData-ICppXFTX.js → useNextRenderData-BKv-kpPs.js} +3 -3
- package/assets/forge-app/app/index.html +2 -2
- package/assets/forge-app/server.mjs +2445 -8770
- package/dist/cli.mjs +11908 -6997
- package/examples/component-workspace/README.md +23 -0
- package/examples/component-workspace/components/@example/greeting/component.json +8 -0
- package/examples/component-workspace/components/@example/greeting/main.tsx +22 -0
- package/examples/component-workspace/components/@example/greeting/options.schema.json +6 -0
- package/examples/component-workspace/forge.workspace.json +7 -0
- package/examples/component-workspace/stage.json +11 -0
- package/examples/header-slot-widget/README.md +30 -0
- package/examples/header-slot-widget/components/@example/page-actions/component.json +8 -0
- package/examples/header-slot-widget/components/@example/page-actions/main.tsx +37 -0
- package/examples/header-slot-widget/components/@example/page-actions/options.schema.json +9 -0
- package/examples/index.json +159 -0
- package/examples/layout-regions/README.md +41 -0
- package/examples/layout-regions/components/@example/workspace-shell/component.json +21 -0
- package/examples/layout-regions/components/@example/workspace-shell/main.tsx +61 -0
- package/examples/layout-regions/components/@example/workspace-shell/options.schema.json +29 -0
- package/examples/layout-regions/components/@example/workspace-shell/styles.css +95 -0
- package/examples/portal-list-page/README.md +22 -0
- package/examples/portal-list-page/portal.mjs +40 -0
- package/examples/portal-record-page/README.md +23 -0
- package/examples/portal-record-page/portal.mjs +62 -0
- package/examples/primitive-and-utility/README.md +19 -0
- package/examples/primitive-and-utility/components/@example/number-format/component.json +6 -0
- package/examples/primitive-and-utility/components/@example/number-format/main.tsx +30 -0
- package/examples/primitive-and-utility/components/@example/stat-tile/component.json +6 -0
- package/examples/primitive-and-utility/components/@example/stat-tile/main.tsx +45 -0
- package/examples/primitive-and-utility/components/@example/work-summary/component.json +9 -0
- package/examples/primitive-and-utility/components/@example/work-summary/main.tsx +31 -0
- package/examples/primitive-and-utility/components/@example/work-summary/options.schema.json +6 -0
- package/examples/primitive-and-utility/components/@example/work-summary/server.js +27 -0
- package/examples/side-panel/README.md +18 -0
- package/examples/side-panel/components/@example/help-button/component.json +8 -0
- package/examples/side-panel/components/@example/help-button/main.tsx +26 -0
- package/examples/side-panel/components/@example/help-button/options.schema.json +7 -0
- package/examples/side-panel/portal.mjs +46 -0
- package/examples/theme/README.md +16 -0
- package/examples/theme/themes/teal-harbor/theme.css +11 -0
- package/examples/theme/themes/teal-harbor/theme.json +8 -0
- package/examples/theme/themes/teal-harbor/tokens.json +72 -0
- package/examples/widget-options/README.md +25 -0
- package/examples/widget-options/components/@example/notice-banner/component.json +14 -0
- package/examples/widget-options/components/@example/notice-banner/main.tsx +60 -0
- package/examples/widget-options/components/@example/notice-banner/options.schema.json +24 -0
- package/examples/widget-server-user/README.md +21 -0
- package/examples/widget-server-user/components/@example/user-card/component.json +9 -0
- package/examples/widget-server-user/components/@example/user-card/main.tsx +51 -0
- package/examples/widget-server-user/components/@example/user-card/options.schema.json +6 -0
- package/examples/widget-server-user/components/@example/user-card/server.js +27 -0
- package/package.json +7 -3
- package/skills/react-portal/SKILL.md +23 -1
- package/skills/react-portal/references/cli.md +11 -0
- package/skills/react-portal/references/components.md +40 -2
- package/assets/forge-app/app/assets/file-panel-BnUdO2N6.js +0 -1199
- package/assets/forge-app/app/assets/index-DYFQser1.js +0 -291
- package/assets/forge-app/app/assets/index-Ddi87x2p.css +0 -1
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# A record page: header, form, tabs, related lists, side panels and a variant
|
|
2
|
+
|
|
3
|
+
One URL (`record`, opened with `table` + `sys_id`) that works for every table, plus a **page variant** that gives
|
|
4
|
+
incidents their own arrangement. Configured entirely with React Portal's record widgets, placed by reference.
|
|
5
|
+
|
|
6
|
+
## Files
|
|
7
|
+
|
|
8
|
+
- `portal.mjs`: a fragment. Merge the `pages` entry and the two `panels` into your portal.mjs.
|
|
9
|
+
|
|
10
|
+
## What to notice
|
|
11
|
+
|
|
12
|
+
- The default placements: `record-tabs` in the shell's `tabs` header slot (Details, then a tab per side panel with
|
|
13
|
+
live counts) and `record-form`. The form draws the record header itself (title, highlights, presence) in the
|
|
14
|
+
shell's header slots. `record-header` is a primitive: import it into your own widget, never place it.
|
|
15
|
+
- `variants`: the first variant whose `condition` matches the URL params (`table=incident`) replaces the page's
|
|
16
|
+
placements. Here a `split` block puts the form beside a compact `activity-card`; block children are listed per
|
|
17
|
+
drop zone (`start`, `end`).
|
|
18
|
+
- `panels`: side panels with their own placements, offered on the pages in `pages`. `record-tabs` counts the
|
|
19
|
+
`attachments` and `related` panels by key (its `attachmentsPanel` / `relatedPanel` options default to those keys).
|
|
20
|
+
`body: 'full'` gives a panel's widgets the whole panel.
|
|
21
|
+
- The layout must render `<SidePanelRegion>` (app-shell does) for panels to open.
|
|
22
|
+
|
|
23
|
+
Read more: `read_doc concepts/page-variants`, `read_doc concepts/side-panels`, `read_doc primitives/record-header`.
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
pages: [
|
|
3
|
+
{
|
|
4
|
+
route: 'record',
|
|
5
|
+
name: 'Record',
|
|
6
|
+
order: 300,
|
|
7
|
+
contentWidth: 'full',
|
|
8
|
+
layoutOptions: { subheader: 'banner' },
|
|
9
|
+
widgets: [
|
|
10
|
+
{ key: 'tabs', c: 'record-tabs', order: 150, options: { slot: 'tabs', counts: true } },
|
|
11
|
+
{ key: 'form', c: 'record-form', order: 200 },
|
|
12
|
+
],
|
|
13
|
+
variants: [
|
|
14
|
+
{
|
|
15
|
+
key: 'incident',
|
|
16
|
+
name: 'Incident',
|
|
17
|
+
order: 100,
|
|
18
|
+
condition: 'table=incident',
|
|
19
|
+
widgets: [
|
|
20
|
+
{ key: 'tabs', c: 'record-tabs', order: 150, options: { slot: 'tabs', counts: true } },
|
|
21
|
+
{
|
|
22
|
+
key: 'layout',
|
|
23
|
+
c: 'split',
|
|
24
|
+
order: 200,
|
|
25
|
+
options: { template: 'minmax(0, 2fr) minmax(0, 1fr)', gap: '1.5rem' },
|
|
26
|
+
children: {
|
|
27
|
+
start: [{ key: 'form', c: 'record-form', order: 100 }],
|
|
28
|
+
end: [
|
|
29
|
+
{
|
|
30
|
+
key: 'activity',
|
|
31
|
+
c: 'activity-card',
|
|
32
|
+
order: 100,
|
|
33
|
+
options: { variant: 'compact', composer: true },
|
|
34
|
+
},
|
|
35
|
+
],
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
},
|
|
40
|
+
],
|
|
41
|
+
},
|
|
42
|
+
],
|
|
43
|
+
panels: [
|
|
44
|
+
{
|
|
45
|
+
key: 'attachments',
|
|
46
|
+
title: 'Attachments',
|
|
47
|
+
icon: 'paperclip',
|
|
48
|
+
pages: ['record'],
|
|
49
|
+
order: 100,
|
|
50
|
+
widgets: [{ key: 'files', c: 'attachments-card', order: 100, options: { layout: 'list' } }],
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
key: 'related',
|
|
54
|
+
title: 'Related',
|
|
55
|
+
icon: 'list-tree',
|
|
56
|
+
pages: ['record'],
|
|
57
|
+
body: 'full',
|
|
58
|
+
order: 200,
|
|
59
|
+
widgets: [{ key: 'lists', c: 'related-lists-card', order: 100, options: { layout: 'stacked' } }],
|
|
60
|
+
},
|
|
61
|
+
],
|
|
62
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# A primitive and a utility, imported by a widget
|
|
2
|
+
|
|
3
|
+
Three components that show the layering rule: shared UI goes in a **primitive**, shared logic in a **utility**, and
|
|
4
|
+
the placeable **widget** composes them.
|
|
5
|
+
|
|
6
|
+
| Component | Kind | Imported as |
|
|
7
|
+
|---|---|---|
|
|
8
|
+
| `example/stat-tile` | primitive | `import { StatTile } from 'components:example/stat-tile'` |
|
|
9
|
+
| `example/number-format` | utility | `import { useCompactFormat } from 'utilities:example/number-format'` |
|
|
10
|
+
| `example/work-summary` | widget (placed on pages) | not imported; `c: 'example/work-summary'` in portal.mjs |
|
|
11
|
+
|
|
12
|
+
## Notes
|
|
13
|
+
|
|
14
|
+
- A primitive's default export is its Studio preview; importers get the named exports.
|
|
15
|
+
- A utility's `main.tsx` has no default export: hooks and helpers only.
|
|
16
|
+
- Record imports compile once per component and are shared by every widget that imports them; widgets never copy a
|
|
17
|
+
primitive's code.
|
|
18
|
+
- Copy all three into a workspace with `rpf examples copy primitive-and-utility --ns <your namespace>`: the
|
|
19
|
+
`example` namespace is renamed in folders and import specifiers.
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { useUser } from '@portal/runtime';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* utilities:example/number-format: compact number formatting in the user's language.
|
|
6
|
+
*
|
|
7
|
+
* A utility: code without UI, imported as `utilities:example/number-format`. Export every hook and helper by name so
|
|
8
|
+
* widgets and primitives share one implementation.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Formats a number compactly (1234 → "1.2K").
|
|
13
|
+
* @param value the number (non-numbers render as "–")
|
|
14
|
+
* @param locale a BCP 47 language tag (default: the runtime's)
|
|
15
|
+
* @returns the formatted text
|
|
16
|
+
*/
|
|
17
|
+
export function formatCompact(value: unknown, locale?: string): string {
|
|
18
|
+
const n = typeof value === 'number' ? value : Number(value);
|
|
19
|
+
if (!Number.isFinite(n)) return '–';
|
|
20
|
+
return new Intl.NumberFormat(locale, { notation: 'compact', maximumFractionDigits: 1 }).format(n);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* A formatter bound to the signed-in user's language.
|
|
25
|
+
* @returns (value) => compact text
|
|
26
|
+
*/
|
|
27
|
+
export function useCompactFormat(): (value: unknown) => string {
|
|
28
|
+
const { language } = useUser();
|
|
29
|
+
return useMemo(() => (value: unknown) => formatCompact(value, language || undefined), [language]);
|
|
30
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
|
+
import { Card, CardContent } from 'components:card';
|
|
3
|
+
import { Skeleton } from 'components:skeleton';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* components:example/stat-tile: a labeled number with an optional hint, for KPI rows and dashboards.
|
|
7
|
+
*
|
|
8
|
+
* A primitive: never placed on a page, imported by widgets (`import { StatTile } from 'components:example/stat-tile'`).
|
|
9
|
+
* Named exports are what importers get; the default export is only Studio's preview.
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export interface StatTileProps {
|
|
13
|
+
label: string;
|
|
14
|
+
/** The formatted value; undefined renders a skeleton (data still loading). */
|
|
15
|
+
value?: ReactNode;
|
|
16
|
+
hint?: ReactNode;
|
|
17
|
+
className?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** One KPI tile. */
|
|
21
|
+
export function StatTile({ label, value, hint, className = '' }: StatTileProps) {
|
|
22
|
+
return (
|
|
23
|
+
<Card className={className}>
|
|
24
|
+
<CardContent className="flex flex-col gap-1">
|
|
25
|
+
<span className="text-sm text-muted-foreground">{label}</span>
|
|
26
|
+
{value === undefined ? (
|
|
27
|
+
<Skeleton className="h-8 w-16" />
|
|
28
|
+
) : (
|
|
29
|
+
<span className="text-3xl font-semibold tabular-nums">{value}</span>
|
|
30
|
+
)}
|
|
31
|
+
{hint ? <span className="text-xs text-muted-foreground">{hint}</span> : null}
|
|
32
|
+
</CardContent>
|
|
33
|
+
</Card>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Shown in Studio's preview of the primitive. */
|
|
38
|
+
export default function StatTilePreview() {
|
|
39
|
+
return (
|
|
40
|
+
<div className="grid max-w-md grid-cols-2 gap-3">
|
|
41
|
+
<StatTile label="Open" value="12" hint="assigned to you" />
|
|
42
|
+
<StatTile label="Loading" />
|
|
43
|
+
</div>
|
|
44
|
+
);
|
|
45
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "Work summary",
|
|
3
|
+
"kind": "widget",
|
|
4
|
+
"description": "KPI tiles for the signed-in user's open work, built from the stat-tile primitive and number-format utility",
|
|
5
|
+
"placeable": true,
|
|
6
|
+
"serverMode": "on-load",
|
|
7
|
+
"tailwind": true,
|
|
8
|
+
"defaults": { "title": "My work" }
|
|
9
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { useServer } from '@portal/runtime';
|
|
2
|
+
import { StatTile } from 'components:example/stat-tile';
|
|
3
|
+
import { useCompactFormat } from 'utilities:example/number-format';
|
|
4
|
+
|
|
5
|
+
type Options = { title?: string };
|
|
6
|
+
type Counts = { open?: number; dueToday?: number; updatedThisWeek?: number };
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* components:example/work-summary: three KPI tiles for the signed-in user's open work.
|
|
10
|
+
*
|
|
11
|
+
* It composes the stat-tile primitive and the number-format utility (record imports of other components) instead of
|
|
12
|
+
* re-implementing either, and gets its numbers from server.js (serverMode "on-load").
|
|
13
|
+
*/
|
|
14
|
+
export default function WorkSummary({ options = {} }: { options?: Options }) {
|
|
15
|
+
const { data, error } = useServer();
|
|
16
|
+
const fmt = useCompactFormat();
|
|
17
|
+
const counts = (data || {}) as Counts;
|
|
18
|
+
// undefined until the result arrives: StatTile shows a skeleton for an undefined value.
|
|
19
|
+
const value = (n: number | undefined) => (data === undefined ? undefined : fmt(n || 0));
|
|
20
|
+
if (error) return <p className="text-sm text-destructive">{error.message}</p>;
|
|
21
|
+
return (
|
|
22
|
+
<section className="flex flex-col gap-3">
|
|
23
|
+
{options.title ? <h2 className="text-lg font-semibold">{options.title}</h2> : null}
|
|
24
|
+
<div className="grid grid-cols-1 gap-3 sm:grid-cols-3">
|
|
25
|
+
<StatTile label="Open" value={value(counts.open)} hint="assigned to you" />
|
|
26
|
+
<StatTile label="Due today" value={value(counts.dueToday)} />
|
|
27
|
+
<StatTile label="Updated this week" value={value(counts.updatedThisWeek)} />
|
|
28
|
+
</div>
|
|
29
|
+
</section>
|
|
30
|
+
);
|
|
31
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server script of components:example/work-summary: counts the visitor's open tasks.
|
|
3
|
+
*
|
|
4
|
+
* GlideRecordSecure applies the visitor's ACLs, so the counts only include tasks they may read. getRowCount() reads
|
|
5
|
+
* the whole result set: fine for one person's work; for big tables, aggregate after checking access yourself.
|
|
6
|
+
*/
|
|
7
|
+
(function () {
|
|
8
|
+
/**
|
|
9
|
+
* Counts active tasks assigned to the visitor that match an extra encoded query.
|
|
10
|
+
* @param {string} extra an encoded query ('' for none)
|
|
11
|
+
* @returns {number} the row count
|
|
12
|
+
*/
|
|
13
|
+
function count(extra) {
|
|
14
|
+
var gr = new GlideRecordSecure('task');
|
|
15
|
+
gr.addActiveQuery();
|
|
16
|
+
gr.addQuery('assigned_to', gs.getUserID());
|
|
17
|
+
if (extra) gr.addEncodedQuery(extra);
|
|
18
|
+
gr.query();
|
|
19
|
+
return gr.getRowCount();
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
data.open = count('');
|
|
23
|
+
data.dueToday = count('due_dateONToday@javascript:gs.beginningOfToday()@javascript:gs.endOfToday()');
|
|
24
|
+
data.updatedThisWeek = count(
|
|
25
|
+
'sys_updated_onONThis week@javascript:gs.beginningOfThisWeek()@javascript:gs.endOfThisWeek()'
|
|
26
|
+
);
|
|
27
|
+
})();
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# A side panel with its own placements, opened from a page
|
|
2
|
+
|
|
3
|
+
## Files
|
|
4
|
+
|
|
5
|
+
- `portal.mjs`: a fragment with a `panels` entry (`get-help`, two React Portal widgets placed inside it by
|
|
6
|
+
reference), a menu item that opens it (`{ panel: 'get-help' }`) and a page placement of the button below. Merge the
|
|
7
|
+
entries into your portal.mjs.
|
|
8
|
+
- `components/@example/help-button`: a widget that toggles the panel with `useSidePanel()`.
|
|
9
|
+
|
|
10
|
+
## What to notice
|
|
11
|
+
|
|
12
|
+
- A panel is a record with placements, like a page. `pages: [...]` limits where it's offered (none = every page);
|
|
13
|
+
`body: 'full'` gives its widgets the whole panel; `width` sets its default width.
|
|
14
|
+
- Three ways to open one: a menu item `{ panel: '<key>' }`, `<Link panel="<key>">`, or `useSidePanel().openPanel` /
|
|
15
|
+
`toggle` in code. A page's `defaultPanel` opens one when the page loads.
|
|
16
|
+
- The layout decides where panels appear by rendering `<SidePanelRegion>` (push beside main, or overlay).
|
|
17
|
+
|
|
18
|
+
Read more: `read_doc concepts/side-panels`.
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useSidePanel } from '@portal/runtime';
|
|
2
|
+
import { Button } from 'components:button';
|
|
3
|
+
import { Icon } from 'components:icon';
|
|
4
|
+
|
|
5
|
+
type Options = { panel?: string; label?: string };
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* components:example/help-button: opens (or closes) a side panel from a page.
|
|
9
|
+
*
|
|
10
|
+
* useSidePanel() exposes the open panel and openPanel / close / toggle. A panel opens only where it is offered (its
|
|
11
|
+
* `pages` in portal.mjs, or every page when it lists none) and only in a layout that renders <SidePanelRegion>;
|
|
12
|
+
* `available` is false otherwise, and the button hides. A menu item `{ panel: '<key>' }` or
|
|
13
|
+
* `<Link panel="<key>">` opens one without code.
|
|
14
|
+
*/
|
|
15
|
+
export default function HelpButton({ options = {} }: { options?: Options }) {
|
|
16
|
+
const panels = useSidePanel();
|
|
17
|
+
const key = options.panel || 'get-help';
|
|
18
|
+
if (!panels.available || !panels.panels.some((p) => p.key === key)) return null;
|
|
19
|
+
const open = panels.open && panels.key === key;
|
|
20
|
+
return (
|
|
21
|
+
<Button variant={open ? 'secondary' : 'outline'} onClick={() => panels.toggle(key)} aria-pressed={open}>
|
|
22
|
+
<Icon name="life-buoy" />
|
|
23
|
+
{options.label || 'Get help'}
|
|
24
|
+
</Button>
|
|
25
|
+
);
|
|
26
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
pages: [
|
|
3
|
+
{
|
|
4
|
+
route: 'home',
|
|
5
|
+
name: 'Home',
|
|
6
|
+
order: 100,
|
|
7
|
+
widgets: [{ key: 'help', c: 'example/help-button', order: 900, options: { panel: 'get-help' } }],
|
|
8
|
+
},
|
|
9
|
+
],
|
|
10
|
+
panels: [
|
|
11
|
+
{
|
|
12
|
+
key: 'get-help',
|
|
13
|
+
title: 'Get help',
|
|
14
|
+
icon: 'life-buoy',
|
|
15
|
+
order: 100,
|
|
16
|
+
widgets: [
|
|
17
|
+
{
|
|
18
|
+
key: 'articles',
|
|
19
|
+
c: 'kb-articles',
|
|
20
|
+
order: 100,
|
|
21
|
+
options: { title: 'Popular answers', modes: ['popular'], limit: 5, compact: true },
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
key: 'links',
|
|
25
|
+
c: 'quick-links',
|
|
26
|
+
order: 200,
|
|
27
|
+
options: {
|
|
28
|
+
title: 'Still stuck?',
|
|
29
|
+
columns: 2,
|
|
30
|
+
items: [
|
|
31
|
+
{ label: 'Report an issue', icon: 'bug', to: 'catalog' },
|
|
32
|
+
{ label: 'My requests', icon: 'inbox', to: 'requests' },
|
|
33
|
+
],
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
],
|
|
39
|
+
menus: [
|
|
40
|
+
{
|
|
41
|
+
key: 'primary',
|
|
42
|
+
name: 'Primary',
|
|
43
|
+
items: [{ panel: 'get-help', label: 'Get help', icon: 'life-buoy', order: 900 }],
|
|
44
|
+
},
|
|
45
|
+
],
|
|
46
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# A theme: theme.json, tokens.json and theme.css
|
|
2
|
+
|
|
3
|
+
## Files (`themes/<key>/`)
|
|
4
|
+
|
|
5
|
+
- `theme.json`: `key`, `name`, `source: "custom"`, `order`, `active`, `description`.
|
|
6
|
+
- `tokens.json`: `{ "light": { … }, "dark": { … } }`, token names without the leading `--` (OKLCH colors, fonts,
|
|
7
|
+
radius). Generated here with `rpf themes generate --color "#0f766e" --tint tinted --radius 0.75rem --out …`, which
|
|
8
|
+
also checks contrast; re-check after hand edits with `rpf themes generate --from-css themes/<key>/tokens.json`.
|
|
9
|
+
- `theme.css`: optional portal-wide base CSS (links, selection), loaded first. Never component styling.
|
|
10
|
+
|
|
11
|
+
## Using it
|
|
12
|
+
|
|
13
|
+
Put the folder in a workspace and set `theme: 'teal-harbor'` in portal.mjs; the push creates the theme. Components
|
|
14
|
+
read tokens as Tailwind utilities (`bg-card`, `text-primary`) or raw variables (`var(--card)`).
|
|
15
|
+
|
|
16
|
+
The `react-portal-theme` skill covers the whole workflow (brand colors, fonts, contrast).
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Portal-wide base CSS for the Teal Harbor theme, loaded before everything else. Only base elements (body text,
|
|
3
|
+
* links, selection): component styling belongs in components. Tokens are var(--primary) etc.; there are no
|
|
4
|
+
* --color-* variables at runtime.
|
|
5
|
+
*/
|
|
6
|
+
a {
|
|
7
|
+
text-underline-offset: 0.2em;
|
|
8
|
+
}
|
|
9
|
+
::selection {
|
|
10
|
+
background: color-mix(in oklch, var(--primary) 25%, transparent);
|
|
11
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
{
|
|
2
|
+
"light": {
|
|
3
|
+
"background": "oklch(0.99 0.00458 186.391)",
|
|
4
|
+
"foreground": "oklch(0.2 0.02016 186.391)",
|
|
5
|
+
"card": "oklch(1 0 0)",
|
|
6
|
+
"card-foreground": "oklch(0.2 0.02016 186.391)",
|
|
7
|
+
"popover": "oklch(1 0 0)",
|
|
8
|
+
"popover-foreground": "oklch(0.2 0.02016 186.391)",
|
|
9
|
+
"primary": "oklch(0.51094 0.08606 186.391)",
|
|
10
|
+
"primary-foreground": "oklch(0.985 0 0)",
|
|
11
|
+
"secondary": "oklch(0.955 0.01374 186.391)",
|
|
12
|
+
"secondary-foreground": "oklch(0.25 0.02291 186.391)",
|
|
13
|
+
"muted": "oklch(0.96 0.011 186.391)",
|
|
14
|
+
"muted-foreground": "oklch(0.5 0.02749 186.391)",
|
|
15
|
+
"accent": "oklch(0.945 0.01893 186.391)",
|
|
16
|
+
"accent-foreground": "oklch(0.28 0.05163 186.391)",
|
|
17
|
+
"destructive": "oklch(0.577 0.215 27.3)",
|
|
18
|
+
"destructive-foreground": "oklch(0.985 0 0)",
|
|
19
|
+
"border": "oklch(0.9 0.01374 186.391)",
|
|
20
|
+
"input": "oklch(0.66069 0.01374 186.391)",
|
|
21
|
+
"ring": "oklch(0.51094 0.08606 186.391)",
|
|
22
|
+
"sidebar": "oklch(0.975 0.00916 186.391)",
|
|
23
|
+
"sidebar-foreground": "oklch(0.25 0.02291 186.391)",
|
|
24
|
+
"sidebar-primary": "oklch(0.51094 0.08606 186.391)",
|
|
25
|
+
"sidebar-primary-foreground": "oklch(0.985 0 0)",
|
|
26
|
+
"sidebar-accent": "oklch(0.93 0.01721 186.391)",
|
|
27
|
+
"sidebar-accent-foreground": "oklch(0.22 0.04303 186.391)",
|
|
28
|
+
"sidebar-border": "oklch(0.9 0.01374 186.391)",
|
|
29
|
+
"sidebar-ring": "oklch(0.51094 0.08606 186.391)",
|
|
30
|
+
"radius": "0.75rem",
|
|
31
|
+
"font-sans": "Inter, ui-sans-serif, system-ui, sans-serif",
|
|
32
|
+
"chart-1": "oklch(0.62 0.08606 186.391)",
|
|
33
|
+
"chart-2": "oklch(0.62 0.07315 231.391)",
|
|
34
|
+
"chart-3": "oklch(0.62 0.08606 281.391)",
|
|
35
|
+
"chart-4": "oklch(0.62 0.07315 346.391)",
|
|
36
|
+
"chart-5": "oklch(0.62 0.08606 46.391)"
|
|
37
|
+
},
|
|
38
|
+
"dark": {
|
|
39
|
+
"background": "oklch(0.16 0.01374 186.391)",
|
|
40
|
+
"foreground": "oklch(0.96 0.00916 186.391)",
|
|
41
|
+
"card": "oklch(0.2 0.01649 186.391)",
|
|
42
|
+
"card-foreground": "oklch(0.96 0.00916 186.391)",
|
|
43
|
+
"popover": "oklch(0.21 0.01649 186.391)",
|
|
44
|
+
"popover-foreground": "oklch(0.96 0.00916 186.391)",
|
|
45
|
+
"primary": "oklch(0.71094 0.07745 186.391)",
|
|
46
|
+
"primary-foreground": "oklch(0.17 0.01833 186.391)",
|
|
47
|
+
"secondary": "oklch(0.27 0.01833 186.391)",
|
|
48
|
+
"secondary-foreground": "oklch(0.96 0.00916 186.391)",
|
|
49
|
+
"muted": "oklch(0.26 0.01833 186.391)",
|
|
50
|
+
"muted-foreground": "oklch(0.72 0.02749 186.391)",
|
|
51
|
+
"accent": "oklch(0.3 0.02582 186.391)",
|
|
52
|
+
"accent-foreground": "oklch(0.96 0.00916 186.391)",
|
|
53
|
+
"destructive": "oklch(0.68 0.19 24)",
|
|
54
|
+
"destructive-foreground": "oklch(0.17 0 0)",
|
|
55
|
+
"border": "oklch(1 0 0 / 0.12)",
|
|
56
|
+
"input": "oklch(0.4813 0.01374 186.391)",
|
|
57
|
+
"ring": "oklch(0.71094 0.07745 186.391)",
|
|
58
|
+
"sidebar": "oklch(0.14 0.01374 186.391)",
|
|
59
|
+
"sidebar-foreground": "oklch(0.94 0.00916 186.391)",
|
|
60
|
+
"sidebar-primary": "oklch(0.71094 0.07745 186.391)",
|
|
61
|
+
"sidebar-primary-foreground": "oklch(0.17 0.01833 186.391)",
|
|
62
|
+
"sidebar-accent": "oklch(1 0 0 / 0.07)",
|
|
63
|
+
"sidebar-accent-foreground": "oklch(0.96 0.00916 186.391)",
|
|
64
|
+
"sidebar-border": "oklch(1 0 0 / 0.1)",
|
|
65
|
+
"sidebar-ring": "oklch(0.71094 0.07745 186.391)",
|
|
66
|
+
"chart-1": "oklch(0.72 0.07745 186.391)",
|
|
67
|
+
"chart-2": "oklch(0.72 0.06884 231.391)",
|
|
68
|
+
"chart-3": "oklch(0.72 0.07745 281.391)",
|
|
69
|
+
"chart-4": "oklch(0.72 0.06884 346.391)",
|
|
70
|
+
"chart-5": "oklch(0.72 0.07745 46.391)"
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
# Widget options: schema, defaults and the options prop
|
|
2
|
+
|
|
3
|
+
A widget with no server script whose behavior is entirely placement options.
|
|
4
|
+
|
|
5
|
+
## Files
|
|
6
|
+
|
|
7
|
+
- `options.schema.json`: JSON Schema that drives the page designer's form. Shown here: a plain string, a textarea
|
|
8
|
+
(`format: "textarea"`), an enum with quick-value buttons (`x-presets`), a color that becomes a CSS variable on the
|
|
9
|
+
placement (`format: "color"` + `x-css-var`), and a boolean.
|
|
10
|
+
- `component.json` `defaults`: the default options object. Effective options are the defaults overlaid (shallowly) by
|
|
11
|
+
the placement's `options`.
|
|
12
|
+
- `main.tsx`: reads `options` from its props. No `serverMode`, so no server script runs.
|
|
13
|
+
|
|
14
|
+
## In portal.mjs
|
|
15
|
+
|
|
16
|
+
```js
|
|
17
|
+
{ key: 'maintenance', c: 'example/notice-banner', order: 50, options: { tone: 'warning', dismissible: true } }
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Notes
|
|
21
|
+
|
|
22
|
+
- Write full Tailwind class names (`TONES` maps a tone to its classes); a class built at runtime (`'bg-' + tone`) is
|
|
23
|
+
invisible to the compiler.
|
|
24
|
+
- Anything that grants authority (a table, a query) should be `"x-embed": "server"` so only a parent's server script
|
|
25
|
+
can set it.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "Notice banner",
|
|
3
|
+
"kind": "widget",
|
|
4
|
+
"description": "A notice whose text, tone, icon, accent color, link and dismiss button are placement options",
|
|
5
|
+
"placeable": true,
|
|
6
|
+
"tailwind": true,
|
|
7
|
+
"defaults": {
|
|
8
|
+
"title": "Heads up",
|
|
9
|
+
"message": "Scheduled maintenance this Saturday from 08:00 to 10:00.",
|
|
10
|
+
"tone": "info",
|
|
11
|
+
"icon": "info",
|
|
12
|
+
"dismissible": false
|
|
13
|
+
}
|
|
14
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
2
|
+
import { Link } from '@portal/runtime';
|
|
3
|
+
import { Button } from 'components:button';
|
|
4
|
+
import { Icon } from 'components:icon';
|
|
5
|
+
|
|
6
|
+
type Tone = 'info' | 'success' | 'warning';
|
|
7
|
+
type Options = {
|
|
8
|
+
title?: string;
|
|
9
|
+
message?: string;
|
|
10
|
+
tone?: Tone;
|
|
11
|
+
icon?: string;
|
|
12
|
+
linkLabel?: string;
|
|
13
|
+
linkPage?: string;
|
|
14
|
+
dismissible?: boolean;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/** Tailwind classes per tone: full class names, since classes built at runtime are invisible to the compiler. */
|
|
18
|
+
const TONES: Record<Tone, string> = {
|
|
19
|
+
info: 'border-info/40 bg-info/5',
|
|
20
|
+
success: 'border-success/40 bg-success/5',
|
|
21
|
+
warning: 'border-warning/40 bg-warning/5',
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* components:example/notice-banner: a notice whose text, tone, icon, link and dismiss button all come from options.
|
|
26
|
+
*
|
|
27
|
+
* Effective options = component.json `defaults` overlaid by the placement's `options` (shallow), so every field has
|
|
28
|
+
* a value even on a fresh placement. The accent color is a CSS variable the placement sets (`x-css-var` in
|
|
29
|
+
* options.schema.json), read here with a fallback to the theme's primary.
|
|
30
|
+
*/
|
|
31
|
+
export default function NoticeBanner({ options = {} }: { options?: Options }) {
|
|
32
|
+
const [hidden, setHidden] = useState(false);
|
|
33
|
+
if (hidden) return null;
|
|
34
|
+
const tone: Tone = options.tone && TONES[options.tone] ? options.tone : 'info';
|
|
35
|
+
return (
|
|
36
|
+
<div
|
|
37
|
+
className={'flex items-start gap-3 rounded-lg border p-4 ' + TONES[tone]}
|
|
38
|
+
style={{ borderLeft: '4px solid var(--example-notice-accent, var(--primary))' }}
|
|
39
|
+
role="status"
|
|
40
|
+
>
|
|
41
|
+
{options.icon ? <Icon name={options.icon} className="mt-0.5 size-5 shrink-0" /> : null}
|
|
42
|
+
<div className="min-w-0 flex-1">
|
|
43
|
+
{options.title ? <p className="font-medium">{options.title}</p> : null}
|
|
44
|
+
{options.message ? (
|
|
45
|
+
<p className="whitespace-pre-line text-sm text-muted-foreground">{options.message}</p>
|
|
46
|
+
) : null}
|
|
47
|
+
{options.linkPage ? (
|
|
48
|
+
<Link page={options.linkPage} className="mt-2 inline-block text-sm font-medium underline">
|
|
49
|
+
{options.linkLabel || 'Learn more'}
|
|
50
|
+
</Link>
|
|
51
|
+
) : null}
|
|
52
|
+
</div>
|
|
53
|
+
{options.dismissible ? (
|
|
54
|
+
<Button size="icon-sm" variant="ghost" aria-label="Dismiss" onClick={() => setHidden(true)}>
|
|
55
|
+
<Icon name="x" />
|
|
56
|
+
</Button>
|
|
57
|
+
) : null}
|
|
58
|
+
</div>
|
|
59
|
+
);
|
|
60
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
{
|
|
2
|
+
"type": "object",
|
|
3
|
+
"properties": {
|
|
4
|
+
"title": { "type": "string", "title": "Title" },
|
|
5
|
+
"message": { "type": "string", "title": "Message", "format": "textarea" },
|
|
6
|
+
"tone": {
|
|
7
|
+
"type": "string",
|
|
8
|
+
"title": "Tone",
|
|
9
|
+
"enum": ["info", "success", "warning"],
|
|
10
|
+
"default": "info",
|
|
11
|
+
"x-presets": ["info", "success", "warning"]
|
|
12
|
+
},
|
|
13
|
+
"icon": { "type": "string", "title": "Icon (Lucide name)", "default": "info" },
|
|
14
|
+
"accent": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"title": "Accent color",
|
|
17
|
+
"format": "color",
|
|
18
|
+
"x-css-var": "--example-notice-accent"
|
|
19
|
+
},
|
|
20
|
+
"linkLabel": { "type": "string", "title": "Link label" },
|
|
21
|
+
"linkPage": { "type": "string", "title": "Link to page (route)" },
|
|
22
|
+
"dismissible": { "type": "boolean", "title": "Can be dismissed", "default": false }
|
|
23
|
+
}
|
|
24
|
+
}
|