Skip to content

Commit

Permalink
Feature/mui v5 (#270)
Browse files Browse the repository at this point in the history
* start migrating the repo

* create MikeTypography

* rename folders. add palette

* fix a few first components

* CalendarItem styled

* adjust barlegend styles

* progress on component migration

* progress on component migration

* addjust Card, CatBarLegend, CollBox, GapBox to MUIv5

* migrate Loader to mui 5

* change subtitle color Card

* migrate LegendBase to MUIv5

* migrate multifield

* migrate ResizeHandle to Mui.5

* snackbar mui.5

* StaticLegend mui.5

* timestepPlayer mui.v5

* fix typography in theme

* migrate theme story navbar mui.5

* fix styles further

* further migrate theme overrides

* update theme to Mui.5

* update deprecated storybook import

* perf(Material-UI v.5): Update the components and the theme to Material-UI v.5

* fix linting

* Update packages/react-components-lab/src/components/CalendarItem/CalendarItem.tsx

Co-authored-by: rihr <[email protected]>

* Update packages/react-components-lab/.storybook/preview.js

Co-authored-by: rihr <[email protected]>

* commit dist folder so it can be shared

* bump package

* accomodate theme to latest updates from mui4 main

* update package version. fix themeProvider

* remove commiting dist

* update deps and theme

* update version

* switch primary and secondary colors

* Add splash screen component and everything for it

* use logo svg instead of png

* feat: add splash screen (#319)

Add splash screen component and everything for it

* remove dhi logo file and use url. Publish new version

* add margin to splash screen, change dhi log to url, and make image/button optional

* release mui5 version 3.3 with splash screen improvements

* remove static dhi logo

* remove unused imports

* fix workflow name and docs

* update icons to use mui 5

* improve dev start script

* fix compile error. Update packages versions and deps

* fix types and linting errors

* update peer deps for mui

* upload peerDependencies version

* update peerDeps

Co-authored-by: rihr <[email protected]>
Co-authored-by: DenizYil <[email protected]>
Co-authored-by: DenizYil <[email protected]>
  • Loading branch information
4 people authored Jul 22, 2022
1 parent c6c74af commit 24f268a
Show file tree
Hide file tree
Showing 109 changed files with 2,399 additions and 2,468 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CI - lab
name: CI - lab&icons
on:
push:
branches:
Expand Down
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# DHI | React Components
[![CI - icons](https://github.com/DHI/react-components/actions/workflows/main-icons.yml/badge.svg)](https://github.com/DHI/react-components/actions/workflows/main-icons.yml)
[![CI - lab](https://github.com/DHI/react-components/actions/workflows/main-lab.yml/badge.svg)](https://github.com/DHI/react-components/actions/workflows/main-lab.yml)
[![CI - lab&icons](https://github.com/DHI/react-components/actions/workflows/main-lab-icons.yml/badge.svg)](https://github.com/DHI/react-components/actions/workflows/main-lab-icons.yml)
![CI - core](https://github.com/DHI/react-components/workflows/CI/badge.svg)
[![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)

Expand Down
8 changes: 4 additions & 4 deletions packages/icons/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.4.0",
"version": "2.0.0",
"license": "MIT",
"name": "@dhi/icons",
"author": "DHI",
Expand Down Expand Up @@ -27,8 +27,8 @@
"@types/react-dom": "^17.0.3"
},
"peerDependencies": {
"@material-ui/core": "^4.12.3",
"react": "^17.0.2",
"react-dom": "^17.0.2"
"@mui/material": "~5",
"react": "~17 || ~18",
"react-dom": "~17 || ~18"
}
}
10 changes: 4 additions & 6 deletions packages/icons/utils/createSvgIcon.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import * as React from 'react';
import SvgIcon from '@material-ui/core/SvgIcon';
import { SvgIcon } from '@mui/material';

export default function createSvgIcon(path, displayName): typeof SvgIcon {
const Component = (props, ref) => (
Expand All @@ -14,9 +14,7 @@ export default function createSvgIcon(path, displayName): typeof SvgIcon {
Component.displayName = `${displayName}Icon`;
}

Component.muiName = (SvgIcon as any).muiName;
Component.muiName = SvgIcon.muiName;

return React.memo(React.forwardRef(Component));
}


return React.memo(React.forwardRef(Component)) as any;
}
Empty file.
3 changes: 3 additions & 0 deletions packages/react-components-lab/.storybook/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,7 @@ module.exports = {
reactDocgen: 'react-docgen-typescript',
tsconfigPath: "./../tsconfig.json"
},
features: {
emotionAlias: false
}
}
4 changes: 3 additions & 1 deletion packages/react-components-lab/.storybook/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,7 @@ export const parameters = {
}

export const decorators = [(Story, context) => {
return <ThemeProvider type={useDarkMode() ? 'dark' : 'light'}><Story /></ThemeProvider>
const isDarkMode = useDarkMode()

return <ThemeProvider mode={isDarkMode ? 'dark' : 'light'}><Story /></ThemeProvider>
}]
21 changes: 11 additions & 10 deletions packages/react-components-lab/package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "1.14.3",
"version": "2.0.0",
"license": "MIT",
"main": "dist/index.js",
"name": "@dhi/react-components-lab",
Expand All @@ -19,14 +19,15 @@
},
"scripts": {
"dev": "yarn sb",
"start": "../../node_modules/.bin/start-storybook -p 6006",
"start": "cd ../icons && yarn build && cd ../react-components-lab && ../../node_modules/.bin/start-storybook -p 6006",
"build": "../../node_modules/.bin/tsdx build",
"test": "../../node_modules/.bin/tsdx test --passWithNoTests",
"lint": "../../node_modules/eslint/bin/eslint.js .",
"lint:fix": "../../node_modules/eslint/bin/eslint.js . --fix",
"build-storybook": "cd ../icons && yarn build && cd ../react-components-lab && ../../node_modules/.bin/build-storybook"
},
"devDependencies": {
"@dhi/icons": "workspace:^",
"@types/classnames": "^2.2.10",
"@types/jsonpath": "^0.2.0",
"@types/lodash": "^4.14.150",
Expand All @@ -36,20 +37,20 @@
"storybook-dark-mode": "^1.1.0"
},
"peerDependencies": {
"react": "^17.0.2",
"react-dom": "^17.0.2"
"@mui/material": "~5",
"react": "~17 || ~18",
"react-dom": "~17 || ~18"
},
"dependencies": {
"@ctrl/tinycolor": "^3.4.0",
"@dhi/icons": "workspace:^",
"@material-ui/core": "^4.12.3",
"@material-ui/icons": "^4.11.2",
"@material-ui/system": "^4.12.1",
"clsx": "^1.1.1",
"@emotion/react": "^11.9.0",
"@emotion/styled": "^11.8.1",
"@mui/icons-material": "^5.8.3",
"@mui/material": "^5.8.3",
"@mui/system": "^5.8.3",
"copy-to-clipboard": "^3.3.1",
"date-fns": "^2.27.0",
"lodash": "^4.17.21",
"lodash.assignin": "^4.2.0",
"prismjs": "^1.24.1"
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import React, { useEffect, useState, FC } from 'react';
import { Box, Typography } from '@material-ui/core';
import { Box, Typography, useTheme } from '@mui/material';
import { BarLegendProps } from './types';
import useStyles from './styles';
import ImgLegendStyled from './ImgLegend.styled';

const BarLegend: FC<BarLegendProps> = ({ src, length, range, unit = '' }) => {
const classes = useStyles();
const [val, setVals] = useState<number[] | undefined>();

const theme = useTheme();
useEffect(() => {
if (
length !== undefined &&
Expand All @@ -30,13 +29,13 @@ const BarLegend: FC<BarLegendProps> = ({ src, length, range, unit = '' }) => {
}, [range, length]);

return (
<Box style={{ width: '100%' }}>
<img src={src} alt="legend-colorbar" className={classes.colorbar} />
<Box width={1}>
<ImgLegendStyled src={src} alt="legend-colorbar" theme={theme} />
{range &&
(typeof range[0] === 'number' && typeof range[1] === 'number' && val ? (
<Box display="flex" justifyContent="space-between">
{val.map((v: number) => (
<Typography key={`value-${v}`} style={{ fontSize: 10 }}>
<Typography key={`value-${v}`} sx={{ fontSize: 10 }}>
{`${v} ${unit}`}
</Typography>
))}
Expand All @@ -45,10 +44,10 @@ const BarLegend: FC<BarLegendProps> = ({ src, length, range, unit = '' }) => {
['number', 'string'].includes(typeof range[0]) &&
['number', 'string'].includes(typeof range[1]) && (
<Box display="flex" justifyContent="space-between">
<Typography style={{ fontSize: 10 }}>
<Typography sx={{ fontSize: 10 }}>
{`${range[0]} ${unit}`}
</Typography>
<Typography style={{ fontSize: 10 }}>
<Typography sx={{ fontSize: 10 }}>
{`${range[1]} ${unit}`}
</Typography>
</Box>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { styled } from '@mui/material/styles';

const ImgLegendStyled = styled('img')({
width: '100%',
height: 6,
borderRadius: 4,
});

export default ImgLegendStyled;

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { FC } from 'react';
import { Box, Typography } from '@material-ui/core';
import { Box, Typography } from '@mui/material';
import { CalendarBoxProps } from './types';

const CalendarBox: FC<CalendarBoxProps> = ({ children, title }) => (
Expand All @@ -9,7 +9,7 @@ const CalendarBox: FC<CalendarBoxProps> = ({ children, title }) => (
{title}
</Typography>
)}
<Box width={1} display="flex" flexWrap="wrap" flexDirection="space-between">
<Box width={1} display="flex" flexWrap="wrap">
{children.map((comp) => comp)}
</Box>
</Box>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import React from 'react';
import { Box } from '@mui/material';
import { styled } from '@mui/material/styles';
import { experimental_sx as sx } from '@mui/system';
import { CalendarItemProps } from './types';

const options = {
shouldForwardProp: (prop) =>
prop !== 'disabled' || prop !== 'variant' || prop !== 'active',
};

const CalendarItemBox = styled(
Box,
options
)<Partial<CalendarItemProps>>(({ disabled, variant, active }) => {
const getStyle = () => {
if (disabled)
return {
backgroundColor: 'mediumGrey.light',
color: 'mediumGrey.dark',
};
if (variant === 'button' && !disabled)
return {
backgroundColor: active ? 'secondary.main' : 'mediumGrey.light',
color: active ? 'background.paper' : 'primary.main',
'&:hover': {
backgroundColor: active ? 'secondary.main' : 'mediumGrey.main',
},
};

if (variant === 'semi-button' && !disabled)
return {
backgroundColor: active ? 'secondary.main' : 'mediumGrey.light',
color: active ? 'background.paper' : 'primary.main',
'&:hover': {
backgroundColor: active ? 'secondary.main' : 'mediumGrey.main',
},
};

return {};
};

const stableCss = {
cursor: disabled ? 'default' : 'pointer',
borderRadius: 4,
minWidth: 42,
margin: '2px',
padding: '0px 7px',
textAlign: 'center',
flexGrow: 1,
...getStyle(),
} as const;

return sx(stableCss);
});

export default CalendarItemBox;
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { FC } from 'react';
import { Box, Typography } from '@material-ui/core';
import clsx from 'clsx';
import useStyles from './styles';
import { Typography } from '@mui/material';
import CalendarItemBox from './CalendarItem.styled';
import { CalendarItemProps } from './types';

const CalendarItem: FC<CalendarItemProps> = ({
Expand All @@ -10,34 +9,17 @@ const CalendarItem: FC<CalendarItemProps> = ({
children,
active = false,
disabled = false,
}) => {
const classes = useStyles();

return (
<Box
className={clsx(
disabled && {
[classes.button]: true,
[classes.disabled]: true,
},
variant === 'button' &&
!disabled && {
[classes.button]: true,
[classes.active]: active,
},
variant === 'semi-button' &&
!disabled && {
[classes.button]: true,
[classes.semiActive]: active,
}
)}
onClick={() => !disabled && onClick()}
>
<Typography variant="body2" style={{ color: 'inherit' }}>
{children}
</Typography>
</Box>
);
};
}) => (
<CalendarItemBox
onClick={() => !disabled && onClick()}
disabled={disabled}
variant={variant}
active={active}
>
<Typography variant="body2" sx={{ color: 'inherit' }}>
{children}
</Typography>
</CalendarItemBox>
);

export default CalendarItem;

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { styled } from '@mui/material/styles';
import { Box } from '@mui/material';
import { experimental_sx as sx } from '@mui/system';

export default styled(Box)(
sx({
position: 'absolute',
top: 0,
left: 0,
zIndex: 100,
borderRadius: 4,
backgroundColor: 'lightGrey.main',
width: '100%',
height: '100%',
opacity: 0.7,
})
);
Loading

0 comments on commit 24f268a

Please sign in to comment.