Skip to content
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
53 changes: 53 additions & 0 deletions packages/ra-ui-materialui/src/Link.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import * as React from 'react';
import { Paper, Stack } from '@mui/material';
import { AdminContext } from './AdminContext';
import { Link, LinkProps } from './Link';
import { defaultDarkTheme, defaultLightTheme } from './theme';

export default { title: 'ra-ui-materialui/Link' };

export const Basic = ({
theme,
value,
...props
}: Partial<LinkProps> & { theme?: string; value?: string }) => {
return (
<AdminContext
theme={
theme === 'light'
? defaultLightTheme
: theme === 'dark'
? defaultDarkTheme
: {
components: {
RaLink: {
styleOverrides: {
root: {
color: 'purple',
},
},
},
},
}
}
>
<Paper sx={{ p: 2 }}>
<Stack direction="row">
<Link to="/" {...props}>
Test
</Link>
</Stack>
</Paper>
</AdminContext>
);
};

Basic.argTypes = {
theme: {
options: ['light', 'dark', 'custom'],
control: { type: 'select' },
},
};
Basic.args = {
theme: 'light',
};
12 changes: 6 additions & 6 deletions packages/ra-ui-materialui/src/Link.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ export const LinkClasses = {
link: `${PREFIX}-link`,
};

const StyledMuiLink = styled(MuiLink)({
const StyledMuiLink = styled(MuiLink, {
name: PREFIX,
overridesResolver: (props, styles) => styles.root,
}) as typeof MuiLink; // @see https://mui.com/material-ui/guides/typescript/#complications-with-the-component-prop
})({}) as typeof MuiLink; // @see https://mui.com/material-ui/guides/typescript/#complications-with-the-component-prop

// @see https://mui.com/material-ui/guides/composition/#with-typescript
export interface LinkProps
Expand All @@ -50,19 +50,19 @@ export interface LinkProps

declare module '@mui/material/styles' {
interface ComponentNameToClassKey {
RaLink: 'root' | 'link';
[PREFIX]: 'root';
}

interface ComponentsPropsList {
RaLink: Partial<LinkProps>;
[PREFIX]: Partial<LinkProps>;
}

interface Components {
RaLink?: {
defaultProps?: ComponentsPropsList['RaLink'];
defaultProps?: ComponentsPropsList[typeof PREFIX];
styleOverrides?: ComponentsOverrides<
Omit<Theme, 'components'>
>['RaLink'];
>[typeof PREFIX];
};
}
}
Loading