mirror of
https://github.com/Stremio/stremio-web.git
synced 2026-04-20 10:42:12 +00:00
refactor(Ratings): align with new design
This commit is contained in:
parent
dc9cfb12f3
commit
be73839349
6 changed files with 94 additions and 36 deletions
|
|
@ -17,7 +17,7 @@ const ActionButton = require('./ActionButton');
|
|||
const MetaLinks = require('./MetaLinks');
|
||||
const MetaPreviewPlaceholder = require('./MetaPreviewPlaceholder');
|
||||
const styles = require('./styles');
|
||||
const { default: useRating } = require('./useRating');
|
||||
const { Ratings } = require('./Ratings');
|
||||
|
||||
const ALLOWED_LINK_REDIRECTS = [
|
||||
routesRegexp.search.regexp,
|
||||
|
|
@ -27,7 +27,6 @@ const ALLOWED_LINK_REDIRECTS = [
|
|||
|
||||
const MetaPreview = React.forwardRef(({ className, compact, name, logo, background, runtime, releaseInfo, released, description, deepLinks, links, trailerStreams, inLibrary, toggleInLibrary, metaId, like }, ref) => {
|
||||
const { t } = useTranslation();
|
||||
const { onLiked, onLoved, liked, loved } = useRating(metaId, like);
|
||||
const [shareModalOpen, openShareModal, closeShareModal] = useBinaryState(false);
|
||||
const linksGroups = React.useMemo(() => {
|
||||
return Array.isArray(links) ?
|
||||
|
|
@ -262,30 +261,10 @@ const MetaPreview = React.forwardRef(({ className, compact, name, logo, backgrou
|
|||
}
|
||||
{
|
||||
!compact ?
|
||||
<ActionButton
|
||||
className={classnames(styles['action-button'], styles['rating-button'], {
|
||||
[styles['active']]: liked
|
||||
})}
|
||||
icon={'thumbs-up'}
|
||||
label={t('LIKE')}
|
||||
tooltip={true}
|
||||
tabIndex={compact ? -1 : 0}
|
||||
onClick={onLiked}
|
||||
/>
|
||||
:
|
||||
null
|
||||
}
|
||||
{
|
||||
!compact ?
|
||||
<ActionButton
|
||||
className={classnames(styles['action-button'], styles['rating-button'], {
|
||||
[styles['active']]: loved
|
||||
})}
|
||||
icon={'heart'}
|
||||
label={t('LOVE')}
|
||||
tooltip={true}
|
||||
tabIndex={compact ? -1 : 0}
|
||||
onClick={onLoved}
|
||||
<Ratings
|
||||
metaId={metaId}
|
||||
like={like}
|
||||
className={styles['ratings']}
|
||||
/>
|
||||
:
|
||||
null
|
||||
|
|
|
|||
42
src/components/MetaPreview/Ratings/Ratings.less
Normal file
42
src/components/MetaPreview/Ratings/Ratings.less
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
// Copyright (C) 2017-2025 Smart code 203358507
|
||||
|
||||
@height: 4rem;
|
||||
@width: 4rem;
|
||||
|
||||
.ratings-container {
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
align-items: center;
|
||||
justify-content: flex-start;
|
||||
background-color: var(--overlay-color);
|
||||
border-radius: 2rem;
|
||||
height: @height;
|
||||
width: fit-content;
|
||||
|
||||
.icon-container {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: @height;
|
||||
width: @width;
|
||||
padding: 0 1rem;
|
||||
cursor: pointer;
|
||||
|
||||
.icon {
|
||||
width: calc(@width / 2);
|
||||
height: calc(@height / 2);
|
||||
color: var(--primary-foreground-color);
|
||||
opacity: 0.7;
|
||||
transition: 0.3s all ease-in-out;
|
||||
|
||||
&:hover {
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
&.active {
|
||||
opacity: 0.9;
|
||||
fill: var(--primary-foreground-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
35
src/components/MetaPreview/Ratings/Ratings.tsx
Normal file
35
src/components/MetaPreview/Ratings/Ratings.tsx
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
// Copyright (C) 2017-2025 Smart code 203358507
|
||||
|
||||
import React from 'react';
|
||||
import useRating from './useRating';
|
||||
import styles from './Ratings.less';
|
||||
import Icon from '@stremio/stremio-icons/react';
|
||||
import classNames from 'classnames';
|
||||
|
||||
type Like = {
|
||||
content: 'liked' | 'loved';
|
||||
type: 'Ready' | 'Loading' | 'Error';
|
||||
};
|
||||
|
||||
type Props = {
|
||||
metaId?: string;
|
||||
like?: Like;
|
||||
className?: string;
|
||||
};
|
||||
|
||||
const Ratings = ({ metaId, like, className }: Props) => {
|
||||
const { onLiked, onLoved, liked, loved } = useRating(metaId, like);
|
||||
|
||||
return (
|
||||
<div className={classNames(styles['ratings-container'], className)}>
|
||||
<div className={styles['icon-container']} onClick={onLiked}>
|
||||
<Icon name={'thumbs-up'} className={classNames(styles['icon'], { [styles['active']]: liked })} />
|
||||
</div>
|
||||
<div className={styles['icon-container']} onClick={onLoved}>
|
||||
<Icon name={'heart'} className={classNames(styles['icon'], { [styles['active']]: loved })} />
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Ratings;
|
||||
5
src/components/MetaPreview/Ratings/index.ts
Normal file
5
src/components/MetaPreview/Ratings/index.ts
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
// Copyright (C) 2017-2025 Smart code 203358507
|
||||
|
||||
import Ratings from './Ratings';
|
||||
|
||||
export { Ratings };
|
||||
|
|
@ -1,3 +1,5 @@
|
|||
// Copyright (C) 2017-2025 Smart code 203358507
|
||||
|
||||
import { useMemo, useCallback } from 'react';
|
||||
import { useServices } from 'stremio/services';
|
||||
|
||||
|
|
@ -207,18 +207,13 @@
|
|||
outline: none;
|
||||
}
|
||||
}
|
||||
|
||||
&.rating-button {
|
||||
&.active {
|
||||
background-color: var(--primary-accent-color);
|
||||
|
||||
.icon {
|
||||
color: var(--primary-foreground-color);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.ratings {
|
||||
margin-bottom: 1rem;
|
||||
margin-right: 1rem;
|
||||
}
|
||||
}
|
||||
|
||||
.share-prompt {
|
||||
|
|
|
|||
Loading…
Reference in a new issue