Skip to content

Commit

Permalink
[code-infra] Move HighlightedCodeWithTabs to @mui/docs (#42060)
Browse files Browse the repository at this point in the history
  • Loading branch information
Janpot committed Jul 4, 2024
1 parent df2b591 commit 53c8624
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 8 deletions.
3 changes: 1 addition & 2 deletions docs/src/modules/components/Demo.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import IconButton from '@mui/material/IconButton';
import Box from '@mui/material/Box';
import Collapse from '@mui/material/Collapse';
import NoSsr from '@mui/material/NoSsr';
import { HighlightedCode } from '@mui/docs/HighlightedCode';
import { HighlightedCode, CodeTab, CodeTabList } from '@mui/docs/HighlightedCode';
import ContentCopyRoundedIcon from '@mui/icons-material/ContentCopyRounded';
import LibraryAddCheckRoundedIcon from '@mui/icons-material/LibraryAddCheckRounded';
import DemoSandbox from 'docs/src/modules/components/DemoSandbox';
Expand All @@ -28,7 +28,6 @@ import { useUserLanguage, useTranslate } from '@mui/docs/i18n';
import stylingSolutionMapping from 'docs/src/modules/utils/stylingSolutionMapping';
import DemoToolbarRoot from 'docs/src/modules/components/DemoToolbarRoot';
import { BrandingProvider, blue, blueDark, grey } from '@mui/docs/branding';
import { CodeTab, CodeTabList } from 'docs/src/modules/components/HighlightedCodeWithTabs';

/**
* Removes leading spaces (indentation) present in the `.tsx` previews
Expand Down
5 changes: 5 additions & 0 deletions docs/src/modules/components/HighlightedCodeWithTabs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// Backwards compatibility for Toolpad and X.
// TODO: remove when Toolpad and X migrated to `@mui/docs/HighlightedCode`
import { HighlightedCodeWithTabs } from '@mui/docs/HighlightedCode';

export default HighlightedCodeWithTabs;
2 changes: 1 addition & 1 deletion docs/src/modules/components/RichMarkdownElement.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import * as React from 'react';
import PropTypes from 'prop-types';
import { useTranslate, useUserLanguage } from '@mui/docs/i18n';
import { HighlightedCodeWithTabs } from '@mui/docs/HighlightedCode';
import { MarkdownElement } from '@mui/docs/MarkdownElement';
import HighlightedCodeWithTabs from 'docs/src/modules/components/HighlightedCodeWithTabs';
import Demo from 'docs/src/modules/components/Demo';

function noComponent(moduleID) {
Expand Down
1 change: 1 addition & 0 deletions packages/mui-docs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
"@mui/material": "^5.0.0",
"@mui/system": "^5.0.0",
"@types/react": "^17.0.0 || ^18.0.0",
"chai": "^4.4.1",
"next": "^13.5.1 || ^14",
"react": "^17.0.0 || ^18.0.0"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import * as React from 'react';
import { expect } from 'chai';
import { createRenderer } from '@mui/internal-test-utils';
import { ThemeProvider, createTheme } from '@mui/material/styles';
import { getDesignTokens } from '@mui/docs/branding';
import { HighlightedCode } from '@mui/docs/HighlightedCode';
import { getDesignTokens } from '../branding';
import { HighlightedCode } from './HighlightedCode';

describe('HighlightedCode', () => {
const { render } = createRenderer();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { TabsList as TabsListBase } from '@mui/base/TabsList';
import { TabPanel as TabPanelBase } from '@mui/base/TabPanel';
import { Tab as TabBase } from '@mui/base/Tab';
import useLocalStorageState from '@mui/utils/useLocalStorageState';
import { HighlightedCode } from '@mui/docs/HighlightedCode';
import { HighlightedCode } from './HighlightedCode';

export const CodeTabList = styled(TabsListBase)<{
ownerState: { mounted: boolean; contained?: boolean };
Expand Down Expand Up @@ -285,7 +285,7 @@ type TabsConfig = {
tab: string;
};

export default function HighlightedCodeWithTabs(
export function HighlightedCodeWithTabs(
props: {
tabs: Array<TabsConfig>;
storageKey?: string;
Expand Down Expand Up @@ -320,7 +320,6 @@ export default function HighlightedCodeWithTabs(
{tabs.map(({ tab, language, code }) => (
<CodeTabPanel ownerState={ownerState} key={tab} value={tab}>
<HighlightedCode
// @ts-ignore
language={language || 'bash'}
code={typeof code === 'function' ? code(tab) : code}
/>
Expand Down
1 change: 1 addition & 0 deletions packages/mui-docs/src/HighlightedCode/index.tsx
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * from './HighlightedCode';
export * from './HighlightedCodeWithTabs';
4 changes: 4 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 53c8624

Please sign in to comment.