Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(nx-dev): allow callout component to be expanded by default #29806

Merged
merged 1 commit into from
Jan 29, 2025
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
2 changes: 1 addition & 1 deletion docs/blog/2025-01-27-project-references.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ cover_image: /blog/images/articles/ts-islands.png
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:

Expand Down
2 changes: 1 addition & 1 deletion docs/blog/2025-01-28-managing-ts-pkgs-in-monorepos.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ tags: [typescript, monorepo, nx]
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:

Expand Down
2 changes: 1 addition & 1 deletion docs/blog/2025-01-29-new-nx-experience.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ cover_image: /blog/images/articles/new-ts-experience-bg.jpg
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:

Expand Down
12 changes: 6 additions & 6 deletions nx-dev/ui-markdoc/src/lib/tags/callout.component.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
'use client';

import React, { useState, useEffect } from 'react';
import React, { useState, useEffect, type ReactNode } from 'react';
import cx from 'classnames';
import {
ChevronRightIcon,
Expand Down Expand Up @@ -84,22 +84,22 @@ export function Callout({
title,
type,
children,
defaultExpanded = false,
expanded = false,
}: {
title: string;
type: CalloutType;
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 isCollapsible = type === 'deepdive';

useEffect(() => {
if (isCollapsible) {
setIsOpen(defaultExpanded);
setIsOpen(expanded);
}
}, [defaultExpanded, isCollapsible]);
}, [expanded, isCollapsible]);

const toggleOpen = () => {
if (isCollapsible) {
Expand Down
10 changes: 5 additions & 5 deletions nx-dev/ui-markdoc/src/lib/tags/callout.schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ import { Schema } from '@markdoc/markdoc';

export const callout: Schema = {
render: 'Callout',
description: 'Display the enclosed content in a callout box',
children: ['paragraph', 'tag', 'list'],
attributes: {
type: {
type: 'String',
default: 'note',
matches: ['caution', 'check', 'note', 'warning'],
matches: ['caution', 'check', 'note', 'warning', 'deepdive'],
errorLevel: 'critical',
description:
'Controls the color and icon of the callout. Can be: "caution", "check", "note", "warning"',
},
title: {
type: 'String',
required: true,
description: 'The title displayed at the top of the callout',
},
expanded: {
type: 'Boolean',
default: false,
},
},
};