Skip to content

Commit

Permalink
feat: Move default props def from theme creation to components
Browse files Browse the repository at this point in the history
Ideally, defaultProps should be in the `components` key of the theme https://mui.com/material-ui/customization/theme-components/#default-props but we will reserve this key for overrides. And anyway we already change defaultProps directly from components.
  • Loading branch information
JF-Cozy committed May 23, 2023
1 parent faa161d commit 233ea87
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 18 deletions.
8 changes: 5 additions & 3 deletions react/MuiCozyTheme/Accordion/Readme.md
@@ -1,9 +1,11 @@
See [Material UI documentation](https://material-ui.com/demos/expansion-panels/) to learn more about Accordion.

```jsx
import Accordion from '@material-ui/core/Accordion';
import AccordionSummary from '@material-ui/core/AccordionSummary';
import AccordionDetails from '@material-ui/core/AccordionDetails';
import Accordion from 'cozy-ui/transpiled/react/MuiCozyTheme/Accordion'
import AccordionSummary from 'cozy-ui/transpiled/react/MuiCozyTheme/AccordionSummary'
import AccordionDetails from 'cozy-ui/transpiled/react/MuiCozyTheme/AccordionDetails'

;

<>
<Accordion>
Expand Down
7 changes: 7 additions & 0 deletions react/MuiCozyTheme/AccordionSummary/index.js
@@ -1,3 +1,10 @@
import React from 'react'
import AccordionSummary from '@material-ui/core/AccordionSummary'

import AccordionExpandIcon from '../AccordionExpandIcon'

AccordionSummary.defaultProps = {
expandIcon: <AccordionExpandIcon />
}

export default AccordionSummary
15 changes: 0 additions & 15 deletions react/MuiCozyTheme/makeTheme.jsx
@@ -1,9 +1,6 @@
import React from 'react'

import { createTheme } from '../styles'
import { getCssVariableValue } from '../utils/color'
import isTesting from '../helpers/isTesting'
import AccordionExpandIcon from './AccordionExpandIcon'
import { makePalette } from './makePalette'
import { makeTypography } from './makeTypography'
import { makeShadows } from './makeShadows'
Expand All @@ -30,18 +27,6 @@ const themesCommonConfig = {
'0px 2px 8px rgba(29, 33, 42, 0.16), 0px 0px 1px rgba(29, 33, 42, 0.48)'
],
shadows: makeShadows(), // Shadow ar not linked to themes
props: {
MuiTabs: {
textColor: 'primary',
TabIndicatorProps: { color: 'primary' }
},
MuiTooltip: {
arrow: true
},
MuiAccordionSummary: {
expandIcon: <AccordionExpandIcon />
}
},
...(isTesting() && { transitions: { create: () => 'none' } })
}

Expand Down
5 changes: 5 additions & 0 deletions react/MuiTabs/index.jsx
Expand Up @@ -8,4 +8,9 @@ const Tabs = props => {
return <MuiTabs variant={isMobile ? 'fullWidth' : undefined} {...props} />
}

Tabs.defaultProps = {
textColor: 'primary',
TabIndicatorProps: { color: 'primary' }
}

export { Tabs, Tab }
4 changes: 4 additions & 0 deletions react/Tooltip/index.jsx
@@ -1,3 +1,7 @@
import MUITooltip from '@material-ui/core/Tooltip'

MUITooltip.defaultProps = {
arrow: true
}

export default MUITooltip

0 comments on commit 233ea87

Please sign in to comment.