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>
62 lines
1.6 KiB
JavaScript
62 lines
1.6 KiB
JavaScript
// @flow
|
|
import * as ICONS from 'constants/icons';
|
|
import * as COLLECTIONS_CONSTS from 'constants/collections';
|
|
import React from 'react';
|
|
import { FormField } from 'component/common/form';
|
|
import Icon from 'component/common/icon';
|
|
|
|
type Props = {
|
|
collection: Collection,
|
|
hasClaim: boolean,
|
|
category: string,
|
|
edited: boolean,
|
|
editCollection: (string, CollectionEditParams) => void,
|
|
uri: string,
|
|
collectionPending: Collection,
|
|
};
|
|
|
|
function CollectionSelectItem(props: Props) {
|
|
const { collection, hasClaim, category, editCollection, uri, collectionPending } = props;
|
|
const { name, id } = collection;
|
|
const handleChange = (e) => {
|
|
editCollection(id, { uris: [uri], remove: hasClaim });
|
|
};
|
|
|
|
let icon;
|
|
switch (category) {
|
|
case 'builtin':
|
|
icon =
|
|
(id === COLLECTIONS_CONSTS.WATCH_LATER_ID && ICONS.TIME) ||
|
|
(id === COLLECTIONS_CONSTS.FAVORITES_ID && ICONS.STAR) ||
|
|
ICONS.STACK;
|
|
break;
|
|
case 'published':
|
|
icon = ICONS.STACK;
|
|
break;
|
|
default:
|
|
// 'unpublished'
|
|
icon = ICONS.LOCK;
|
|
break;
|
|
}
|
|
|
|
return (
|
|
<div className={'collection-select__item'}>
|
|
<FormField
|
|
checked={hasClaim}
|
|
disabled={collectionPending}
|
|
icon={icon}
|
|
type="checkbox"
|
|
name={`select-${id}`}
|
|
onChange={handleChange} // edit the collection
|
|
label={
|
|
<span>
|
|
<Icon icon={icon} className={'icon-collection-select'} />
|
|
{`${name}`}
|
|
</span>
|
|
} // the collection name
|
|
/>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default CollectionSelectItem;
|