Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
/**
* The Slide Master tab Slide Master view shows first, as in PowerPoint:
* Edit Master (Insert Layout, Delete, Rename), Master Layout (Insert
* Placeholder, Title, Footers), Background (theme Colors and Fonts, Format
* Background, Hide Background Graphics), Size, and Close Master View.
*/
import { fireAndForget } from '@core/util/fireAndForget';
import ChartBar from '@icon/system/regular/chart-bar.svg';
import FilmStrip from '@icon/system/regular/film-strip.svg';
import ImageIcon from '@icon/system/regular/image.svg';
import Layout from '@icon/system/regular/layout.svg';
import PaintBucket from '@icon/system/regular/paint-bucket.svg';
import PencilSimpleLine from '@icon/system/regular/pencil-simple-line.svg';
import RectangleDashed from '@icon/system/regular/rectangle-dashed.svg';
import SquaresFour from '@icon/system/regular/squares-four.svg';
import Table from '@icon/system/regular/table.svg';
import Textbox from '@icon/system/regular/textbox.svg';
import Trash from '@icon/system/regular/trash.svg';
import TreeStructure from '@icon/system/regular/tree-structure.svg';
import XCircle from '@icon/system/regular/x-circle.svg';
import { For, type JSX } from 'solid-js';
import {
backgroundStylePreview,
PLACEHOLDER_CHOICES,
} from '../../core/master-view';
import { COLOR_SETS, FONT_PAIRS } from '../../core/themes';
import type { MasterView } from '../../primitives/create-master-view';
import {
PopoverItem,
RibbonGroup,
RibbonPopover,
RibbonTextButton,
} from './controls';
import { SlideSizeGroup } from './deck-setup-controls';
import { useRibbon } from './ribbon';
const PLACEHOLDER_ICONS: Record<string, () => JSX.Element> = {
content: () => <SquaresFour />,
text: () => <Textbox />,
picture: () => <ImageIcon />,
chart: () => <ChartBar />,
table: () => <Table />,
smartArt: () => <TreeStructure />,
media: () => <FilmStrip />,
};
/** A labelled checkbox, as the Slide Master tab shows Title and Footers. */
function RibbonCheckbox(props: {
label: string;
checked: boolean;
disabled?: boolean;
testId: string;
tooltip?: string;
onChange: (checked: boolean) => void;
}) {
return (
<label
class="flex h-7 items-center gap-1 rounded-md px-1.5 text-xs"
classList={{ 'opacity-50': props.disabled }}
title={props.tooltip}
>
<input
type="checkbox"
class="accent-accent"
data-testid={props.testId}
checked={props.checked}
disabled={props.disabled}
onChange={(e) => props.onChange(e.currentTarget.checked)}
/>
{props.label}
</label>
);
}
export function SlideMasterTab(props: { master: MasterView }) {
const env = useRibbon();
const m = props.master;
const ro = () => env.readonly();
const layout = () => m.page()?.layout;
const options = () => m.options();
return (
<>
<RibbonGroup label="Edit Master">
<RibbonTextButton
aria-label="Insert Layout"
tooltip="Insert Layout: add a layout to the slide master"
disabled={ro() || !m.page()}
data-testid="pptx-master-insert-layout"
onClick={() => fireAndForget(m.insertLayout(), 'pptx-editor')}
>
<Layout />
Insert Layout
</RibbonTextButton>
<RibbonTextButton
aria-label="Delete"
tooltip={
m.deleteBlocker() ??
(layout() ? 'Delete this layout' : 'Delete this slide master')
}
disabled={ro() || !m.page() || !!m.deleteBlocker()}
data-testid="pptx-master-delete"
onClick={() => fireAndForget(m.deletePage(), 'pptx-editor')}
>
<Trash />
Delete
</RibbonTextButton>
<RibbonTextButton
aria-label="Rename"
tooltip={layout() ? 'Rename this layout' : 'Rename this slide master'}
disabled={ro() || !m.page()}
data-testid="pptx-master-rename"
onClick={() => m.startRename()}
>
<PencilSimpleLine />
Rename
</RibbonTextButton>
</RibbonGroup>
<RibbonGroup label="Master Layout">
<RibbonPopover
label="Insert Placeholder"
text="Insert Placeholder"
icon={<RectangleDashed class="size-3.5" />}
disabled={ro() || !layout()}
testId="pptx-master-insert-placeholder"
>
{(close) => (
<div
class="flex w-48 flex-col"
data-testid="pptx-master-placeholder-menu"
>
<For each={PLACEHOLDER_CHOICES}>
{(choice) => (
<PopoverItem
label={choice.label}
icon={PLACEHOLDER_ICONS[choice.kind]()}
testId={`pptx-master-placeholder-${choice.kind}${choice.vertical ? '-vertical' : ''}`}
onClick={() => {
close();
fireAndForget(
m.insertPlaceholder(choice.kind, choice.vertical),
'pptx-editor'
);
}}
/>
)}
</For>
</div>
)}
</RibbonPopover>
<RibbonCheckbox
label="Title"
testId="pptx-master-title"
tooltip="Show the title placeholder on this layout"
checked={options().title}
disabled={ro() || !layout()}
onChange={(title) =>
fireAndForget(m.setOptions({ title }), 'pptx-editor')
}
/>
<RibbonCheckbox
label="Footers"
testId="pptx-master-footers"
tooltip="Show the date, footer, and slide number placeholders on this layout"
checked={options().footers}
disabled={ro() || !layout()}
onChange={(footers) =>
fireAndForget(m.setOptions({ footers }), 'pptx-editor')
}
/>
</RibbonGroup>
<RibbonGroup label="Background">
<ThemeColorsMenu />
<ThemeFontsMenu />
<BackgroundStylesMenu master={m} />
<RibbonTextButton
aria-label="Format Background"
tooltip="Format the background of this master or layout"
disabled={ro()}
data-testid="pptx-master-format-background"
onClick={() => env.openFormatPane('background')}
>
<PaintBucket />
Format Background
</RibbonTextButton>
<RibbonCheckbox
label="Hide Background Graphics"
testId="pptx-master-hide-background"
tooltip="Hide the slide master's shapes on this layout"
checked={!!layout()?.hideBackgroundGraphics}
disabled={ro() || !layout()}
onChange={(hide) =>
fireAndForget(
m.setOptions({ hideBackgroundGraphics: hide }),
'pptx-editor'
)
}
/>
</RibbonGroup>
<SlideSizeGroup />
<RibbonGroup label="Close">
<RibbonTextButton
aria-label="Close Master View"
tooltip="Close Master View: back to editing slides"
variant="primary"
data-testid="pptx-master-close"
onClick={() => fireAndForget(m.close(), 'pptx-editor')}
>
<XCircle />
Close Master View
</RibbonTextButton>
</RibbonGroup>
</>
);
}
/** Background ▸ Colors: the theme color sets, as on the Design tab. */
function ThemeColorsMenu() {
const env = useRibbon();
const accents = () =>
(env.deck()?.themeColors ?? [])
.filter(([slot]) => slot.startsWith('accent'))
.map(([, css]) => css.replace('#', '').toUpperCase());
return (
<RibbonPopover
label="Theme colors"
text="Colors"
icon={
<span class="flex gap-px">
<For each={accents()}>
{(hex) => (
<span
class="h-3 w-1 rounded-sm"
style={{ background: `#${hex}` }}
/>
)}
</For>
</span>
}
disabled={env.readonly()}
testId="pptx-master-theme-colors"
>
{(close) => (
<div class="flex max-h-[60vh] w-64 flex-col overflow-y-auto">
<For each={COLOR_SETS}>
{(set) => (
<PopoverItem
label={set.name}
active={accents().every(
(hex, i) => set.colors[`accent${i + 1}`] === hex
)}
icon={
<span
class="block size-3.5 border border-edge-muted"
style={{ background: `#${set.colors.accent1}` }}
/>
}
onClick={() => {
close();
fireAndForget(
env.commands.setThemeColors(set.colors, set.name),
'pptx-editor'
);
}}
/>
)}
</For>
</div>
)}
</RibbonPopover>
);
}
/** Background ▸ Fonts: the theme font pairs, as on the Design tab. */
function ThemeFontsMenu() {
const env = useRibbon();
return (
<RibbonPopover
label="Theme fonts"
text="Fonts"
icon={<span class="font-serif text-sm leading-none">Aa</span>}
disabled={env.readonly()}
testId="pptx-master-theme-fonts"
>
{(close) => (
<div class="flex max-h-[60vh] w-64 flex-col overflow-y-auto">
<For each={FONT_PAIRS}>
{(pair) => (
<PopoverItem
label={`${pair.name}: ${pair.major} / ${pair.minor}`}
active={
env.deck()?.themeFonts?.major === pair.major &&
env.deck()?.themeFonts?.minor === pair.minor
}
onClick={() => {
close();
fireAndForget(
env.commands.setThemeFonts(
pair.major,
pair.minor,
pair.name
),
'pptx-editor'
);
}}
/>
)}
</For>
</div>
)}
</RibbonPopover>
);
}
/**
* Background ▸ Background Styles: the theme's twelve background styles
* (three fills by four colors), Format Background, and Reset.
*/
function BackgroundStylesMenu(props: { master: MasterView }) {
const env = useRibbon();
const colors = () => env.deck()?.themeColors ?? [];
return (
<RibbonPopover
label="Background Styles"
text="Background Styles"
icon={
<span
class="size-3.5 rounded-sm border border-edge-muted"
style={{ background: backgroundStylePreview(colors(), 9) }}
/>
}
disabled={env.readonly() || !props.master.page()}
testId="pptx-master-background-styles"
>
{(close) => (
<div class="flex w-64 flex-col gap-2">
<div class="grid grid-cols-4 gap-1.5 p-1">
<For each={Array.from({ length: 12 }, (_, i) => i + 1)}>
{(style) => (
<button
type="button"
title={`Style ${style}`}
aria-label={`Style ${style}`}
data-testid={`pptx-master-background-style-${style}`}
class="aspect-[4/3] rounded-sm border border-edge-muted hover:outline hover:outline-2 hover:outline-accent"
style={{
background: backgroundStylePreview(colors(), style),
}}
onClick={() => {
close();
fireAndForget(
props.master.setBackgroundStyle(style),
'pptx-editor'
);
}}
/>
)}
</For>
</div>
<PopoverItem
label="Format Background…"
icon={<PaintBucket class="size-3.5" />}
onClick={() => {
close();
env.openFormatPane('background');
}}
/>
<PopoverItem
label="Reset Background"
testId="pptx-master-background-reset"
onClick={() => {
close();
env.commands.setBackground(null);
}}
/>
</div>
)}
</RibbonPopover>
);
}