/* * Copyright (C) Contributors to the Suwayomi project * * This Source Code Form is subject to the terms of the Mozilla Public * 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/. */ import React from 'react'; import Card from '@mui/material/Card'; import CardContent from '@mui/material/CardContent'; import { useHistory } from 'react-router-dom'; import Button from '@mui/material/Button'; 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 MobileWidthButtons = styled('div')(({ theme }) => ({ display: 'flex', [theme.breakpoints.up('sm')]: { display: 'none', }, })); const WiderWidthButtons = styled('div')(({ theme }) => ({ display: 'flex', [theme.breakpoints.down('sm')]: { display: 'none', }, '& .MuiButton-root': { marginLeft: '20px', }, })); interface IProps { source: ISource } export default function SourceCard(props: IProps) { const { source: { id, name, lang, iconUrl, supportsLatest, isNsfw, }, } = props; const history = useHistory(); const [serverAddress] = useLocalStorage('serverBaseURL', ''); const [useCache] = useLocalStorage('useCache', true); const redirectTo = (e: any, to: string) => { history.push(to); // prevent parent tags from getting the event e.stopPropagation(); }; return ( redirectTo(e, `/sources/${id}/popular/`)} > {name} {id !== '0' && ( {langCodeToName(lang)} {isNsfw && ( {' 18+'} )} )} <> {supportsLatest && ( )} {supportsLatest && ( )} ); }