diff --git a/.storybook/pages/Cad/Cad.tsx b/.storybook/pages/Cad/Cad.tsx index 8ee37cf77..6718b3450 100644 --- a/.storybook/pages/Cad/Cad.tsx +++ b/.storybook/pages/Cad/Cad.tsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { useState } from 'react'; import { PageHeader, @@ -20,6 +20,7 @@ import { GridItem, Text, ProjectCard, + NumberIcon, } from '../../../src'; import '../../../src/components/Utilities/Spacing.css'; @@ -260,240 +261,266 @@ const StandardsRows = [ }, ]; -export const Cad = () => ( - <> - +export const Cad = () => { + const [indexState, setIndexState] = useState(2); + const returnUpdatedItems = (updatedItems: any) => { + console.log(updatedItems); + updatedItems.containers['container-2'].itemIds.map( + (item: string, index: number) => { + if (item === 'item-2') { + updatedItems.items['item-2'].behavior = 'hover'; + setIndexState(20); + } + }, + ); + }; + + const changeNumber = () => { + setIndexState(20); + console.log(indexState); + }; + return ( + <> + + + + + + + + } + headingSize="title-sm" + orientation="2up" + right={ + + + + + } + title="Course Planner: History 6" + /> + + - - } - headingSize="title-sm" - orientation="2up" - right={ - - - - - } - title="Course Planner: History 6" - /> - - - - - - - - Select projects for your History 6 plan - - -

- Make a plan so that you can stay connected to learning - objectives even as changes occur throughout the year. -

-

- Room for more instructional copy per Content Strategy lorem - ipsum dolor sit amet, consectetur adipiscing elit. Phasellus est - quam, consequat iaculis pretium accumsan, fringilla id ligula. -

-
+ + + + + Select projects for your History 6 plan + + +

+ Make a plan so that you can stay connected to learning + objectives even as changes occur throughout the year. +

+

+ Room for more instructional copy per Content Strategy lorem + ipsum dolor sit amet, consectetur adipiscing elit. Phasellus + est quam, consequat iaculis pretium accumsan, fringilla id + ligula. +

+
- - -

- There are no more available projects to create your - course plan -

-
- hand with pencil - - ), - header: ( - - - - - Available projects - - - - - - - - ), - }, - 'container-2': { - itemIds: [], - emptyContent: ( - <> - -

- Drag in available projects to build your course plan -

-
- hand with pencil - - ), - header: ( - - - - - Planned projects - - - - - - - - ), - }, - }} - items={{ - 'item-1': { - behavior: 'hover', - title: 'Project #1', - children: ( - - ), - }, - 'item-2': { - title: 'Project #2', - children: ( - - ), - }, - 'item-3': { - title: 'Project #3', - children: ( - - ), - }, - 'item-4': { - title: 'Project #4', - children: ( - - ), - }, - 'item-5': { - title: 'Project #5', - children: ( - - ), - }, - 'item-6': { - title: 'Project #6', - children: ( - - ), - }, - }} - multipleContainers={false} - unstyledItems={true} - /> -
-
- - - - + returnUpdatedItems(updatedItems) + } + containers={{ + 'container-1': { + itemIds: ['item-1', 'item-2', 'item-3', 'item-4', 'item-5'], + emptyContent: ( + <> + +

+ There are no more available projects to create your + course plan +

+
+ hand with pencil + + ), + header: ( + + + + + Available projects + + + + + + + + ), + }, + 'container-2': { + itemIds: [], + emptyContent: ( + <> + +

+ Drag in available projects to build your course plan +

+
+ hand with pencil + + ), + header: ( + + + + + Planned projects + + + + + + + + ), + }, + }} + items={{ + 'item-1': { + title: 'Project #1', + children: ( + + ), + }, + 'item-2': { + title: 'Project #2', + children: ( + + ), + }, + 'item-3': { + title: 'Project #3', + children: ( + + ), + }, + 'item-4': { + title: 'Project #4', + children: ( + + ), + }, + 'item-5': { + title: 'Project #5', + children: ( + + ), + }, + 'item-6': { + title: 'Project #6', + children: ( + + ), + }, + }} + multipleContainers={false} + unstyledItems={true} /> -
-
- - - - - - - - -
-
-
- -); + + + + + + + + + + + + + + + + + + + + + ); +}; diff --git a/src/components/DragDrop/DragDrop.tsx b/src/components/DragDrop/DragDrop.tsx index 95b652136..c31b5a3b3 100644 --- a/src/components/DragDrop/DragDrop.tsx +++ b/src/components/DragDrop/DragDrop.tsx @@ -42,6 +42,10 @@ export interface Props { * Child node(s) that can be nested inside component. `ModalHeader`, `ModalBody`, and `ModelFooter` are the only permissible children of the Modal */ children?: ReactNode; + /** + * Prop that allows parent components to get the updated drag and drop object data from the outside + */ + getNewState?: (newState: object) => void; } /** @@ -51,6 +55,7 @@ export const DragDrop = ({ className, items, containers, + getNewState, multipleContainers = false, unstyledItems = false, }: Props) => { @@ -136,7 +141,7 @@ export const DragDrop = ({ return () => { window.removeEventListener('resize', setShadows); /* 3 */ }; - }, []); + }, [items]); /** * Update sticky wrapper height on mount @@ -209,6 +214,9 @@ export const DragDrop = ({ * Update state with new container's contents */ setState(newState); + if (getNewState) { + getNewState(newState); + } return; } @@ -248,6 +256,9 @@ export const DragDrop = ({ * Update state with both source and destination containers */ setState(newState); + if (getNewState) { + getNewState(newState); + } }; /** diff --git a/src/components/NumberIcon/NumberIcon.tsx b/src/components/NumberIcon/NumberIcon.tsx index ea5925e9c..6432a0c00 100644 --- a/src/components/NumberIcon/NumberIcon.tsx +++ b/src/components/NumberIcon/NumberIcon.tsx @@ -21,7 +21,7 @@ export interface Props { /** * Number to be shown as the icon. */ - number: number; + number?: number; /** * The size of the icon. Defaults to 'lg'. */