Skip to content
51 changes: 34 additions & 17 deletions src/modules/add-site/components/blueprint-deeplink.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import {
__experimentalVStack as VStack,
__experimentalHStack as HStack,
__experimentalHeading as Heading,
__experimentalText as Text,
Icon,
} from '@wordpress/components';
import { check } from '@wordpress/icons';
import { check, link } from '@wordpress/icons';
import { useI18n } from '@wordpress/react-i18n';
import { BlueprintValidationWarning } from 'common/lib/blueprint-validation';
import { Blueprint } from 'src/stores/wpcom-api';
Expand All @@ -29,27 +30,43 @@ export default function BlueprintDeeplink( {
<Heading className="text-center text-[32px] text-gray-900 mb-5" weight={ 500 }>
{ __( 'Start from a Blueprint' ) }
</Heading>

<BlueprintWarningNotice
warnings={ warnings }
fileName={ blueprintTitle }
className="w-full max-w-4xl mx-auto mb-6"
className="w-full max-w-4xl mx-auto"
/>

<div className="w-full max-w-[400px] h-[250px] mx-auto p-12 border-2 rounded-xl border-gray-300 bg-gray-50">
<VStack className="items-center justify-center h-full" spacing={ 2 }>
<Icon icon={ check } size={ 24 } className="text-green-600" />
<Text className="text-xl font-medium text-gray-900">{ __( 'Blueprint selected' ) }</Text>
<Text className="text-base font-medium text-gray-900 max-w-md px-4" weight={ 400 }>
{ blueprintTitle }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm unsure if this came up before, but should we filter/sanitize that data?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would say that in this case a clamp on the length should be enough. I have added it in 2b244d3.

The Blueprint JSON also gets validated before we get title and description out of it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, React escapes any tags included in those, but we could consider some sanitization, too.

</Text>
{ blueprintDescription && (
<Text className="text-sm text-gray-600 max-w-md px-4 line-clamp-2">
{ blueprintDescription }
</Text>
) }
<VStack className="max-w-[400px] min-w-[350px] mx-auto mt-16 justify-start" spacing={ 0 }>
<VStack className="w-full max-h-[172px] p-6 border rounded-t-lg border-gray-200 justify-start">
<HStack className="h-full justify-start" alignment="top" spacing={ 4 }>
<Icon className="fill-a8c-blue-50 shrink-0" icon={ check } size={ 29 } />
<VStack alignment="left" spacing={ 1 }>
<Text className="text-lg font-medium text-gray-900 text-left line-clamp-2">
{ blueprintTitle }
</Text>
<VStack alignment="left" spacing={ 4 }>
{ blueprintDescription && (
<Text
className="text-[13px] text-a8c-gray-700 line-clamp-3"
weight={ 400 }
align="start"
>
{ blueprintDescription }
</Text>
) }
</VStack>
</VStack>
</HStack>
</VStack>
</div>
<HStack
alignment="start"
className="w-full bg-[#FAFAFA] border border-t-0 rounded-b-lg py-[14px] pe-[14px] ps-[68px] justify-start"
>
<Icon icon={ link } size={ 18 } />
<Text className="text-[13px] text-a8c-gray-800">
{ __( 'Blueprint loaded from URL' ) }
</Text>
</HStack>
</VStack>
</VStack>
);
}
5 changes: 2 additions & 3 deletions src/modules/add-site/hooks/use-blueprint-deeplink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ export function useBlueprintDeeplink( options: UseBlueprintDeeplinkOptions ): vo

const fileBlueprint: Blueprint = {
slug: `file:${ fileName }`,
title: blueprintMeta?.title || fileName.replace( '.json', '' ),
excerpt: blueprintMeta?.description || __( 'Blueprint loaded from URL' ),
title: blueprintMeta?.title || '',
excerpt: blueprintMeta?.description || '',
image: '',
playground_url: '',
blueprint: blueprintJson,
Expand Down Expand Up @@ -89,7 +89,6 @@ export function useBlueprintDeeplink( options: UseBlueprintDeeplinkOptions ): vo
},
[
isAnySiteProcessing,
__,
setSelectedBlueprint,
setPhpVersion,
setWpVersion,
Expand Down