Skip to content

Commit 4481819

Browse files
chore(stats): refactor Stats component to accept children and integrate with Overview and PriceFeeds for better flexibility
1 parent 3ff90d9 commit 4481819

File tree

5 files changed

+12
-34
lines changed

5 files changed

+12
-34
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
import styles from "./index.module.scss";
2-
import { Stats } from "../Stats";
32

43
export const Overview = () => (
54
<div className={styles.overview}>
65
<h1 className={styles.header}>Overview</h1>
7-
<Stats />
86
</div>
97
);

apps/insights/src/components/PriceFeeds/index.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ export const PriceFeeds = async () => {
4949
<div className={styles.priceFeeds}>
5050
<h1 className={styles.header}>Price Feeds</h1>
5151
<div className={styles.body}>
52-
<Stats />
53-
<section className={styles.stats}>
52+
<Stats>
5453
<StatCard
5554
variant="primary"
5655
header="Active Feeds"
@@ -76,7 +75,7 @@ export const PriceFeeds = async () => {
7675
corner={<Info weight="fill" />}
7776
/>
7877
</AssetClassesDrawer>
79-
</section>
78+
</Stats>
8079
<YesterdaysPricesProvider
8180
feeds={Object.fromEntries(
8281
featuredRecentlyAdded.map(({ symbol, product }) => [
@@ -167,6 +166,7 @@ const FeaturedFeedsCard = <T extends ElementType>({
167166
}: FeaturedFeedsCardProps<T>) => (
168167
<Card {...props}>
169168
<div className={styles.featuredFeeds}>
169+
<Stats>
170170
{feeds.map((feed) => (
171171
<Card
172172
key={feed.product.price_account}
@@ -193,6 +193,7 @@ const FeaturedFeedsCard = <T extends ElementType>({
193193
</div>
194194
</Card>
195195
))}
196+
</Stats>
196197
</div>
197198
</Card>
198199
);

apps/insights/src/components/Stats/index.module.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
}
2828

2929
.statsContainer {
30-
gap: theme.spacing(6);
30+
gap: theme.spacing(2);
3131
width: 100%;
3232
display: flex;
3333
flex-direction: row;

apps/insights/src/components/Stats/index.tsx

+6-28
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,15 @@
1-
import { ArrowLineDown } from "@phosphor-icons/react/dist/ssr/ArrowLineDown"
2-
import { StatCard } from "@pythnetwork/component-library/StatCard"
31

42
import styles from "./index.module.scss"
53

6-
export const Stats = () => {
4+
export const Stats = ({
5+
children
6+
}: {
7+
children: React.ReactNode
8+
}) => {
79
return (
810
<div className={styles.statWrapper}>
911
<div className={styles.statsContainer}>
10-
<StatCard
11-
variant="primary"
12-
header="Active Feeds"
13-
stat={7}
14-
href={'/price-feeds'}
15-
corner={<ArrowLineDown />}
16-
/>
17-
<StatCard
18-
header="Active Feeds"
19-
stat={7}
20-
href={'/price-feeds'}
21-
corner={<ArrowLineDown />}
22-
/>
23-
<StatCard
24-
header="Active Feeds"
25-
stat={7}
26-
href={'/price-feeds'}
27-
corner={<ArrowLineDown />}
28-
/>
29-
<StatCard
30-
header="Active Feeds"
31-
stat={7}
32-
href={'/price-feeds'}
33-
corner={<ArrowLineDown />}
34-
/>
12+
{children}
3513
</div>
3614
</div>
3715
)

packages/component-library/src/Card/index.module.scss

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
position: relative;
1717
padding: theme.spacing(1);
1818
isolation: isolate;
19+
overflow: hidden;
1920

2021
@at-root button#{&} {
2122
cursor: pointer;

0 commit comments

Comments
 (0)