Skip to content

Commit

Permalink
Site Profiler: Add a blur effect for locked metrics
Browse files Browse the repository at this point in the history
  • Loading branch information
WBerredo committed May 14, 2024
1 parent 5825a0e commit a7f1dc6
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 6 deletions.
53 changes: 48 additions & 5 deletions client/site-profiler/components/metrics-insights-list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import styled from '@emotion/styled';
import { useTranslate } from 'i18n-calypso';

type MetricsInsightsListProps = {
insights: Insight[];
insights?: Insight[];
locked?: boolean;
};

type Insight = {
header: string;
description: string;
description?: string;
};

const Container = styled.div`
Expand All @@ -18,9 +19,15 @@ const Container = styled.div`
letter-spacing: -0.1px;
`;

type InsightHeaderProps = {
locked: boolean;
children: React.ReactNode;
};
const InsightHeader = styled.div`
font-family: 'SF Pro Text';
font-size: 16px;
filter: ${ ( props: InsightHeaderProps ) => ( props.locked ? 'blur(2px)' : 'none' ) };
user-select: ${ ( props: InsightHeaderProps ) => ( props.locked ? 'none' : 'auto' ) };
`;

const InsightContent = styled.div`
Expand All @@ -29,21 +36,57 @@ const InsightContent = styled.div`

export const MetricsInsightsList = ( props: MetricsInsightsListProps ) => {
const translate = useTranslate();
const { insights } = props;
const { insights = [], locked = false } = props;
const lockedInsights = useLockedInsights();

const itemsToRender = locked ? lockedInsights : insights;
return (
<Container className="metrics-insights-list">
{ insights.map( ( insight ) => (
{ itemsToRender.map( ( insight ) => (
<FoldableCard
header={ <InsightHeader>{ insight.header }</InsightHeader> }
header={ <InsightHeader locked={ locked }>{ insight.header }</InsightHeader> }
screenReaderText={ translate( 'More' ) }
compact
clickableHeader
smooth
disabled={ locked }
icon={ locked ? 'lock' : 'chevron-down' }
>
<InsightContent>{ insight.description }</InsightContent>
</FoldableCard>
) ) }
</Container>
);
};

export function useLockedInsights(): Insight[] {
const translate = useTranslate();

return [
{
header: translate(
'The full report will display all the informations you need to improve your site domain, hosting, performance, health, and security'
),
},
{
header: translate(
'Click on the "Get full site report - It\'s free" button to unlock the all the information you need to make your site stand out on the web'
),
},
{
header: translate(
"You'll be asked to provide your name and email, and once you confirm your email, you should be able to view all of your site stats"
),
},
{
header: translate(
'The full report will display all the information about how your site is perfoming currently among with information about how to improve it'
),
},
{
header: translate(
'Feel free to use our tool how many times you want, its free, and once you have unlocked all functionalities you can see informations for any site'
),
},
];
}
4 changes: 3 additions & 1 deletion client/site-profiler/components/site-profiler.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,9 @@ export default function SiteProfiler( props: Props ) {
) }
subtitle={ translate( "Optimize your site's health" ) }
ref={ healthScoresRef }
/>
>
<MetricsInsightsList locked />
</MetricsSection>
</LayoutBlockSection>
) }
</LayoutBlock>
Expand Down

0 comments on commit a7f1dc6

Please sign in to comment.