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

Open
wants to merge 16 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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.
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
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
20 changes: 20 additions & 0 deletions src/common/HorizontalScroll/HorizontalScroll.less
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%);
}
}
40 changes: 40 additions & 0 deletions src/common/HorizontalScroll/HorizontalScroll.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
// Copyright (C) 2017-2024 Smart code 203358507

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

const SCROLL_THRESHOLD = 1;

type Props = {
className: string,
children: React.ReactNode,
};

const HorizontalScroll = ({ className, children }: Props) => {
const ref = useRef<HTMLDivElement>(null);
const [scrollPosition, setScrollPosition] = useState('left');

useEffect(() => {
const onScroll = ({ target }: Event) => {
const { scrollLeft, scrollWidth, offsetWidth } = target as HTMLDivElement;

setScrollPosition(() => (
(scrollLeft - SCROLL_THRESHOLD) <= 0 ? 'left' :
(scrollLeft + offsetWidth + SCROLL_THRESHOLD) >= scrollWidth ? 'right' :
'center'
));
};

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

return (
<div ref={ref} className={classNames(styles['horizontal-scroll'], className, [styles[scrollPosition]])}>
{children}
</div>
);
};

export default HorizontalScroll;
4 changes: 4 additions & 0 deletions src/common/HorizontalScroll/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// Copyright (C) 2017-2024 Smart code 203358507

import HorizontalScroll from './HorizontalScroll';
export default HorizontalScroll;
1 change: 1 addition & 0 deletions src/common/MainNavBars/MainNavBars.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ const TABS = [
{ id: 'board', label: 'Board', icon: 'home', href: '#/' },
{ id: 'discover', label: 'Discover', icon: 'discover', href: '#/discover' },
{ id: 'library', label: 'Library', icon: 'library', href: '#/library' },
{ id: 'calendar', label: 'Calendar', icon: 'calendar', href: '#/calendar' },
{ id: 'addons', label: 'ADDONS', icon: 'addons', href: '#/addons' },
{ id: 'settings', label: 'SETTINGS', icon: 'settings', href: '#/settings' },
];
Expand Down
23 changes: 11 additions & 12 deletions src/common/NavBar/VerticalNavBar/styles.less
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
align-items: center;
gap: 1rem;
width: var(--vertical-nav-bar-size);
padding: 1rem 0;
background-color: transparent;
overflow-y: auto;
scrollbar-width: none;
Expand All @@ -20,14 +21,6 @@
.nav-tab-button {
width: calc(var(--vertical-nav-bar-size) - 1.5rem);
height: calc(var(--vertical-nav-bar-size) - 1.5rem);

&:first-child {
margin-top: 1rem;
}

&:last-child {
margin-bottom: 1rem;
}
}
}

Expand All @@ -45,12 +38,18 @@
.nav-tab-button {
flex: none;

&:first-child {
margin-top: 0;
&:last-child {
display: none;
}

}
}
}

@media only screen and (max-height: @minimum) {
.vertical-nav-bar-container {
.nav-tab-button {
&:last-child {
margin-bottom: 0;
display: none;
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/common/PaginationInput/styles.less
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,12 @@
.icon {
display: block;
color: var(--primary-foreground-color);
opacity: 0.7;
transition: opacity 0.2s ease-in-out;

&:hover {
opacity: 1;
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions src/common/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const MetaRow = require('./MetaRow');
const ModalDialog = require('./ModalDialog');
const Multiselect = require('./Multiselect');
const { HorizontalNavBar, VerticalNavBar } = require('./NavBar');
const { default: HorizontalScroll } = require('./HorizontalScroll');
const PaginationInput = require('./PaginationInput');
const PlayIconCircleCentered = require('./PlayIconCircleCentered');
const Popup = require('./Popup');
Expand Down Expand Up @@ -64,6 +65,7 @@ module.exports = {
ModalDialog,
Multiselect,
HorizontalNavBar,
HorizontalScroll,
VerticalNavBar,
PaginationInput,
PlayIconCircleCentered,
Expand Down
4 changes: 4 additions & 0 deletions src/common/routesRegexp.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ const routesRegexp = {
regexp: /^\/library(?:\/([^/]*))?$/,
urlParamsNames: ['type']
},
calendar: {
regexp: /^\/calendar(?:\/([^/]*)\/([^/]*))?$/,
urlParamsNames: ['year', 'month']
},
continuewatching: {
regexp: /^\/continuewatching(?:\/([^/]*))?$/,
urlParamsNames: ['type']
Expand Down
1 change: 1 addition & 0 deletions src/modules.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
declare module '*.less';
declare module 'stremio/services';
declare module 'stremio/common';
declare module 'stremio/common/*';
78 changes: 78 additions & 0 deletions src/routes/Calendar/Calendar.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
// Copyright (C) 2017-2024 Smart code 203358507

@import (reference) '~stremio/common/screen-sizes.less';

:import('~stremio/common/PaginationInput/styles.less') {
pagination-prev-button-container: prev-button-container;
pagination-next-button-container: next-button-container;
pagination-button-icon: icon;
pagination-label: label;
}

.calendar {
width: 100%;
height: 100%;
background-color: transparent;

.content {
position: relative;
display: flex;
flex-direction: row;
gap: 0.5rem;
width: 100%;
height: 100%;
padding: 0 0 2rem 2rem;

.main {
flex: auto;
position: relative;
display: flex;
flex-direction: column;
gap: 1rem;

.inputs {
flex: none;
align-self: stretch;
display: flex;
flex-direction: row;
justify-content: center;

.pagination-input {
flex: none;
height: 3rem;

.pagination-prev-button-container, .pagination-next-button-container {
width: 3rem;
height: 3rem;

.pagination-button-icon {
width: 1rem;
height: 1rem;
}
}

.pagination-label {
width: 9rem;
max-width: initial;
}
}
}
}
}
}

@media only screen and (max-width: @minimum) {
.calendar {
.content {
padding: 0;
}
}
}

@media only screen and (max-width: @small) and (orientation: landscape) {
.calendar {
.content {
padding: 0 0 0 1rem;
}
}
}
Loading
Loading