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
Gutenboarding: Domain Picker Modal #41212
Changes from all commits
bd09373
23913e6
e4d003e
0693f13
f0a2c62
cbd9cdc
0fa467f
f22e6f7
7aa5134
1ddf02d
4770de1
74e2812
e616558
3390dfd
f81559a
c2154e7
b2546f8
9d4c05c
e608b09
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import * as React from 'react'; | ||
import Modal from 'react-modal'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import DomainPicker, { Props as DomainPickerProps } from '../domain-picker'; | ||
|
||
/** | ||
* Style dependencies | ||
*/ | ||
import './style.scss'; | ||
|
||
interface Props extends DomainPickerProps { | ||
isOpen: boolean; | ||
onMoreOptions?: () => void; | ||
} | ||
|
||
const DomainPickerModal: React.FunctionComponent< Props > = ( { isOpen, ...props } ) => { | ||
// This is needed otherwise it throws a warning. | ||
Modal.setAppElement( '#wpcom' ); | ||
|
||
if ( ! isOpen ) return null; | ||
|
||
return ( | ||
<Modal | ||
isOpen | ||
className="domain-picker-modal" | ||
overlayClassName="domain-picker-modal-overlay" | ||
bodyOpenClassName="has-domain-picker-modal" | ||
> | ||
<DomainPicker showDomainConnectButton showDomainCategories { ...props } /> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default DomainPickerModal; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
@import 'assets/stylesheets/gutenberg-base-styles'; | ||
@import '../../mixins.scss'; | ||
|
||
.domain-picker-modal-overlay { | ||
// Absolute positioning allows the modal | ||
// to reuse the <body> element's scrollbar. | ||
position: absolute; | ||
|
||
// This positions the domain picker modal | ||
// right below the gutenboarding header, | ||
// keeping the header clickable. | ||
top: $gutenboarding-header-height; | ||
left: 0; | ||
|
||
// Using min-height lets the overlay cover | ||
// the entire viewport ensuring nothing behind | ||
// it can be seen. | ||
// | ||
// When the domain picker's content is taller | ||
// than the viewport height, it will expand taller | ||
// than the provided min-height, triggering | ||
// the appearance of the <body> element's scrollbar. | ||
min-height: calc( 100vh - $gutenboarding-header-height ); | ||
width: 100%; | ||
|
||
background: var( --studio-white ); | ||
} | ||
|
||
.domain-picker-modal { | ||
|
||
|
||
.domain-picker__panel-row-main { | ||
|
||
// Replace domain picker's padding with onboarding block margins | ||
padding: 0; | ||
|
||
// Increase specificity to override margin: 0 from .components-panel__row | ||
&.components-panel__row { | ||
@include onboarding-block-margin; | ||
} | ||
} | ||
|
||
.domain-picker__header { | ||
@include onboarding-heading-padding; | ||
margin-bottom: 27px; // Maintain the same 27px bottom margin as in the original domain picker | ||
|
||
@include break-mobile { | ||
margin-bottom: 27px; | ||
} | ||
} | ||
|
||
.domain-picker__header-title { | ||
@include onboarding-heading-text; | ||
} | ||
|
||
// Do not display domain picker footer which contains | ||
// the confirm button when showing inside a modal. | ||
.domain-picker__panel-row-footer { | ||
display: none; | ||
} | ||
} | ||
|
||
// Hide onboarding block when domain picker modal is open | ||
body.has-domain-picker-modal { | ||
.onboarding-block { | ||
display: none; | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
import * as React from 'react'; | ||
import { Button, Popover } from '@wordpress/components'; | ||
import { useI18n } from '@automattic/react-i18n'; | ||
import config from 'config'; | ||
|
||
// Core package needs to add this to the type definitions. | ||
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore | ||
// @ts-ignore | ||
import { useViewportMatch } from '@wordpress/compose'; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
import DomainPicker, { Props as DomainPickerProps } from '../domain-picker'; | ||
import CloseButton from '../close-button'; | ||
|
||
/** | ||
* Style dependencies | ||
*/ | ||
import './style.scss'; | ||
|
||
interface Props extends DomainPickerProps { | ||
isOpen: boolean; | ||
onMoreOptions?: () => void; | ||
} | ||
|
||
const DomainPickerPopover: React.FunctionComponent< Props > = ( { | ||
isOpen, | ||
onMoreOptions, | ||
...props | ||
} ) => { | ||
const { __ } = useI18n(); | ||
const onClose = props.onClose; | ||
|
||
// Popover expands at medium viewport width | ||
const isMobile = useViewportMatch( 'medium', '<' ); | ||
|
||
// Don't render popover when isOpen is false. | ||
// We need this component to be hot because useViewportMatch | ||
// returns false on initial mount before returning true, | ||
// causing search input to be automatically focused. | ||
if ( ! isOpen ) return null; | ||
|
||
return ( | ||
<div className="domain-picker-popover"> | ||
<Popover | ||
focusOnMount={ isMobile ? 'container' : 'firstElement' } | ||
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. I seem to get the input focused on mobile now. Is that a regression? 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. Fixed. 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. Oh, that's a shame. It looks like something that could be improved in 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. Created an issue WordPress/gutenberg#21676. |
||
noArrow | ||
onClose={ onClose } | ||
onFocusOutside={ onClose } | ||
position={ 'bottom center' } | ||
expandOnMobile={ true } | ||
> | ||
<DomainPicker { ...props } /> | ||
<div className="domain-picker-popover__addons"> | ||
{ config.isEnabled( 'gutenboarding/domain-picker-modal' ) && ( | ||
<Button | ||
className="domain-picker-popover__more-button" | ||
isTertiary | ||
onClick={ onMoreOptions } | ||
> | ||
{ __( 'More Options' ) } | ||
</Button> | ||
) } | ||
<CloseButton className="domain-picker-popover__close-button" onClick={ onClose } /> | ||
</div> | ||
</Popover> | ||
</div> | ||
); | ||
}; | ||
|
||
export default DomainPickerPopover; |
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.
It might be time to organize all these under a
domain-picker
directory: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.
Created an issue for this. #41221