-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Studio: Move the create new WPcom site inside the modal (#740)
* Move the create new WPcom site inside the modal --------- Co-authored-by: Kateryna Kodonenko <kateryna@automattic.com>
- Loading branch information
1 parent
8eca8f3
commit cf5a393
Showing
4 changed files
with
85 additions
and
78 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,84 @@ | ||
import { __ } from '@wordpress/i18n'; | ||
import { useOffline } from '../hooks/use-offline'; | ||
import { cx } from '../lib/cx'; | ||
import { getIpcApi } from '../lib/get-ipc-api'; | ||
import { ArrowIcon } from './arrow-icon'; | ||
import Button, { ButtonVariant } from './button'; | ||
import offlineIcon from './offline-icon'; | ||
import { Tooltip } from './tooltip'; | ||
|
||
interface ConnectCreateButtonsProps { | ||
connectSite: () => void; | ||
isOffline: boolean; | ||
connectButtonVariant: ButtonVariant; | ||
createButtonVariant: ButtonVariant; | ||
interface ConnectButtonProps { | ||
variant: ButtonVariant; | ||
connectSite?: () => void; | ||
disableConnectButtonStyle?: boolean; | ||
className?: string; | ||
} | ||
|
||
interface CreateButtonProps { | ||
variant: ButtonVariant; | ||
selectedSite: SiteDetails; | ||
text?: string; | ||
className?: string; | ||
} | ||
|
||
export const ConnectCreateButtons = ( { | ||
export const ConnectButton = ( { | ||
variant, | ||
connectSite, | ||
isOffline, | ||
createButtonVariant, | ||
connectButtonVariant, | ||
disableConnectButtonStyle, | ||
selectedSite, | ||
}: ConnectCreateButtonsProps ) => { | ||
className, | ||
}: ConnectButtonProps ) => { | ||
const isOffline = useOffline(); | ||
return ( | ||
<> | ||
<Tooltip | ||
disabled={ ! isOffline } | ||
text={ __( 'Connecting a site requires an internet connection.' ) } | ||
icon={ offlineIcon } | ||
placement="top-start" | ||
<Tooltip | ||
disabled={ ! isOffline } | ||
text={ __( 'Connecting a site requires an internet connection.' ) } | ||
icon={ offlineIcon } | ||
placement="top-start" | ||
> | ||
<Button | ||
onClick={ connectSite } | ||
disabled={ isOffline } | ||
aria-disabled={ isOffline } | ||
variant={ variant } | ||
className={ cx( | ||
! disableConnectButtonStyle && ! isOffline && '!text-a8c-blueberry !shadow-a8c-blueberry', | ||
className | ||
) } | ||
> | ||
<Button | ||
onClick={ connectSite } | ||
disabled={ isOffline } | ||
aria-disabled={ isOffline } | ||
variant={ connectButtonVariant } | ||
className={ cx( | ||
! disableConnectButtonStyle && | ||
! isOffline && | ||
'!text-a8c-blueberry !shadow-a8c-blueberry' | ||
) } | ||
> | ||
{ __( 'Connect site' ) } | ||
</Button> | ||
</Tooltip> | ||
<Tooltip | ||
disabled={ ! isOffline } | ||
text={ __( 'Creating a site requires an internet connection.' ) } | ||
icon={ offlineIcon } | ||
placement="top-start" | ||
{ __( 'Connect site' ) } | ||
</Button> | ||
</Tooltip> | ||
); | ||
}; | ||
|
||
export const CreateButton = ( { | ||
variant, | ||
selectedSite, | ||
text = __( 'Create new site' ), | ||
className, | ||
}: CreateButtonProps ) => { | ||
const isOffline = useOffline(); | ||
return ( | ||
<Tooltip | ||
disabled={ ! isOffline } | ||
text={ __( 'Creating a site requires an internet connection.' ) } | ||
icon={ offlineIcon } | ||
placement="top-start" | ||
> | ||
<Button | ||
onClick={ () => { | ||
getIpcApi().openURL( | ||
`https://wordpress.com/setup/new-hosted-site?ref=studio§ion=studio-sync&studioSiteId=${ selectedSite.id }` | ||
); | ||
} } | ||
variant={ variant } | ||
className={ cx( ! isOffline && '!text-a8c-blueberry !shadow-a8c-blueberry', className ) } | ||
disabled={ isOffline } | ||
aria-disabled={ isOffline } | ||
> | ||
<Button | ||
onClick={ () => { | ||
getIpcApi().openURL( | ||
`https://wordpress.com/setup/new-hosted-site?ref=studio§ion=studio-sync&studioSiteId=${ selectedSite.id }` | ||
); | ||
} } | ||
variant={ createButtonVariant } | ||
className={ cx( ! isOffline && '!text-a8c-blueberry !shadow-a8c-blueberry' ) } | ||
disabled={ isOffline } | ||
aria-disabled={ isOffline } | ||
> | ||
{ __( 'Create new site' ) } | ||
<ArrowIcon /> | ||
</Button> | ||
</Tooltip> | ||
</> | ||
{ text } | ||
<ArrowIcon /> | ||
</Button> | ||
</Tooltip> | ||
); | ||
}; |
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
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