Skip to content

feat: CodeGroup component - #166

Merged
lawreka merged 20 commits into
mainfrom
kathryn/eng-5509-pt-2
Jan 23, 2026
Merged

feat: CodeGroup component#166
lawreka merged 20 commits into
mainfrom
kathryn/eng-5509-pt-2

Conversation

@lawreka

@lawreka lawreka commented Jan 22, 2026

Copy link
Copy Markdown
Contributor

Note

Adds a new multi-tab code snippet container with unified theming and copy behavior, and updates CodeBlock to align with it.

  • New CodeGroup component: Tabbed code snippets with optional language dropdown, shared header actions (copy/Ask AI/feedback), expandable panels, and system/dark themes; includes LanguageDropdown, CodeSelectDropdown, LanguageIcon, Dropdown primitives, and CodeSnippet helper
  • CodeBlock updates: Replaces literal union with CodeBlockTheme type, passes theme to header/copy button, adds copyButtonProps (deprecates direct onCopied on CodeBlock), minor base highlighting/height logic tweaks
  • Icons/utilities: ActiveCopyButtonIcon/CopyButtonIcon accept CodeBlockTheme; Shiki background util and validation types updated to use CodeBlockTheme
  • Storybook: Extensive stories for CodeGroup (wrapping, lines, highlight/focus, themes, dropdowns, expandable, long lines, special chars)

Risk: Medium — new UI component and API adjustments for CodeBlock (prop changes) plus new dependencies (@base-ui/react/*, dropdown/scroll helpers) may impact consumers.

Written by Cursor Bugbot for commit f566c72. This will update automatically on new commits. Configure here.

@linear

linear Bot commented Jan 22, 2026

Copy link
Copy Markdown
ENG-5509 Code Block + Code Group

Move the codeGroup component into the OSS components package repository.

Check general rules and specifics in https://www.notion.so/mintlify/Docs-Components-rules-audit-2d1aa841023480ba93b7e1a8676522db

@lawreka
lawreka marked this pull request as ready for review January 22, 2026 23:00
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

Comment thread packages/components/src/components/code-group/code-group-select.tsx Outdated
interface CodeGroupSelectProps {
snippets: Record<string, Record<string, ExampleCodeSnippet>>;
setSelectedExampleIndex?: (index: number) => void;
codeBlockTheme?: "system" | "dark";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't we already have this type somewhere?

noMargins?: boolean;
feedbackModalOpen?: boolean;
anchorRef?: RefObject<HTMLDivElement>;
codeBlockTheme?: "dark" | "system";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Comment thread packages/components/src/components/code-group/code-group.tsx Outdated
Comment on lines +255 to +261
{
children: ReactNode;
value: number;
isSelected: boolean;
tabsLength: number;
codeBlockTheme: "dark" | "system" | undefined;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we move this to TabItemProps

Comment thread packages/components/src/components/code-group/code-select-dropdown.tsx Outdated
selectedOption?: string;
setSelectedOption: (option: string) => void;
options: string[];
codeBlockTheme?: "system" | "dark";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Comment thread packages/components/src/components/code-group/code-snippet.tsx Outdated
selectedLanguage: string;
setSelectedLanguage: (language: string, index: number) => void;
languages: string[];
codeBlockTheme?: "dark" | "system";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Comment on lines +8 to +9
language: string;
className?: string;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LanguageIconProps

lawreka and others added 3 commits January 23, 2026 10:03
…t.tsx

Co-authored-by: dmytro <71014515+pqoqubbw@users.noreply.github.com>
Co-authored-by: dmytro <71014515+pqoqubbw@users.noreply.github.com>
lawreka and others added 5 commits January 23, 2026 10:05
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

@lawreka
lawreka merged commit a06b0a9 into main Jan 23, 2026
3 checks passed
@lawreka
lawreka deleted the kathryn/eng-5509-pt-2 branch January 23, 2026 18:45

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

*/
onCopied?: (result: CopyToClipboardResult, textToCopy?: string) => void;
children?: ReactNode;
copyButtonProps?: CopyToClipboardButtonProps;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copyButtonProps type requires textToCopy, overrides computed value

Medium Severity

The copyButtonProps prop has type CopyToClipboardButtonProps which requires textToCopy: string. Since the component computes textToCopy internally and spreads copyButtonProps after the explicit prop, users face two problems: TypeScript errors when passing just onCopied without textToCopy, and unintentional override of the computed text when they do provide textToCopy. The type should likely be Omit<CopyToClipboardButtonProps, 'textToCopy'> to allow passing callbacks without forcing a textToCopy value.

Additional Locations (1)

Fix in Cursor Fix in Web

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants