migrate ExtensionCard.tsx to Mui 5 (#81)
* migrate ExtensionCard.tsx to Mui 5 * fix styling
This commit is contained in:
@@ -6,7 +6,6 @@
|
|||||||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||||
|
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import makeStyles from '@mui/styles/makeStyles';
|
|
||||||
import Card from '@mui/material/Card';
|
import Card from '@mui/material/Card';
|
||||||
import CardContent from '@mui/material/CardContent';
|
import CardContent from '@mui/material/CardContent';
|
||||||
import Button from '@mui/material/Button';
|
import Button from '@mui/material/Button';
|
||||||
@@ -14,35 +13,7 @@ import Avatar from '@mui/material/Avatar';
|
|||||||
import Typography from '@mui/material/Typography';
|
import Typography from '@mui/material/Typography';
|
||||||
import client from 'util/client';
|
import client from 'util/client';
|
||||||
import useLocalStorage from 'util/useLocalStorage';
|
import useLocalStorage from 'util/useLocalStorage';
|
||||||
|
import { Box } from '@mui/system';
|
||||||
const useStyles = makeStyles((theme) => ({
|
|
||||||
root: {
|
|
||||||
display: 'flex',
|
|
||||||
justifyContent: 'space-between',
|
|
||||||
alignItems: 'center',
|
|
||||||
padding: 16,
|
|
||||||
},
|
|
||||||
bullet: {
|
|
||||||
display: 'inline-block',
|
|
||||||
margin: '0 2px',
|
|
||||||
transform: 'scale(0.8)',
|
|
||||||
},
|
|
||||||
title: {
|
|
||||||
fontSize: 14,
|
|
||||||
},
|
|
||||||
pos: {
|
|
||||||
marginBottom: 12,
|
|
||||||
},
|
|
||||||
icon: {
|
|
||||||
width: theme.spacing(7),
|
|
||||||
height: theme.spacing(7),
|
|
||||||
flex: '0 0 auto',
|
|
||||||
marginRight: 16,
|
|
||||||
},
|
|
||||||
card: {
|
|
||||||
margin: '10px',
|
|
||||||
},
|
|
||||||
}));
|
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
extension: IExtension
|
extension: IExtension
|
||||||
@@ -67,7 +38,6 @@ export default function ExtensionCard(props: IProps) {
|
|||||||
const [serverAddress] = useLocalStorage<String>('serverBaseURL', '');
|
const [serverAddress] = useLocalStorage<String>('serverBaseURL', '');
|
||||||
const [useCache] = useLocalStorage<boolean>('useCache', true);
|
const [useCache] = useLocalStorage<boolean>('useCache', true);
|
||||||
|
|
||||||
const classes = useStyles();
|
|
||||||
const langPress = lang === 'all' ? 'All' : lang.toUpperCase();
|
const langPress = lang === 'all' ? 'All' : lang.toUpperCase();
|
||||||
|
|
||||||
function install() {
|
function install() {
|
||||||
@@ -118,16 +88,27 @@ export default function ExtensionCard(props: IProps) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card className={classes.card}>
|
<Card sx={{ margin: '10px' }}>
|
||||||
<CardContent className={classes.root}>
|
<CardContent sx={{
|
||||||
<div style={{ display: 'flex' }}>
|
display: 'flex',
|
||||||
|
justifyContent: 'space-between',
|
||||||
|
alignItems: 'center',
|
||||||
|
p: 2,
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Box sx={{ display: 'flex' }}>
|
||||||
<Avatar
|
<Avatar
|
||||||
variant="rounded"
|
variant="rounded"
|
||||||
className={classes.icon}
|
sx={{
|
||||||
|
width: 56,
|
||||||
|
height: 56,
|
||||||
|
flex: '0 0 auto',
|
||||||
|
mr: 2,
|
||||||
|
}}
|
||||||
alt={name}
|
alt={name}
|
||||||
src={`${serverAddress}${iconUrl}?useCache=${useCache}`}
|
src={`${serverAddress}${iconUrl}?useCache=${useCache}`}
|
||||||
/>
|
/>
|
||||||
<div style={{ display: 'flex', flexDirection: 'column' }}>
|
<Box sx={{ display: 'flex', flexDirection: 'column' }}>
|
||||||
<Typography variant="h5" component="h2">
|
<Typography variant="h5" component="h2">
|
||||||
{name}
|
{name}
|
||||||
</Typography>
|
</Typography>
|
||||||
@@ -136,12 +117,12 @@ export default function ExtensionCard(props: IProps) {
|
|||||||
{' '}
|
{' '}
|
||||||
{versionName}
|
{versionName}
|
||||||
</Typography>
|
</Typography>
|
||||||
</div>
|
</Box>
|
||||||
</div>
|
</Box>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
style={{ color: installedState === 'obsolete' ? 'red' : 'inherit' }}
|
sx={{ color: installedState === 'obsolete' ? 'red' : 'inherit' }}
|
||||||
onClick={() => handleButtonClick()}
|
onClick={() => handleButtonClick()}
|
||||||
>
|
>
|
||||||
{installedState}
|
{installedState}
|
||||||
|
|||||||
Reference in New Issue
Block a user