Skip to content

Commit 31c59f3

Browse files
committed
fix: dapp category buttons
Prevent emoji from shrinking, replace flex with grid to make buttons more responsive to available screen width. Fixes cn conditional usage. Removes single-use component abstraction.
1 parent a45bb78 commit 31c59f3

File tree

1 file changed

+19
-39
lines changed

1 file changed

+19
-39
lines changed

src/pages/dapps.tsx

Lines changed: 19 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -126,38 +126,6 @@ const Content = (props: ChildOnlyProp) => (
126126
<div className="w-full px-8 py-4" {...props} />
127127
)
128128

129-
const OptionContainer = (props: ChildOnlyProp) => (
130-
<Flex
131-
className="mb-8 w-full flex-col justify-center px-8 lg:w-auto lg:flex-row"
132-
{...props}
133-
/>
134-
)
135-
136-
const Option = (
137-
props: Pick<ButtonProps, "children" | "onClick"> & { isActive: boolean }
138-
) => {
139-
return (
140-
<Button
141-
variant="outline"
142-
className={cn(
143-
`my-2 flex w-full items-center justify-center rounded-4xl border px-6 py-4 transition-none lg:mx-2 lg:w-auto lg:justify-start ${
144-
props.isActive
145-
? "border-primary text-primary shadow-table-box"
146-
: "border-body text-body"
147-
} hover:border-primary hover:text-primary active:bg-transparent`
148-
)}
149-
{...props}
150-
/>
151-
)
152-
}
153-
154-
const OptionText = (props: ChildOnlyProp) => (
155-
<span
156-
className="text-center text-md font-semibold md:text-2xl md:font-normal"
157-
{...props}
158-
/>
159-
)
160-
161129
const ButtonPrimary = (props: Pick<ButtonProps, "children" | "onClick">) => (
162130
<Button {...props} />
163131
)
@@ -1324,14 +1292,21 @@ const DappsPage = () => {
13241292
<H2 id="explore">{t("page-dapps-explore-dapps-title")}</H2>
13251293
<CenterText>{t("page-dapps-explore-dapps-description")}</CenterText>
13261294
<H3>{t("page-dapps-choose-category")}</H3>
1327-
<OptionContainer>
1295+
<div className="mb-8 grid w-full grid-cols-1 justify-center gap-4 px-8 sm:grid-cols-2 lg:w-auto lg:grid-cols-3 2xl:grid-cols-6">
13281296
{categoryKeys.map((key, idx) => {
13291297
const categoryType = key as CategoryType
13301298
const category = categories[categoryType]
13311299
return (
1332-
<Option
1300+
<Button
13331301
key={idx}
1334-
isActive={selectedCategory === categoryType}
1302+
variant="outline"
1303+
className={cn(
1304+
"flex items-center justify-center rounded-4xl border px-6 py-4 transition-none lg:justify-start",
1305+
selectedCategory === categoryType
1306+
? "border-primary text-primary shadow-table-box"
1307+
: "border-body text-body",
1308+
"hover:border-primary hover:text-primary active:bg-transparent"
1309+
)}
13351310
onClick={() => {
13361311
handleCategorySelect(categoryType, false)
13371312
trackCustomEvent({
@@ -1341,12 +1316,17 @@ const DappsPage = () => {
13411316
})
13421317
}}
13431318
>
1344-
<Emoji className="me-4 text-2xl" text={category.emoji} />
1345-
<OptionText>{category.title}</OptionText>
1346-
</Option>
1319+
<Emoji
1320+
className="me-4 shrink-0 text-2xl"
1321+
text={category.emoji}
1322+
/>
1323+
<span className="text-center text-md font-semibold md:text-2xl md:font-normal">
1324+
{category.title}
1325+
</span>
1326+
</Button>
13471327
)
13481328
})}
1349-
</OptionContainer>
1329+
</div>
13501330
{/* Category-specific content */}
13511331
{selectedCategory === CategoryType.FINANCE && (
13521332
<Content>

0 commit comments

Comments
 (0)