diff --git a/src/components/molecules/OakDroppable/OakDroppable.stories.tsx b/src/components/molecules/OakDroppable/OakDroppable.stories.tsx index 5ca03052..4b0aba67 100644 --- a/src/components/molecules/OakDroppable/OakDroppable.stories.tsx +++ b/src/components/molecules/OakDroppable/OakDroppable.stories.tsx @@ -30,6 +30,12 @@ type Story = StoryObj; export const Default: Story = {}; +export const Disabled: Story = { + args: { + isDisabled: true, + }, +}; + /** * A draggable has entered the droppable so it has entered an active state */ @@ -41,18 +47,21 @@ export const DraggingOver: Story = { export const Occupied: Story = { args: { + canDrop: true, children: Elephant, }, }; export const WithSlotLabel: Story = { args: { + canDrop: true, labelSlot: "never forgets", }, }; export const OccupiedWithSlotLabel: Story = { args: { + canDrop: true, labelSlot: "never forgets", children: Elephant, }, @@ -62,6 +71,7 @@ export const OccupiedWithSlotLabel: Story = { */ export const DraggingOverWithSlotLabel: Story = { args: { + canDrop: true, isOver: true, labelSlot: "never forgets", }, @@ -69,6 +79,7 @@ export const DraggingOverWithSlotLabel: Story = { export const WithLongSlotLabel: Story = { args: { + canDrop: true, labelSlot: "which animal never forgets and is the largest land animal on earth?", }, @@ -76,6 +87,7 @@ export const WithLongSlotLabel: Story = { export const WithAVeryLongSlotLabel: Story = { args: { + canDrop: true, labelSlot: "which animal is the largest land mammal with a long trunk, large ears, and tusks? Known for intelligence and social behavior, it symbolizes strength and conservation efforts worldwide.", }, diff --git a/src/components/molecules/OakDroppable/OakDroppable.tsx b/src/components/molecules/OakDroppable/OakDroppable.tsx index 8f2ccd22..09b8a405 100644 --- a/src/components/molecules/OakDroppable/OakDroppable.tsx +++ b/src/components/molecules/OakDroppable/OakDroppable.tsx @@ -16,6 +16,10 @@ export type OakDroppableProps = { * Indicates whether a draggable is currently being dragged over the droppable */ isOver?: boolean; + /** + * Present the element in a state making it clear that it can be dropped into + */ + isDisabled?: boolean; /** * A slot for a label to be displayed to the RHS of the droppable * @@ -31,6 +35,10 @@ export type OakDroppableProps = { const StyledFlex = styled(OakFlex)` outline: ${parseBorder("border-solid-l")} ${parseColor("border-primary")}; outline-style: dashed; + + &[data-disabled="true"] { + outline-color: ${parseColor("border-neutral")}; + } `; /** @@ -44,7 +52,18 @@ export const OakDroppable: FC< > = forwardRef< HTMLDivElement, OakDroppableProps & ComponentPropsWithoutRef ->(({ children, labelSlot, isOver, ...props }, ref) => { +>(({ children, labelSlot, isOver, isDisabled, ...props }, ref) => { + const slotBackground = (() => { + if (isOver) { + return "bg-primary"; + } + if (!isDisabled) { + return "bg-neutral"; + } + + return "transparent"; + })(); + return ( {children} diff --git a/src/components/molecules/OakDroppable/__snapshots__/OakDroppable.test.tsx.snap b/src/components/molecules/OakDroppable/__snapshots__/OakDroppable.test.tsx.snap index b5db440f..7d002c30 100644 --- a/src/components/molecules/OakDroppable/__snapshots__/OakDroppable.test.tsx.snap +++ b/src/components/molecules/OakDroppable/__snapshots__/OakDroppable.test.tsx.snap @@ -47,6 +47,10 @@ exports[`OakDroppable matches snapshot 1`] = ` outline-style: dashed; } +.c4[data-disabled="true"] { + outline-color: #808080; +} + @media (min-width:750px) { .c1 { -webkit-flex-direction: row; diff --git a/src/components/organisms/pupil/OakQuizOrder/OakQuizOrder.tsx b/src/components/organisms/pupil/OakQuizOrder/OakQuizOrder.tsx index f6e66f9c..fffb6edd 100644 --- a/src/components/organisms/pupil/OakQuizOrder/OakQuizOrder.tsx +++ b/src/components/organisms/pupil/OakQuizOrder/OakQuizOrder.tsx @@ -56,22 +56,20 @@ const ConnectedDraggable = ({ id, label }: OakQuizOrderItem) => { setNodeRef, transform, transition, - active, - over, + isOver, + isDragging, } = useSortable({ id }); - const isGhostItem = active?.id === id; - const isGhostSlot = over?.id === id; const style = { transform: CSS.Transform.toString(transform), transition, }; return ( - +