From 9739d58fdfacf16cd45ba1a7f883a85cc8e5550b Mon Sep 17 00:00:00 2001 From: Jackson Harper Date: Thu, 29 Feb 2024 12:46:02 +0800 Subject: [PATCH] Add multi select file --- .../homeFeed/MultiSelectControls.tsx | 300 ++++++++++++++++++ 1 file changed, 300 insertions(+) create mode 100644 packages/web/components/templates/homeFeed/MultiSelectControls.tsx diff --git a/packages/web/components/templates/homeFeed/MultiSelectControls.tsx b/packages/web/components/templates/homeFeed/MultiSelectControls.tsx new file mode 100644 index 000000000..e7d3ae075 --- /dev/null +++ b/packages/web/components/templates/homeFeed/MultiSelectControls.tsx @@ -0,0 +1,300 @@ +import { useState } from 'react' +import { theme } from '../../tokens/stitches.config' +import { Box, HStack, SpanBox } from '../../elements/LayoutPrimitives' +import { Button } from '../../elements/Button' +import { BulkAction } from '../../../lib/networking/mutations/bulkActionMutation' +import { ArchiveIcon } from '../../elements/icons/ArchiveIcon' +import { LabelIcon } from '../../elements/icons/LabelIcon' +import { TrashIcon } from '../../elements/icons/TrashIcon' +import { ConfirmationModal } from '../../patterns/ConfirmationModal' +import { AddBulkLabelsModal } from '../article/AddBulkLabelsModal' +import { X } from 'phosphor-react' +import { LibraryHeaderProps } from './LibraryHeader' +import { HeaderCheckboxIcon } from '../../elements/icons/HeaderCheckboxIcon' + +export const MultiSelectControls = (props: LibraryHeaderProps): JSX.Element => { + const [showConfirmDelete, setShowConfirmDelete] = useState(false) + const [showLabelsModal, setShowLabelsModal] = useState(false) + // Don't change on immediate hover, the button has to be blurred at least once + const [hoveredOut, setHoveredOut] = useState(false) + const [hoverColor, setHoverColor] = useState( + theme.colors.thTextContrast2.toString() + ) + const compact = false + + return ( + { + setHoveredOut(true) + event.preventDefault() + }} + > + { + e.preventDefault() + }} + > + + + + + + {props.numItemsSelected} items selected + + + + + {showConfirmDelete && ( + { + props.performMultiSelectAction(BulkAction.DELETE) + }} + onOpenChange={(open: boolean) => { + setShowConfirmDelete(false) + }} + /> + )} + {showLabelsModal && ( + { + const labelIds = labels.map((l) => l.id) + props.performMultiSelectAction(BulkAction.ADD_LABELS, labelIds) + }} + onOpenChange={(open: boolean) => { + setShowLabelsModal(false) + }} + /> + )} + + + + + ) +} + +export const CheckBoxButton = (props: LibraryHeaderProps): JSX.Element => { + return ( + + ) +} + +export const ArchiveButton = (props: LibraryHeaderProps): JSX.Element => { + const [color, setColor] = useState( + theme.colors.thTextContrast2.toString() + ) + return ( + + ) +} + +type AddLabelsButtonProps = { + setShowLabelsModal: (set: boolean) => void +} + +export const AddLabelsButton = (props: AddLabelsButtonProps): JSX.Element => { + const [color, setColor] = useState( + theme.colors.thTextContrast2.toString() + ) + return ( + + ) +} + +type RemoveItemsButtonProps = { + setShowConfirmDelete: (set: boolean) => void +} + +export const RemoveItemsButton = ( + props: RemoveItemsButtonProps +): JSX.Element => { + const [color, setColor] = useState( + theme.colors.thTextContrast2.toString() + ) + return ( + + ) +} + +export const CancelButton = (props: LibraryHeaderProps): JSX.Element => { + const [color, setColor] = useState( + theme.colors.thTextContrast2.toString() + ) + return ( + + ) +}