2021-03-26 04:17:02 +04:30
|
|
|
/*
|
|
|
|
|
* Copyright (C) Contributors to the Suwayomi project
|
|
|
|
|
*
|
|
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
2021-01-26 23:32:12 +03:30
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
|
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
2020-12-25 06:36:34 +03:30
|
|
|
import React from 'react';
|
2021-09-09 20:43:13 +04:30
|
|
|
import { useTheme } from '@mui/material/styles';
|
2021-09-09 17:51:22 +04:30
|
|
|
import makeStyles from '@mui/styles/makeStyles';
|
|
|
|
|
import Card from '@mui/material/Card';
|
|
|
|
|
import CardContent from '@mui/material/CardContent';
|
2021-09-09 20:43:13 +04:30
|
|
|
import { Link, useHistory } from 'react-router-dom';
|
|
|
|
|
import SearchIcon from '@mui/icons-material/Search';
|
2021-09-09 17:51:22 +04:30
|
|
|
import Button from '@mui/material/Button';
|
2021-09-09 20:43:13 +04:30
|
|
|
import IconButton from '@mui/material/IconButton';
|
|
|
|
|
import FiberNewOutlinedIcon from '@mui/icons-material/FiberNewOutlined';
|
2021-09-09 17:51:22 +04:30
|
|
|
import Avatar from '@mui/material/Avatar';
|
|
|
|
|
import Typography from '@mui/material/Typography';
|
2021-05-27 05:13:01 +04:30
|
|
|
import useLocalStorage from 'util/useLocalStorage';
|
|
|
|
|
import { langCodeToName } from 'util/language';
|
2020-12-25 06:36:34 +03:30
|
|
|
|
|
|
|
|
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,
|
|
|
|
|
},
|
2021-09-07 05:08:54 +08:00
|
|
|
card: {
|
|
|
|
|
margin: '10px',
|
2021-09-09 20:43:13 +04:30
|
|
|
'&:hover': {
|
|
|
|
|
backgroundColor: 'rgba(255, 255, 255, 0.2)',
|
|
|
|
|
transition: 'background-color 0ms ease',
|
|
|
|
|
},
|
|
|
|
|
'&:active': {
|
|
|
|
|
backgroundColor: 'rgba(255, 255, 255, 0.1)',
|
|
|
|
|
transition: 'background-color 100ms ease-out',
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
showMobile: {
|
|
|
|
|
display: 'flex',
|
|
|
|
|
[theme.breakpoints.up('sm')]: {
|
|
|
|
|
display: 'none',
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
showBigger: {
|
|
|
|
|
display: 'flex',
|
|
|
|
|
[theme.breakpoints.down('sm')]: {
|
|
|
|
|
display: 'none',
|
|
|
|
|
},
|
2021-09-07 05:08:54 +08:00
|
|
|
},
|
2020-12-25 06:36:34 +03:30
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
interface IProps {
|
|
|
|
|
source: ISource
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default function SourceCard(props: IProps) {
|
|
|
|
|
const {
|
|
|
|
|
source: {
|
2021-08-08 14:17:43 +04:30
|
|
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
2021-07-31 05:06:46 +04:30
|
|
|
id, name, lang, iconUrl, supportsLatest, isConfigurable,
|
2020-12-25 06:36:34 +03:30
|
|
|
},
|
|
|
|
|
} = props;
|
|
|
|
|
|
2021-09-09 20:43:13 +04:30
|
|
|
const theme = useTheme();
|
|
|
|
|
const history = useHistory();
|
|
|
|
|
|
2021-03-07 22:35:27 +03:30
|
|
|
const [serverAddress] = useLocalStorage<String>('serverBaseURL', '');
|
|
|
|
|
|
2020-12-25 06:36:34 +03:30
|
|
|
const classes = useStyles();
|
|
|
|
|
|
|
|
|
|
return (
|
2021-09-07 05:08:54 +08:00
|
|
|
<Card className={classes.card}>
|
2021-09-09 20:43:13 +04:30
|
|
|
<Link
|
|
|
|
|
to={`/sources/${id}/popular/`}
|
|
|
|
|
style={{
|
|
|
|
|
textDecoration: 'none',
|
|
|
|
|
color: theme.palette.text.primary,
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
<CardContent className={classes.root}>
|
|
|
|
|
|
|
|
|
|
<div style={{ display: 'flex' }}>
|
|
|
|
|
<Avatar
|
|
|
|
|
variant="rounded"
|
|
|
|
|
className={classes.icon}
|
|
|
|
|
alt={name}
|
|
|
|
|
src={serverAddress + iconUrl}
|
|
|
|
|
/>
|
|
|
|
|
<div style={{ display: 'flex', flexDirection: 'column' }}>
|
|
|
|
|
<Typography variant="h5" component="h2">
|
|
|
|
|
{name}
|
|
|
|
|
</Typography>
|
|
|
|
|
<Typography variant="caption" display="block" gutterBottom>
|
|
|
|
|
{langCodeToName(lang)}
|
|
|
|
|
</Typography>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div>
|
|
|
|
|
<div className={classes.showMobile}>
|
|
|
|
|
<IconButton
|
|
|
|
|
style={{ width: 59, height: 59 }}
|
|
|
|
|
onClick={() => history.push(`/sources/${id}/search/`)}
|
|
|
|
|
size="large"
|
|
|
|
|
edge="end"
|
|
|
|
|
>
|
|
|
|
|
<SearchIcon
|
|
|
|
|
fontSize="medium"
|
|
|
|
|
/>
|
|
|
|
|
</IconButton>
|
|
|
|
|
{supportsLatest && (
|
|
|
|
|
<IconButton
|
|
|
|
|
onClick={() => history.push(`/sources/${id}/latest/`)}
|
|
|
|
|
size="large"
|
|
|
|
|
>
|
|
|
|
|
<FiberNewOutlinedIcon
|
|
|
|
|
fontSize="large"
|
|
|
|
|
/>
|
|
|
|
|
</IconButton>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
<div className={classes.showBigger}>
|
|
|
|
|
<Button
|
|
|
|
|
variant="outlined"
|
|
|
|
|
style={{ marginLeft: 20 }}
|
|
|
|
|
onClick={() => history.push(`/sources/${id}/search/`)}
|
|
|
|
|
>
|
|
|
|
|
Search
|
|
|
|
|
</Button>
|
|
|
|
|
{supportsLatest && (
|
|
|
|
|
<Button
|
|
|
|
|
variant="outlined"
|
|
|
|
|
style={{ marginLeft: 20 }}
|
|
|
|
|
onClick={() => history.push(`/sources/${id}/latest/`)}
|
|
|
|
|
>
|
|
|
|
|
Latest
|
|
|
|
|
</Button>
|
|
|
|
|
)}
|
|
|
|
|
<Button
|
|
|
|
|
variant="outlined"
|
|
|
|
|
style={{ marginLeft: 20 }}
|
|
|
|
|
onClick={() => history.push(`/sources/${id}/popular/`)}
|
|
|
|
|
>
|
|
|
|
|
Browse
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
2020-12-25 06:36:34 +03:30
|
|
|
</div>
|
2021-09-09 20:43:13 +04:30
|
|
|
</CardContent>
|
|
|
|
|
</Link>
|
2020-12-25 06:36:34 +03:30
|
|
|
</Card>
|
|
|
|
|
);
|
|
|
|
|
}
|