feat(nx-dev): allow callout component to be expanded by default (#29806)
This commit is contained in:
parent
3dd3ab7421
commit
10c14b6f17
@ -7,7 +7,7 @@ cover_image: /blog/images/articles/ts-islands.png
|
|||||||
youtubeUrl: https://youtu.be/SDE3cIq28s8
|
youtubeUrl: https://youtu.be/SDE3cIq28s8
|
||||||
---
|
---
|
||||||
|
|
||||||
{% callout type="deepdive" title="TypeScript Project References Series" %}
|
{% callout type="deepdive" title="TypeScript Project References Series" expanded=true %}
|
||||||
|
|
||||||
This article is part of the TypeScript Project References series:
|
This article is part of the TypeScript Project References series:
|
||||||
|
|
||||||
|
|||||||
@ -6,7 +6,7 @@ tags: [typescript, monorepo, nx]
|
|||||||
cover_image: /blog/images/articles/bg-managing-typescript-packages.jpg
|
cover_image: /blog/images/articles/bg-managing-typescript-packages.jpg
|
||||||
---
|
---
|
||||||
|
|
||||||
{% callout type="deepdive" title="TypeScript Project References Series" %}
|
{% callout type="deepdive" title="TypeScript Project References Series" expanded=true %}
|
||||||
|
|
||||||
This article is part of the TypeScript Project References series:
|
This article is part of the TypeScript Project References series:
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,7 @@ cover_image: /blog/images/articles/new-ts-experience-bg.jpg
|
|||||||
youtubeUrl: https://youtu.be/D9D8KNffyBk
|
youtubeUrl: https://youtu.be/D9D8KNffyBk
|
||||||
---
|
---
|
||||||
|
|
||||||
{% callout type="deepdive" title="TypeScript Project References Series" %}
|
{% callout type="deepdive" title="TypeScript Project References Series" expanded=true %}
|
||||||
|
|
||||||
This article is part of the TypeScript Project References series:
|
This article is part of the TypeScript Project References series:
|
||||||
|
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
'use client';
|
'use client';
|
||||||
|
|
||||||
import React, { useState, useEffect } from 'react';
|
import React, { useState, useEffect, type ReactNode } from 'react';
|
||||||
import cx from 'classnames';
|
import cx from 'classnames';
|
||||||
import {
|
import {
|
||||||
ChevronRightIcon,
|
ChevronRightIcon,
|
||||||
@ -84,22 +84,22 @@ export function Callout({
|
|||||||
title,
|
title,
|
||||||
type,
|
type,
|
||||||
children,
|
children,
|
||||||
defaultExpanded = false,
|
expanded = false,
|
||||||
}: {
|
}: {
|
||||||
title: string;
|
title: string;
|
||||||
type: CalloutType;
|
type: CalloutType;
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
defaultExpanded?: boolean;
|
expanded?: boolean;
|
||||||
}) {
|
}) {
|
||||||
const [isOpen, setIsOpen] = useState(type !== 'deepdive');
|
const [isOpen, setIsOpen] = useState(type !== 'deepdive' || expanded);
|
||||||
const ui = typeMap[type] || typeMap.note;
|
const ui = typeMap[type] || typeMap.note;
|
||||||
const isCollapsible = type === 'deepdive';
|
const isCollapsible = type === 'deepdive';
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (isCollapsible) {
|
if (isCollapsible) {
|
||||||
setIsOpen(defaultExpanded);
|
setIsOpen(expanded);
|
||||||
}
|
}
|
||||||
}, [defaultExpanded, isCollapsible]);
|
}, [expanded, isCollapsible]);
|
||||||
|
|
||||||
const toggleOpen = () => {
|
const toggleOpen = () => {
|
||||||
if (isCollapsible) {
|
if (isCollapsible) {
|
||||||
|
|||||||
@ -2,21 +2,21 @@ import { Schema } from '@markdoc/markdoc';
|
|||||||
|
|
||||||
export const callout: Schema = {
|
export const callout: Schema = {
|
||||||
render: 'Callout',
|
render: 'Callout',
|
||||||
description: 'Display the enclosed content in a callout box',
|
|
||||||
children: ['paragraph', 'tag', 'list'],
|
children: ['paragraph', 'tag', 'list'],
|
||||||
attributes: {
|
attributes: {
|
||||||
type: {
|
type: {
|
||||||
type: 'String',
|
type: 'String',
|
||||||
default: 'note',
|
default: 'note',
|
||||||
matches: ['caution', 'check', 'note', 'warning'],
|
matches: ['caution', 'check', 'note', 'warning', 'deepdive'],
|
||||||
errorLevel: 'critical',
|
errorLevel: 'critical',
|
||||||
description:
|
|
||||||
'Controls the color and icon of the callout. Can be: "caution", "check", "note", "warning"',
|
|
||||||
},
|
},
|
||||||
title: {
|
title: {
|
||||||
type: 'String',
|
type: 'String',
|
||||||
required: true,
|
required: true,
|
||||||
description: 'The title displayed at the top of the callout',
|
},
|
||||||
|
expanded: {
|
||||||
|
type: 'Boolean',
|
||||||
|
default: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user