1
0
Fork 0
mirror of https://github.com/sussy-code/smov.git synced 2024-12-20 14:37:43 +01:00

feat(progress): add progress in search on MovieRow

This commit is contained in:
Jip Fr 2021-07-15 21:24:11 +02:00
parent 2b8878ed9a
commit 95cb59fcf6
7 changed files with 46 additions and 23 deletions

View file

@ -1,4 +1,5 @@
.movieRow {
position: relative;
display: flex;
border-radius: 5px;
background-color: var(--content);
@ -8,6 +9,7 @@
cursor: pointer;
transition: transform 50ms ease-in-out;
user-select: none;
overflow: hidden;
}
.movieRow p {

View file

@ -1,10 +1,25 @@
import React from 'react'
import { Arrow } from './Arrow'
import './MovieRow.css'
import { PercentageOverlay } from './PercentageOverlay'
// title: string
// onClick: () => void
export function MovieRow(props) {
console.log(props)
const progressData = JSON.parse(localStorage.getItem("video-progress") || "{}")
let progress;
let percentage = null;
if(props.type === "movie") {
progress = progressData?.lookmovie?.movie?.[props.slug]?.full
if(progress) {
console.log(progress)
percentage = Math.floor((progress.currentlyAt / progress.totalDuration) * 100)
}
}
console.log(percentage)
return (
<div className="movieRow" onClick={() => props.onClick && props.onClick()}>
<div className="left">
@ -15,6 +30,7 @@ export function MovieRow(props) {
<p>Watch {props.type}</p>
<Arrow/>
</div>
<PercentageOverlay percentage={percentage} />
</div>
)
}

View file

@ -48,15 +48,3 @@
background-color: var(--choice-active);
}
.numberSelector .progressBar {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0.2;
}
.numberSelector .progressBarInner {
background: var(--theme-color);
height: 100%;
}

View file

@ -1,27 +1,19 @@
import React from 'react';
// import { Arrow } from './Arrow';
import './NumberSelector.css'
import { PercentageOverlay } from './PercentageOverlay';
// setType: (txt: string) => void
// choices: { label: string, value: string }[]
// selected: string
export function NumberSelector({ setType, choices, selected }) {
choices.forEach(choice => {
if(choice.percentage > 3) choice.percentage = Math.max(20, choice.percentage < 90 ? choice.percentage : 100)
})
return (
<div className="numberSelector">
{choices.map(v=>(
<div key={v.value} className="choiceWrapper">
<div className={`choice ${selected&&selected===v.value?'selected':''}`} onClick={() => setType(v.value)}>
{v.label}
{v.percentage > 0 ? (
<div class="progressBar">
<div class="progressBarInner" style={{width: `${v.percentage}%`}}></div>
</div>
) : ''}
<PercentageOverlay percentage={v.percentage} />
</div>
</div>
))}

View file

@ -0,0 +1,12 @@
.progressBar {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
height: 100%;
opacity: 0.2;
}
.progressBarInner {
background: var(--theme-color);
height: 100%;
}

View file

@ -0,0 +1,13 @@
import React from 'react'
import './PercentageOverlay.css'
export function PercentageOverlay({ percentage }) {
if(percentage && percentage > 3) percentage = Math.max(20, percentage < 90 ? percentage : 100)
return percentage > 0 ? (
<div class="progressBar">
<div class="progressBarInner" style={{width: `${percentage}%`}}></div>
</div>
) : <React.Fragment></React.Fragment>
}

View file

@ -127,7 +127,7 @@ export function SearchView() {
Whoops, there are a few {type}s like that
</Title>
{options?.map((v, i) => (
<MovieRow key={i} title={v.title} type={v.type} year={v.year} season={v.season} episode={v.episode} onClick={() => {
<MovieRow key={i} title={v.title} slug={v.slug} type={v.type} year={v.year} season={v.season} episode={v.episode} onClick={() => {
setShowingOptions(false)
getStream(v.title, v.slug, v.type, v.season, v.episode)
}}/>