Skip to content

Commit cf95340

Browse files
committed
refactor: simplify why Rspack card
1 parent 0eb85b2 commit cf95340

3 files changed

Lines changed: 18 additions & 197 deletions

File tree

src/why-rspack/index.module.scss

Lines changed: 6 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,8 @@
11
// ---------- responsive layout
2-
// XXL
3-
@media screen and (min-width: 1441px) {
4-
.featureCard {
5-
flex: 1 0 30% !important;
6-
}
7-
}
8-
92
// XL
10-
@media screen and (min-width: 1281px) and (max-width: 1440px) {
3+
@media screen and (min-width: 1281px) {
114
.featureCard {
12-
flex: 1 0 30% !important;
5+
flex: 1 0 20% !important;
136
}
147
}
158

@@ -123,77 +116,6 @@
123116
}
124117
}
125118

126-
.whyRspackCard {
127-
flex: 2 0 60% !important;
128-
align-self: stretch;
129-
130-
.whyRspack {
131-
box-sizing: border-box;
132-
height: 100%;
133-
display: flex;
134-
padding: 32px;
135-
flex-direction: column;
136-
align-items: center;
137-
gap: 16px;
138-
139-
// style
140-
border-radius: 20px;
141-
border: 1px solid var(--rs-why-rspack-card-stroke);
142-
background: var(--rs-why-rspack-card-gradient);
143-
144-
.whyRspackBg {
145-
width: 250px;
146-
height: 75%;
147-
position: absolute;
148-
bottom: 32px;
149-
right: 32px;
150-
z-index: 0;
151-
user-select: none;
152-
}
153-
154-
.whyRspackContent {
155-
display: flex;
156-
padding: 16px;
157-
flex-direction: column;
158-
justify-content: center;
159-
align-items: flex-start;
160-
gap: 16px;
161-
162-
.whyRspackTitle {
163-
font-size: 42px;
164-
font-style: normal;
165-
font-weight: 700;
166-
line-height: normal;
167-
letter-spacing: -2px;
168-
margin: 0;
169-
// style
170-
background: var(
171-
--Linear-Text,
172-
linear-gradient(278deg, #ff8b00 52.48%, #f93920 98.12%)
173-
);
174-
background-clip: text;
175-
-webkit-background-clip: text;
176-
-webkit-text-fill-color: transparent;
177-
}
178-
179-
.whyRspackDescription {
180-
// text
181-
font-size: 19px;
182-
font-style: normal;
183-
font-weight: 400;
184-
line-height: 40px; /* 166.667% */
185-
margin-top: 4px;
186-
187-
// style
188-
background: var(--rs-why-rspack-description-bg);
189-
background-clip: text;
190-
-webkit-background-clip: text;
191-
-webkit-text-fill-color: transparent;
192-
}
193-
}
194-
}
195-
}
196-
197119
.features {
198120
width: 100%;
199121
display: flex;
@@ -220,28 +142,22 @@
220142
border-radius: 20px;
221143
border: 1px solid var(--rs-why-rspack-card-stroke);
222144
background: var(--rs-why-rspack-card-gradient);
223-
padding: 32px;
145+
padding: 28px;
224146

225147
// reset
226148
text-decoration: none;
227149

228150
.featureIcon {
229-
background: url('https://assets.rspack.dev/rspack/assets/landingpage-why-rspack-card-bg.png')
230-
no-repeat;
231-
background-size: 100% 100%;
232-
233151
display: flex;
234152
justify-content: center;
235153
align-items: center;
236-
height: 100%;
237154
width: 100%;
238-
height: 150px;
239155

240156
user-select: none;
241157

242158
.featureIconImg {
243159
width: 150px;
244-
height: 120px;
160+
height: 110px;
245161
}
246162
}
247163

@@ -256,7 +172,7 @@
256172
.featureTitle {
257173
color: var(--rs-why-rspack-title-color);
258174

259-
font-size: 20px;
175+
font-size: 17px;
260176
font-style: normal;
261177
font-weight: 700;
262178
line-height: 1.5;
@@ -268,7 +184,7 @@
268184
.featureDescription {
269185
color: var(--rs-why-rspack-desc-color);
270186

271-
font-size: 15px;
187+
font-size: 14px;
272188
font-style: normal;
273189
font-weight: 400;
274190
line-height: 24px; /* 150% */

src/why-rspack/index.tsx

Lines changed: 2 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -12,88 +12,6 @@ export type Feature = {
1212
lottieJsonData?: any;
1313
};
1414

15-
type WhyRspackCardProps = {
16-
title: string;
17-
description: string;
18-
};
19-
20-
const WhyRspackCard: FC<WhyRspackCardProps> = memo(({ title, description }) => {
21-
const {
22-
container,
23-
onMouseEnter,
24-
onMouseLeave,
25-
onMouseMove,
26-
onTouchEnd,
27-
onTouchMove,
28-
onTouchStart,
29-
outerContainer,
30-
ref,
31-
shine,
32-
shineBg,
33-
} = useCardAnimation();
34-
35-
return (
36-
<div
37-
style={{
38-
position: 'relative',
39-
transform: outerContainer,
40-
transformStyle: 'preserve-3d',
41-
zIndex: 6,
42-
WebkitTapHighlightColor: 'rgba(#000, 0)',
43-
}}
44-
className={styles.whyRspackCard}
45-
ref={ref as any}
46-
onMouseEnter={onMouseEnter}
47-
onMouseLeave={onMouseLeave}
48-
onMouseMove={onMouseMove}
49-
onTouchMove={onTouchMove}
50-
onTouchEnd={onTouchEnd}
51-
onTouchStart={onTouchStart}
52-
>
53-
<div
54-
className={styles.whyRspack}
55-
style={{
56-
transform: container,
57-
position: 'relative',
58-
transition: 'all 0.2s ease-out',
59-
}}
60-
>
61-
<div
62-
className="shine"
63-
style={{
64-
position: 'absolute',
65-
top: '0',
66-
left: '0',
67-
right: '0',
68-
bottom: '0',
69-
borderRadius: '20px',
70-
zIndex: '8',
71-
...(shine
72-
? {
73-
transform: shine,
74-
}
75-
: {}),
76-
...(shineBg
77-
? {
78-
background: shineBg,
79-
}
80-
: {}),
81-
}}
82-
/>
83-
<div className={styles.whyRspackContent}>
84-
<h3 className={styles.whyRspackTitle}>{title}</h3>
85-
<p className={styles.whyRspackDescription}>{description}</p>
86-
<img
87-
className={styles.whyRspackBg}
88-
src="https://assets.rspack.dev/rspack/assets/landingpage-why-rspack-card-why-bg.png"
89-
alt="bg"
90-
/>
91-
</div>
92-
</div>
93-
</div>
94-
);
95-
});
96-
9715
const FeatureItem = memo(
9816
({ feature, LinkComp }: { feature: Feature; LinkComp: LinkComp }) => {
9917
const { description, img, title, url, lottieJsonData } = feature;
@@ -228,19 +146,11 @@ const FeatureList: FC<FeatureListProps> = memo(({ LinkComp, features }) => {
228146
);
229147
});
230148

231-
export type WhyRspackProps = FeatureListProps & Partial<WhyRspackCardProps>;
149+
export type WhyRspackProps = FeatureListProps;
232150

233-
export const WhyRspack: FC<WhyRspackProps> = ({
234-
title,
235-
description,
236-
features,
237-
LinkComp,
238-
}) => {
151+
export const WhyRspack: FC<WhyRspackProps> = ({ features, LinkComp }) => {
239152
return (
240153
<div className={styles.features}>
241-
{title && description ? (
242-
<WhyRspackCard title={title} description={description} />
243-
) : null}
244154
<FeatureList features={features} LinkComp={LinkComp} />
245155
</div>
246156
);

stories/WhyRspack.stories.tsx

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,50 +13,45 @@ import Lightning from './why-rspack-assets/Lightning.svg';
1313
import SpeedometerJson from './why-rspack-assets/Speedometer.json';
1414
import Speedometer from './why-rspack-assets/Speedometer.svg';
1515

16+
const description =
17+
'Using Rspack to bring you the ultimate development experience.';
18+
1619
const features: Feature[] = [
1720
{
1821
img: Speedometer,
1922
url: '/guide/start/introduction',
2023
title: 'FastStartup',
21-
description: 'FastStartupDesc',
24+
description,
2225
lottieJsonData: SpeedometerJson,
2326
},
2427
{
2528
img: Lightning,
2629
url: '/guide/start/introduction',
2730
title: 'LightningHMR',
28-
description: 'LightningHMRDesc',
31+
description,
2932
lottieJsonData: LightningJson,
3033
},
3134
{
3235
img: FrameCheck,
3336
url: '/guide/tech/react',
3437
title: 'FrameworkAgnostic',
35-
description: 'FrameworkAgnosticDesc',
38+
description,
3639
lottieJsonData: FrameCheckJson,
3740
},
3841
{
3942
img: Compatible,
4043
url: '/guide/compatibility/plugin',
4144
title: 'WebpackCompatible',
42-
description: 'WebpackCompatibleDesc',
45+
description,
4346
lottieJsonData: CompatibleJson,
4447
},
4548
];
4649

47-
const title = 'Why Rspack?';
48-
const description =
49-
'Rspack is a high performance JavaScript bundler written in Rust. It offers strong compatibility with the webpack ecosystem, allowing for seamless replacement of webpack, and provides lightning fast build speeds.';
50-
5150
export const WhyRspackStory = () => {
5251
return (
53-
<section className={containerStyle} key={title}>
52+
<section className={containerStyle}>
5453
<div className={innerContainerStyle}>
55-
<WhyRspack
56-
features={features}
57-
title={title}
58-
description={description}
59-
/>
54+
<WhyRspack features={features} />
6055
</div>
6156
</section>
6257
);
@@ -109,7 +104,7 @@ const rsbuildFeatures = [
109104

110105
export const WhyRspackStoryWithoutFirstCardAndLottie = () => {
111106
return (
112-
<section className={containerStyle} key={title}>
107+
<section className={containerStyle}>
113108
<div className={innerContainerStyle}>
114109
<WhyRspack features={rsbuildFeatures} />
115110
</div>

0 commit comments

Comments
 (0)