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

feat: calendar #651

Merged
merged 48 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from 38 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
8a79058
feat: calendar
tymmesyde Jun 18, 2024
4250c9b
refactor(Calendar): improve responsiveness
tymmesyde Jun 28, 2024
c7b3c31
feat(Calendar): add auth placeholder
tymmesyde Jun 28, 2024
c6ad7e9
feat(Calendar): implement selected logic
tymmesyde Jul 3, 2024
e7ddbcf
refactor: use shared HorizontalScroll component for Chips and Calendar
tymmesyde Jul 3, 2024
a561ee0
feat(Calendar): add play icons on items
tymmesyde Jul 4, 2024
f6c4e66
refactor(Calendar): improve responsiveness
tymmesyde Jul 4, 2024
098a6cb
refactor(NavBar): remove settings tab on mobile
tymmesyde Jul 4, 2024
5f90577
fix(Calendar): hide cell items when height is too small
tymmesyde Jul 4, 2024
98b3891
fix(Calendar): make cells acessible with keyboard
tymmesyde Jul 4, 2024
fe663f1
feat: arrows hover effect
kKaskak Jul 4, 2024
c5efdcb
fix: chips offset
kKaskak Jul 4, 2024
13aeae0
refactor: imports
kKaskak Jul 4, 2024
b6eef9a
fix(Calendar): cells border radius
tymmesyde Jul 5, 2024
971c393
Merge branch 'feat/calendar' of https://github.com/Stremio/stremio-we…
tymmesyde Jul 5, 2024
076c1e0
fix(Calendar): list items border radius
tymmesyde Jul 5, 2024
0b70f67
feat: add BottomSheet to calendar for mobile
tymmesyde Sep 23, 2024
03a6100
Merge branch 'development' of https://github.com/Stremio/stremio-web …
tymmesyde Sep 23, 2024
3f8c64f
fix(Calendar): remove border radius on 29nth cell
tymmesyde Sep 24, 2024
184f191
refactor(BottomSheet): style for landscape mode
tymmesyde Sep 24, 2024
3870c6a
refactor(Calendar): improve responsive layout
tymmesyde Sep 24, 2024
2d9f3fa
refactor(Calendar): improve placeholder responsiveness on mobile
tymmesyde Oct 3, 2024
59d490c
refactor(Calendar): make placeholder login button go to the login form
tymmesyde Oct 3, 2024
77ce946
Merge branch 'development' of https://github.com/Stremio/stremio-web …
tymmesyde Oct 9, 2024
1d0cb4d
refactor(BottomSheet): make container follow to size of content
tymmesyde Oct 9, 2024
19085da
refactor(BottomSheet): remove unnecessary useCallback
tymmesyde Oct 9, 2024
820f7ea
fix(Calendar): use useCallback for useCalendarDate functions
tymmesyde Oct 29, 2024
d9b82ac
fix(Calendar): lint
tymmesyde Oct 29, 2024
ea933fe
refactor(PaginationInput): transition when hovering the button
tymmesyde Oct 29, 2024
ac01908
fix(Calendar): deselect day when closing details
tymmesyde Oct 29, 2024
7cefc8d
feat(Calendar): add transition to border of items
tymmesyde Oct 29, 2024
6337f25
Merge branch 'development' of https://github.com/Stremio/stremio-web …
tymmesyde Oct 29, 2024
a98d38f
fix(BottomSheet): remove chrome mobile highlight color for backdrop
tymmesyde Oct 30, 2024
57fc3bc
fix(BottomSheet): add bottom padding to container
tymmesyde Oct 30, 2024
79cde15
fix(Calendar): toMonthYear returned incorrect month depending on the day
tymmesyde Oct 31, 2024
7874062
chore: use dev build of core-web
tymmesyde Oct 31, 2024
9df9a4e
fix(Calendar): layout issue for small viewports
tymmesyde Nov 4, 2024
941e379
chore: update stremio-core-web
tymmesyde Nov 20, 2024
e5e67d5
feat(Calendar): implement selector
tymmesyde Nov 28, 2024
ef28d74
Merge branch 'development' of https://github.com/Stremio/stremio-web …
tymmesyde Nov 28, 2024
320bca2
fix(Calendar): copyright headers
tymmesyde Nov 28, 2024
73ab4ad
refactor(Calendar): use fixed widths for selector
tymmesyde Nov 28, 2024
c5ab6b6
fix: navbar item label was cut
kKaskak Nov 28, 2024
bb05f6d
Merge pull request #732 from Stremio/fix/navbar-item-label-not-visible
tymmesyde Nov 28, 2024
03a29c5
refactor(Calendar): simplify mobile media query
tymmesyde Nov 28, 2024
1f7cf89
refactor(Calendar): remove chrome mobile highlight on buttons
tymmesyde Nov 28, 2024
83c5c5a
refactor(Calendar): month selector style
tymmesyde Nov 28, 2024
7b87715
refactor(Calendar): remove past items styling
tymmesyde Nov 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added images/calendar_placeholder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 18 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"@babel/runtime": "7.16.0",
"@sentry/browser": "6.13.3",
"@stremio/stremio-colors": "5.0.1",
"@stremio/stremio-core-web": "0.47.8",
"@stremio/stremio-core-web": "0.48.0",
"@stremio/stremio-icons": "5.2.0",
"@stremio/stremio-video": "0.0.38",
"a-color-picker": "1.2.1",
Expand Down Expand Up @@ -55,6 +55,7 @@
"@stylistic/eslint-plugin-jsx": "^2.9.0",
"@types/hat": "^0.0.4",
"@types/react": "^18.2.9",
"@types/react-dom": "^18.3.0",
"babel-loader": "8.2.3",
"clean-webpack-plugin": "4.0.0",
"copy-webpack-plugin": "9.0.1",
Expand Down
4 changes: 4 additions & 0 deletions src/App/routerViewsConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ const routerViewsConfig = [
...routesRegexp.library,
component: routes.Library
},
{
...routesRegexp.calendar,
component: routes.Calendar
},
{
...routesRegexp.continuewatching,
component: routes.Library
Expand Down
1 change: 1 addition & 0 deletions src/App/styles.less
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ html {
min-height: 480px;
font-family: 'PlusJakartaSans', 'sans-serif';
overflow: auto;
overscroll-behavior: none;

body {
width: 100%;
Expand Down
102 changes: 102 additions & 0 deletions src/common/BottomSheet/BottomSheet.less
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%;
}
}
}
87 changes: 87 additions & 0 deletions src/common/BottomSheet/BottomSheet.tsx
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;
4 changes: 4 additions & 0 deletions src/common/BottomSheet/index.ts
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;
4 changes: 3 additions & 1 deletion src/common/Chips/Chip/Chip.less
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@
background-color: transparent;
user-select: none;
overflow: hidden;
opacity: 0.6;

&:hover {
background-color: var(--overlay-color);
transition: background-color 0.1s ease-out;
opacity: 1;
}

&.active {
font-weight: 700;
opacity: 1;
background-color: var(--quaternary-accent-color);
transition: background-color 0.1s ease-in;
}
Expand Down
15 changes: 0 additions & 15 deletions src/common/Chips/Chips.less
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%);
}
}
27 changes: 4 additions & 23 deletions src/common/Chips/Chips.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (C) 2017-2024 Smart code 203358507

import React, { memo, useEffect, useRef, useState } from 'react';
import classNames from 'classnames';
import React, { memo } from 'react';
import HorizontalScroll from '../HorizontalScroll';
import Chip from './Chip';
import styles from './Chips.less';

Expand All @@ -16,28 +16,9 @@ type Props = {
onSelect: (value: string) => {},
};

const SCROLL_THRESHOLD = 1;

const Chips = memo(({ options, selected, onSelect }: Props) => {
const ref = useRef<HTMLDivElement>(null);
const [scrollPosition, setScrollPosition] = useState('left');

useEffect(() => {
const onScroll = ({ target }: Event) => {
const { scrollLeft, scrollWidth, offsetWidth} = target as HTMLDivElement;
const position =
(scrollLeft - SCROLL_THRESHOLD) <= 0 ? 'left' :
(scrollLeft + offsetWidth + SCROLL_THRESHOLD) >= scrollWidth ? 'right' :
'center';
setScrollPosition(position);
};

ref.current?.addEventListener('scroll', onScroll);
return () => ref.current?.removeEventListener('scroll', onScroll);
}, []);

return (
<div ref={ref} className={classNames(styles['chips'], [styles[scrollPosition]])}>
<HorizontalScroll className={styles['chips']}>
{
options.map(({ label, value }) => (
<Chip
Expand All @@ -49,7 +30,7 @@ const Chips = memo(({ options, selected, onSelect }: Props) => {
/>
))
}
</div>
</HorizontalScroll>
);
});

Expand Down
Loading