diff --git a/Includes/Modules/CountdownTimer/assets/src/components/DesignTab.js b/Includes/Modules/CountdownTimer/assets/src/components/DesignTab.js index 934571a6..74bffcbf 100644 --- a/Includes/Modules/CountdownTimer/assets/src/components/DesignTab.js +++ b/Includes/Modules/CountdownTimer/assets/src/components/DesignTab.js @@ -21,28 +21,36 @@ function DesignTab( props ) { noop, options, handleSelect, + undoHandler, + showUndoIcon } = props; return ( @@ -53,20 +61,11 @@ function DesignTab( props ) { /> - - - {/**/} - {/*
*/} - {/* {options.map((option, index) => (*/} - {/* handleSelect(option.theme)}*/} - {/* isSelected={option.theme === formData.selected_theme}*/} - {/* />*/} - {/* ))}*/} - {/*
*/} - {/*
*/} +
); } diff --git a/Includes/Modules/CountdownTimer/assets/src/components/SalesCountdownLayout.js b/Includes/Modules/CountdownTimer/assets/src/components/SalesCountdownLayout.js index 7b9fe2b0..bffc7fb2 100644 --- a/Includes/Modules/CountdownTimer/assets/src/components/SalesCountdownLayout.js +++ b/Includes/Modules/CountdownTimer/assets/src/components/SalesCountdownLayout.js @@ -56,11 +56,6 @@ function SalesCountdownLayout({ navigate, useSearchParams ,moduleId}) { ...initialSalesCountdownData, }); - const [showUndo, setShowUndo] = useState( false ); - const [undoData, setUndoData] = useState({ - ...initialSalesCountdownData, - }); - const onFormReset = () => { setFormData({ ...initialSalesCountdownData }); setShowUndo( false ); @@ -138,14 +133,40 @@ function SalesCountdownLayout({ navigate, useSearchParams ,moduleId}) { onFieldChange("selected_theme", theme); }; + const [showUndo, setShowUndo] = useState({ + border_color : false, + heading_text_color : false, + widget_background_color : false + }); + + const [undoData, setUndoData] = useState({ + ...initialSalesCountdownData, + }); + + const colorKeyStack = [ + 'border_color', + 'heading_text_color', + 'widget_background_color' + ]; + const onFieldChange = (key, value) => { setFormData({ ...formData, [key]: value }); - setShowUndo( true ); + if ( colorKeyStack?.includes( key ) ) { + setShowUndo({ ...showUndo, [key]: true }); + } }; - const onUndoClick = () => { - setShowUndo( false ); - setFormData({ ...undoData }); + const onUndoClick = ( key ) => { + if ( colorKeyStack?.includes( key ) ) { + setShowUndo({ + ...showUndo, + [key]: false, + }); + setFormData({ + ...formData, + [key]: undoData?.[key], + }); + } }; const noop = () => {}; @@ -181,6 +202,8 @@ function SalesCountdownLayout({ navigate, useSearchParams ,moduleId}) { title: __("Design", "storegrowth-sales-booster"), panel: ( { +const Templates = ( { formData, setFormData, showUndoIcon } ) => { let templates = [ { key: 'ct-layout-1', component: }, { key: 'ct-layout-2', component: }, @@ -41,6 +41,10 @@ const Templates = ( { formData, setFormData } ) => { ); const onTemplateChange = ( name, value ) => { + for ( let key in showUndoIcon ) { + showUndoIcon[key] = false; + } + setFormData( { ...formData, ...templateStyles?.[ value ] diff --git a/Includes/Modules/ProgressiveDiscountBanner/assets/src/components/DesignTab.js b/Includes/Modules/ProgressiveDiscountBanner/assets/src/components/DesignTab.js index 974555c3..7de427a1 100644 --- a/Includes/Modules/ProgressiveDiscountBanner/assets/src/components/DesignTab.js +++ b/Includes/Modules/ProgressiveDiscountBanner/assets/src/components/DesignTab.js @@ -19,6 +19,8 @@ function DesignTab(props) { buttonLoading, fontFamily, onFormReset, + undoHandler, + showUndoIcon } = props; return ( @@ -51,31 +53,39 @@ function DesignTab(props) { ) } { Boolean( formData.btn_style ) && ( @@ -83,22 +93,30 @@ function DesignTab(props) { ) } - + { setFormData({ ...initialShipData }); setShowUndo( false ); @@ -130,6 +125,28 @@ function FreeShippingBarLayout({ outlet: Outlet, navigate, useSearchParams , mod return !!pattern.test( input ); }; + const [showUndo, setShowUndo] = useState({ + btn_color : false, + text_color : false, + icon_color : false, + btn_text_color : false, + close_icon_color : false, + background_color : false, + }); + + const [undoData, setUndoData] = useState({ + ...initialShipData, + }); + + const colorKeyStack = [ + 'btn_color', + 'text_color', + 'icon_color', + 'btn_text_color', + 'close_icon_color', + 'background_color' + ]; + const onFieldChange = (key, value) => { if ( key === 'btn_target' ) { setIsValidUrl( validateURL( value ) ); @@ -140,12 +157,22 @@ function FreeShippingBarLayout({ outlet: Outlet, navigate, useSearchParams , mod [key]: value, }); - setShowUndo( true ); + if ( colorKeyStack?.includes( key ) ) { + setShowUndo({ ...showUndo, [key]: true }); + } }; - const onUndoClick = () => { - setShowUndo( false ); - setFormData({ ...undoData }); + const onUndoClick = ( key ) => { + if ( colorKeyStack?.includes( key ) ) { + setShowUndo({ + ...showUndo, + [key]: false, + }); + setFormData({ + ...formData, + [key]: undoData?.[key], + }); + } }; const changeTab = (key) => { @@ -213,6 +240,8 @@ function FreeShippingBarLayout({ outlet: Outlet, navigate, useSearchParams , mod title: __("Design", "storegrowth-sales-booster"), panel: ( { +const Templates = ( { formData, setFormData, showUndoIcon } ) => { let templates = [ { key: 'shipping_bar_one', component: }, ]; @@ -46,6 +46,10 @@ const Templates = ( { formData, setFormData } ) => { ); const onTemplateChange = ( name, value ) => { + for ( let key in showUndoIcon ) { + showUndoIcon[key] = false; + } + setFormData( { ...formData, ...templateStyles?.[ value ] diff --git a/assets/src/admin.scss b/assets/src/admin.scss index b38ea749..9b1ec54d 100644 --- a/assets/src/admin.scss +++ b/assets/src/admin.scss @@ -2033,14 +2033,12 @@ End Settings Sidebar .settings-panel { margin-right: 32px; - .ant-tabs-extra-content { - .dashicons { + .dashicons { + color: #0875ff; + cursor: pointer; + &.dashicons-undo { color: #0875ff; cursor: pointer; - &.dashicons-undo { - color: #0875ff; - cursor: pointer; - } } } diff --git a/assets/src/components/settings/Panels/PanelSettings/Fields/ColorPicker.js b/assets/src/components/settings/Panels/PanelSettings/Fields/ColorPicker.js index 2fc1b48c..92fa9334 100644 --- a/assets/src/components/settings/Panels/PanelSettings/Fields/ColorPicker.js +++ b/assets/src/components/settings/Panels/PanelSettings/Fields/ColorPicker.js @@ -10,10 +10,12 @@ const ColourPicker = ( { name, title, tooltip, + undoHandler, changeHandler, colSpan = 24, fieldValue = '#82B9FF', - needUpgrade = false + needUpgrade = false, + showUndoIcon = false, } ) => { const colors = [ '#000000', @@ -64,16 +66,26 @@ const ColourPicker = ( { - {/* Handle settings color-picker field by using dynamic props */} - changeHandler( name, hex ) } - /> +
+ { showUndoIcon && undoHandler( name ) } className="dashicons dashicons-undo"> } + {/* Handle settings color-picker field by using dynamic props */} + changeHandler(name, hex)} + /> +
- { needUpgrade && } + {needUpgrade && } ); } diff --git a/assets/src/components/settings/Panels/PanelSettings/TabPanels.js b/assets/src/components/settings/Panels/PanelSettings/TabPanels.js index 8674dc25..13e12a99 100644 --- a/assets/src/components/settings/Panels/PanelSettings/TabPanels.js +++ b/assets/src/components/settings/Panels/PanelSettings/TabPanels.js @@ -2,16 +2,13 @@ import { Tabs } from "antd"; const { TabPane } = Tabs; -const TabPanels = ( { tabPanels, activeTab, changeHandler, classes, undoHandler, showUndoIcon = false } ) => { +const TabPanels = ( { tabPanels, activeTab, changeHandler, classes } ) => { return ( // Handle settings tab & panels preview by using props. ) - } } > { tabPanels && tabPanels?.map( tab => ( diff --git a/assets/src/components/settings/Panels/PanelSettings/index.js b/assets/src/components/settings/Panels/PanelSettings/index.js index 1db69094..cfe819f4 100644 --- a/assets/src/components/settings/Panels/PanelSettings/index.js +++ b/assets/src/components/settings/Panels/PanelSettings/index.js @@ -4,10 +4,8 @@ import TabPanels from "./TabPanels"; const PanelSettings = ( { tabPanels, activeTab, - undoHandler, changeHandler, colSpan = 12, - showUndoIcon = false } ) => { return ( // Handle settings column width dynamically by using colSpan. @@ -16,8 +14,6 @@ const PanelSettings = ( {