Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unavailable videos comparisons list #1522

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
1 change: 1 addition & 0 deletions frontend/src/components/LoaderWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const LoaderWrapper = ({ isLoading, sx = {}, children }: LoaderProps) => {
pointerEvents: 'none',
},
]}
width="100%"
>
{children}
</Box>
Expand Down
31 changes: 28 additions & 3 deletions frontend/src/components/entity/EntityCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ const EntityCard = ({
const [settingsVisible, setSettingsVisible] = useState(!isSmallScreen);

useEffect(() => {
setContentDisplayed(isAvailable);
}, [isAvailable]);
setContentDisplayed(isAvailable || compact);
}, [isAvailable, compact]);

const displayEntityCardScores = () => {
if ('tournesol_score' in entity && !compact) {
Expand All @@ -75,7 +75,7 @@ const EntityCard = ({

return (
<Grid container sx={entityCardMainSx}>
{!isAvailable && (
{!isAvailable && !compact && (
<Grid container justifyContent="space-between" alignItems="center">
<Grid item pl={1} py={2}>
<Typography>
Expand Down Expand Up @@ -104,6 +104,7 @@ const EntityCard = ({
sx={{
display: 'flex',
justifyContent: 'center',
position: 'relative',
...(compact
? {}
: { minWidth: '240px', maxWidth: { sm: '240px' } }),
Expand All @@ -114,6 +115,30 @@ const EntityCard = ({
compact={compact}
config={entityTypeConfig}
/>
{!isAvailable && compact && (
<Box
display="flex"
justifyContent="center"
alignItems="center"
position="absolute"
top="0"
color="white"
bgcolor="rgba(0,0,0,.6)"
width="100%"
height="100%"
sx={{
[theme.breakpoints.down('sm')]: {
fontSize: '0.6rem',
},
}}
>
<Typography textAlign="center" fontSize="inherit">
{entity.type == TypeEnum.VIDEO
? t('video.notAvailableAnymore')
: t('entityCard.thisElementIsNotAvailable')}
</Typography>
</Box>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The same components are also used by <EntitySelectorInnerAuth>.

Let's factorize them in their own component.

)}
</Grid>
<Grid
item
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/entity/EntityImagery.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ const EntityImagery = ({
className="full-width entity-thumbnail"
src={`https://i.ytimg.com/vi/${idFromUid(entity.uid)}/mqdefault.jpg`}
alt={entity.metadata.name}
style={{ aspectRatio: '16/9' }}
/>
</DurationWrapper>
);
Expand Down
25 changes: 15 additions & 10 deletions frontend/src/features/comparisons/ComparisonList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { Compare as CompareIcon } from '@mui/icons-material';
import type { Comparison } from 'src/services/openapi';
import EntityCard from 'src/components/entity/EntityCard';
import { useCurrentPoll } from 'src/hooks/useCurrentPoll';
import AvailableEntity from 'src/components/entity/AvailableEntity';

const ComparisonThumbnail = ({ comparison }: { comparison: Comparison }) => {
const { t } = useTranslation();
Expand All @@ -24,11 +25,13 @@ const ComparisonThumbnail = ({ comparison }: { comparison: Comparison }) => {
gap: '16px',
}}
>
<EntityCard
compact
entity={entity_a}
entityTypeConfig={{ video: { displayPlayer: false } }}
/>
<AvailableEntity uid={entity_a.uid}>
<EntityCard
compact
entity={entity_a}
entityTypeConfig={{ video: { displayPlayer: false } }}
/>
</AvailableEntity>
<Box
sx={{
position: 'relative',
Expand Down Expand Up @@ -56,11 +59,13 @@ const ComparisonThumbnail = ({ comparison }: { comparison: Comparison }) => {
</Fab>
</Tooltip>
</Box>
<EntityCard
compact
entity={entity_b}
entityTypeConfig={{ video: { displayPlayer: false } }}
/>
<AvailableEntity uid={entity_b.uid}>
<EntityCard
compact
entity={entity_b}
entityTypeConfig={{ video: { displayPlayer: false } }}
/>
</AvailableEntity>
</Box>
);
};
Expand Down