Skip to content

Commit

Permalink
Merge pull request #2264 from zeitgeistpm/tr-new-categories
Browse files Browse the repository at this point in the history
New categories
  • Loading branch information
Robiquet authored Feb 16, 2024
2 parents c56f9fd + 6379de9 commit 7d1123d
Show file tree
Hide file tree
Showing 20 changed files with 21 additions and 10 deletions.
7 changes: 4 additions & 3 deletions components/front-page/PopularCategories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ export const CATEGORIES = [
{ name: "Technology", imagePath: "/category/technology.png" },
{ name: "Crypto", imagePath: "/category/crypto.png" },
{ name: "Science", imagePath: "/category/science.png" },
{ name: "E-Sports", imagePath: "/category/e-sports.png" },
{ name: "News", imagePath: "/category/news.png" },
{ name: "Dotsama", imagePath: "/category/dotsama.png" },
{ name: "Zeitgeist", imagePath: "/category/zeitgeist.png" },
{ name: "Entertainment", imagePath: "/category/entertainment.png" },
{ name: "Finance", imagePath: "/category/finance.png" },
] as const;

const Category = ({
Expand All @@ -32,7 +33,7 @@ const Category = ({
className="ztg-transition flex w-full min-w-[80px] flex-1 flex-col md:hover:scale-[1.035]"
data-testid="category"
>
<div className="relative aspect-square h-full w-full">
<div className="relative aspect-square h-full w-full">
<Link
href={`/markets?status=Active&tag=${title}#market-list`}
className="relative block h-full w-full"
Expand Down Expand Up @@ -74,7 +75,7 @@ const PopularCategories: FC<{
placeholder: imagePlaceholders[index],
}))
.sort((a, b) => b.count - a.count)
.slice(0, 6);
.slice(0, 8);

return (
<div className="flex flex-col" data-testid="popularCategories">
Expand Down
14 changes: 10 additions & 4 deletions components/top-bar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -267,9 +267,17 @@ const GetTokensButton = () => {

const CategoriesMenu = ({ onSelect }: { onSelect: () => void }) => {
const { data: counts } = useCategoryCounts();

const topCategories = CATEGORIES.map((category, index) => ({
...category,
count: counts?.[index] ?? 0,
}))
.sort((a, b) => b.count - a.count)
.slice(0, 9);

return (
<div className="grid grid-flow-row-dense grid-cols-2 md:h-full md:grid-cols-3">
{CATEGORIES.map((category, index) => (
{topCategories.map((category, index) => (
<Link
key={index}
onClick={onSelect}
Expand All @@ -286,9 +294,7 @@ const CategoriesMenu = ({ onSelect }: { onSelect: () => void }) => {
</div>
<div className="flex flex-col">
<div className="font-light">{category.name}</div>
<div className="h-[16px] text-xs font-light">
{counts ? counts[index] : ""}
</div>
<div className="h-[16px] text-xs font-light">{category.count}</div>
</div>
</Link>
))}
Expand Down
4 changes: 3 additions & 1 deletion lib/constants/category-images.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,11 @@ export const CATEGORY_IMAGES = union<(typeof tags)[number]>().exhaustAsRecord({
Technology: range(1, 5).map((i) => `/categories/tech/${i}.png`),
Crypto: range(1, 5).map((i) => `/categories/crypto/${i}.png`),
Science: range(1, 5).map((i) => `/categories/science/${i}.png`),
"E-Sports": range(1, 6).map((i) => `/categories/esports/${i}.png`),
News: range(1, 6).map((i) => `/categories/news/${i}.png`),
Dotsama: range(1, 2).map((i) => `/categories/dotsama/${i}.png`),
Zeitgeist: range(1, 2).map((i) => `/categories/zeitgeist/${i}.png`),
Finance: range(1, 5).map((i) => `/categories/finance/${i}.png`),
//todo: add selections for entertainment
Entertainment: range(1, 2).map((i) => `/categories/zeitgeist/${i}.png`),
untagged: range(1, 2).map((i) => `/categories/zeitgeist/${i}.png`),
});
3 changes: 2 additions & 1 deletion lib/constants/market-filter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ export const categoryImages: Record<
Technology: "/category/technology.png",
Crypto: "/category/crypto.png",
Science: "/category/science.png",
"E-Sports": "/category/e-sports.png",
Zeitgeist: "/category/zeitgeist.png",
Dotsama: "/category/dotsama.png",
News: "/category/news.png",
Entertainment: "/category/entertainment.png",
Finance: "/category/finance.png",
} as const;

export const marketTagFilterOptions: MarketTagFilter[] = defaultTags.map(
Expand Down
3 changes: 2 additions & 1 deletion lib/constants/markets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ export const prodTags = [
"Science",
"News",
"Sports",
"E-Sports",
"Entertainment",
"Finance",
] as const;

const otherTags = process.env.NEXT_PUBLIC_OTHER_TAGS
Expand Down
Binary file added public/categories/finance/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/categories/finance/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/categories/finance/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/categories/finance/4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/category/crypto.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/category/dotsama.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed public/category/e-sports.png
Binary file not shown.
Binary file added public/category/entertainment.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/category/finance.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/category/news.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/category/politics.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/category/science.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/category/sports.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/category/technology.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified public/category/zeitgeist.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 7d1123d

Please sign in to comment.