docs(nx-dev): add support for 'announcement' type callout (#31583)

Extended the `Callout` component and schema to support a new 'announcement' type with corresponding styles and icon. Updated documentation example for the new type.
This commit is contained in:
Benjamin Cabanes 2025-06-13 11:55:49 -04:00 committed by GitHub
parent 7c5faba41b
commit 363058ee54
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 32 additions and 6 deletions

View File

@ -88,7 +88,7 @@ The documentation website [nx.dev](https://nx.dev) is using custom Markdown synt
Callouts are available to get the attention of the reader on some specific type of information.
```markdown
{% callout type="caution|check|note|warning" title="string" %}
{% callout type="announcement|caution|check|note|warning" title="string" %}
Your content goes here.
{% /callout %}
```

View File

@ -1,6 +1,6 @@
'use client';
import React, { useState, useEffect, type ReactNode } from 'react';
import { useState, useEffect, type ReactNode, type ReactElement } from 'react';
import cx from 'classnames';
import {
ChevronRightIcon,
@ -10,14 +10,21 @@ import {
HandRaisedIcon,
InformationCircleIcon,
AcademicCapIcon,
MegaphoneIcon,
} from '@heroicons/react/24/outline';
type CalloutType = 'note' | 'warning' | 'check' | 'caution' | 'deepdive';
type CalloutType =
| 'announcement'
| 'caution'
| 'check'
| 'deepdive'
| 'note'
| 'warning';
const typeMap: Record<
CalloutType,
{
icon: JSX.Element;
icon: ReactElement;
backgroundColor: string;
borderColor: string;
titleColor: string;
@ -36,6 +43,18 @@ const typeMap: Record<
titleColor: 'text-slate-600 dark:text-slate-300',
textColor: 'text-slate-700 dark:text-slate-400',
},
announcement: {
icon: (
<MegaphoneIcon
className="h-5 w-5 text-blue-500 dark:text-blue-400"
aria-hidden="true"
/>
),
backgroundColor: 'bg-blue-50 dark:bg-blue-900/30',
borderColor: 'border-blue-200 dark:border-blue-800',
titleColor: 'text-blue-600 dark:text-blue-400',
textColor: 'text-blue-700 dark:text-blue-600',
},
warning: {
icon: (
<ExclamationCircleIcon
@ -90,7 +109,7 @@ export function Callout({
type: CalloutType;
children: ReactNode;
expanded?: boolean;
}) {
}): ReactElement {
const [isOpen, setIsOpen] = useState(type !== 'deepdive' || expanded);
const ui = typeMap[type] || typeMap.note;
const isCollapsible = type === 'deepdive';

View File

@ -7,7 +7,14 @@ export const callout: Schema = {
type: {
type: 'String',
default: 'note',
matches: ['caution', 'check', 'note', 'warning', 'deepdive'],
matches: [
'announcement',
'caution',
'check',
'note',
'warning',
'deepdive',
],
errorLevel: 'critical',
},
title: {