Skip to content

Commit 85bd9c2

Browse files
committed
fix(tooltip): wrap parent story with tooltipprovider
1 parent 5a6e82b commit 85bd9c2

File tree

1 file changed

+38
-33
lines changed

1 file changed

+38
-33
lines changed

src/components/BannerGrid/BannerGrid.stories.tsx

Lines changed: 38 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
import { MdInfoOutline } from "react-icons/md"
2-
import { Box, Icon } from "@chakra-ui/react"
32
import { Meta, StoryObj } from "@storybook/react"
43

5-
import { Image } from "@/components/Image"
4+
import { ChildOnlyProp } from "@/lib/types"
5+
6+
import { TwImage } from "@/components/Image"
67
import InlineLink from "@/components/Link"
7-
import Text from "@/components/OldText"
88
import Tooltip from "@/components/Tooltip"
99

1010
import { getTranslation } from "@/storybook-utils"
1111

1212
import { langViewportModes } from "../../../.storybook/modes"
1313
import { ContentContainer } from "../MdComponents"
14+
import { TooltipProvider } from "../ui/tooltip"
1415

1516
import {
1617
Banner as BannerComponent,
@@ -35,11 +36,13 @@ const meta = {
3536
},
3637
decorators: [
3738
(Story) => (
38-
<Box position="relative" w="full">
39+
<div className="relative w-full">
3940
<ContentContainer>
40-
<Story />
41+
<TooltipProvider>
42+
<Story />
43+
</TooltipProvider>
4144
</ContentContainer>
42-
</Box>
45+
</div>
4346
),
4447
],
4548
} satisfies Meta<typeof BannerComponent>
@@ -59,13 +62,19 @@ const tooltipContent = ({ apiUrl, apiProvider, ariaLabel }) => (
5962
</div>
6063
)
6164

65+
const StatPrimary = (props: ChildOnlyProp) => (
66+
<div className="mb-4 text-5xl leading-none" {...props} />
67+
)
68+
69+
const StatDescription = (props: ChildOnlyProp) => (
70+
<div className="text-md text-[#666] dark:text-[#b2b2b2]" {...props} />
71+
)
72+
6273
export const Banner: Story = {
6374
render: () => {
6475
return (
6576
<BannerComponent>
66-
<Box fontSize="md" color="text200">
67-
Banner
68-
</Box>
77+
<div className="text-md text-[#666] dark:text-[#b2b2b2]">Banner</div>
6978
</BannerComponent>
7079
)
7180
},
@@ -76,9 +85,9 @@ export const BannerBody: Story = {
7685
return (
7786
<BannerComponent>
7887
<BannerBodyComponent>
79-
<Box fontSize="md" color="text200">
88+
<div className="text-md text-[#666] dark:text-[#b2b2b2]">
8089
Banner Body
81-
</Box>
90+
</div>
8291
</BannerBodyComponent>
8392
</BannerComponent>
8493
)
@@ -90,7 +99,7 @@ export const BannerImage: Story = {
9099
return (
91100
<BannerComponent>
92101
<BannerImageComponent>
93-
<Image src={stats} alt="" width={400} />
102+
<TwImage src={stats} alt="" width={400} />
94103
</BannerImageComponent>
95104
</BannerComponent>
96105
)
@@ -103,15 +112,13 @@ export const BannerGridCell: Story = {
103112
<BannerComponent>
104113
<BannerBodyComponent>
105114
<BannerGridCellComponent>
106-
<Box fontSize="5xl" mb={4} lineHeight={1}>
107-
4k+
108-
</Box>
109-
<Box fontSize="md" color="text200">
115+
<StatPrimary>4k+</StatPrimary>
116+
<StatDescription>
110117
{getTranslation(
111118
"page-what-is-ethereum-ethereum-in-numbers-stat-1-desc",
112119
PAGE_WHAT_IS_ETH
113120
)}
114-
<Text as="span" whiteSpace="nowrap">
121+
<span className="whitespace-nowrap">
115122
&nbsp;
116123
<Tooltip
117124
content={tooltipContent({
@@ -120,12 +127,12 @@ export const BannerGridCell: Story = {
120127
ariaLabel: "Read more about Ethereum projects stats",
121128
})}
122129
>
123-
<Box as="span">
124-
<Icon as={MdInfoOutline} verticalAlign="middle" />
125-
</Box>
130+
<span>
131+
<MdInfoOutline className="inline-block align-middle" />
132+
</span>
126133
</Tooltip>
127-
</Text>
128-
</Box>
134+
</span>
135+
</StatDescription>
129136
</BannerGridCellComponent>
130137
</BannerBodyComponent>
131138
</BannerComponent>
@@ -141,15 +148,13 @@ export const BannerGrid: Story = {
141148
<BannerGridComponent>
142149
{Array.from({ length: 6 }, (_, i) => i + 1).map((item) => (
143150
<BannerGridCellComponent key={item}>
144-
<Box fontSize="5xl" mb={4} lineHeight={1}>
145-
{item}k+
146-
</Box>
147-
<Box fontSize="md" color="text200">
151+
<StatPrimary>{item}k+</StatPrimary>
152+
<StatDescription>
148153
{getTranslation(
149154
"page-what-is-ethereum-ethereum-in-numbers-stat-1-desc",
150155
PAGE_WHAT_IS_ETH
151156
)}
152-
<Text as="span" whiteSpace="nowrap">
157+
<span className="whitespace-nowrap">
153158
&nbsp;
154159
<Tooltip
155160
content={tooltipContent({
@@ -159,18 +164,18 @@ export const BannerGrid: Story = {
159164
ariaLabel: "Read more about Ethereum projects stats",
160165
})}
161166
>
162-
<Box as="span">
163-
<Icon as={MdInfoOutline} verticalAlign="middle" />
164-
</Box>
167+
<span>
168+
<MdInfoOutline className="inline-block align-middle" />
169+
</span>
165170
</Tooltip>
166-
</Text>
167-
</Box>
171+
</span>
172+
</StatDescription>
168173
</BannerGridCellComponent>
169174
))}
170175
</BannerGridComponent>
171176
</BannerBodyComponent>
172177
<BannerImageComponent>
173-
<Image src={stats} alt="" width={400} />
178+
<TwImage src={stats} alt="" width={400} />
174179
</BannerImageComponent>
175180
</BannerComponent>
176181
)

0 commit comments

Comments
 (0)