From d35f7c64d3370e4f4eda4f32dbefb1fa11fcd481 Mon Sep 17 00:00:00 2001 From: Aria Moradi Date: Wed, 17 Nov 2021 15:45:25 +0330 Subject: [PATCH] migrate SourceCard to Mui 5 (#82) * migrate SourceCard to Mui 5 * give semantic meaning --- src/components/SourceCard.tsx | 113 +++++++++++++++------------------- 1 file changed, 49 insertions(+), 64 deletions(-) diff --git a/src/components/SourceCard.tsx b/src/components/SourceCard.tsx index 1ca0da6a..3a4bb1fc 100644 --- a/src/components/SourceCard.tsx +++ b/src/components/SourceCard.tsx @@ -6,7 +6,6 @@ * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ import React from 'react'; -import makeStyles from '@mui/styles/makeStyles'; import Card from '@mui/material/Card'; import CardContent from '@mui/material/CardContent'; import { useHistory } from 'react-router-dom'; @@ -18,53 +17,23 @@ import Avatar from '@mui/material/Avatar'; import Typography from '@mui/material/Typography'; import useLocalStorage from 'util/useLocalStorage'; import { langCodeToName } from 'util/language'; +import { Box, styled } from '@mui/system'; -const useStyles = makeStyles((theme) => ({ - root: { - display: 'flex', - justifyContent: 'space-between', - alignItems: 'center', - padding: 16, +const MobileWidthButtons = styled('div')(({ theme }) => ({ + display: 'flex', + [theme.breakpoints.up('sm')]: { + display: 'none', }, - bullet: { - display: 'inline-block', - margin: '0 2px', - transform: 'scale(0.8)', +})); + +const WiderWidthButtons = styled('div')(({ theme }) => ({ + display: 'flex', + [theme.breakpoints.down('sm')]: { + display: 'none', }, - title: { - fontSize: 14, - }, - pos: { - marginBottom: 12, - }, - icon: { - width: theme.spacing(7), - height: theme.spacing(7), - flex: '0 0 auto', - marginRight: 16, - }, - card: { - margin: '10px', - '&:hover': { - backgroundColor: theme.palette.action.hover, - transition: 'background-color 100ms cubic-bezier(0.4, 0, 0.2, 1) 0ms', - }, - '&:active': { - backgroundColor: theme.palette.action.selected, - transition: 'background-color 100ms cubic-bezier(0.4, 0, 0.2, 1) 0ms', - }, - }, - showMobile: { - display: 'flex', - [theme.breakpoints.up('sm')]: { - display: 'none', - }, - }, - showBigger: { - display: 'flex', - [theme.breakpoints.down('sm')]: { - display: 'none', - }, + + '& .MuiButton-root': { + marginLeft: '20px', }, })); @@ -84,8 +53,6 @@ export default function SourceCard(props: IProps) { const [serverAddress] = useLocalStorage('serverBaseURL', ''); const [useCache] = useLocalStorage('useCache', true); - const classes = useStyles(); - const redirectTo = (e: any, to: string) => { history.push(to); @@ -95,19 +62,40 @@ export default function SourceCard(props: IProps) { return ( redirectTo(e, `/sources/${id}/popular/`)} > - + -
+ -
+ {name} @@ -116,12 +104,12 @@ export default function SourceCard(props: IProps) { {langCodeToName(lang)} )} -
-
-
-
+ + + <> + redirectTo(e, `/sources/${id}/search/`)} size="large" edge="end" @@ -140,11 +128,10 @@ export default function SourceCard(props: IProps) { /> )} -
-
+ + -
-
+ +
);