-
Notifications
You must be signed in to change notification settings - Fork 860
Newsletters: modernize Page / footer / header styles #47399
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
base: trunk
Are you sure you want to change the base?
Changes from all commits
28df75a
cf89c54
3e07f5e
6328cef
8af1559
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| Significance: minor | ||
| Type: changed | ||
|
|
||
| Modernize newsletter settings UI with WordPress Admin UI components. |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -292,7 +292,15 @@ private function get_subscriber_management_url( $wp_admin_enabled, $is_wpcom_sim | |||||||||||||||||
| */ | ||||||||||||||||||
| public function render() { | ||||||||||||||||||
| ?> | ||||||||||||||||||
| <div id="newsletter-settings-root"></div> | ||||||||||||||||||
| <style> | ||||||||||||||||||
| /* Admin menu indicators */ | ||||||||||||||||||
| ul#adminmenu a.wp-has-current-submenu::after, | ||||||||||||||||||
| ul#adminmenu > li.current > a.current::after { | ||||||||||||||||||
| border-right-color: #fff; | ||||||||||||||||||
| } | ||||||||||||||||||
| body { background: #fff; } | ||||||||||||||||||
| </style> | ||||||||||||||||||
|
Comment on lines
+295
to
+302
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WP Boot package applies these (and more) styles in similar manner, so this is future-compatible. It basically applies white background so that loading state and notice-banners on top look better (otherwise they have grey background). It also changes menu indicator triangle to be white insteead of grey to match page background.
Comment on lines
+295
to
+302
|
||||||||||||||||||
| <style> | |
| /* Admin menu indicators */ | |
| ul#adminmenu a.wp-has-current-submenu::after, | |
| ul#adminmenu > li.current > a.current::after { | |
| border-right-color: #fff; | |
| } | |
| body { background: #fff; } | |
| </style> |
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,21 +3,21 @@ | |
| */ | ||
| import analytics from '@automattic/jetpack-analytics'; | ||
| import { | ||
| AdminPage, | ||
| Col, | ||
| Container, | ||
| JetpackLogo, | ||
| GlobalNotices, | ||
| useGlobalNotices, | ||
| JetpackFooter, | ||
| } from '@automattic/jetpack-components'; | ||
| import { getSiteType, isSimpleSite } from '@automattic/jetpack-script-data'; | ||
| import { Notice } from '@wordpress/components'; | ||
| import { Page } from '@wordpress/admin-ui'; | ||
| import { Disabled, Spinner, Notice } from '@wordpress/components'; | ||
| import { createRoot, useCallback, useEffect, useState, useMemo } from '@wordpress/element'; | ||
| import { __ } from '@wordpress/i18n'; | ||
| import { Stack } from '@wordpress/ui'; | ||
| /** | ||
| * Internal dependencies | ||
| */ | ||
| import { fetchSettings, updateSettings } from './api'; | ||
| import { Header } from './components/header'; | ||
| import { getNewsletterScriptData } from './script-data'; | ||
| import { | ||
| EmailContentSection, | ||
|
|
@@ -33,8 +33,6 @@ import { | |
| import type { NewsletterSettings } from './types'; | ||
| import './style.scss'; | ||
|
|
||
| const MODULE_NAME = __( 'Jetpack Newsletter', 'jetpack-newsletter' ); | ||
|
|
||
| /** | ||
| * Normalize settings from API response | ||
| * | ||
|
|
@@ -54,6 +52,37 @@ function normalizeSettings( settings: Record< string, unknown > ): NewsletterSet | |
| }; | ||
| } | ||
|
|
||
| /** | ||
| * Newsletter page container | ||
| * | ||
| * @param {React.ReactNode} children - The children to render inside the page | ||
| * @return {JSX.Element} The newsletter page container | ||
| */ | ||
| function NewsletterPage( { children }: { children: React.ReactNode } ): JSX.Element { | ||
| return ( | ||
| <div className="jetpack-page-container"> | ||
| <Page | ||
| title={ | ||
| <Stack gap="xs" align="center" justify="start" direction="row"> | ||
| <JetpackLogo showText={ false } width={ 20 } /> | ||
| { /** "Newsletter" is a product name, do not translate. */ } | ||
| <span>Newsletter</span> | ||
| </Stack> | ||
| } | ||
| subTitle={ __( | ||
| 'Transform your blog posts into newsletters to easily reach your subscribers.', | ||
| 'jetpack-newsletter' | ||
| ) } | ||
| > | ||
| <Stack gap="md" direction="column" className="newsletter-settings"> | ||
| { children } | ||
| </Stack> | ||
| <JetpackFooter /> | ||
| </Page> | ||
| </div> | ||
| ); | ||
| } | ||
|
|
||
| /** | ||
| * Newsletter Settings App | ||
| * | ||
|
|
@@ -333,50 +362,36 @@ function NewsletterSettingsApp(): JSX.Element | null { | |
|
|
||
| if ( isLoading ) { | ||
| return ( | ||
| <AdminPage moduleName={ MODULE_NAME } header={ <Header /> }> | ||
| <Container horizontalSpacing={ 3 }> | ||
| <Col> | ||
| <div className="newsletter-settings"> | ||
| <p>{ __( 'Loading newsletter settings…', 'jetpack-newsletter' ) }</p> | ||
| </div> | ||
| </Col> | ||
| </Container> | ||
| </AdminPage> | ||
| <NewsletterPage> | ||
| <Stack justify="center" align="center" style={ { minHeight: '100%' } }> | ||
| <Spinner /> | ||
| </Stack> | ||
| </NewsletterPage> | ||
| ); | ||
| } | ||
|
|
||
| if ( error ) { | ||
| if ( error || ! data ) { | ||
| return ( | ||
| <AdminPage moduleName={ MODULE_NAME } header={ <Header /> }> | ||
| <Container horizontalSpacing={ 3 }> | ||
| <Col> | ||
| <div className="newsletter-settings newsletter-settings--error"> | ||
| <Notice status="error" isDismissible={ false }> | ||
| { error } | ||
| </Notice> | ||
| </div> | ||
| </Col> | ||
| </Container> | ||
| </AdminPage> | ||
| <NewsletterPage> | ||
| <Notice status="error" isDismissible={ false }> | ||
| { error || __( 'Failed to load settings.', 'jetpack-newsletter' ) } | ||
| </Notice> | ||
| </NewsletterPage> | ||
| ); | ||
| } | ||
|
|
||
| if ( ! data ) { | ||
| return null; | ||
| } | ||
|
|
||
| const hasSubscriptionChanges = Object.keys( subscriptionChanges ).length > 0; | ||
| const hasSenderNameChanges = Object.keys( senderNameChanges ).length > 0; | ||
| const hasNewsletterCategoriesChanges = Object.keys( newsletterCategoriesChanges ).length > 0; | ||
| const hasWelcomeEmailChanges = Object.keys( welcomeEmailChanges ).length > 0; | ||
|
|
||
| return ( | ||
| <AdminPage moduleName={ MODULE_NAME } header={ <Header /> }> | ||
| <Container horizontalSpacing={ 3 }> | ||
| <Col> | ||
| <div className="newsletter-settings"> | ||
| { ! isSimpleSite() && <NewsletterSection data={ data } onChange={ handleAutoSave } /> } | ||
| <NewsletterPage> | ||
| <Stack gap="md" direction="column" className="newsletter-settings"> | ||
| { ! isSimpleSite() && <NewsletterSection data={ data } onChange={ handleAutoSave } /> } | ||
|
|
||
|
Comment on lines
+389
to
392
|
||
| <Disabled isDisabled={ ! data.subscriptions }> | ||
| <Stack gap="md" direction="column"> | ||
| <SubscriptionsSection | ||
| data={ data } | ||
| onChange={ handleSubscriptionChange } | ||
|
|
@@ -435,16 +450,15 @@ function NewsletterSettingsApp(): JSX.Element | null { | |
| hasChanges={ hasWelcomeEmailChanges } | ||
| isNewsletterEnabled={ data.subscriptions } | ||
| /> | ||
|
|
||
| <GlobalNotices /> | ||
| </div> | ||
| </Col> | ||
| </Container> | ||
| </AdminPage> | ||
| </Stack> | ||
| </Disabled> | ||
| </Stack> | ||
| <GlobalNotices /> | ||
| </NewsletterPage> | ||
| ); | ||
| } | ||
|
|
||
| const container = document.getElementById( 'newsletter-settings-root' ); | ||
| const container = document.getElementById( 'jetpack-newsletter-wp-admin-app' ); | ||
| if ( container ) { | ||
| const root = createRoot( container ); | ||
| root.render( <NewsletterSettingsApp /> ); | ||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,9 +1,45 @@ | ||||||
| // Import dataviews styles for DataForm component | ||||||
| @use "@automattic/jetpack-base-styles/gutenberg-base-styles" as gb; | ||||||
| @import "@wordpress/theme/design-tokens.css"; | ||||||
| @import "@wordpress/admin-ui/build-style/style.css"; | ||||||
| @import "@wordpress/dataviews/build-style/style.css"; | ||||||
|
Comment on lines
+1
to
4
|
||||||
|
|
||||||
| $content-max-width: 1040px; | ||||||
|
|
||||||
| .jetpack-page-container { | ||||||
| margin-left: -20px; | ||||||
|
||||||
| margin-left: -20px; | |
| margin-inline-start: -20px; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -121,6 +121,7 @@ export default { | |
| requestMap: { | ||
| // Bundle the package with our assets until WP core exposes wp-admin-ui. | ||
| '@wordpress/admin-ui': { external: false }, | ||
| '@wordpress/admin-ui/build-style/style.css': { external: false }, | ||
| }, | ||
|
Comment on lines
121
to
125
|
||
| }, | ||
| } ), | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The inline
<style>block includes global selectors (body,ul#adminmenu ...) which makes the page styling harder to maintain and can have unintended side effects if this markup is ever reused/embedded. Prefer moving these rules into the existing bundled stylesheet and scoping them to the newsletter admin page (e.g.,body.jetpack_page_jetpack-newsletter ...or#jetpack-newsletter-wp-admin-app ...).