Skip to content

Commit d05b5a6

Browse files
authored
Product card tweaks for main (#1956)
1 parent 15972ea commit d05b5a6

File tree

4 files changed

+47
-32
lines changed

4 files changed

+47
-32
lines changed

.changeset/slimy-trainers-joke.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@theguild/components": patch
3+
---
4+
5+
Tweak ProductCard styles on mobile

packages/components/src/components/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,5 +29,6 @@ export * from './explore-main-product-cards';
2929
export * from './text-link';
3030
export * from './contact-us';
3131
export { Giscus } from './giscus';
32+
export * from './product-card';
3233
export * from './version-dropdown';
3334
export * from './dropdown';

packages/components/src/components/product-card/index.tsx

Lines changed: 40 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { useId } from 'react';
22
import { cn } from '../../cn';
33
import { FOUR_MAIN_PRODUCTS, ProductInfo, PRODUCTS } from '../../products';
4-
import { HighlightDecoration } from '../decorations';
4+
import { DecorationIsolation, HighlightDecoration } from '../decorations';
55
import { ArrowIcon } from '../icons';
66
import { ReactComponent as HiveDecoration } from './hive-decoration.svg';
77
import { ReactComponent as HiveGatewayDecoration } from './hive-gateway-decoration.svg';
@@ -25,7 +25,7 @@ export function MainProductCard({ as: Root, product, className, ...rest }: Produ
2525
return (
2626
<Root
2727
className={cn(
28-
'hive-focus-within group relative flex-1 shrink-0 basis-[283.5px] overflow-hidden rounded-2xl max-md:w-[283.5px]',
28+
'hive-focus-within group relative flex-1 shrink-0 basis-[283.5px] overflow-hidden rounded-2xl max-md:min-w-[283.5px]',
2929
isHive ? 'bg-green-1000 text-white' : 'bg-blue-400 text-green-1000',
3030
className,
3131
)}
@@ -38,36 +38,45 @@ export function MainProductCard({ as: Root, product, className, ...rest }: Produ
3838
<p className="font-medium">{product.name}</p>
3939
<Icon className="mt-8" />
4040
<ArrowIcon className="absolute bottom-8 right-8" />
41-
</a>
42-
<Decoration
43-
strokeWidth="0.5px"
44-
className={cn(
45-
'stroke-white/70',
46-
'pointer-events-none absolute bottom-0 right-0 h-full opacity-0 transition-opacity duration-500 group-focus-within:opacity-100 group-hover:opacity-100',
47-
)}
48-
fill={`url(#${id})`}
49-
/>
50-
<svg
51-
// To remove from layout, but we can't use `display: none` because it breaks the gradient
52-
className="size-0"
53-
>
54-
<defs>
55-
<linearGradient id={id} x1="1" y1="2" x2="161" y2="171" gradientUnits="userSpaceOnUse">
56-
{isHive ? (
57-
<>
58-
<stop stopColor="#3b736a" />
59-
<stop offset="1" stopColor="#245850" />
60-
</>
61-
) : (
62-
<>
63-
<stop stopColor="white" stopOpacity="0.1" />
64-
<stop offset="1" stopColor="white" stopOpacity="0.4" />
65-
</>
41+
<DecorationIsolation>
42+
<Decoration
43+
strokeWidth="0.5px"
44+
className={cn(
45+
'stroke-white/70',
46+
'pointer-events-none absolute bottom-0 right-0 h-full opacity-0 transition-opacity duration-500 group-focus-within:opacity-100 group-hover:opacity-100',
6647
)}
67-
</linearGradient>
68-
</defs>
69-
</svg>
70-
<HighlightDecoration className="pointer-events-none absolute left-0 top-[-15%] h-[150%] w-full opacity-0 transition-opacity duration-1000 group-focus-within:opacity-100 group-hover:opacity-100" />
48+
fill={`url(#${id})`}
49+
/>
50+
<svg
51+
// To remove from layout, but we can't use `display: none` because it breaks the gradient
52+
className="size-0"
53+
>
54+
<defs>
55+
<linearGradient
56+
id={id}
57+
x1="1"
58+
y1="2"
59+
x2="161"
60+
y2="171"
61+
gradientUnits="userSpaceOnUse"
62+
>
63+
{isHive ? (
64+
<>
65+
<stop stopColor="#3b736a" />
66+
<stop offset="1" stopColor="#245850" />
67+
</>
68+
) : (
69+
<>
70+
<stop stopColor="white" stopOpacity="0.1" />
71+
<stop offset="1" stopColor="white" stopOpacity="0.4" />
72+
</>
73+
)}
74+
</linearGradient>
75+
</defs>
76+
</svg>
77+
<HighlightDecoration className="pointer-events-none absolute left-0 top-[-15%] h-[150%] w-full opacity-0 transition-opacity duration-1000 group-focus-within:opacity-100 group-hover:opacity-100" />
78+
</DecorationIsolation>
79+
</a>
7180
</Root>
7281
);
7382
}

packages/components/src/components/product-card/product-card.stories.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export const Default: StoryObj<typeof ProductCard> = {
2121
name: 'ProductCard',
2222
render() {
2323
return (
24-
<ul className="mt-5 grid grid-cols-4 gap-5 overflow-x-auto p-4 last-of-type:mb-24">
24+
<ul className="mt-5 grid grid-cols-1 gap-5 overflow-x-auto p-4 last-of-type:mb-24 sm:grid-cols-4">
2525
{productsLexicographically.map(product => (
2626
<ProductCard as="li" key={product.name} product={product} />
2727
))}

0 commit comments

Comments
 (0)