Skip to content

Commit 0c4fee7

Browse files
authored
"Recommended" text in Plan cards (#6735)
1 parent 7d431d8 commit 0c4fee7

File tree

6 files changed

+49
-33
lines changed

6 files changed

+49
-33
lines changed

packages/libraries/core/tests/usage.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ test('should send data to Hive (deprecated endpoint)', async () => {
333333
expect(operation.execution.ok).toBe(true);
334334
});
335335

336-
test('should not leak the exception', async () => {
336+
test('should not leak the exception', { retry: 3 }, async () => {
337337
const logger = createHiveTestingLogger();
338338

339339
const hive = createHive({

packages/libraries/yoga/tests/persisted-documents.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,7 @@ test('deduplication of parallel requests resolving the same document from CDN',
720720
httpScope.done();
721721
});
722722

723-
test('usage reporting with batch execution and persisted documents', async () => {
723+
test('usage reporting with batch execution and persisted documents', { retry: 3 }, async () => {
724724
const httpScope = nock('http://artifacts-cdn.localhost', {
725725
reqheaders: {
726726
'X-Hive-CDN-Key': value => {

packages/web/docs/src/components/pricing/index.tsx

Lines changed: 2 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
'use client';
22

33
import { HTMLAttributes, ReactElement, ReactNode, useRef, useState } from 'react';
4-
import { Content, Root, Trigger } from '@radix-ui/react-tooltip';
54
import {
65
CallToAction,
76
cn,
@@ -11,6 +10,7 @@ import {
1110
ShieldFlashIcon,
1211
TextLink,
1312
} from '@theguild/components';
13+
import { Tooltip } from '../tooltip';
1414
import {
1515
AvailabilityIcon,
1616
BillingIcon,
@@ -25,33 +25,6 @@ import {
2525
import { PlanCard } from './plan-card';
2626
import { PricingSlider } from './pricing-slider';
2727

28-
function Tooltip({ content, children }: { content: string; children: ReactNode }) {
29-
return (
30-
<Root delayDuration={350}>
31-
<Trigger className="hive-focus -mx-1 -my-0.5 rounded px-1 py-0.5 text-left">
32-
{children}
33-
</Trigger>
34-
<Content
35-
align="start"
36-
sideOffset={5}
37-
className="bg-green-1000 z-20 rounded p-2 text-sm font-normal leading-4 text-white shadow"
38-
>
39-
{content}
40-
<svg
41-
// radix arrow is in wrong spot, so I added a custom one
42-
width="10"
43-
height="14"
44-
viewBox="0 0 12 16"
45-
fill="currentColor"
46-
className="text-green-1000 absolute bottom-0 left-1/3 -translate-x-1/2 translate-y-1/2"
47-
>
48-
<path d="M0 8L6 0L12 8L6 16L0 8Z" />
49-
</svg>
50-
</Content>
51-
</Root>
52-
);
53-
}
54-
5528
interface PlanFeaturesListItemProps extends HTMLAttributes<HTMLLIElement> {
5629
icon: ReactNode;
5730
category: string;
@@ -158,7 +131,7 @@ export function Pricing({ className }: { className?: string }): ReactElement {
158131
<div
159132
ref={scrollviewRef}
160133
// the padding is here so `overflow-auto` doesn't cut button hover states
161-
className="nextra-scrollbar -mx-4 -mb-6 flex flex-col items-stretch gap-6 px-4 py-6 sm:flex-row sm:overflow-auto sm:*:min-w-[380px] md:-mx-6 md:px-6 lg:mt-6"
134+
className="nextra-scrollbar -mx-4 -mb-6 flex flex-col items-stretch gap-6 px-4 py-6 sm:flex-row sm:overflow-auto sm:*:min-w-[380px] md:-mx-6 md:px-6"
162135
>
163136
<PlanCard
164137
data-plan="Hobby"

packages/web/docs/src/components/pricing/plan-card.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,12 +175,14 @@ export function PlanCard({
175175
ref={cardRef}
176176
className={cn(
177177
'relative isolate rounded-3xl bg-white shadow-[inset_0_0_0_1px_theme(colors.green.400)]',
178-
'before:absolute before:inset-0 before:-z-10 before:rounded-3xl before:bg-[linear-gradient(#fff,#fff),linear-gradient(to_bottom,#E1FF00,#DEDACF,#68A8B6)] before:p-[4px] before:opacity-0 before:transition-[opacity] before:duration-700 before:content-[""] before:[background-clip:content-box,padding-box]',
178+
'duration-200 before:absolute before:inset-0 before:-z-10 before:rounded-3xl before:bg-[linear-gradient(#fff,#fff),linear-gradient(to_bottom,#68A8B6,#DEDACF,#E1FF00)] before:p-[4px] before:opacity-0 before:transition-[opacity,top,height] before:content-[""] before:[background-clip:content-box,padding-box] before:[transition-duration:50ms,25ms,25ms] sm:mt-[52px] sm:before:top-[-40px]',
179179
(highlighted || !collapsed) && 'before:opacity-100',
180180
'max-sm:transition-[width,height,border-radius] max-sm:duration-700 max-sm:ease-in-out',
181181
!collapsed &&
182182
'max-sm:fixed max-sm:inset-2 max-sm:z-50 max-sm:m-0 max-sm:h-[calc(100vh-16px)] max-sm:bg-white',
183183
transitioning && 'z-50',
184+
highlighted && // delay is 29ms so fast swipes don't blink needlessly
185+
'sm:before:top-[-52px] sm:before:h-[calc(100%+52px)] sm:before:pt-[50px] sm:before:delay-[29ms] sm:before:[transition-duration:150ms,75ms,75ms]',
184186
className,
185187
)}
186188
{...rest}
@@ -192,6 +194,15 @@ export function PlanCard({
192194
!collapsed && 'nextra-scrollbar h-full max-sm:overflow-auto',
193195
)}
194196
>
197+
<div
198+
aria-hidden={!highlighted}
199+
className={cn(
200+
'absolute -top-9 left-0 w-full text-center font-medium text-white transition-opacity max-sm:hidden',
201+
highlighted ? 'opacity-100' : 'opacity-0',
202+
)}
203+
>
204+
Recommended
205+
</div>
195206
<header className="relative text-green-800">
196207
<div className="flex flex-row items-center gap-2">
197208
<h2 className="text-2xl font-medium">{name}</h2>
@@ -213,7 +224,9 @@ export function PlanCard({
213224
</button>
214225
)}
215226
</header>
216-
<div className="mt-4 h-6 text-[#4F6C6A]">{startingFrom && 'Starting from'}</div>
227+
<div className={cn('mt-4 h-6 text-[#4F6C6A]', !startingFrom && 'max-sm:h-0')}>
228+
{startingFrom && 'Starting from'}
229+
</div>
217230
<div className="text-5xl font-medium leading-[56px] tracking-[-0.48px]">{price}</div>
218231
<div className="mt-4 flex *:grow">{callToAction}</div>
219232

packages/web/docs/src/components/slider.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,8 @@ export function Slider({ counter, className, deadZone, style, ...rest }: SliderP
111111
<div className="flex w-full">
112112
<button
113113
className="z-10 my-3"
114+
tabIndex={-1}
115+
title="Set to minimum"
114116
style={{ width: deadZone }}
115117
onClick={event => {
116118
const input = event.currentTarget.parentElement!.querySelector(
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { ReactNode } from 'react';
2+
import { Content, Root, Trigger } from '@radix-ui/react-tooltip';
3+
4+
export function Tooltip({ content, children }: { content: string; children: ReactNode }) {
5+
return (
6+
<Root delayDuration={350}>
7+
<Trigger className="hive-focus -mx-1 -my-0.5 rounded px-1 py-0.5 text-left">
8+
{children}
9+
</Trigger>
10+
<Content
11+
align="start"
12+
sideOffset={5}
13+
className="bg-green-1000 z-20 rounded px-2 py-[3px] text-sm font-normal text-white shadow"
14+
>
15+
{content}
16+
<TooltipArrow className="text-green-1000 absolute bottom-0 left-1/3 -translate-x-1/2 translate-y-full" />
17+
</Content>
18+
</Root>
19+
);
20+
}
21+
22+
function TooltipArrow(props: React.SVGProps<SVGSVGElement>) {
23+
return (
24+
<svg width="10" height="5" viewBox="0 0 8 4" fill="currentColor" {...props}>
25+
<path d="M5.06066 2.93934C4.47487 3.52513 3.52513 3.52513 2.93934 2.93934L-6.03983e-07 -6.99382e-07L8 0L5.06066 2.93934Z" />
26+
</svg>
27+
);
28+
}

0 commit comments

Comments
 (0)