Skip to content

Commit 1fcee8c

Browse files
Merge pull request #1231 from dacadeorg/fix/scoreboard-filter-spacing
Fix: scoreboard filter spacing
2 parents ff9a6f0 + 0670bd8 commit 1fcee8c

File tree

4 files changed

+42
-46
lines changed

4 files changed

+42
-46
lines changed

src/components/sections/communities/overview/Sidebar.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { useSelector } from "@/hooks/useTypedSelector";
22
import Link from "next/link";
33
import { useRouter } from "next/router";
44
import { useTranslation } from "next-i18next";
5+
import classNames from "classnames";
56

67
/**
78
* @interface SidebarProps
@@ -41,7 +42,7 @@ export default function Sidebar(): JSX.Element {
4142
</Link>
4243
{hasCurrentCommunity && (
4344
<Link href={scoreboardLink}>
44-
<div className={isActive(scoreboardLink) ? "pt-5" : "opacity-80 md:block hidden scroll-smooth pt-5"}>
45+
<div className={classNames("pt-6", { "opacity-80 md:block hidden scroll-smooth": isActive(scoreboardLink) })}>
4546
<div className="font-medium text-.5xl leading-snug">{t("communities.overview.scoreboard.title")}</div>
4647
<div className="text-sm font-light lg:w-full lg:pr-7 pt-2 mb-6 md:mb-0">{t("communities.overview.scoreboard.description")}</div>
4748
</div>

src/components/sections/communities/overview/scoreboard/Filter.tsx

Lines changed: 29 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -108,42 +108,38 @@ export default function Filters(): ReactElement {
108108
};
109109

110110
return (
111-
<div className="lg:flex flex-col w-2/4 mr-8 divide-y divide-solid divide-gray-200 hidden">
112-
<div className="divide-y divide-gray-200">
113-
<div className="block mt-6 mb-6">
114-
<span className="text-gray-700 mb-4">Filter by</span>
115-
<div className="mt-6 mb-6">
116-
{filterOptions.map((option, i) => (
117-
<FilterOption
118-
key={`option-${i}`}
119-
defaultChecked={filterBy === option.value}
120-
label={option.label}
121-
value={option.value}
122-
data={filterBy}
123-
name="filter-by-option"
124-
onChange={handleFilterByChange}
125-
/>
126-
))}
127-
</div>
111+
<div className="lg:flex flex-col mr-8 hidden mt-6 space-y-6">
112+
<div>
113+
<span className="text-gray-700">Filter by</span>
114+
<div className="mt-3 space-y-1">
115+
{filterOptions.map((option, i) => (
116+
<FilterOption
117+
key={`option-${i}`}
118+
defaultChecked={filterBy === option.value}
119+
label={option.label}
120+
value={option.value}
121+
data={filterBy}
122+
name="filter-by-option"
123+
onChange={handleFilterByChange}
124+
/>
125+
))}
128126
</div>
129127
</div>
130128

131-
<div className="pt-4">
132-
<div className="block">
133-
<span className="text-gray-700 mb-4">Sort</span>
134-
<div className="mt-6 mb-6">
135-
{sortingOptions.map((option, i) => (
136-
<FilterOption
137-
key={`sorting-option-${i}`}
138-
defaultChecked={sortBy === option.value}
139-
label={option.label}
140-
value={option.value}
141-
data={sortBy}
142-
name="sort-by-option"
143-
onChange={handleSortByChange}
144-
/>
145-
))}
146-
</div>
129+
<div>
130+
<span className="text-gray-700">Sort</span>
131+
<div className="mt-3 space-y-1">
132+
{sortingOptions.map((option, i) => (
133+
<FilterOption
134+
key={`sorting-option-${i}`}
135+
defaultChecked={sortBy === option.value}
136+
label={option.label}
137+
value={option.value}
138+
data={sortBy}
139+
name="sort-by-option"
140+
onChange={handleSortByChange}
141+
/>
142+
))}
147143
</div>
148144
</div>
149145
</div>

src/components/sections/communities/overview/scoreboard/_partials/FilterOption.tsx

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,14 @@ export default function FilterOption({ label = "", value = "", data = "", name =
3333
const isChecked = useMemo(() => value.toString().toLowerCase() === data.toLowerCase(), [data, value]);
3434

3535
return (
36-
<div className="mt-2 mb-2">
37-
<label className="inline-flex items-center">
38-
<Radio disabled={isChecked} {...props} name={name} data={data} value={value} className="w-8" />
39-
<span
40-
className={classNames("ml-4", {
41-
"font-bold": isChecked,
42-
})}
43-
>
44-
{label}
45-
</span>
36+
<div className="flex items-center gap-2">
37+
<Radio disabled={isChecked} {...props} name={name} data={data} value={value} className="!w-4.5 !h-4.5 mx-0" />
38+
<label
39+
className={classNames("text-sm", {
40+
"font-bold": isChecked,
41+
})}
42+
>
43+
{label}
4644
</label>
4745
</div>
4846
);

src/components/ui/Radio.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import React, { HTMLProps, useMemo } from "react";
33

44
interface RadioProps extends HTMLProps<HTMLInputElement> {
55
communityStyles?: boolean;
6+
className?: string;
67
}
78

89
const colors = {
@@ -20,10 +21,10 @@ const colors = {
2021
* @typedef {RadioProps}
2122
*/
2223

23-
export default function Radio({ disabled, communityStyles, ...props }: RadioProps) {
24+
export default function Radio({ disabled, communityStyles, className = "", ...props }: RadioProps) {
2425
const styles = useMemo(() => (!communityStyles ? {} : { color: colors?.textAccent }), [communityStyles]);
2526

26-
const radioClassName = classNames("w-9 h-9 border-gray-400 text-primary rounded-full", { "cursor-not-allowed border-4": disabled }, { "cursor-pointer": !disabled });
27+
const radioClassName = classNames("w-9 h-9 border-gray-400 text-primary rounded-full", { "cursor-not-allowed border-4": disabled }, { "cursor-pointer": !disabled }, className);
2728

2829
return <input disabled {...props} className={radioClassName} style={styles} type="radio" />;
2930
}

0 commit comments

Comments
 (0)