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

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 72 additions & 4 deletions src/lib/default-blocks.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {
AlignLeft,
Bell,
FileText,
GalleryHorizontal,
Image as ImageIcon,
Expand Down Expand Up @@ -658,6 +659,71 @@ export const defaultPalette: readonly PaletteSection[] = [
}
]
},
{
name: 'Alert',
icon: Bell,
variants: [
{
id: 'alert_default',
label: 'Default',
factory: () => ({
type: 'alert',
text: {
type: 'mrkdwn',
text: 'A neutral alert message.'
}
})
},
{
id: 'alert_info',
label: 'Info',
factory: () => ({
type: 'alert',
level: 'info',
text: {
type: 'mrkdwn',
text: 'FYI: the build finished in 42 seconds.'
}
})
},
{
id: 'alert_warning',
label: 'Warning',
factory: () => ({
type: 'alert',
level: 'warning',
text: {
type: 'mrkdwn',
text: 'Heads up: this action cannot be undone.'
}
})
},
{
id: 'alert_error',
label: 'Error',
factory: () => ({
type: 'alert',
level: 'error',
text: {
type: 'mrkdwn',
text: 'Something went wrong. Please try again.'
}
})
},
{
id: 'alert_success',
label: 'Success',
factory: () => ({
type: 'alert',
level: 'success',
text: {
type: 'mrkdwn',
text: 'Your changes have been saved.'
}
})
}
]
},
{
name: 'Rich Text',
icon: Pilcrow,
Expand Down Expand Up @@ -1273,10 +1339,12 @@ export const legacyInputVariants: readonly PaletteVariant[] = [
] as const;

/**
* Modal-only `alert` block variant. Dropped from `defaultPalette` to
* match Slack's Block Kit Builder sidebar (which doesn't list it), but
* kept reachable so consumers who want it back can re-add via a custom
* palette section.
* Standalone `alert` block variant. The full set of severity-level alert
* variants ships in `defaultPalette` under the "Alert" section; this
* export is retained for backward compatibility with consumers who
* previously spread it onto a custom palette. Shares the `alert_warning`
* id with its counterpart in `defaultPalette` — spread after
* `defaultPalette` (or omit it entirely) to avoid duplicate-id lookups.
*/
export const extraAlertVariant: PaletteVariant = {
id: 'alert_warning',
Expand Down
4 changes: 1 addition & 3 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,7 @@ export interface BlockKitchenProps {
* you previously relied on the long flat list of single-element
* `input` variants (`input_users_select`, `input_multi_users_select`,
* `input_radio_buttons`, etc.), import `legacyInputVariants` and
* spread them into a custom section. The modal-only `alert` block was
* also dropped from the default; reach for `extraAlertVariant` to
* keep it.
* spread them into a custom section.
*
* Variant ids must be unique across the array — the drag-drop lookup
* keys by id, so duplicates would shadow each other. The palette is
Expand Down
Loading