Skip to content

Commit

Permalink
Solves build errors (#154)
Browse files Browse the repository at this point in the history
  • Loading branch information
DenisBessa authored Sep 30, 2023
1 parent d5e4250 commit c1dec9e
Show file tree
Hide file tree
Showing 26 changed files with 133 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,8 @@ export function InstallCommand() {
<SampleCodeSnippet
className="language-bash"
style={{ overflowX: 'hidden' }}
>
{tabValue.command}
</SampleCodeSnippet>
code={tabValue.command}
/>
</Tabs.Panel>
))}
</Tabs>
Expand Down
19 changes: 2 additions & 17 deletions apps/mantine-react-table-docs/components/mdx/SampleCodeSnippet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,13 @@ import {
CodeHighlight,
type CodeHighlightProps,
} from '@mantine/code-highlight';
import { Code, Paper, useMantineTheme } from '@mantine/core';

interface Props extends CodeHighlightProps {
children: string;
}

export function SampleCodeSnippet(props: Props) {
const { primaryColor } = useMantineTheme();

if (!props.language && !props.className) {
return <Code color={primaryColor} fz="0.9em" {...props} />;
}

if (!props.withCopyButton) {
return <CodeHighlight code={props.children} />;
}
import { Paper } from '@mantine/core';

export function SampleCodeSnippet(props: CodeHighlightProps) {
return (
<Paper radius="sm" shadow="sm" withBorder={props.withCopyButton}>
<CodeHighlight
{...props}
code={props.children}
language={props.language ?? props?.className?.replace(/language-/, '')}
/>
</Paper>
Expand Down
49 changes: 30 additions & 19 deletions apps/mantine-react-table-docs/components/mdx/SourceCodeSnippet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,11 @@ export const SourceCodeSnippet = ({
[defaultTS],
);

function filterUndefined<TValue>(value: TValue | undefined): value is TValue {
if (value === null || value === undefined) return false;
return true;
}

return (
<Box className={classes.wrapper}>
{Component && (
Expand Down Expand Up @@ -188,25 +193,31 @@ export const SourceCodeSnippet = ({
language: 'tsx',
icon: <IconBrandTypescript />,
},
javaScriptCode && {
fileName: 'JS',
code: javaScriptCode,
language: 'jsx',
icon: <IconBrandJavascript />,
},
legacyCode && {
fileName: 'Legacy',
code: legacyCode,
language: 'tsx',
icon: <IconCode />,
},
apiCode && {
fileName: 'API',
code: apiCode,
language: 'typescript',
icon: <IconApi />,
},
].filter(Boolean)}
javaScriptCode
? {
fileName: 'JS',
code: javaScriptCode,
language: 'jsx',
icon: <IconBrandJavascript />,
}
: undefined,
legacyCode
? {
fileName: 'Legacy',
code: legacyCode,
language: 'tsx',
icon: <IconCode />,
}
: undefined,
apiCode
? {
fileName: 'API',
code: apiCode,
language: 'typescript',
icon: <IconApi />,
}
: undefined,
].filter(filterUndefined)}
/>
</Box>
);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.directoryWrapper {
display: flex;
align-items: center;
margin-bottom: 20px;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import Head from 'next/head';
import Link from 'next/link';
import { Anchor, Breadcrumbs } from '@mantine/core';
import { useRouter } from 'next/router';
import classes from './BreadCrumbs.module.css';

export const BreadCrumbs = () => {
const { route } = useRouter();
Expand Down Expand Up @@ -51,15 +52,7 @@ export const BreadCrumbs = () => {
<Breadcrumbs aria-label="breadcrumb" style={{ paddingBottom: '16px' }}>
{breadCrumbLinks.map((link, index) => (
<Link key={index} href={link} passHref legacyBehavior>
<Anchor
color="inherit"
style={{
cursor: 'pointer',
textTransform: 'capitalize',
textDecoration: 'none',
'&:hover': { textDecoration: 'hover' },
}}
>
<Anchor c="inherit" className={classes.wrapper}>
{link === '/'
? 'Home'
: link
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import { useEffect, useState } from 'react';
import { Box, Anchor, Text } from '@mantine/core';
import { Box, Anchor, Text, useMantineColorScheme } from '@mantine/core';
import { useMediaQuery } from '@mantine/hooks';
import { useRouter } from 'next/router';

export const MiniNav = () => {
const { pathname } = useRouter();
const isXLDesktop = useMediaQuery('(min-width: 1800px)');
const [headings, setHeadings] = useState<NodeListOf<HTMLElement>>();
const { colorScheme } = useMantineColorScheme();

useEffect(() => {
setHeadings(
Expand Down Expand Up @@ -54,12 +55,12 @@ export const MiniNav = () => {
href={`#${heading.id}`}
style={(theme) => ({
color:
theme.colorScheme === 'dark'
colorScheme === 'dark'
? theme.colors.gray[3]
: theme.colors.gray[7],
})}
>
<Text underline component="span">
<Text td="underline" component="span">
{heading.innerText}
</Text>
</Anchor>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { Fragment, useCallback } from 'react';
import { useRouter } from 'next/router';
import Link from 'next/link';
import { UnstyledButton, Flex, rgba } from '@mantine/core';
import {
UnstyledButton,
Flex,
rgba,
useMantineColorScheme,
} from '@mantine/core';
import { useMediaQuery } from '@mantine/hooks';
import { IconExternalLink } from '@tabler/icons-react';
import { type RouteItem } from './routes';
Expand All @@ -27,6 +32,8 @@ export const SideBarItems = ({ depth = 1, routes, setNavOpen }: Props) => {
}
}, []);

const { colorScheme } = useMantineColorScheme();

return (
<>
{routes.map(({ href, items, label, external, secondaryItems }) => {
Expand All @@ -53,15 +60,12 @@ export const SideBarItems = ({ depth = 1, routes, setNavOpen }: Props) => {
? rgba(getPrimaryColor(theme), 0.2)
: 'transparent',
color: !items
? getPrimaryColor(
theme,
theme.colorScheme === 'dark' ? 3 : 8,
)
? getPrimaryColor(theme, colorScheme === 'dark' ? 3 : 8)
: depth === 1
? theme.colorScheme === 'dark'
? colorScheme === 'dark'
? theme.white
: theme.black
: theme.colorScheme === 'dark'
: colorScheme === 'dark'
? theme.colors.gray[3]
: theme.colors.gray[7],
display: 'block',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
} from '@mantine/core';
import { IconBrandGithub, IconBrandDiscord } from '@tabler/icons-react';
import { useMediaQuery } from '@mantine/hooks';
import { IconSun, IconMoonStars } from '@tabler/icons-react';
import docsearch from '@docsearch/js';
import '@docsearch/css';
import { getPrimaryColor } from 'mantine-react-table/src/column.utils';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ const CellInstanceAPIsTable = ({ onlyOptions }: Props) => {
header: 'Type',
enableGlobalFilter: false,
Cell: ({ cell }) => (
<SampleCodeSnippet language="typescript" noCopy>
{cell.getValue<string>()}
</SampleCodeSnippet>
<SampleCodeSnippet
language="typescript"
withCopyButton={false}
code={cell.getValue<string>()}
/>
),
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,11 @@ const ColumnInstanceAPIsTable = ({ onlyOptions }: Props) => {
header: 'Type',
enableGlobalFilter: false,
Cell: ({ cell }) => (
<SampleCodeSnippet language="typescript" noCopy>
{cell.getValue<string>()}
</SampleCodeSnippet>
<SampleCodeSnippet
language="typescript"
withCopyButton={false}
code={cell.getValue<string>()}
/>
),
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,11 @@ const ColumnOptionsTable = ({ onlyOptions }: Props) => {
header: 'Type',
enableGlobalFilter: false,
Cell: ({ cell }) => (
<SampleCodeSnippet language="typescript" noCopy>
{cell.getValue<string>()}
</SampleCodeSnippet>
<SampleCodeSnippet
language="typescript"
withCopyButton={false}
code={cell.getValue<string>()}
/>
),
},
{
Expand All @@ -59,9 +61,11 @@ const ColumnOptionsTable = ({ onlyOptions }: Props) => {
enableGlobalFilter: false,
header: 'Default Value',
Cell: ({ cell }) => (
<SampleCodeSnippet language="typescript" noCopy>
{cell.getValue<string>()}
</SampleCodeSnippet>
<SampleCodeSnippet
language="typescript"
withCopyButton={false}
code={cell.getValue<string>()}
/>
),
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ const RowInstanceAPIsTable = ({ onlyOptions }: Props) => {
header: 'Type',
enableGlobalFilter: false,
Cell: ({ cell }) => (
<SampleCodeSnippet language="typescript" noCopy>
{cell.getValue<string>()}
</SampleCodeSnippet>
<SampleCodeSnippet
language="typescript"
withCopyButton={false}
code={cell.getValue<string>()}
/>
),
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,23 @@ const StateOptionsTable = ({ onlyOptions }: Props) => {
header: 'Type',
enableGlobalFilter: false,
Cell: ({ cell }) => (
<SampleCodeSnippet language="typescript" noCopy>
{cell.getValue<string>()}
</SampleCodeSnippet>
<SampleCodeSnippet
language="typescript"
withCopyButton={false}
code={cell.getValue<string>()}
/>
),
},
{
accessorKey: 'defaultValue',
enableGlobalFilter: false,
header: 'Default Value',
Cell: ({ cell }) => (
<SampleCodeSnippet language="typescript" noCopy>
{cell.getValue<string>()}
</SampleCodeSnippet>
<SampleCodeSnippet
language="typescript"
withCopyButton={false}
code={cell.getValue<string>()}
/>
),
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,11 @@ const TableInstanceAPIsTable = ({ onlyOptions }: Props) => {
header: 'Type',
enableGlobalFilter: false,
Cell: ({ cell }) => (
<SampleCodeSnippet language="typescript" noCopy>
{cell.getValue<string>()}
</SampleCodeSnippet>
<SampleCodeSnippet
language="typescript"
withCopyButton={false}
code={cell.getValue<string>()}
/>
),
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,11 @@ const TableOptionsTable = ({ onlyOptions }: Props) => {
accessorKey: 'type',
enableGlobalFilter: false,
Cell: ({ cell }) => (
<SampleCodeSnippet language="typescript" noCopy>
{cell.getValue<string>()}
</SampleCodeSnippet>
<SampleCodeSnippet
language="typescript"
withCopyButton={false}
code={cell.getValue<string>()}
/>
),
},
{
Expand All @@ -63,9 +65,11 @@ const TableOptionsTable = ({ onlyOptions }: Props) => {
accessorKey: 'defaultValue',
enableGlobalFilter: false,
Cell: ({ cell }) => (
<SampleCodeSnippet language="typescript" noCopy>
{cell.getValue<string>()}
</SampleCodeSnippet>
<SampleCodeSnippet
language="typescript"
withCopyButton={false}
code={cell.getValue<string>()}
/>
),
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const RemoteFetching = ({ isPage = false }) => {
<Box style={{ width: '100%', marginTop: '1rem' }}>
<Tabs
value={isPage ? pathname.split('/').pop() : activeTab}
onTabChange={(newPath) =>
onChange={(newPath) =>
isPage && newPath !== 'more'
? push(newPath as string)
: setActiveTab(newPath as string)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const EditingCRUD = ({ isPage = false }) => {
<Box style={{ width: '100%', marginTop: '1rem' }}>
<Tabs
value={isPage ? pathname.split('/').pop() : activeTab}
onTabChange={(newPath) =>
onChange={(newPath) =>
isPage && newPath !== 'more'
? push(newPath as string)
: setActiveTab(newPath as string)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ const LocaleExamples = () => {
return (
<>
<Box style={{ width: '100%' }}>
<Tabs onTabChange={setCurrentLocale} value={currentLocale}>
<Tabs onChange={setCurrentLocale} value={currentLocale}>
<Tabs.List>
{supportedLocales.map((locale) => (
<Tabs.Tab key={locale} value={locale}>
Expand Down
Loading

0 comments on commit c1dec9e

Please sign in to comment.