File tree Expand file tree Collapse file tree 2 files changed +59
-6
lines changed
packages/ra-ui-materialui/src Expand file tree Collapse file tree 2 files changed +59
-6
lines changed Original file line number Diff line number Diff line change 1+ import * as React from 'react' ;
2+ import { Paper , Stack } from '@mui/material' ;
3+ import { AdminContext } from './AdminContext' ;
4+ import { Link , LinkProps } from './Link' ;
5+ import { defaultDarkTheme , defaultLightTheme } from './theme' ;
6+
7+ export default { title : 'ra-ui-materialui/Link' } ;
8+
9+ export const Basic = ( {
10+ theme,
11+ value,
12+ ...props
13+ } : Partial < LinkProps > & { theme ?: string ; value ?: string } ) => {
14+ return (
15+ < AdminContext
16+ theme = {
17+ theme === 'light'
18+ ? defaultLightTheme
19+ : theme === 'dark'
20+ ? defaultDarkTheme
21+ : {
22+ components : {
23+ RaLink : {
24+ styleOverrides : {
25+ root : {
26+ color : 'purple' ,
27+ } ,
28+ } ,
29+ } ,
30+ } ,
31+ }
32+ }
33+ >
34+ < Paper sx = { { p : 2 } } >
35+ < Stack direction = "row" >
36+ < Link to = "/" { ...props } >
37+ Test
38+ </ Link >
39+ </ Stack >
40+ </ Paper >
41+ </ AdminContext >
42+ ) ;
43+ } ;
44+
45+ Basic . argTypes = {
46+ theme : {
47+ options : [ 'light' , 'dark' , 'custom' ] ,
48+ control : { type : 'select' } ,
49+ } ,
50+ } ;
51+ Basic . args = {
52+ theme : 'light' ,
53+ } ;
Original file line number Diff line number Diff line change @@ -37,10 +37,10 @@ export const LinkClasses = {
3737 link : `${ PREFIX } -link` ,
3838} ;
3939
40- const StyledMuiLink = styled ( MuiLink ) ( {
40+ const StyledMuiLink = styled ( MuiLink , {
4141 name : PREFIX ,
4242 overridesResolver : ( props , styles ) => styles . root ,
43- } ) as typeof MuiLink ; // @see https://mui.com/material-ui/guides/typescript/#complications-with-the-component-prop
43+ } ) ( { } ) as typeof MuiLink ; // @see https://mui.com/material-ui/guides/typescript/#complications-with-the-component-prop
4444
4545// @see https://mui.com/material-ui/guides/composition/#with-typescript
4646export interface LinkProps
@@ -50,19 +50,19 @@ export interface LinkProps
5050
5151declare module '@mui/material/styles' {
5252 interface ComponentNameToClassKey {
53- RaLink : 'root' | 'link' ;
53+ [ PREFIX ] : 'root' | 'link' ;
5454 }
5555
5656 interface ComponentsPropsList {
57- RaLink : Partial < LinkProps > ;
57+ [ PREFIX ] : Partial < LinkProps > ;
5858 }
5959
6060 interface Components {
6161 RaLink ?: {
62- defaultProps ?: ComponentsPropsList [ 'RaLink' ] ;
62+ defaultProps ?: ComponentsPropsList [ typeof PREFIX ] ;
6363 styleOverrides ?: ComponentsOverrides <
6464 Omit < Theme , 'components' >
65- > [ 'RaLink' ] ;
65+ > [ typeof PREFIX ] ;
6666 } ;
6767 }
6868}
You can’t perform that action at this time.
0 commit comments