-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Performance Profiler: weekly report subscribe page (#94065)
* update controller * add message display component * add redirect to log-in page * update redirect * add loading and error states * update button link * update cta focus state * update mutation name
- Loading branch information
Showing
10 changed files
with
364 additions
and
4 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
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,20 @@ | ||
import { useMutation } from '@tanstack/react-query'; | ||
import { LeadMutationResponse } from 'calypso/data/site-profiler/types'; | ||
import wp from 'calypso/lib/wp'; | ||
|
||
export const useLeadMutation = ( url?: string, hash?: string ) => { | ||
return useMutation( { | ||
mutationKey: [ 'lead', url, hash ], | ||
mutationFn: (): Promise< LeadMutationResponse > => | ||
wp.req.post( | ||
{ | ||
path: '/site-profiler/lead', | ||
apiNamespace: 'wpcom/v2', | ||
}, | ||
{ | ||
url, | ||
hash, | ||
} | ||
), | ||
} ); | ||
}; |
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
55 changes: 55 additions & 0 deletions
55
client/performance-profiler/components/message-display/index.tsx
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,55 @@ | ||
import { Gridicon } from '@automattic/components'; | ||
import { Button, IconType } from '@wordpress/components'; | ||
import clsx from 'clsx'; | ||
import { ReactNode } from 'react'; | ||
import { Badge } from 'calypso/performance-profiler/components/badge'; | ||
|
||
import './style.scss'; | ||
|
||
type Props = { | ||
title?: string; | ||
message: string | ReactNode; | ||
ctaText?: string; | ||
ctaHref?: string; | ||
secondaryMessage?: string; | ||
displayBadge?: boolean; | ||
ctaIcon?: string; | ||
isErrorMessage?: boolean; | ||
}; | ||
|
||
export const MessageDisplay = ( { | ||
displayBadge = false, | ||
title, | ||
message, | ||
ctaText, | ||
ctaHref, | ||
secondaryMessage, | ||
ctaIcon = '', | ||
isErrorMessage = false, | ||
}: Props ) => { | ||
return ( | ||
<div className="message-display"> | ||
<div className="l-block-wrapper"> | ||
<div className="message-wrapper"> | ||
{ displayBadge && <Badge /> } | ||
<div className={ clsx( 'main-message', { error: isErrorMessage } ) }> | ||
{ isErrorMessage && <Gridicon icon="notice-outline" /> } | ||
{ title && <h1 className="title">{ title }</h1> } | ||
<p className="message">{ message }</p> | ||
{ ctaText && ctaHref && ( | ||
<Button | ||
variant="primary" | ||
icon={ ctaIcon as IconType } | ||
className="cta-button" | ||
href={ ctaHref } | ||
> | ||
{ ctaText } | ||
</Button> | ||
) } | ||
</div> | ||
{ secondaryMessage && <p className="secondary-message">{ secondaryMessage }</p> } | ||
</div> | ||
</div> | ||
</div> | ||
); | ||
}; |
105 changes: 105 additions & 0 deletions
105
client/performance-profiler/components/message-display/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,105 @@ | ||
@import "@wordpress/base-styles/breakpoints"; | ||
@import "@automattic/typography/styles/variables"; | ||
|
||
$blueberry-color: #3858e9; | ||
|
||
.message-display { | ||
color: #fff; | ||
padding-top: 40px; | ||
background: linear-gradient(180deg, var(--studio-gray-100) 25.44%, rgba(16, 21, 23, 0) 100%), url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTYiIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNiAxNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGNpcmNsZSBjeD0iOCIgY3k9IjgiIHI9IjEiIGZpbGw9IndoaXRlIiBmaWxsLW9wYWNpdHk9IjAuMjUiLz4KPC9zdmc+Cg==) repeat, var(--studio-gray-100); | ||
|
||
a { | ||
color: $blueberry-color; | ||
|
||
&:hover { | ||
color: darken($blueberry-color, 10%); | ||
text-decoration: underline; | ||
} | ||
|
||
&.is-primary { | ||
color: #fff; | ||
background-color: $blueberry-color; | ||
border-radius: 4px; | ||
|
||
&:hover:not(:disabled), | ||
&:active:not(:disabled), | ||
&:focus:not(:disabled) { | ||
background-color: darken($blueberry-color, 10%); | ||
border-color: darken($blueberry-color, 10%); | ||
box-shadow: none; | ||
} | ||
} | ||
} | ||
|
||
p { | ||
margin: 0; | ||
} | ||
|
||
.l-block-wrapper { | ||
height: 100%; | ||
max-width: 1056px; | ||
} | ||
|
||
.message-wrapper { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: flex-start; | ||
justify-content: center; | ||
gap: 64px; | ||
min-height: 700px; | ||
width: 50%; | ||
|
||
.main-message { | ||
display: flex; | ||
flex-direction: column; | ||
align-items: flex-start; | ||
justify-content: center; | ||
gap: 16px; | ||
|
||
&.error { | ||
border-radius: 4px; | ||
border: 1px solid var(--studio-red-70); | ||
background-color: var(--studio-red-70); | ||
padding: 16px; | ||
padding-left: 52px; | ||
position: relative; | ||
|
||
.gridicon { | ||
position: absolute; | ||
top: 16px; | ||
left: 16px; | ||
} | ||
|
||
.cta-button { | ||
margin: 0; | ||
} | ||
} | ||
|
||
.title { | ||
font-family: $brand-serif; | ||
font-size: $font-headline-medium; | ||
line-height: $font-headline-large; | ||
color: #fff; | ||
} | ||
|
||
.message { | ||
font-size: $font-body; | ||
font-weight: 500; | ||
line-height: $font-title-medium; | ||
} | ||
|
||
.cta-button { | ||
margin-top: 16px; | ||
font-size: $font-body-small; | ||
line-height: $font-title-small; | ||
padding: 20px; | ||
} | ||
} | ||
|
||
.secondary-message { | ||
font-size: $font-body-small; | ||
line-height: $font-title-small; | ||
color: var(--studio-gray-20); | ||
} | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,9 @@ | ||
import page from '@automattic/calypso-router'; | ||
import { makeLayout, render as clientRender } from 'calypso/controller/index.web'; | ||
import { PerformanceProfilerDashboardContext, notFound } from './controller'; | ||
import { PerformanceProfilerDashboardContext, WeeklyReportContext, notFound } from './controller'; | ||
|
||
export default function () { | ||
page( '/speed-test-tool/', PerformanceProfilerDashboardContext, makeLayout, clientRender ); | ||
page( '/speed-test-tool/weekly-report', WeeklyReportContext, makeLayout, clientRender ); | ||
page( '/speed-test-tool*', notFound, makeLayout, clientRender ); | ||
} |
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.