Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add BF deal #4121

Merged
merged 12 commits into from
Oct 23, 2023
13 changes: 13 additions & 0 deletions assets/apps/customizer-controls/src/@types/utils.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,19 @@ declare global {
nonce: string;
hideConditionalHeaderSelector: boolean;
dashUpdatesMessage: string;
deal?: {
active?: boolean;
dealSlug?: string;
urgencyText?: string;
remaningTime?: string;
bannerUrl?: string;
customizerBannerUrl?: string;
linkDashboard?: string;
linkGlobal?: string;
linkCustomizer?: string;
customizerBannerAlt?: string;
bannerAlt?: string;
};
};
NeveProReactCustomize: undefined | StringObjectKeys;
}
Expand Down
25 changes: 25 additions & 0 deletions assets/apps/customizer-controls/src/builder-upsell/Upsells.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,31 @@ const Upsells: React.FC<Props> = ({ control }) => {
const { params } = control;
const { title, url } = params;

if (window?.NeveReactCustomize?.deal?.active) {
return (
<div className="upsell-inner">
<a
href={window?.NeveReactCustomize?.deal?.linkCustomizer}
target="_blank"
rel="external noreferrer noopener"
style={{ width: '100%', lineHeight: '0' }}
>
<img
src={
window?.NeveReactCustomize?.deal
?.customizerBannerUrl
}
alt={
window?.NeveReactCustomize?.deal
?.customizerBannerAlt
}
style={{ width: '100%' }}
/>
</a>
</div>
);
}

return (
<div className="upsell-inner">
{title && (
Expand Down
2 changes: 2 additions & 0 deletions assets/apps/dashboard/src/Components/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { fetchOptions } from '../utils/rest';
import { withDispatch, withSelect } from '@wordpress/data';
import { compose } from '@wordpress/compose';
import { useState, Fragment, useEffect } from '@wordpress/element';
import Deal from './Deal';

const App = ({ setSettings, toast, currentTab, setTab }) => {
const [loading, setLoading] = useState(true);
Expand All @@ -27,6 +28,7 @@ const App = ({ setSettings, toast, currentTab, setTab }) => {
<div className="content-wrap">
<div className="container content">
<div className="main">
{'start' === currentTab && <Deal />}
{'starter-sites' !== currentTab && <Notifications />}
<TabsContent currentTab={currentTab} setTab={setTab} />
</div>
Expand Down
21 changes: 21 additions & 0 deletions assets/apps/dashboard/src/Components/Deal.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
/* global neveDash */

const Deal = () => {
if (!Boolean(window.neveDash?.deal?.active)) {
return <></>;
}

return (
<div className="nv-deal">
<a href={neveDash?.deal?.linkDashboard}>
Soare-Robert-Daniel marked this conversation as resolved.
Show resolved Hide resolved
<img
src={neveDash?.deal?.bannerUrl}
alt={neveDash?.deal?.bannerAlt}
/>
<div className="nv-urgency">{neveDash?.deal?.urgencyText}</div>
</a>
</div>
);
};

export default Deal;
25 changes: 25 additions & 0 deletions assets/apps/dashboard/src/scss/content/_start.scss
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,28 @@
}
}
}

@import url('https://fonts.cdnfonts.com/css/barlow');
Soare-Robert-Daniel marked this conversation as resolved.
Show resolved Hide resolved
.nv-deal {
margin-bottom: 10px;
display: flex;

a {
position: relative;
}

.nv-urgency {
position: absolute;
top: 15px;
left: 19px;

color: #FFF;
font-family: Barlow, -apple-system, system-ui, BlinkMacSystemFont, "Segoe UI", sans-serif;
font-size: 14px;
font-style: normal;
font-weight: 700;
line-height: normal;
letter-spacing: 0.3px;
text-transform: uppercase;
}
}
Binary file added assets/img/dashboard/black-friday-banner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions inc/admin/dashboard/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

namespace Neve\Admin\Dashboard;

use Neve\Core\Limited_Offers;
use Neve\Core\Theme_Info;
/**
* Class Main
Expand Down Expand Up @@ -315,6 +316,9 @@ public function enqueue() {
* @return array
*/
private function get_localization() {

$offer = new Limited_Offers();

$old_about_config = apply_filters( 'ti_about_config_filter', [ 'useful_plugins' => true ] );
$theme_name = apply_filters( 'ti_wl_theme_name', $this->theme_args['name'] );
$plugin_name = apply_filters( 'ti_wl_plugin_name', 'Neve Pro' );
Expand Down Expand Up @@ -376,6 +380,7 @@ private function get_localization() {
'getPluginStateBaseURL' => esc_url( rest_url( '/nv/v1/dashboard/plugin-state/' ) ),
'canInstallPlugins' => current_user_can( 'install_plugins' ),
'canActivatePlugins' => current_user_can( 'activate_plugins' ),
'deal' => $offer->get_localized_data(),
];

if ( defined( 'NEVE_PRO_PATH' ) ) {
Expand Down
5 changes: 5 additions & 0 deletions inc/core/admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ function () {

add_action( 'rest_api_init', [ $this, 'register_rest_routes' ] );
add_filter( 'neve_pro_react_controls_localization', [ $this, 'adapt_conditional_headers' ] );

$offer = new Limited_Offers();
if ( $offer->can_show_dashboard_banner() && $offer->is_active() ) {
$offer->load_dashboard_hooks();
}
}

/**
Expand Down
Loading