Skip to content

Commit e2218e6

Browse files
authored
Hero section v2 (#2004)
1 parent 911c3b1 commit e2218e6

File tree

3 files changed

+92
-87
lines changed

3 files changed

+92
-87
lines changed

.changeset/calm-ducks-rest.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@theguild/components": minor
3+
---
4+
5+
Hero section v2:
6+
7+
- Change `logo` prop to `top={{ logo: }}`
8+
- Remove decorations

packages/components/src/components/hero/index.stories.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ export default {
2020
checkmarks: {
2121
name: 'Checkmarks text',
2222
},
23-
logo: {
24-
name: 'Logo',
23+
top: {
24+
logo: <ModulesLogo />,
2525
},
2626
text: {
2727
name: 'Hero text',
@@ -33,7 +33,9 @@ export const Default: StoryObj<ComponentProps<typeof Hero>> = {
3333
args: {
3434
heading: 'Enterprise Grade Tooling for Your GraphQL Server',
3535
text: 'GraphQL Modules is a toolset of libraries and guidelines dedicated to create reusable, maintainable, testable and extendable modules out of your GraphQL server.',
36-
logo: <ModulesLogo />,
36+
top: {
37+
logo: <ModulesLogo />,
38+
},
3739
checkmarks: ['Fully open source', 'No vendor lock'],
3840
children: (
3941
<>

packages/components/src/components/hero/index.tsx

Lines changed: 79 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,24 @@
1-
import { cloneElement, ComponentProps, FC, ReactElement, ReactNode, useId } from 'react';
1+
import { cloneElement, FC, ReactElement, ReactNode, useId } from 'react';
22
import { cn } from '../../cn';
3-
import { DecorationIsolation } from '../decorations';
43
import { Heading } from '../heading';
54
import { CheckIcon } from '../icons';
65

7-
export const Hero: FC<{
6+
export interface HeroProps {
87
className?: string;
98
heading: string;
109
text: string;
1110
checkmarks: string[];
12-
logo: ReactElement<ComponentProps<'svg'>>;
11+
top?:
12+
| {
13+
logo: ReactElement<{ className?: string; fill?: string }>;
14+
}
15+
| {
16+
children: ReactNode;
17+
};
1318
children?: ReactNode;
14-
}> = props => {
19+
}
20+
21+
export const Hero: FC<HeroProps> = props => {
1522
const gradientWhiteId = useId();
1623
const gradientWhiteId2 = useId();
1724
const greenBgId = useId();
@@ -23,86 +30,74 @@ export const Hero: FC<{
2330
props.className,
2431
)}
2532
>
26-
<DecorationIsolation className="-z-10">
27-
{cloneElement(props.logo, {
28-
className: cn(
29-
'absolute stroke-white/10 max-lg:hidden',
30-
'-left-1/2 top-1/2 -translate-y-1/2',
31-
),
32-
fill: `url(#${gradientWhiteId2})`,
33-
strokeWidth: '0.1',
34-
width: 'auto',
35-
height: '50%',
36-
})}
37-
{cloneElement(props.logo, {
38-
className: cn(
39-
'absolute top-1/2 -translate-y-1/2 stroke-white/10',
40-
'-right-1/2 lg:-right-1/3',
41-
'h-2/3 lg:h-[calc(100%-5%)]',
42-
),
43-
fill: `url(#${gradientWhiteId2})`,
44-
strokeWidth: '0.1',
45-
width: 'auto',
46-
})}
47-
</DecorationIsolation>
4833
<div className="relative">
49-
{cloneElement(props.logo, {
50-
fill: `url(#${gradientWhiteId})`,
51-
className: 'absolute inset-1/2 -translate-x-1/2 -translate-y-1/2 size-1/2',
52-
})}
53-
<svg
54-
width="96"
55-
height="96"
56-
viewBox="0 0 96 96"
57-
fill="none"
58-
xmlns="http://www.w3.org/2000/svg"
59-
>
60-
<rect width="96" height="96" rx="24" fill={`url(#${greenBgId})`} />
61-
<rect
62-
x="0.5"
63-
y="0.5"
64-
width="95"
65-
height="95"
66-
rx="23.5"
67-
stroke={`url(#${gradientWhiteId})`}
68-
/>
69-
<path d="M57.0264 32.1652H48.9577L53.8032 27.3197L48.4855 22L43.1658 27.3197L48.0114 32.1652H39.9427C38.9042 32.1652 37.9069 32.5786 37.1721 33.3134L23 47.4855L28.3197 52.8052L45.715 35.4099C47.2452 33.8797 49.7258 33.8797 51.2561 35.4099L68.6513 52.8052L73.971 47.4855L59.797 33.3114C59.0622 32.5767 58.0649 32.1632 57.0264 32.1632V32.1652ZM48.4854 63.3623L43.1665 68.6811L48.4854 74L53.8042 68.6811L48.4854 63.3623ZM39.9446 52.8054H48.4855H48.4894H57.0303C58.0688 52.8054 59.0661 53.2188 59.8008 53.9536L63.89 58.0428L58.5704 63.3625L51.258 56.0501C49.7277 54.5198 47.2472 54.5198 45.7169 56.0501L38.4045 63.3625L33.0848 58.0428L37.174 53.9536C37.9088 53.2188 38.9061 52.8054 39.9446 52.8054Z" />
70-
<defs>
71-
<linearGradient
72-
id={greenBgId}
73-
x1="0"
74-
y1="0"
75-
x2="96"
76-
y2="96"
77-
gradientUnits="userSpaceOnUse"
78-
>
79-
<stop stopColor="#3B736A" />
80-
<stop offset="1" stopColor="#15433C" />
81-
</linearGradient>
82-
<linearGradient
83-
id={gradientWhiteId}
84-
x1="0"
85-
y1="0"
86-
x2="96"
87-
y2="96"
88-
gradientUnits="userSpaceOnUse"
89-
>
90-
<stop stopColor="white" stopOpacity="0.8" />
91-
<stop offset="1" stopColor="white" stopOpacity="0.4" />
92-
</linearGradient>
93-
<linearGradient
94-
id={gradientWhiteId2}
95-
x1="1"
96-
y1="2"
97-
x2="161"
98-
y2="171"
99-
gradientUnits="userSpaceOnUse"
100-
>
101-
<stop stopColor="white" stopOpacity="0.1" />
102-
<stop offset="1" stopColor="white" stopOpacity="0.5" />
103-
</linearGradient>
104-
</defs>
105-
</svg>
34+
{props.top &&
35+
('logo' in props.top ? (
36+
<>
37+
{cloneElement(props.top.logo, {
38+
fill: `url(#${gradientWhiteId})`,
39+
className: cn(
40+
'absolute inset-1/2 size-1/2 -translate-x-1/2 -translate-y-1/2',
41+
props.top.logo.props.className,
42+
),
43+
})}
44+
<svg
45+
width="96"
46+
height="96"
47+
viewBox="0 0 96 96"
48+
fill="none"
49+
xmlns="http://www.w3.org/2000/svg"
50+
>
51+
<rect width="96" height="96" rx="24" fill={`url(#${greenBgId})`} />
52+
<rect
53+
x="0.5"
54+
y="0.5"
55+
width="95"
56+
height="95"
57+
rx="23.5"
58+
stroke={`url(#${gradientWhiteId})`}
59+
/>
60+
<path d="M57.0264 32.1652H48.9577L53.8032 27.3197L48.4855 22L43.1658 27.3197L48.0114 32.1652H39.9427C38.9042 32.1652 37.9069 32.5786 37.1721 33.3134L23 47.4855L28.3197 52.8052L45.715 35.4099C47.2452 33.8797 49.7258 33.8797 51.2561 35.4099L68.6513 52.8052L73.971 47.4855L59.797 33.3114C59.0622 32.5767 58.0649 32.1632 57.0264 32.1632V32.1652ZM48.4854 63.3623L43.1665 68.6811L48.4854 74L53.8042 68.6811L48.4854 63.3623ZM39.9446 52.8054H48.4855H48.4894H57.0303C58.0688 52.8054 59.0661 53.2188 59.8008 53.9536L63.89 58.0428L58.5704 63.3625L51.258 56.0501C49.7277 54.5198 47.2472 54.5198 45.7169 56.0501L38.4045 63.3625L33.0848 58.0428L37.174 53.9536C37.9088 53.2188 38.9061 52.8054 39.9446 52.8054Z" />
61+
<defs>
62+
<linearGradient
63+
id={greenBgId}
64+
x1="0"
65+
y1="0"
66+
x2="96"
67+
y2="96"
68+
gradientUnits="userSpaceOnUse"
69+
>
70+
<stop stopColor="#3B736A" />
71+
<stop offset="1" stopColor="#15433C" />
72+
</linearGradient>
73+
<linearGradient
74+
id={gradientWhiteId}
75+
x1="0"
76+
y1="0"
77+
x2="96"
78+
y2="96"
79+
gradientUnits="userSpaceOnUse"
80+
>
81+
<stop stopColor="white" stopOpacity="0.8" />
82+
<stop offset="1" stopColor="white" stopOpacity="0.4" />
83+
</linearGradient>
84+
<linearGradient
85+
id={gradientWhiteId2}
86+
x1="1"
87+
y1="2"
88+
x2="161"
89+
y2="171"
90+
gradientUnits="userSpaceOnUse"
91+
>
92+
<stop stopColor="white" stopOpacity="0.1" />
93+
<stop offset="1" stopColor="white" stopOpacity="0.5" />
94+
</linearGradient>
95+
</defs>
96+
</svg>
97+
</>
98+
) : (
99+
props.top.children
100+
))}
106101
</div>
107102
<Heading as="h1" size="xl" className="mx-auto max-w-3xl text-balance text-center">
108103
{props.heading}

0 commit comments

Comments
 (0)