Front: EpisodeLine: add 'Expand' button for description

This commit is contained in:
Arthur Jamet 2023-12-20 14:46:55 +01:00 committed by Zoe Roux
parent 9bee5df036
commit df451f56b1
3 changed files with 36 additions and 13 deletions

View File

@ -21,6 +21,7 @@
import { import {
focusReset, focusReset,
H6, H6,
IconButton,
ImageBackground, ImageBackground,
ImageProps, ImageProps,
important, important,
@ -28,6 +29,7 @@ import {
P, P,
Skeleton, Skeleton,
SubP, SubP,
tooltip,
ts, ts,
} from "@kyoo/primitives"; } from "@kyoo/primitives";
import { useTranslation } from "react-i18next"; import { useTranslation } from "react-i18next";
@ -38,6 +40,8 @@ import { KyooImage, WatchStatusV } from "@kyoo/models";
import { ItemProgress } from "../browse/grid"; import { ItemProgress } from "../browse/grid";
import { EpisodesContext } from "../components/context-menus"; import { EpisodesContext } from "../components/context-menus";
import { useState } from "react"; import { useState } from "react";
import ExpandMore from "@material-symbols/svg-400/rounded/expand_more-fill.svg";
import ExpandLess from "@material-symbols/svg-400/rounded/expand_less-fill.svg";
export const episodeDisplayNumber = ( export const episodeDisplayNumber = (
episode: { episode: {
@ -99,7 +103,7 @@ export const EpisodeBox = ({
borderStyle: "solid", borderStyle: "solid",
}, },
more: { more: {
display: "none", opacity: 0,
}, },
}, },
fover: { fover: {
@ -111,7 +115,7 @@ export const EpisodeBox = ({
textDecorationLine: "underline", textDecorationLine: "underline",
}, },
more: { more: {
display: "flex", opacity: 1,
}, },
}, },
}, },
@ -214,6 +218,7 @@ export const EpisodeLine = ({
PressableProps & PressableProps &
Stylable) => { Stylable) => {
const [moreOpened, setMoreOpened] = useState(false); const [moreOpened, setMoreOpened] = useState(false);
const [descriptionExpanded, setDescriptionExpanded] = useState(false);
const { css } = useYoshiki("episode-line"); const { css } = useYoshiki("episode-line");
const { t } = useTranslation(); const { t } = useTranslation();
@ -227,7 +232,7 @@ export const EpisodeLine = ({
flexDirection: "row", flexDirection: "row",
child: { child: {
more: { more: {
display: "none", opacity: 0,
}, },
}, },
fover: { fover: {
@ -236,7 +241,7 @@ export const EpisodeLine = ({
textDecorationLine: "underline", textDecorationLine: "underline",
}, },
more: { more: {
display: "flex", opacity: 1,
}, },
}, },
}, },
@ -297,6 +302,7 @@ export const EpisodeLine = ({
</H6> </H6>
)} )}
</Skeleton> </Skeleton>
<View {...css({ flexDirection: "row", alignItems: "center" })}>
{isLoading || {isLoading ||
(runtime && ( (runtime && (
<Skeleton> <Skeleton>
@ -304,8 +310,20 @@ export const EpisodeLine = ({
</Skeleton> </Skeleton>
))} ))}
</View> </View>
</View>
<View {...css({ flexDirection: "row" })}> <View {...css({ flexDirection: "row" })}>
<Skeleton>{isLoading || <P numberOfLines={3}>{overview}</P>}</Skeleton> <Skeleton>
{isLoading || <P numberOfLines={descriptionExpanded ? undefined : 3}>{overview}</P>}
</Skeleton>
<IconButton
{...css(["more"])}
icon={descriptionExpanded ? ExpandLess : ExpandMore}
{...tooltip(t(descriptionExpanded ? "misc.collapse" : "misc.expand"))}
onPress={(e) => {
e.preventDefault();
setDescriptionExpanded((isExpanded) => !isExpanded);
}}
/>
{slug && watchedStatus !== undefined && ( {slug && watchedStatus !== undefined && (
<EpisodesContext <EpisodesContext
slug={slug} slug={slug}
@ -315,6 +333,7 @@ export const EpisodeLine = ({
setOpen={(v) => setMoreOpened(v)} setOpen={(v) => setMoreOpened(v)}
{...css([ {...css([
"more", "more",
{ display: "flex", marginLeft: ts(3) },
Platform.OS === "web" && moreOpened && { display: important("flex") }, Platform.OS === "web" && moreOpened && { display: important("flex") },
])} ])}
/> />

View File

@ -64,7 +64,9 @@
"next-page": "Next page", "next-page": "Next page",
"delete": "Delete", "delete": "Delete",
"cancel": "Cancel", "cancel": "Cancel",
"more": "More" "more": "More",
"expand": "Expand",
"collapse": "Collapse"
}, },
"navbar": { "navbar": {
"home": "Home", "home": "Home",

View File

@ -64,7 +64,9 @@
"next-page": "Page suivante", "next-page": "Page suivante",
"delete": "Supprimer", "delete": "Supprimer",
"cancel": "Annuler", "cancel": "Annuler",
"more": "Plus" "more": "Plus",
"expand": "Développer",
"collapse": "Replier"
}, },
"navbar": { "navbar": {
"home": "Accueil", "home": "Accueil",