PluginProbe
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More / 2.2.1
Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More v2.2.1
2.4.1 2.4.0 2.3.4 2.3.3 2.3.2 2.3.1 2.3.0 2.2.2 2.2.1 2.2.0 2.1.2 2.1.1 trunk 0.0.1 0.0.2 0.0.3 0.0.4 0.0.5 0.0.6 0.0.7 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 All 68 releases
better-payment / src / campaign-builder / components / Column.js

Column.js in Better Payment – Instant Payments, Donations, Fundraising with Subscriptions & More 2.2.1, at src/campaign-builder/components/Column.js

63 lines 2.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { __ } from '@wordpress/i18n';
2 import { useDroppable } from '@dnd-kit/core';
3 import { SortableContext, verticalListSortingStrategy } from '@dnd-kit/sortable';
4 import ElementCard from './ElementCard';
5
6 /**
7 * A single droppable column in the campaign canvas.
8 *
9 * Accepts elements dragged from the FieldsPanel (via useDroppable) and
10 * supports sortable reordering of its own elements (via SortableContext).
11 */
12 export default function Column( { column, meta, campaignId, selectedElementId, dispatch, isActiveDropTarget, dropTargetElementId } ) {
13 const { setNodeRef, isOver } = useDroppable( {
14 id: `col-${ column.id }`,
15 data: { columnId: column.id },
16 } );
17
18 const elementIds = column.elements.map( ( el ) => el.id );
19 const isEmpty = column.elements.length === 0;
20 const isHighlighted = isOver || isActiveDropTarget;
21
22 return (
23 <div
24 className={ [
25 'bp-canvas-column',
26 isEmpty ? 'bp-canvas-column--empty' : '',
27 isHighlighted ? 'bp-canvas-column--over' : '',
28 ].filter( Boolean ).join( ' ' ) }
29 style={ { flex: `${ parseFloat( column.width ) || 1 } 1 0`, minWidth: 0 } }
30 >
31 <div className="bp-canvas-column__label">
32 { column.label }
33 </div>
34
35 <SortableContext items={ elementIds } strategy={ verticalListSortingStrategy }>
36 <div ref={ setNodeRef } className="bp-canvas-column__drop-area">
37 { isEmpty ? (
38 <div className="bp-canvas-column__placeholder">
39 <span className="dashicons dashicons-plus-alt2"></span>
40 <p>{ __( 'Drop elements here', 'better-payment' ) }</p>
41 </div>
42 ) : (
43 column.elements.map( ( element, index ) => (
44 <ElementCard
45 key={ element.id }
46 element={ element }
47 columnId={ column.id }
48 index={ index }
49 totalElements={ column.elements.length }
50 meta={ meta }
51 campaignId={ campaignId }
52 isSelected={ element.id === selectedElementId }
53 dispatch={ dispatch }
54 isDropTarget={ element.id === dropTargetElementId }
55 />
56 ) )
57 ) }
58 </div>
59 </SortableContext>
60 </div>
61 );
62 }
63