Skip to content

Commit

Permalink
feat: allow customising dnd indicator classname/style
Browse files Browse the repository at this point in the history
  • Loading branch information
prevwong committed Jul 25, 2024
1 parent 46eb68e commit 2186c83
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
6 changes: 6 additions & 0 deletions .changeset/modern-socks-retire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@craftjs/utils': patch
'@craftjs/core': patch
---

Allow customising dnd indicator style/classname
2 changes: 2 additions & 0 deletions packages/core/src/events/RenderEditorIndicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ export const RenderEditorIndicator = () => {
}

return React.createElement(RenderIndicator, {
className: indicatorOptions.className,
style: {
...movePlaceholder(
indicator.placement,
Expand All @@ -47,6 +48,7 @@ export const RenderEditorIndicator = () => {
? indicatorOptions.error
: indicatorOptions.success,
transition: indicatorOptions.transition || '0.2s ease-in',
...(indicatorOptions.style ?? {}),
},
parentDom: indicator.placement.parent.dom,
});
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/interfaces/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export type Options = {
error: string;
transition: string;
thickness: number;
className: string;
style: React.CSSProperties;
}>;
handlers: (store: EditorStore) => CoreEventHandlers;
normalizeNodes: (
Expand Down
8 changes: 7 additions & 1 deletion packages/utils/src/RenderIndicator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@ import ReactDOM from 'react-dom';

type RenderIndicatorProps = {
style: React.CSSProperties;
className?: string;
parentDom?: HTMLElement;
};

export const RenderIndicator = ({ style, parentDom }: RenderIndicatorProps) => {
export const RenderIndicator = ({
style,
className,
parentDom,
}: RenderIndicatorProps) => {
const indicator = (
<div
className={className}
style={{
position: 'fixed',
display: 'block',
Expand Down

0 comments on commit 2186c83

Please sign in to comment.