Skip to content

Commit

Permalink
Merge 9dce22b into 15e7153
Browse files Browse the repository at this point in the history
  • Loading branch information
2fd committed Oct 16, 2023
2 parents 15e7153 + 9dce22b commit 4dab874
Show file tree
Hide file tree
Showing 125 changed files with 11,189 additions and 1,133 deletions.
12 changes: 3 additions & 9 deletions src/__data__/categories.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
import { CategoryAttributes } from "../entities/Category/types"

export const categories: CategoryAttributes[] = [
export const categoriesWithPlacesCount = [
{
name: "Art",
active: true,
created_at: new Date("2023-04-01T04:53:07.000Z"),
updated_at: new Date("2023-04-01T04:53:07.000Z"),
count: "10",
},
{
name: "music",
active: true,
created_at: new Date("2023-04-01T04:53:07.000Z"),
updated_at: new Date("2023-04-01T04:53:07.000Z"),
count: "10",
},
]
5 changes: 1 addition & 4 deletions src/__data__/placeGenesisPlaza.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,15 @@ export const placeGenesisPlaza: PlaceAttributes = {
like_score: 0,
highlighted: false,
highlighted_image: null,
featured: false,
featured_image: null,
disabled: false,
updated_at: new Date("2023-03-28T18:37:39.918Z"),
categories: [],
world: false,
world_name: null,
title: "Genesis Plaza",
description:
"Jump in to strike up a chat with other visitors, retake the commands tutorial with a cute floating robot, or dive into the swirling portal to get to Decentraland's visitor center.",
owner: null,
image: "https://decentraland.org/images/thumbnail/genesis-plaza.png",
tags: ["plaza"],
base_position: "-9,-9",
positions: [
"-1,-1",
Expand Down Expand Up @@ -415,4 +411,5 @@ export const placeGenesisPlaza: PlaceAttributes = {
deployed_at: new Date("2022-11-14T17:22:05.307Z"),
hidden: false,
textsearch: undefined,
categories: [],
}
3 changes: 0 additions & 3 deletions src/__data__/placeGenesisPlazaWithAggregatedAttributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export const placeGenesisPlazaWithAggregatedAttributes: AggregatePlaceAttributes
"Jump in to strike up a chat with other visitors, retake the commands tutorial with a cute floating robot, or dive into the swirling portal to get to Decentraland's visitor center.",
image: "https://localhost:8000/images/places/genesis_plaza.jpg",
owner: null,
tags: [],
positions: [
"-1,-1",
"-1,-2",
Expand Down Expand Up @@ -408,8 +407,6 @@ export const placeGenesisPlazaWithAggregatedAttributes: AggregatePlaceAttributes
like_score: 0,
highlighted: true,
highlighted_image: "/images/places/genesis_plaza_banner.jpg",
featured: false,
featured_image: null,
user_favorite: false,
user_like: false,
user_dislike: false,
Expand Down
5 changes: 1 addition & 4 deletions src/__data__/placeRoad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,14 @@ export const placeRoad: PlaceAttributes = {
like_score: 0,
highlighted: false,
highlighted_image: null,
featured: false,
featured_image: null,
disabled: false,
updated_at: new Date("2023-03-28T18:37:39.918Z"),
categories: [],
world: false,
world_name: null,
title: "Road at -89,11 (open road OpenRoad_C)",
description: null,
owner: null,
image: "https://decentraland.org/images/thumbnail/road.png",
tags: ["road"],
base_position: "-89,11",
positions: ["-89,11"],
contact_name: "Decentraland Foundation",
Expand All @@ -33,4 +29,5 @@ export const placeRoad: PlaceAttributes = {
deployed_at: new Date("2022-11-14T17:22:05.307Z"),
hidden: false,
textsearch: undefined,
categories: [],
}
15 changes: 3 additions & 12 deletions src/__data__/world.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ export const worldPlaceParalax: PlaceAttributes = {
image:
"https://api.decentraland.org/v2/map.png?height=1024&width=1024&selected=0%2C0&center=0%2C0&size=20",
owner: null,
tags: [],
positions: ["0,0"],
base_position: "0,0",
contact_name: "paralax",
Expand All @@ -31,17 +30,15 @@ export const worldPlaceParalax: PlaceAttributes = {
likes: 0,
dislikes: 0,
like_score: 0,
categories: [],
like_rate: 0.5,
highlighted: false,
highlighted_image: null,
featured: false,
featured_image: null,
world: true,
world_name: "paralax.dcl.eth",
deployed_at: new Date("2023-03-28T13:05:45.437Z"),
hidden: false,
textsearch: undefined,
categories: [],
}

export const worldPlaceParalaxWithAggregated: AggregatePlaceAttributes = {
Expand All @@ -51,7 +48,6 @@ export const worldPlaceParalaxWithAggregated: AggregatePlaceAttributes = {
image:
"https://api.decentraland.org/v2/map.png?height=1024&width=1024&selected=0%2C0&center=0%2C0&size=20",
owner: null,
tags: [],
positions: ["0,0"],
base_position: "0,0",
contact_name: "paralax",
Expand All @@ -64,13 +60,10 @@ export const worldPlaceParalaxWithAggregated: AggregatePlaceAttributes = {
favorites: 0,
likes: 0,
dislikes: 0,
categories: [],
like_rate: 0.5,
like_score: 0,
highlighted: false,
highlighted_image: null,
featured: false,
featured_image: null,
world: true,
world_name: "paralax.dcl.eth",
deployed_at: new Date("2023-03-28T13:05:45.437Z"),
Expand All @@ -79,6 +72,7 @@ export const worldPlaceParalaxWithAggregated: AggregatePlaceAttributes = {
user_like: false,
user_dislike: false,
textsearch: undefined,
categories: [],
}

export const worldContentEntitySceneParalax: ContentEntityScene = {
Expand Down Expand Up @@ -199,7 +193,6 @@ export const worldPlaceTemplegame: AggregatePlaceAttributes = {
image:
"https://peer.decentraland.org/content/contents/bafkreiag7fylur5qlntcxb2oyaw3asmchxsbhoxnw6iipayfgj4wwmqkli",
owner: null,
tags: [],
positions: [
"-1,0",
"-1,1",
Expand Down Expand Up @@ -273,13 +266,10 @@ export const worldPlaceTemplegame: AggregatePlaceAttributes = {
favorites: 0,
likes: 0,
dislikes: 0,
categories: [],
like_rate: 0.5,
like_score: 0,
highlighted: false,
highlighted_image: null,
featured: false,
featured_image: null,
world: true,
world_name: "templegame.dcl.eth",
deployed_at: new Date("2023-05-16T15:44:26.395Z"),
Expand All @@ -289,4 +279,5 @@ export const worldPlaceTemplegame: AggregatePlaceAttributes = {
user_dislike: false,
user_count: 3,
textsearch: undefined,
categories: [],
}
26 changes: 23 additions & 3 deletions src/api/Places.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@ import Options from "decentraland-gatsby/dist/utils/api/Options"
import Time from "decentraland-gatsby/dist/utils/date/Time"
import env from "decentraland-gatsby/dist/utils/env"

import { DecentralandCategories } from "../entities/Category/types"
import {
AggregatePlaceAttributes,
PlaceListOptions,
PlaceListOrderBy,
} from "../entities/Place/types"
import { UpdateUserFavoriteResponse } from "../entities/UserFavorite/types"
import { UpdateUserLikeResponse } from "../entities/UserLikes/types"
Expand Down Expand Up @@ -121,7 +123,7 @@ export default class Places extends API {

async getPlacesHightRated(options?: { limit: number; offset: number }) {
return this.getPlaces({
order_by: "like_rate",
order_by: PlaceListOrderBy.LIKE_SCORE_BEST,
order: "desc",
...options,
})
Expand All @@ -137,16 +139,16 @@ export default class Places extends API {

async getPlacesMostActive(options?: { limit: number; offset: number }) {
return this.getPlaces({
order_by: "most_active",
order_by: PlaceListOrderBy.MOST_ACTIVE,
order: "desc",
...options,
})
}

async getPlacesFeatured(options?: { limit: number; offset: number }) {
return this.getPlaces({
only_featured: true,
...options,
categories: [DecentralandCategories.FEATURED],
})
}

Expand Down Expand Up @@ -192,4 +194,22 @@ export default class Places extends API {
this.options({ method: "PUT" }).json(params).authorization({ sign: true })
)
}

async getCategories() {
const result = await super.fetch<{
ok: boolean
data: { name: string; count: number }[]
}>("/categories")

return result.data
}

async getPlaceCategories(placeId: string) {
const result = await super.fetch<{
ok: boolean
data: { categories: string[] }
}>(`/places/${placeId}/categories`)

return result.data
}
}
15 changes: 15 additions & 0 deletions src/components/Button/CategoryButtons.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.category-buttons__container {
display: flex;
flex-wrap: wrap;
width: 100%;
}

.category-buttons__container > .category-button {
margin: 0 17px 17px 0;
}

.category-buttons__container > .dg.Link.ui.button.category-button {
background-color: var(--text-on-primary);
font-weight: normal;
color: var(--text-on-secondary);
}
38 changes: 38 additions & 0 deletions src/components/Button/CategoryButtons.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import React from "react"

import useFormatMessage from "decentraland-gatsby/dist/hooks/useFormatMessage"
import { Link } from "decentraland-gatsby/dist/plugins/intl"
import TokenList from "decentraland-gatsby/dist/utils/dom/TokenList"
import { Button } from "decentraland-ui/dist/components/Button/Button"

import { PlaceListOrderBy } from "../../entities/Place/types"
import locations from "../../modules/locations"

import "./CategoryButtons.css"

type CategoryButtonsProps = {
categories: string[]
className?: string
}

export const CategoryButtons = (props: CategoryButtonsProps) => {
const { categories, className } = props
const l = useFormatMessage()

return (
<div className={TokenList.join(["category-buttons__container", className])}>
{categories.map((category) => (
<Button
as={Link}
key={category}
className="category-button"
content={l(`categories.${category}`)}
href={locations.places({
categories: [category],
order_by: PlaceListOrderBy.LIKE_SCORE_BEST,
})}
/>
))}
</div>
)
}
33 changes: 33 additions & 0 deletions src/components/Category/CategoryFilter.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.category-filter__box {
margin-right: 8px;
margin-bottom: 8px;
}

.category-filter__box .dcl.filter .filter-background {
background-color: var(--primary);
opacity: 1;
}

.category-filter__box--not-active .dcl.filter .filter-background {
background-color: var(--background);
}

.category-filter__box .dcl.filter > span {
color: var(--text-on-primary);
display: flex;
align-items: center;
}

.category-filter__box.category-filter__box--not-active .dcl.filter > span {
color: var(--text);
}

.category-filter__icon {
width: 20px;
height: 20px;
margin-left: 2px;
}

.category-filter__box > .dcl.filter {
margin-bottom: 2px;
}
41 changes: 41 additions & 0 deletions src/components/Category/CategoryFilter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import React, { useCallback } from "react"

import useFormatMessage from "decentraland-gatsby/dist/hooks/useFormatMessage"
import TokenList from "decentraland-gatsby/dist/utils/dom/TokenList"
import { Filter } from "decentraland-ui/dist/components/Filter/Filter"

import "./CategoryFilter.css"

export type CategoryFilterProps = {
category: string
onChange?: (
e: React.MouseEvent<HTMLSpanElement, MouseEvent>,
props: CategoryFilterProps
) => void
active?: boolean
actionIcon?: React.ReactNode
}

export const CategoryFilter = (props: CategoryFilterProps) => {
const { category, active, onChange, actionIcon } = props
const l = useFormatMessage()

const handleClick = useCallback(
(e) => onChange && onChange(e, { active: !active, category }),
[active, onChange, category]
)
return (
<span
className={TokenList.join([
`category-filter__box`,
!active && "category-filter__box--not-active",
])}
onClick={handleClick}
>
<Filter>
{l(`categories.${category}`)}
{active && <span className="category-filter__icon">{actionIcon}</span>}
</Filter>
</span>
)
}
Loading

0 comments on commit 4dab874

Please sign in to comment.