From 4f4f1f1ef9e20b6c926dea1df76c3048642d871c Mon Sep 17 00:00:00 2001 From: 3p1cPh4r40h Date: Thu, 18 Nov 2021 21:58:25 -0500 Subject: [PATCH 1/3] CEM-2596 Draggable Row A draggable row based on the 'MiddleCanvas' component logic for reordering 'Draggable' items. --- .../DraggableRow/DraggableRow.stories.tsx | 23 +++ src/Containers/DraggableRow/DraggableRow.tsx | 22 +++ .../DraggableRow/DraggableRowTypes.tsx | 31 ++++ .../DroppableContainerContents.tsx | 27 ++++ .../DraggableRow/DroppableElement.tsx | 121 +++++++++++++++ src/Containers/DraggableRow/Template.tsx | 139 ++++++++++++++++++ src/Containers/index.ts | 1 + 7 files changed, 364 insertions(+) create mode 100644 src/Containers/DraggableRow/DraggableRow.stories.tsx create mode 100644 src/Containers/DraggableRow/DraggableRow.tsx create mode 100644 src/Containers/DraggableRow/DraggableRowTypes.tsx create mode 100644 src/Containers/DraggableRow/DroppableContainerContents.tsx create mode 100644 src/Containers/DraggableRow/DroppableElement.tsx create mode 100644 src/Containers/DraggableRow/Template.tsx diff --git a/src/Containers/DraggableRow/DraggableRow.stories.tsx b/src/Containers/DraggableRow/DraggableRow.stories.tsx new file mode 100644 index 00000000..1a2ef24d --- /dev/null +++ b/src/Containers/DraggableRow/DraggableRow.stories.tsx @@ -0,0 +1,23 @@ +import React from 'react'; +import { Story, Meta } from '@storybook/react'; +import { DraggableRow, DraggableRowProps } from '../../index'; +import { createStoryTitle } from '../../Constants'; + +export default { + title: createStoryTitle('Draggable Row'), + component: DraggableRow, + args: { + templatePrefills: { + TEMPLATE_ITEM: { + caption: 'This is a template caption.' + }, + TEMPLATE_ITEM2: { + caption: 'This is another template caption.' + }, + }, + }, +} as Meta; + +export const Basic: Story = (args) => ( + +); \ No newline at end of file diff --git a/src/Containers/DraggableRow/DraggableRow.tsx b/src/Containers/DraggableRow/DraggableRow.tsx new file mode 100644 index 00000000..1e314695 --- /dev/null +++ b/src/Containers/DraggableRow/DraggableRow.tsx @@ -0,0 +1,22 @@ +import React from 'react'; +import { Template } from './Template'; +import { ITemplatePrefill } from './DraggableRowTypes'; + +export interface DraggableRowProps extends React.HTMLAttributes { + /*Template of a draggable element that can be reordered*/ + templatePrefills: ITemplatePrefill; +} + +export const DraggableRow: React.FC = ({ + templatePrefills, + ...props +}): React.ReactElement => { + + return ( +
+