5fdac4898f
* Add horizontal layout (#636) * Test out a horizontal scroll for upcoming (tile only for now) * - add support for list layout - add following label on home page - clan up css and naming conventions * Update header type + show only if scheduled streams are showing * [Playlist] Pull in sorting changes from desktop + Add Drag-n-Drop + Handle unavailable/deleted claims (#641) * Add ordering Icons * Refactor doCollectionEdit - It required claims as parameter, when only uris are used to populate the collection, so that was changed to pass down the uris instead. - There were unused and mostly unnecessary functions inside, for example the parameter claimIds was never used so it would never enter the claimSearch function which again would be used to generate uris, so it's better to just use uris as parameter * Add List Reordering changes * Add toggle button for list editing * Add toggle on content page collection sidebar * Enable drag-n-drop to re-order list items https://www.youtube.com/watch?v=aYZRRyukuIw * Allow removing all unavailable claims from a List * Fix <g> on icons * Fix section buttons positioning * Move preventDefault and stopPropagation to buttons div instead of each button, preventing clicking even if disabled opening the claim * Change dragging cursor * Fix sizing * Fix dragging component * Restrict dragging to vertical axis * Ignore shuffle state for ordering * Fix console errors * Mobile fixes * Fix sidebar spacing * Fix grey on mobile after click * cleanup Co-authored-by: Dan Peterson <dan@dan-peterson.ca> Co-authored-by: saltrafael <76502841+saltrafael@users.noreply.github.com>
132 lines
3.7 KiB
JavaScript
132 lines
3.7 KiB
JavaScript
// @flow
|
|
|
|
// $FlowFixMe
|
|
import { DragDropContext, Droppable } from 'react-beautiful-dnd';
|
|
|
|
import React from 'react';
|
|
import classnames from 'classnames';
|
|
import ClaimList from 'component/claimList';
|
|
import Card from 'component/common/card';
|
|
import Button from 'component/button';
|
|
import * as PAGES from 'constants/pages';
|
|
import * as COLLECTIONS_CONSTS from 'constants/collections';
|
|
import Icon from 'component/common/icon';
|
|
import * as ICONS from 'constants/icons';
|
|
|
|
type Props = {
|
|
id: string,
|
|
url: string,
|
|
isMyCollection: boolean,
|
|
collectionUrls: Array<Claim>,
|
|
collectionName: string,
|
|
collection: any,
|
|
loop: boolean,
|
|
shuffle: boolean,
|
|
doToggleLoopList: (string, boolean) => void,
|
|
doToggleShuffleList: (string, string, boolean) => void,
|
|
createUnpublishedCollection: (string, Array<any>, ?string) => void,
|
|
doCollectionEdit: (string, CollectionEditParams) => void,
|
|
};
|
|
|
|
export default function CollectionContent(props: Props) {
|
|
const {
|
|
isMyCollection,
|
|
collectionUrls,
|
|
collectionName,
|
|
id,
|
|
url,
|
|
loop,
|
|
shuffle,
|
|
doToggleLoopList,
|
|
doToggleShuffleList,
|
|
doCollectionEdit,
|
|
} = props;
|
|
|
|
const [showEdit, setShowEdit] = React.useState(false);
|
|
|
|
function handleOnDragEnd(result) {
|
|
const { source, destination } = result;
|
|
|
|
if (!destination) return;
|
|
|
|
const { index: from } = source;
|
|
const { index: to } = destination;
|
|
|
|
doCollectionEdit(id, { order: { from, to } });
|
|
}
|
|
|
|
return (
|
|
<Card
|
|
isBodyList
|
|
className="file-page__recommended-collection"
|
|
title={
|
|
<>
|
|
<span className="file-page__recommended-collection__row">
|
|
<Icon
|
|
icon={
|
|
(id === COLLECTIONS_CONSTS.WATCH_LATER_ID && ICONS.TIME) ||
|
|
(id === COLLECTIONS_CONSTS.FAVORITES_ID && ICONS.STAR) ||
|
|
ICONS.STACK
|
|
}
|
|
className="icon--margin-right"
|
|
/>
|
|
{collectionName}
|
|
</span>
|
|
<span className="file-page__recommended-collection__row">
|
|
<Button
|
|
button="alt"
|
|
title={__('Loop')}
|
|
icon={ICONS.REPEAT}
|
|
iconColor={loop && 'blue'}
|
|
className="button--file-action"
|
|
onClick={() => doToggleLoopList(id, !loop)}
|
|
/>
|
|
<Button
|
|
button="alt"
|
|
title={__('Shuffle')}
|
|
icon={ICONS.SHUFFLE}
|
|
iconColor={shuffle && 'blue'}
|
|
className="button--file-action"
|
|
onClick={() => doToggleShuffleList(url, id, !shuffle)}
|
|
/>
|
|
</span>
|
|
</>
|
|
}
|
|
titleActions={
|
|
<>
|
|
<div className="card__title-actions--link">
|
|
{/* TODO: BUTTON TO SAVE COLLECTION - Probably save/copy modal */}
|
|
<Button label={__('View List')} button="link" navigate={`/$/${PAGES.LIST}/${id}`} />
|
|
</div>
|
|
|
|
{isMyCollection && (
|
|
<Button
|
|
title={__('Edit')}
|
|
className={classnames('button-toggle', { 'button-toggle--active': showEdit })}
|
|
icon={ICONS.EDIT}
|
|
onClick={() => setShowEdit(!showEdit)}
|
|
/>
|
|
)}
|
|
</>
|
|
}
|
|
body={
|
|
<DragDropContext onDragEnd={handleOnDragEnd}>
|
|
<Droppable droppableId="list__ordering">
|
|
{(DroppableProvided) => (
|
|
<ClaimList
|
|
isCardBody
|
|
type="small"
|
|
activeUri={url}
|
|
uris={collectionUrls}
|
|
collectionId={id}
|
|
empty={__('List is Empty')}
|
|
showEdit={showEdit}
|
|
droppableProvided={DroppableProvided}
|
|
/>
|
|
)}
|
|
</Droppable>
|
|
</DragDropContext>
|
|
}
|
|
/>
|
|
);
|
|
}
|