-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move custom status component into separate class, add drag handle
- Loading branch information
1 parent
47f9432
commit e2909f8
Showing
9 changed files
with
158 additions
and
250 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
<?php return array('dependencies' => array('react', 'react-dom', 'wp-dom-ready', 'wp-element', 'wp-i18n'), 'version' => 'b3ad43d2379bdf79244b'); | ||
<?php return array('dependencies' => array('react', 'react-dom', 'wp-dom-ready', 'wp-element', 'wp-i18n', 'wp-primitives'), 'version' => 'a0162d0b6134374f1c60'); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
38 changes: 38 additions & 0 deletions
38
modules/custom-status/lib/components/draggable-custom-status.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { dragHandle, Icon } from '@wordpress/icons'; | ||
import clsx from 'clsx'; | ||
|
||
export default function DraggableCustomStatus( { customStatus, index, provided, snapshot } ) { | ||
const className = clsx( | ||
{ | ||
dragging: snapshot.isDragging, | ||
}, | ||
'custom-status-item' | ||
); | ||
|
||
return ( | ||
<> | ||
<div | ||
className={ className } | ||
ref={ provided.innerRef } | ||
{ ...provided.draggableProps } | ||
{ ...provided.dragHandleProps } | ||
style={ getItemStyle( index, snapshot.isDragging, provided.draggableProps.style ) } | ||
> | ||
<div className="name">{ customStatus.name }</div> | ||
|
||
<div className="drag-handle"> | ||
<Icon icon={ dragHandle } size={ 24 } /> | ||
</div> | ||
</div> | ||
</> | ||
); | ||
} | ||
|
||
const getItemStyle = ( index, isDragging, draggableStyle ) => { | ||
const defaultBackgroundColor = index % 2 ? 'white' : '#f6f7f7'; | ||
|
||
return { | ||
background: isDragging ? 'lightgreen' : defaultBackgroundColor, | ||
...draggableStyle, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.