-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
103 changed files
with
11,067 additions
and
1,127 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
}, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import React from "react" | ||
|
||
import { CategoryFilter } from "./CategoryFilter" | ||
|
||
type CategoriesFiltersProps = { | ||
categories: { name: string; active: boolean; count: number }[] | ||
onChange: ( | ||
newCategories: { name: string; active: boolean; count: number }[] | ||
) => void | ||
onlyActives?: boolean | ||
filtersIcon?: JSX.Element | ||
unremovableFilters?: boolean | ||
} | ||
|
||
export const CategoriesFilters = ({ | ||
categories, | ||
onChange, | ||
filtersIcon, | ||
onlyActives, | ||
unremovableFilters, | ||
}: CategoriesFiltersProps) => { | ||
function handleCategorySelection( | ||
action: "add" | "remove", | ||
categoryId: string | ||
): { name: string; active: boolean; count: number }[] { | ||
let currentCategories = categories.filter(({ active }) => active) | ||
if (action === "add") { | ||
if (!currentCategories.find(({ name }) => name === categoryId)) { | ||
const category = { | ||
...categories.find(({ name }) => name === categoryId)!, | ||
} | ||
category.active = true | ||
currentCategories.push(category) | ||
} | ||
} | ||
|
||
if (action === "remove") { | ||
currentCategories = currentCategories.filter( | ||
({ name }) => name !== categoryId | ||
) | ||
} | ||
|
||
return currentCategories | ||
} | ||
|
||
return ( | ||
<> | ||
{categories | ||
.filter(({ active }) => { | ||
if (onlyActives) { | ||
return active | ||
} else { | ||
return true | ||
} | ||
}) | ||
.map((category) => ( | ||
<CategoryFilter | ||
key={category.name} | ||
category={category.name} | ||
active={category.active} | ||
onChange={(_e, { active, category }) => { | ||
const newOnes = handleCategorySelection( | ||
active ? "add" : !unremovableFilters ? "remove" : "add", | ||
category | ||
) | ||
if ( | ||
categories.filter(({ active }) => active).length != | ||
newOnes.length | ||
) { | ||
onChange(newOnes) | ||
} | ||
}} | ||
actionIcon={filtersIcon} | ||
/> | ||
))} | ||
</> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
.categories-list__box { | ||
background-color: var(--secondary-on-modal-hover); | ||
width: 248px; | ||
padding: 16px; | ||
border-radius: 10px; | ||
} | ||
|
||
.categories-list__title { | ||
margin-bottom: 15px; | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.categories-list__title > p { | ||
color: var(--secondary-text); | ||
letter-spacing: 1px; | ||
font-weight: 700; | ||
font-size: 14px; | ||
margin: 0 16px 0 0; | ||
text-transform: uppercase; | ||
} | ||
|
||
.categories-list__title > .ui.label { | ||
font-weight: 700; | ||
font-size: 8px; | ||
background-color: var(--primary); | ||
padding: 2px 5px; | ||
line-height: normal; | ||
border-radius: 3px; | ||
color: var(--text-on-primary); | ||
} | ||
|
||
.categories-list__listing { | ||
display: flex; | ||
flex-direction: column; | ||
} | ||
|
||
.categories-list__listing > .category-filter__box { | ||
margin-bottom: 8px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import React from "react" | ||
|
||
import useFormatMessage from "decentraland-gatsby/dist/hooks/useFormatMessage" | ||
import Label from "semantic-ui-react/dist/commonjs/elements/Label" | ||
|
||
import { Check } from "../Icon/Check" | ||
import { CategoriesFilters } from "./CategoriesFilters" | ||
|
||
import "./CategoriesList.css" | ||
|
||
type CategoriesListProps = { | ||
onChange: ( | ||
categories: { name: string; active: boolean; count: number }[] | ||
) => void | ||
categories: { name: string; active: boolean; count: number }[] | ||
} | ||
|
||
export const CategoriesList = React.memo( | ||
({ categories, onChange }: CategoriesListProps) => { | ||
const l = useFormatMessage() | ||
|
||
return ( | ||
<div className="categories-list__box"> | ||
<div className="categories-list__title"> | ||
<p>{l("categories.title")}</p> | ||
<Label>{l("categories.new_label")}</Label> | ||
</div> | ||
<div className="categories-list__listing"> | ||
{ | ||
<CategoriesFilters | ||
categories={categories} | ||
onChange={onChange} | ||
filtersIcon={<Check />} | ||
unremovableFilters | ||
/> | ||
} | ||
</div> | ||
</div> | ||
) | ||
} | ||
) |
Oops, something went wrong.