Skip to content

Commit 76bb14e

Browse files
committed
feat: Replace deprecated components
1 parent d5b1cd4 commit 76bb14e

File tree

17 files changed

+267
-238
lines changed

17 files changed

+267
-238
lines changed

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ yarn add cozy-ui
3434
If you use the transpiled components (from `cozy-ui/transpiled/react`), you need to import the stylesheet (once):
3535

3636
```
37-
import Button from 'cozy-ui/transpiled/react/deprecated/Button'
37+
import Button from 'cozy-ui/transpiled/react/Buttons'
3838
import 'cozy-ui/transpiled/react/stylesheet.css'
3939
4040
<Button />

docs/components/Wrapper.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import React, { useState } from 'react'
33
import Divider from '../../react/Divider'
44
import Paper from '../../react/Paper'
55
import Typography from '../../react/Typography'
6-
import Button from '../../react/deprecated/Button'
6+
import Button from '../../react/deprecated/Button' // TODO: should remove deprecated
77
import isTesting from '../../react/helpers/isTesting'
88
import CozyTheme from '../../react/providers/CozyTheme'
99
import { isUsingDevStyleguidist } from '../../scripts/build-utils'
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/* eslint-disable @typescript-eslint/ban-ts-comment */
2+
3+
// TODO: remove eslint-disable and @ts-ignore rules
4+
5+
import { Theme, useTheme } from '@material-ui/core'
6+
7+
import { isFlagshipApp } from 'cozy-device-helper'
8+
9+
import { isRsg } from '../hooks/useSetFlagshipUi/helpers'
10+
import { useSetFlagshipUI } from '../hooks/useSetFlagshipUi/useSetFlagshipUI'
11+
import { useCozyTheme } from '../providers/CozyTheme'
12+
13+
const getBottomBackground = (theme: Theme): string => {
14+
const sidebar = document.getElementById('sidebar')
15+
16+
return sidebar
17+
? getComputedStyle(sidebar).getPropertyValue('background-color')
18+
: theme.palette.background.paper
19+
}
20+
21+
const useHook = (): void => {
22+
const theme = useTheme()
23+
24+
const { isLight } = useCozyTheme()
25+
26+
useSetFlagshipUI(
27+
{
28+
bottomBackground: theme.palette.background.paper,
29+
// @ts-expect-error
30+
bottomTheme: isLight ? 'dark' : 'light',
31+
topOverlay: 'rgba(0, 0, 0, 0.5)',
32+
topBackground: theme.palette.background.paper,
33+
// @ts-expect-error
34+
topTheme: 'light'
35+
},
36+
{
37+
bottomBackground: getBottomBackground(theme),
38+
bottomTheme: isLight ? 'dark' : 'light',
39+
topOverlay: 'transparent',
40+
topBackground: theme.palette.background.paper,
41+
topTheme: isLight ? 'dark' : 'light'
42+
},
43+
'cozy-ui/ActionMenu'
44+
)
45+
}
46+
47+
export const useActionMenuEffects =
48+
isFlagshipApp() || isRsg
49+
? useHook
50+
: // eslint-disable-next-line @typescript-eslint/no-empty-function
51+
(): void => {}

react/ActionsMenu/ActionsMenuWrapper.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import PropTypes from 'prop-types'
22
import React from 'react'
33

4+
import { useActionMenuEffects } from './ActionMenuEffects'
45
import BottomSheet from '../BottomSheet'
56
import Menu from '../Menu'
67
import Paper from '../Paper'
7-
import { useActionMenuEffects } from '../deprecated/ActionMenu/ActionMenuEffects'
88
import isTesting from '../helpers/isTesting'
99
import useBreakpoints from '../providers/Breakpoints'
1010

react/Card/Readme.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ A card is a small block used to separate some content from the rest of the UI.
22

33
```jsx
44
import Box from 'cozy-ui/transpiled/react/Box'
5-
import Button from 'cozy-ui/transpiled/react/deprecated/Button'
5+
import Button from 'cozy-ui/transpiled/react/Buttons'
66
import Typography from "cozy-ui/transpiled/react/Typography"
77

88
;

0 commit comments

Comments
 (0)