diff --git a/assets/css/src/admin.styl b/assets/css/src/admin.styl index 58409892a2..85a1c33b3d 100644 --- a/assets/css/src/admin.styl +++ b/assets/css/src/admin.styl @@ -34,6 +34,7 @@ @require 'newsletter_templates' @require 'welcome_wizard' @require 'intro' +@require 'feature_announcement' @require 'in_app_announcements' @require 'newsletter_congratulate.styl' @require 'discounts' diff --git a/assets/css/src/feature_announcement.styl b/assets/css/src/feature_announcement.styl new file mode 100644 index 0000000000..57dd185b03 --- /dev/null +++ b/assets/css/src/feature_announcement.styl @@ -0,0 +1,22 @@ +.mailpoet_feature_announcement + float: right + +.mailpoet_feature_announcement_button + padding: 0 !important + position: relative + +.mailpoet_feature_announcement_icon + font-size: 1.5em + line-height: 1.5em + margin: 0 0.2em + +.mailpoet_feature_announcement_dot::before + content: "" + display: block + position: absolute + top: -4px + right: -4px + height: 10px + width: 10px + background: #d54e21 + border-radius: 10px diff --git a/assets/js/src/announcements/feature_announcement.jsx b/assets/js/src/announcements/feature_announcement.jsx new file mode 100644 index 0000000000..a612775573 --- /dev/null +++ b/assets/js/src/announcements/feature_announcement.jsx @@ -0,0 +1,45 @@ +import React from 'react'; +import classNames from 'classnames'; +import MailPoet from 'mailpoet'; +import PropTypes from 'prop-types'; + +let beamerLoaded = false; + +const loadBeamer = (e) => { + let s; + e.preventDefault(); + if (!beamerLoaded) { + MailPoet.Modal.loading(true); + beamerLoaded = true; + window.mailpoet_feature_announcement_has_news = false; + s = document.createElement('script'); + s.type = 'text/javascript'; + s.src = 'https://app.getbeamer.com/js/beamer-embed.js'; + document.getElementsByTagName('body')[0].appendChild(s); + } +}; + +const FeatureAnnouncement = (props) => { + const buttonClasses = classNames( + 'button mailpoet_feature_announcement_button', + props.hasNews ? 'mailpoet_feature_announcement_dot' : '' + ); + + return ( +
+ + + +
+ ); +}; + +FeatureAnnouncement.propTypes = { + hasNews: PropTypes.bool, +}; + +FeatureAnnouncement.defaultProps = { + hasNews: false, +}; + +export default FeatureAnnouncement; diff --git a/assets/js/src/newsletters/listings/notification.jsx b/assets/js/src/newsletters/listings/notification.jsx index e5317d4559..8c731624a5 100644 --- a/assets/js/src/newsletters/listings/notification.jsx +++ b/assets/js/src/newsletters/listings/notification.jsx @@ -6,6 +6,7 @@ import PropTypes from 'prop-types'; import Listing from 'listing/listing.jsx'; import ListingTabs from 'newsletters/listings/tabs.jsx'; import ListingHeading from 'newsletters/listings/heading.jsx'; +import FeatureAnnouncement from 'announcements/feature_announcement.jsx'; import { MailerMixin, @@ -335,6 +336,8 @@ const NewsletterListNotification = createReactClass({ // eslint-disable-line rea
+ + + + + + + + 'woocommerce', diff --git a/lib/Twig/I18n.php b/lib/Twig/I18n.php index 7768be9ccb..51e8dce229 100644 --- a/lib/Twig/I18n.php +++ b/lib/Twig/I18n.php @@ -2,6 +2,8 @@ namespace MailPoet\Twig; +use MailPoet\Config\Localizer; + if(!defined('ABSPATH')) exit; class I18n extends \Twig_Extension { @@ -22,6 +24,7 @@ class I18n extends \Twig_Extension { '__' => 'translate', '_n' => 'pluralize', '_x' => 'translateWithContext', + 'get_locale' => 'getLocale', 'date' => 'date' ); @@ -67,6 +70,11 @@ class I18n extends \Twig_Extension { return call_user_func_array('_x', $this->setTextDomain($args)); } + function getLocale() { + $localizer = new Localizer; + return $localizer->locale(); + } + function date() { $args = func_get_args(); $date = (isset($args[0])) ? $args[0] : null; diff --git a/views/newsletters.html b/views/newsletters.html index 6f90a065b5..c03e9f3241 100644 --- a/views/newsletters.html +++ b/views/newsletters.html @@ -23,6 +23,7 @@ var mailpoet_premium_active = <%= json_encode(premium_plugin_active) %>; var mailpoet_woocommerce_active = <%= json_encode(is_woocommerce_active) %>; var mailpoet_automatic_emails = <%= json_encode(automatic_emails) %>; + var mailpoet_feature_announcement_has_news = <%= json_encode(feature_announcement_has_news) %>; var mailpoet_in_app_announcements = mailpoet_settings.in_app_announcements; var mailpoet_free_welcome_emails_image = '<%= cdn_url('in-app-announcements/hello-illustration-for-welcome-emails.20181121-1440.png') %>'; var mailpoet_congratulations_success_image = '<%= cdn_url('newsletter/congrat-illu-success.20181121-1440.png') %>'; @@ -314,6 +315,8 @@ 'freeWelcomeEmailsHeading': __('Welcome Emails are now free for everyone'), 'freeWelcomeEmailsParagraph': __('Say “Hello!” automatically to all your new subscribers. They’ll appreciate the extra touch.'), + 'whatsNew': __("What's new"), + 'congratulationsSendSuccessHeader': __('Congratulations, your newsletter is being sent!'), 'congratulationsScheduleSuccessHeader': __('Congratulations, your newsletter is scheduled to be sent.'), 'congratulationsWooSuccessHeader': __('Congratulations, your WooCommerce email has been activated.'), @@ -337,4 +340,25 @@ }); <% endif %> + + + <% endblock %> diff --git a/webpack.config.js b/webpack.config.js index 4da1827a53..b19480655c 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -135,6 +135,13 @@ var baseConfig = { 'babel-loader', ] }, + { + include: path.resolve(__dirname, 'assets/js/src/announcements/feature_announcement.jsx'), + use: [ + 'expose-loader?' + globalPrefix + '.FeatureAnnouncement', + 'babel-loader', + ] + }, { include: path.resolve(__dirname, 'assets/js/src/form/fields/selection.jsx'), use: [ @@ -235,6 +242,7 @@ var adminConfig = { 'newsletters/listings/tabs.jsx', 'newsletters/listings/mixins.jsx', 'newsletters/listings/heading.jsx', + 'announcements/feature_announcement.jsx', 'newsletters/types/automatic_emails/events_list.jsx', 'newsletters/types/automatic_emails/breadcrumb.jsx', 'newsletters/types/welcome/scheduling.jsx',