-
Notifications
You must be signed in to change notification settings - Fork 10.7k
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 Launch Your Store settings section #45402
Merged
Merged
Changes from all commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
708b7ef
Support div setting type
moon0326 c48d121
Add wc_settings_general_site_visibility_slotfill slotfill
moon0326 193de0a
Add site visibility setting section
moon0326 d668bc0
Add placeholder
moon0326 769b8ee
Rename div to slotfill_placeholder
moon0326 28d1821
Add comment
moon0326 307913f
Fix component name
moon0326 f277d6b
Add changefile(s) from automation for the following project(s): wooco…
invalid-email-address 44ac372
Use unique id
moon0326 48fdf30
Rename option names
moon0326 7fd5be7
Put LYS settings behind launch-your-store flag
moon0326 e4efc17
Move Site Visibility header to component
moon0326 bc20d56
Lint fixes
moon0326 0558ed6
Lint fixes
moon0326 01ff813
Use woocommerce-settings scope
moon0326 dfcfa51
lint fix
moon0326 438d631
Update test for slotfill_placeholder
moon0326 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
220 changes: 220 additions & 0 deletions
220
plugins/woocommerce-admin/client/launch-your-store/settings-slotfill.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,220 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import { | ||
createSlotFill, | ||
ToggleControl, | ||
RadioControl, | ||
} from '@wordpress/components'; | ||
import { useState, useEffect } from '@wordpress/element'; | ||
import { registerPlugin } from '@wordpress/plugins'; | ||
import { __ } from '@wordpress/i18n'; | ||
import { OPTIONS_STORE_NAME } from '@woocommerce/data'; | ||
import { withSelect } from '@wordpress/data'; | ||
import classNames from 'classnames'; | ||
import { compose } from '@wordpress/compose'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import { SETTINGS_SLOT_FILL_CONSTANT } from '../settings/settings-slots'; | ||
import './style.scss'; | ||
|
||
const { Fill } = createSlotFill( SETTINGS_SLOT_FILL_CONSTANT ); | ||
|
||
const SiteVisibility = ( { | ||
woocommerce_coming_soon, | ||
woocommerce_store_pages_only, | ||
woocommerce_private_link, | ||
isLoading, | ||
placeholder = false, | ||
} ) => { | ||
const [ comingSoon, setComingSoon ] = useState( woocommerce_coming_soon ); | ||
const [ storePagesOnly, setStorePagesOnly ] = useState( | ||
woocommerce_store_pages_only | ||
); | ||
const [ privateLink, setPrivateLink ] = useState( | ||
woocommerce_private_link | ||
); | ||
|
||
useEffect( () => { | ||
setComingSoon( woocommerce_coming_soon ); | ||
setStorePagesOnly( woocommerce_store_pages_only ); | ||
setPrivateLink( woocommerce_private_link ); | ||
}, [ | ||
woocommerce_coming_soon, | ||
woocommerce_store_pages_only, | ||
woocommerce_private_link, | ||
] ); | ||
|
||
if ( isLoading ) { | ||
return ( | ||
<SiteVisibility | ||
woocommerce_lys_setting_coming_soon={ 'yes' } | ||
isLoading={ false } | ||
placeholder={ true } | ||
/> | ||
); | ||
} | ||
|
||
return ( | ||
<div | ||
className={ classNames( 'site-visibility-settings-slotfill', { | ||
placeholder, | ||
} ) } | ||
> | ||
<input | ||
type="hidden" | ||
value={ comingSoon } | ||
name="woocommerce_coming_soon" | ||
/> | ||
<input | ||
type="hidden" | ||
value={ storePagesOnly } | ||
name="woocommerce_store_pages_only" | ||
/> | ||
<input | ||
type="hidden" | ||
value={ privateLink } | ||
name="woocommerce_private_link" | ||
/> | ||
<h2>{ __( 'Site Visibility', 'woocommerce' ) }</h2> | ||
<p className="site-visibility-settings-slotfill-description"> | ||
{ __( | ||
"Set your site to coming soon or live you're ready to launch", | ||
'woocommerce' | ||
) } | ||
</p> | ||
<div className="site-visibility-settings-slotfill-section"> | ||
<RadioControl | ||
onChange={ () => { | ||
setComingSoon( 'yes' ); | ||
} } | ||
options={ [ | ||
{ | ||
label: 'Coming soon', | ||
value: 'yes', | ||
}, | ||
] } | ||
selected={ comingSoon } | ||
/> | ||
<p className="site-visibility-settings-slotfill-section-description"> | ||
{ __( | ||
'Your site is hidden from visitors behind a “Coming soon” landing page until it’s ready for viewing. You can customize your “Coming soon” landing page via the Editor.', | ||
'woocommerce' | ||
) } | ||
</p> | ||
<div | ||
className={ classNames( | ||
'site-visibility-settings-slotfill-section-content', | ||
{ | ||
'is-hidden': comingSoon !== 'yes', | ||
} | ||
) } | ||
> | ||
<ToggleControl | ||
label={ | ||
<> | ||
{ __( | ||
'Restrict to store pages only', | ||
'woocommerce' | ||
) } | ||
<p> | ||
{ __( | ||
'Hide store pages only behind a “Coming soon” page. The rest of your site will remain public.', | ||
'woocommerce' | ||
) } | ||
</p> | ||
</> | ||
} | ||
checked={ storePagesOnly === 'yes' } | ||
onChange={ () => { | ||
setStorePagesOnly( | ||
storePagesOnly === 'yes' ? 'no' : 'yes' | ||
); | ||
} } | ||
/> | ||
<ToggleControl | ||
label={ | ||
<> | ||
{ __( | ||
'Share your site with a private link', | ||
'woocommerce' | ||
) } | ||
<p> | ||
{ __( | ||
'“Coming soon” sites are only visible to Admins and Shop managers. Enable “Share site” to let other users view your site.', | ||
'woocommerce' | ||
) } | ||
</p> | ||
</> | ||
} | ||
checked={ privateLink === 'yes' } | ||
onChange={ () => { | ||
setPrivateLink( | ||
privateLink === 'yes' ? 'no' : 'yes' | ||
); | ||
} } | ||
/> | ||
</div> | ||
</div> | ||
<div className="site-visibility-settings-slotfill-section"> | ||
<RadioControl | ||
onChange={ () => { | ||
setComingSoon( 'no' ); | ||
} } | ||
options={ [ | ||
{ | ||
label: 'Live', | ||
value: 'no', | ||
}, | ||
] } | ||
selected={ comingSoon } | ||
/> | ||
<p className="site-visibility-settings-slotfill-section-description"> | ||
{ __( 'Your site is visible to everyone.', 'woocommerce' ) } | ||
</p> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
const SiteVisibilityComponent = compose( | ||
withSelect( ( select ) => { | ||
const { getOption, hasFinishedResolution } = | ||
select( OPTIONS_STORE_NAME ); | ||
|
||
return { | ||
woocommerce_coming_soon: getOption( 'woocommerce_coming_soon' ), | ||
woocommerce_store_pages_only: getOption( | ||
'woocommerce_store_pages_only' | ||
), | ||
woocommerce_private_link: getOption( 'woocommerce_private_link' ), | ||
isLoading: | ||
! hasFinishedResolution( 'getOption', [ | ||
'woocommerce_coming_soon', | ||
] ) || | ||
! hasFinishedResolution( 'getOption', [ | ||
'woocommerce_store_pages_only', | ||
] ) || | ||
! hasFinishedResolution( 'getOption', [ | ||
'woocommerce_private_link', | ||
] ), | ||
}; | ||
} ) | ||
)( SiteVisibility ); | ||
|
||
const SiteVisibilitySlotFill = () => { | ||
return ( | ||
<Fill> | ||
<SiteVisibilityComponent /> | ||
</Fill> | ||
); | ||
}; | ||
|
||
export const registerSiteVisibilitySlotFill = () => { | ||
registerPlugin( 'woocommerce-admin-site-visibility-settings-slotfill', { | ||
scope: 'woocommerce-settings', | ||
render: SiteVisibilitySlotFill, | ||
} ); | ||
}; |
79 changes: 79 additions & 0 deletions
79
plugins/woocommerce-admin/client/launch-your-store/style.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
.site-visibility-settings-slotfill { | ||
line-height: 16px; | ||
font-weight: 400; | ||
color: #1e1e1e; | ||
margin: 32px 0 32px 0; | ||
|
||
&.placeholder { | ||
opacity: 0.3; | ||
} | ||
|
||
.components-form-toggle { | ||
.components-form-toggle__input:focus + .components-form-toggle__track { | ||
box-shadow: none; | ||
} | ||
.components-form-toggle__track { | ||
width: 32px; | ||
height: 20px; | ||
background-color: #949494; | ||
border: none; | ||
border-radius: 10px; | ||
} | ||
.components-form-toggle__thumb { | ||
background-color: #fff; | ||
border: 5px solid #fff; | ||
top: 4px; | ||
} | ||
&.is-checked .components-form-toggle__thumb { | ||
transform: translateX(14px); | ||
} | ||
&.is-checked .components-form-toggle__track { | ||
background-color: var(--wp-components-color-accent, var(--wp-admin-theme-color, #3858e9)); | ||
} | ||
} | ||
|
||
.site-visibility-settings-slotfill-section-description { | ||
margin: 4px 0 18px 28px; | ||
} | ||
|
||
p { | ||
color: #757575; | ||
} | ||
|
||
.site-visibility-settings-slotfill-description { | ||
font-size: inherit; | ||
font-weight: inherit; | ||
color: inherit; | ||
margin-bottom: 24px; | ||
} | ||
|
||
.components-radio-control__input[type='radio']:focus { | ||
outline: none; | ||
box-shadow: none; | ||
} | ||
|
||
.site-visibility-settings-slotfill-section { | ||
max-width: 620px; | ||
&:last-child { | ||
margin-top: 16px; | ||
} | ||
|
||
.site-visibility-settings-slotfill-section-content { | ||
&.is-hidden { | ||
display: none; | ||
} | ||
margin: 16px 0 0 30px; | ||
.components-toggle-control { | ||
.components-h-stack { | ||
align-items: baseline; | ||
} | ||
} | ||
|
||
.components-base-control__field { | ||
p { | ||
margin-top: 6px; | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 4 additions & 0 deletions
4
plugins/woocommerce/changelog/45402-add-45107-lys-settings-screen-page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Significance: minor | ||
Type: add | ||
|
||
Add Launch Your Store settings section |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Nice to see this getting used!
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.
Nice! useLaunchYourStore looks fantastic! I'll update this PR to use it 👍
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.
@psealock Could you also return comingSoon, storePagesOnly, privateLink, and shareKey from the function?