From ef55821d8dd7225b666d1e526081240ac1499960 Mon Sep 17 00:00:00 2001 From: Sergey Pavlyuk Date: Tue, 30 Jan 2024 21:42:25 +0300 Subject: [PATCH] feat: dashkit and action panel toggle animations properties --- src/components/ActionPanel/ActionPanel.tsx | 32 +++++---- src/components/DashKit/DashKit.tsx | 1 + .../DashKit/__stories__/CssApiShowcase.tsx | 2 +- .../DashKit/__stories__/DashKitShowcase.tsx | 21 +++++- src/components/GridItem/GridItem.js | 66 ++++++++++++------- src/hocs/withContext.js | 2 + 6 files changed, 86 insertions(+), 38 deletions(-) diff --git a/src/components/ActionPanel/ActionPanel.tsx b/src/components/ActionPanel/ActionPanel.tsx index c1dfdcd..3248951 100644 --- a/src/components/ActionPanel/ActionPanel.tsx +++ b/src/components/ActionPanel/ActionPanel.tsx @@ -17,13 +17,15 @@ export type ActionPanelItem = { export type ActionPanelProps = { items: ActionPanelItem[]; className?: string; - enable?: boolean; + disable?: boolean; + toggleAnimation?: boolean; }; const b = cn('dashkit-action-panel'); export const ActionPanel = (props: ActionPanelProps) => { - const isHidden = !props.enable; + const isDisabled = props.disable ?? false; + const isAnimated = props.toggleAnimation ?? false; const nodeRef = React.useRef(null); const content = ( @@ -47,15 +49,19 @@ export const ActionPanel = (props: ActionPanelProps) => { ); - return ( - - {content} - - ); + if (isAnimated) { + return ( + + {content} + + ); + } else { + return isDisabled ? null : content; + } }; diff --git a/src/components/DashKit/DashKit.tsx b/src/components/DashKit/DashKit.tsx index b34e0e8..59a96c7 100644 --- a/src/components/DashKit/DashKit.tsx +++ b/src/components/DashKit/DashKit.tsx @@ -22,6 +22,7 @@ interface DashKitGeneralProps { editMode: boolean; draggableHandleClassName?: string; overlayControls?: Record; + editModeAnimation?: boolean; } interface DashKitDefaultProps { diff --git a/src/components/DashKit/__stories__/CssApiShowcase.tsx b/src/components/DashKit/__stories__/CssApiShowcase.tsx index a276fcd..5c9f17f 100644 --- a/src/components/DashKit/__stories__/CssApiShowcase.tsx +++ b/src/components/DashKit/__stories__/CssApiShowcase.tsx @@ -104,7 +104,7 @@ export const CssApiShowcase: React.FC = () => { - + diff --git a/src/components/DashKit/__stories__/DashKitShowcase.tsx b/src/components/DashKit/__stories__/DashKitShowcase.tsx index e1ea3dc..5d44893 100644 --- a/src/components/DashKit/__stories__/DashKitShowcase.tsx +++ b/src/components/DashKit/__stories__/DashKitShowcase.tsx @@ -35,6 +35,7 @@ type DashKitDemoState = { customControlsActionData: number; showCustomMenu: boolean; enableActionPanel: boolean; + enableAnimations: boolean; }; export class DashKitShowcase extends React.Component<{}, DashKitDemoState> { @@ -53,6 +54,7 @@ export class DashKitShowcase extends React.Component<{}, DashKitDemoState> { customControlsActionData: 0, showCustomMenu: true, enableActionPanel: false, + enableAnimations: true, }; private dashKitRef = React.createRef(); @@ -107,6 +109,17 @@ export class DashKitShowcase extends React.Component<{}, DashKitDemoState> { {editMode ? 'Disable editMode' : 'Enable editMode'}
+