-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #123 from TienNHM/UI
improve showcase
- Loading branch information
Showing
9 changed files
with
123 additions
and
123 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
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,67 @@ | ||
import Translate, { translate } from "@docusaurus/Translate"; | ||
import { ProjectTagList, ProjectTags } from "@site/src/shared/constants/ProjectConsts"; | ||
import Heading from "@theme/Heading"; | ||
import clsx from "clsx"; | ||
import React from "react"; | ||
import ShowcaseFilterToggle from "../ShowcaseFilterToggle"; | ||
import ShowcaseTagSelect from "../ShowcaseTagSelect"; | ||
import ShowcaseTooltip from "../ShowcaseTooltip"; | ||
import { useFilteredUsers } from "../ShowcaseUserState"; | ||
import { usePluralForm } from "@docusaurus/theme-common"; | ||
import styles from './styles.module.css' | ||
|
||
export function useSiteCountPlural() { | ||
const { selectMessage } = usePluralForm(); | ||
return (sitesCount: number) => | ||
selectMessage( | ||
sitesCount, | ||
translate( | ||
{ | ||
id: 'showcase.filters.resultCount', | ||
description: 'The number of sites found', | ||
message: '{sitesCount} sites', | ||
}, | ||
{ sitesCount }, | ||
), | ||
); | ||
} | ||
|
||
export default function ShowcaseFilters() { | ||
const filteredUsers = useFilteredUsers(); | ||
const siteCountPlural = useSiteCountPlural(); | ||
return ( | ||
<section className="container margin-top--l margin-bottom--lg"> | ||
<div className={clsx('margin-bottom--sm', styles.filterCheckbox)}> | ||
<div> | ||
<Heading as="h2"> | ||
<Translate id="showcase.filters.title">Filters</Translate> | ||
</Heading> | ||
<span>{siteCountPlural(filteredUsers.length)}</span> | ||
</div> | ||
<ShowcaseFilterToggle /> | ||
</div> | ||
<ul className={clsx('clean-list', styles.checkboxList)}> | ||
{ProjectTagList.map((tag, i) => { | ||
const { label, description, color } = ProjectTags[tag]; | ||
const id = `showcase_checkbox_id_${tag}`; | ||
|
||
return ( | ||
<li key={i} className={styles.checkboxListItem}> | ||
<ShowcaseTooltip id={id} text={description} anchorEl="#__docusaurus"> | ||
<ShowcaseTagSelect tag={tag} id={id} label={label} | ||
icon={ | ||
tag === 'favorite' ? ( | ||
<span style={{ marginLeft: '8px' }}>⭐</span> | ||
) : ( | ||
<span className={clsx(styles.dotColor)} style={{ backgroundColor: color }} /> | ||
) | ||
} | ||
/> | ||
</ShowcaseTooltip> | ||
</li> | ||
); | ||
})} | ||
</ul> | ||
</section> | ||
); | ||
} |
45 changes: 45 additions & 0 deletions
45
src/pages/showcase/_components/ShowcaseFilters/styles.module.css
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,45 @@ | ||
.filterCheckbox { | ||
justify-content: space-between; | ||
} | ||
|
||
.filterCheckbox, | ||
.checkboxList { | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.filterCheckbox > div:first-child { | ||
display: flex; | ||
flex: 1 1 auto; | ||
align-items: center; | ||
} | ||
|
||
.filterCheckbox > div > * { | ||
margin-bottom: 0; | ||
margin-right: 8px; | ||
} | ||
|
||
.checkboxList { | ||
flex-wrap: wrap; | ||
} | ||
|
||
.checkboxListItem { | ||
-webkit-user-select: none; | ||
user-select: none; | ||
white-space: nowrap; | ||
height: 32px; | ||
font-size: 0.8rem; | ||
margin-top: 0.5rem; | ||
margin-right: 0.5rem; | ||
} | ||
|
||
.checkboxListItem:last-child { | ||
margin-right: 0; | ||
} | ||
|
||
.dotColor { | ||
width: 10px; | ||
height: 10px; | ||
border-radius: 50%; | ||
margin-left: 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
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 |
---|---|---|
@@ -1,45 +0,0 @@ | ||
.filterCheckbox { | ||
justify-content: space-between; | ||
} | ||
|
||
.filterCheckbox, | ||
.checkboxList { | ||
display: flex; | ||
align-items: center; | ||
} | ||
|
||
.filterCheckbox > div:first-child { | ||
display: flex; | ||
flex: 1 1 auto; | ||
align-items: center; | ||
} | ||
|
||
.filterCheckbox > div > * { | ||
margin-bottom: 0; | ||
margin-right: 8px; | ||
} | ||
|
||
.checkboxList { | ||
flex-wrap: wrap; | ||
} | ||
|
||
.checkboxListItem { | ||
-webkit-user-select: none; | ||
user-select: none; | ||
white-space: nowrap; | ||
height: 32px; | ||
font-size: 0.8rem; | ||
margin-top: 0.5rem; | ||
margin-right: 0.5rem; | ||
} | ||
|
||
.checkboxListItem:last-child { | ||
margin-right: 0; | ||
} | ||
|
||
.dotColor { | ||
width: 10px; | ||
height: 10px; | ||
border-radius: 50%; | ||
margin-left: 8px; | ||
} | ||