Skip to content

Commit 418a5ee

Browse files
mwclemyClement Mwimo
andauthored
feat: switch from @kyper/mui to @mxenabled/mxui
* replaced kyper/mui with mxui * feat: switch from Kyper MUI to MXUI * bump mxui version * fixed client overrides * fixed the test * added a comment * fixed the test * fixed misaligned styles --------- Co-authored-by: Clement Mwimo <clement.mwimo@mx.com>
1 parent 8aa1375 commit 418a5ee

File tree

77 files changed

+157
-376
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+157
-376
lines changed

package-lock.json

Lines changed: 0 additions & 128 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
"@kyper/input": "^6.1.0",
3636
"@kyper/institutionlogo": "^3.1.0",
3737
"@kyper/messagebox": "^3.1.0",
38-
"@kyper/mui": "^4.5.0",
3938
"@kyper/progressindicators": "^3.1.0",
4039
"@kyper/select": "^2.0.0",
4140
"@kyper/selectionbox": "^2.1.0",

src/ConnectedTokenProvider.tsx

Lines changed: 42 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11
import React from 'react'
22
import { RootState } from 'src/redux/Store'
3-
import _isEmpty from 'lodash/isEmpty'
43
import { useSelector } from 'react-redux'
54

65
import { Theme, ThemeProvider } from '@mui/material'
76
import { deepmerge } from '@mui/utils'
87

9-
import { createMXTheme, Icon, IconWeight } from '@kyper/mui'
8+
import { createMXTheme, Icon, IconWeight } from '@mxenabled/mxui'
109
import { TokenProvider, THEMES } from '@kyper/tokenprovider'
1110

12-
import { getTokenProviderValues } from 'src/redux/selectors/ClientColorScheme'
11+
import { getPrimarySeedColor } from 'src/redux/selectors/ClientColorScheme'
1312

1413
declare module '@mui/material/styles' {
1514
interface PaletteColor {
@@ -23,30 +22,6 @@ declare module '@mui/material/styles' {
2322
}
2423
}
2524

26-
interface ColorScheme {
27-
Brand100?: string
28-
Brand200?: string
29-
Brand300?: string
30-
Brand400?: string
31-
Brand500?: string
32-
}
33-
34-
export const clientThemeOverrides = (colorScheme: ColorScheme) => {
35-
if (!_isEmpty(colorScheme)) {
36-
return {
37-
palette: {
38-
primary: {
39-
lighter: colorScheme.Brand100,
40-
light: colorScheme.Brand200,
41-
main: colorScheme.Brand300,
42-
dark: colorScheme.Brand400,
43-
darker: colorScheme.Brand500,
44-
},
45-
},
46-
}
47-
}
48-
return {}
49-
}
5025
const connectThemeOverrides = (palette: Theme['palette']) => ({
5126
components: {
5227
MuiTypography: {
@@ -55,11 +30,6 @@ const connectThemeOverrides = (palette: Theme['palette']) => ({
5530
// Sets the default color of text. Can override singluar usage with color prop.
5631
color: palette?.text?.primary,
5732
},
58-
// TODO: Remove once we fully migrate to @mxenabled/mxui as it would apply the right theme styles automatically.
59-
subtitle2: {
60-
fontSize: '13px',
61-
lineHeight: '20px',
62-
},
6333
},
6434
},
6535
MuiAccordion: {
@@ -111,12 +81,6 @@ const connectThemeOverrides = (palette: Theme['palette']) => ({
11181
},
11282
MuiFormLabel: {
11383
styleOverrides: {
114-
root: {
115-
'&.MuiFormLabel-root': {
116-
fontSize: '13px',
117-
lineHeight: '20px',
118-
},
119-
},
12084
asterisk: {
12185
color: '#E32727',
12286
'&$error': {
@@ -149,6 +113,20 @@ const connectThemeOverrides = (palette: Theme['palette']) => ({
149113
},
150114
},
151115
},
116+
MuiLink: {
117+
defaultProps: {
118+
sx: {
119+
display: 'inline-flex',
120+
alignItems: 'center',
121+
'&:hover': {
122+
textDecoration: 'underline',
123+
},
124+
'&:focus': {
125+
textDecoration: 'underline',
126+
},
127+
},
128+
},
129+
},
152130
},
153131
})
154132

@@ -157,27 +135,45 @@ interface Props {
157135
}
158136

159137
export const ConnectedTokenProvider = ({ children }: Props): React.ReactNode => {
160-
// Client custom tokens from batcave
161-
const clientCustomTokens = useSelector(getTokenProviderValues)
138+
// Client primary seed color from batcave
139+
const clientPrimarySeedColor = useSelector(getPrimarySeedColor)
162140
// "Light" or "Dark"
163141
const colorScheme = useSelector((state: RootState) => state.config.color_scheme)
164142
// Dark mode: true or false
165143
const isDarkModeEnabled: boolean = colorScheme === THEMES.DARK
166144
// Theme object with MX overrides
167-
const mxTheme = createMXTheme(isDarkModeEnabled ? 'dark' : 'light')
145+
const mxTheme = createMXTheme(isDarkModeEnabled ? 'dark' : 'light', {
146+
paletteOptions: {
147+
// Override primary color with widget_brand_color from batcave if it exists or use primary_300 from batcave and
148+
// let the rest of the palette colors be generated by MXUI.
149+
primary: clientPrimarySeedColor,
150+
},
151+
})
168152

169153
const combinedTheme = deepmerge(
170154
mxTheme,
171-
deepmerge(
172-
clientThemeOverrides(clientCustomTokens.tokenOverrides.Color), // Theme object with client custom overrides
173-
connectThemeOverrides(mxTheme.palette as Theme['palette']), // Theme object with connect overrides
174-
),
155+
connectThemeOverrides(mxTheme.palette as Theme['palette']), // Theme object with connect overrides
175156
)
176157

158+
const kyperTokenOverrides = {
159+
Color: {
160+
Brand100: isDarkModeEnabled ? mxTheme.palette.primary[800] : mxTheme.palette.primary[100],
161+
Brand200: mxTheme.palette.primary.light,
162+
Brand300: mxTheme.palette.primary.main,
163+
Brand400: mxTheme.palette.primary.dark,
164+
Brand500: isDarkModeEnabled ? mxTheme.palette.primary[50] : mxTheme.palette.primary[900],
165+
Primary100: isDarkModeEnabled ? mxTheme.palette.primary[800] : mxTheme.palette.primary[100],
166+
Primary200: mxTheme.palette.primary.light,
167+
Primary300: mxTheme.palette.primary.main,
168+
Primary400: mxTheme.palette.primary.dark,
169+
Primary500: isDarkModeEnabled ? mxTheme.palette.primary[50] : mxTheme.palette.primary[900],
170+
},
171+
}
172+
177173
return (
178174
<TokenProvider
179175
theme={isDarkModeEnabled ? THEMES.DARK : colorScheme}
180-
tokenOverrides={clientCustomTokens.tokenOverrides}
176+
tokenOverrides={kyperTokenOverrides}
181177
>
182178
<ThemeProvider theme={combinedTheme}>{children}</ThemeProvider>
183179
</TokenProvider>

src/components/ActionTile.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ import React from 'react'
22
import PropTypes from 'prop-types'
33

44
import { useTokens } from '@kyper/tokenprovider'
5-
import { Text } from '@kyper/mui'
6-
import { ChevronRightIcon } from '@kyper/mui'
5+
import { Text } from '@mxenabled/mxui'
6+
import { ChevronRightIcon } from '@mxenabled/mxui'
77
import { Button } from '@mui/material'
88

99
export const ActionTile = (props) => {

src/components/ActionableUtilityRow.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
22
import React from 'react'
33

4-
import { Text } from '@kyper/mui'
4+
import { Text } from '@mxenabled/mxui'
55
import { useTokens } from '@kyper/tokenprovider'
66
import { Button } from '@mui/material'
77

src/components/ConfigError.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react'
2-
import { Text } from '@kyper/mui'
2+
import { Text } from '@mxenabled/mxui'
33
import { useTokens } from '@kyper/tokenprovider'
44
import { Container } from 'src/components/Container'
55
import { AttentionFilled } from '@kyper/icon/AttentionFilled'

src/components/ConnectLogoHeader.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
22
import React from 'react'
33
import { useSelector } from 'react-redux'
4-
import { InstitutionLogo } from '@kyper/mui'
4+
import { InstitutionLogo } from '@mxenabled/mxui'
55
import { useTokens } from '@kyper/tokenprovider'
66

77
import { selectColorScheme } from 'src/redux/reducers/configSlice'

src/components/ConnectSuccessSurvey.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React, { useState, useImperativeHandle, useContext } from 'react'
2-
import { Text } from '@kyper/mui'
2+
import { Text } from '@mxenabled/mxui'
33
import { Button, TextField } from '@mui/material'
44
import ToggleButton from '@mui/material/ToggleButton'
55
import ToggleButtonGroup from '@mui/material/ToggleButtonGroup'

src/components/DataCluster.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { Fragment } from 'react'
22
import PropTypes from 'prop-types'
33
import { useTokens } from '@kyper/tokenprovider'
4-
import { Text } from '@kyper/mui'
4+
import { Text } from '@mxenabled/mxui'
55

66
export const DataCluster = (props) => {
77
const tokens = useTokens()

src/components/DataClusterDropDown.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react'
22

3-
import { useTokens } from '@kyper/mui'
3+
import { useTokens } from '@mxenabled/mxui'
44
import {
55
Accordion,
66
AccordionSummary,
@@ -10,7 +10,7 @@ import {
1010
Icon,
1111
Stack,
1212
} from '@mui/material'
13-
import { Text } from '@kyper/mui'
13+
import { Text } from '@mxenabled/mxui'
1414

1515
import { __ } from 'src/utilities/Intl'
1616

0 commit comments

Comments
 (0)