-
Notifications
You must be signed in to change notification settings - Fork 279
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #651 from Stremio/feat/calendar
feat: calendar
- Loading branch information
Showing
53 changed files
with
1,628 additions
and
155 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,102 @@ | ||
// Copyright (C) 2017-2024 Smart code 203358507 | ||
|
||
@import (reference) '~stremio/common/screen-sizes.less'; | ||
|
||
.bottom-sheet { | ||
z-index: 99; | ||
position: fixed; | ||
top: 0; | ||
bottom: 0; | ||
left: 0; | ||
right: 0; | ||
display: flex; | ||
justify-content: center; | ||
|
||
.backdrop { | ||
z-index: 0; | ||
position: absolute; | ||
top: 0; | ||
bottom: 0; | ||
left: 0; | ||
right: 0; | ||
background-color: var(--primary-background-color); | ||
opacity: 0.8; | ||
transition: opacity 0.1s ease-out; | ||
cursor: pointer; | ||
-webkit-tap-highlight-color: transparent; | ||
} | ||
|
||
.container { | ||
z-index: 1; | ||
position: absolute; | ||
bottom: 0; | ||
max-height: calc(100% - var(--horizontal-nav-bar-size)); | ||
width: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
gap: 1.5rem; | ||
padding-bottom: 1rem; | ||
border-radius: 2rem 2rem 0 0; | ||
background-color: var(--modal-background-color); | ||
box-shadow: var(--outer-glow); | ||
overflow: hidden; | ||
|
||
&:not(.dragging) { | ||
transition: transform 0.1s ease-out; | ||
} | ||
|
||
.heading { | ||
position: relative; | ||
|
||
.handle { | ||
position: relative; | ||
height: 2.5rem; | ||
width: 100%; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
|
||
&::after { | ||
content: ""; | ||
height: 0.3rem; | ||
width: 3rem; | ||
border-radius: 1rem; | ||
background-color: var(--primary-foreground-color); | ||
opacity: 0.3; | ||
} | ||
} | ||
|
||
.title { | ||
position: relative; | ||
width: 100%; | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
padding: 0 1rem; | ||
padding-left: 1.5rem; | ||
font-size: 1.25rem; | ||
font-weight: 600; | ||
color: var(--primary-foreground-color); | ||
} | ||
} | ||
|
||
.content { | ||
position: relative; | ||
overflow-y: auto; | ||
} | ||
} | ||
} | ||
|
||
@media only screen and (min-width: @xsmall) { | ||
.bottom-sheet { | ||
display: none; | ||
} | ||
} | ||
|
||
@media only screen and (orientation: landscape) { | ||
.bottom-sheet { | ||
.container { | ||
max-width: 90%; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
// Copyright (C) 2017-2024 Smart code 203358507 | ||
|
||
import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react'; | ||
import { createPortal } from 'react-dom'; | ||
import classNames from 'classnames'; | ||
import useBinaryState from 'stremio/common/useBinaryState'; | ||
import styles from './BottomSheet.less'; | ||
|
||
const CLOSE_THRESHOLD = 100; | ||
|
||
type Props = { | ||
children: JSX.Element, | ||
title: string, | ||
show?: boolean, | ||
onClose: () => void, | ||
}; | ||
|
||
const BottomSheet = ({ children, title, show, onClose }: Props) => { | ||
const containerRef = useRef<HTMLDivElement>(null); | ||
const [startOffset, setStartOffset] = useState(0); | ||
const [offset, setOffset] = useState(0); | ||
|
||
const [opened, open, close] = useBinaryState(); | ||
|
||
const containerStyle = useMemo(() => ({ | ||
transform: `translateY(${offset}px)` | ||
}), [offset]); | ||
|
||
const containerHeight = () => containerRef.current?.offsetHeight ?? 0; | ||
|
||
const onCloseRequest = () => setOffset(containerHeight()); | ||
|
||
const onTouchStart = ({ touches }: React.TouchEvent<HTMLDivElement>) => { | ||
const { clientY } = touches[0]; | ||
setStartOffset(clientY); | ||
}; | ||
|
||
const onTouchMove = useCallback(({ touches }: React.TouchEvent<HTMLDivElement>) => { | ||
const { clientY } = touches[0]; | ||
setOffset(Math.max(0, clientY - startOffset)); | ||
}, [startOffset]); | ||
|
||
const onTouchEnd = () => { | ||
setOffset((offset) => offset > CLOSE_THRESHOLD ? containerHeight() : 0); | ||
setStartOffset(0); | ||
}; | ||
|
||
const onTransitionEnd = useCallback(() => { | ||
(offset === containerHeight()) && close(); | ||
}, [offset]); | ||
|
||
useEffect(() => { | ||
setOffset(0); | ||
show ? open() : close(); | ||
}, [show]); | ||
|
||
useEffect(() => { | ||
!opened && onClose(); | ||
}, [opened]); | ||
|
||
return opened && createPortal(( | ||
<div className={styles['bottom-sheet']}> | ||
<div className={styles['backdrop']} onClick={onCloseRequest} /> | ||
<div | ||
ref={containerRef} | ||
className={classNames(styles['container'], { [styles['dragging']]: startOffset }, 'animation-slide-up')} | ||
style={containerStyle} | ||
onTouchStart={onTouchStart} | ||
onTouchMove={onTouchMove} | ||
onTouchEnd={onTouchEnd} | ||
onTransitionEnd={onTransitionEnd} | ||
> | ||
<div className={styles['heading']}> | ||
<div className={styles['handle']} /> | ||
<div className={styles['title']}> | ||
{title} | ||
</div> | ||
</div> | ||
<div className={styles['content']} onClick={onCloseRequest}> | ||
{children} | ||
</div> | ||
</div> | ||
</div> | ||
), document.body); | ||
}; | ||
|
||
export default BottomSheet; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
// Copyright (C) 2017-2024 Smart code 203358507 | ||
|
||
import BottomSheet from './BottomSheet'; | ||
export default BottomSheet; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,10 @@ | ||
// Copyright (C) 2017-2024 Smart code 203358507 | ||
|
||
@mask-width: 10%; | ||
|
||
.chips { | ||
position: relative; | ||
width: 100%; | ||
display: flex; | ||
align-items: center; | ||
justify-content: flex-start; | ||
gap: 1rem; | ||
overflow-x: auto; | ||
|
||
&.left { | ||
mask-image: linear-gradient(90deg, rgba(0, 0, 0, 1) calc(100% - @mask-width), rgba(0, 0, 0, 0) 100%); | ||
} | ||
|
||
&.right { | ||
mask-image: linear-gradient(90deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 1) @mask-width); | ||
} | ||
|
||
&.center { | ||
mask-image: linear-gradient(90deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 1) @mask-width, rgba(0, 0, 0, 1) calc(100% - @mask-width), rgba(0, 0, 0, 0) 100%); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
// Copyright (C) 2017-2024 Smart code 203358507 | ||
|
||
@mask-width: 10%; | ||
|
||
.horizontal-scroll { | ||
position: relative; | ||
overflow-x: auto; | ||
|
||
&.left { | ||
mask-image: linear-gradient(90deg, rgba(0, 0, 0, 1) calc(100% - @mask-width), rgba(0, 0, 0, 0) 100%); | ||
} | ||
|
||
&.right { | ||
mask-image: linear-gradient(90deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 1) @mask-width); | ||
} | ||
|
||
&.center { | ||
mask-image: linear-gradient(90deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 1) @mask-width, rgba(0, 0, 0, 1) calc(100% - @mask-width), rgba(0, 0, 0, 0) 100%); | ||
} | ||
} |
Oops, something went wrong.