Skip to content

Commit b0a9e0b

Browse files
authored
feat: allow customising dnd indicator classname/style (#683)
1 parent 46eb68e commit b0a9e0b

File tree

5 files changed

+24
-4
lines changed

5 files changed

+24
-4
lines changed

.changeset/modern-socks-retire.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@craftjs/utils': patch
3+
'@craftjs/core': patch
4+
---
5+
6+
Allow customising dnd indicator style/classname

packages/core/src/events/RenderEditorIndicator.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export const RenderEditorIndicator = () => {
3535
}
3636

3737
return React.createElement(RenderIndicator, {
38+
className: indicatorOptions.className,
3839
style: {
3940
...movePlaceholder(
4041
indicator.placement,
@@ -47,6 +48,7 @@ export const RenderEditorIndicator = () => {
4748
? indicatorOptions.error
4849
: indicatorOptions.success,
4950
transition: indicatorOptions.transition || '0.2s ease-in',
51+
...(indicatorOptions.style ?? {}),
5052
},
5153
parentDom: indicator.placement.parent.dom,
5254
});

packages/core/src/interfaces/editor.ts

+2
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ export type Options = {
2323
error: string;
2424
transition: string;
2525
thickness: number;
26+
className: string;
27+
style: React.CSSProperties;
2628
}>;
2729
handlers: (store: EditorStore) => CoreEventHandlers;
2830
normalizeNodes: (

packages/utils/src/RenderIndicator.tsx

+7-1
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,18 @@ import ReactDOM from 'react-dom';
33

44
type RenderIndicatorProps = {
55
style: React.CSSProperties;
6+
className?: string;
67
parentDom?: HTMLElement;
78
};
89

9-
export const RenderIndicator = ({ style, parentDom }: RenderIndicatorProps) => {
10+
export const RenderIndicator = ({
11+
style,
12+
className,
13+
parentDom,
14+
}: RenderIndicatorProps) => {
1015
const indicator = (
1116
<div
17+
className={className}
1218
style={{
1319
position: 'fixed',
1420
display: 'block',

site/docs/api/Editor.md

+7-3
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ const App = () => {
5353
```
5454
In the above example, every user element will now be wrapped in a black `div`.
5555

56-
### Specifying the Drop Indicator colour
56+
### Customising the drag-and-drop indicator
5757

58-
You could change the colours of the drag and drop indicators like so:
58+
You could also change the colours/style of the drag-and-drop indicator like so:
5959

6060
```jsx {6-9}
6161
import {Editor} from "@craftjs/core";
@@ -65,7 +65,11 @@ const App = () => {
6565
<Editor
6666
indicator={{
6767
'success': '#2d9d78', // green
68-
'error': '#e34850' // red
68+
'error': '#e34850', // red
69+
'style': { // custom CSS properties
70+
boxShadow: '...
71+
},
72+
'className': 'your-css-class' // custom CSS class
6973
}}
7074
>
7175
<Frame resolver={{Hero}}>

0 commit comments

Comments
 (0)