mirror of
https://github.com/facebook/docusaurus.git
synced 2025-08-06 10:20:09 +02:00
wip
This commit is contained in:
parent
c7cbafc88c
commit
5b6626bcf4
4 changed files with 23 additions and 33 deletions
|
@ -250,10 +250,8 @@ declare module '@theme/BlogPostItems' {
|
||||||
declare module '@theme/Showcase' {
|
declare module '@theme/Showcase' {
|
||||||
import type {ShowcaseItem} from '@docusaurus/plugin-content-showcase';
|
import type {ShowcaseItem} from '@docusaurus/plugin-content-showcase';
|
||||||
|
|
||||||
export type User = ShowcaseItem;
|
|
||||||
|
|
||||||
export type Props = {
|
export type Props = {
|
||||||
content: User[];
|
items: ShowcaseItem[];
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function Showcase(props: Props): JSX.Element;
|
export default function Showcase(props: Props): JSX.Element;
|
||||||
|
@ -262,7 +260,7 @@ declare module '@theme/Showcase' {
|
||||||
declare module '@theme/Showcase/FavoriteIcon' {
|
declare module '@theme/Showcase/FavoriteIcon' {
|
||||||
export interface Props {
|
export interface Props {
|
||||||
className?: string;
|
className?: string;
|
||||||
style?: ComponentProps<'svg'>['style'];
|
style?: React.ComponentProps<'svg'>['style'];
|
||||||
size: 'small' | 'medium' | 'large';
|
size: 'small' | 'medium' | 'large';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -273,7 +271,7 @@ declare module '@theme/Showcase/ShowcaseCard' {
|
||||||
import type {ShowcaseItem} from '@docusaurus/plugin-content-showcase';
|
import type {ShowcaseItem} from '@docusaurus/plugin-content-showcase';
|
||||||
|
|
||||||
export interface Props {
|
export interface Props {
|
||||||
readonly user: ShowcaseItem;
|
readonly item: ShowcaseItem;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function ShowcaseCard(props: Props): JSX.Element;
|
export default function ShowcaseCard(props: Props): JSX.Element;
|
||||||
|
@ -282,16 +280,7 @@ declare module '@theme/Showcase/ShowcaseCard' {
|
||||||
declare module '@theme/Showcase/ShowcaseCards' {
|
declare module '@theme/Showcase/ShowcaseCards' {
|
||||||
export default function ShowcaseCards(): JSX.Element;
|
export default function ShowcaseCards(): JSX.Element;
|
||||||
}
|
}
|
||||||
declare module '@theme/Showcase/ShowcaseTooltip' {
|
|
||||||
export interface Props {
|
|
||||||
anchorEl?: HTMLElement | string;
|
|
||||||
id: string;
|
|
||||||
text: string;
|
|
||||||
children: React.ReactElement;
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function ShowcaseTooltip(props: Props): JSX.Element;
|
|
||||||
}
|
|
||||||
declare module '@theme/Showcase/ShowcaseTagSelect' {
|
declare module '@theme/Showcase/ShowcaseTagSelect' {
|
||||||
import {type ComponentProps, type ReactElement} from 'react';
|
import {type ComponentProps, type ReactElement} from 'react';
|
||||||
import type {TagType} from '@docusaurus/plugin-content-showcase';
|
import type {TagType} from '@docusaurus/plugin-content-showcase';
|
||||||
|
@ -301,15 +290,12 @@ declare module '@theme/Showcase/ShowcaseTagSelect' {
|
||||||
label: string;
|
label: string;
|
||||||
description: string;
|
description: string;
|
||||||
icon: ReactElement<ComponentProps<'svg'>>;
|
icon: ReactElement<ComponentProps<'svg'>>;
|
||||||
|
// TODO: update this type
|
||||||
|
rest?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function ShowcaseTagSelect(props: Props): JSX.Element;
|
export default function ShowcaseTagSelect(props: Props): JSX.Element;
|
||||||
}
|
}
|
||||||
declare module '@theme/Showcase/ShowcaseFilterToggle' {
|
|
||||||
export type Operator = 'OR' | 'AND';
|
|
||||||
|
|
||||||
export default function ShowcaseFilterToggle(): JSX.Element;
|
|
||||||
}
|
|
||||||
|
|
||||||
declare module '@theme/Showcase/ShowcaseFilters' {
|
declare module '@theme/Showcase/ShowcaseFilters' {
|
||||||
export default function ShowcaseFilters(): JSX.Element;
|
export default function ShowcaseFilters(): JSX.Element;
|
||||||
|
|
|
@ -64,27 +64,28 @@ function getCardImage(user: ShowcaseItem): string {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function ShowcaseCard({user}: {user: ShowcaseItem}) {
|
function ShowcaseCard({item}: {item: ShowcaseItem}) {
|
||||||
const image = getCardImage(user);
|
console.log('ShowcaseCard user:', item);
|
||||||
|
const image = getCardImage(item);
|
||||||
return (
|
return (
|
||||||
<li key={user.title} className="card shadow--md">
|
<li key={item.title} className="card shadow--md">
|
||||||
<div className={clsx('card__image', styles.showcaseCardImage)}>
|
<div className={clsx('card__image', styles.showcaseCardImage)}>
|
||||||
{/* TODO change back to ideal image */}
|
{/* TODO change back to ideal image */}
|
||||||
<img src={image} alt={user.title} />
|
<img src={image} alt={item.title} />
|
||||||
</div>
|
</div>
|
||||||
<div className="card__body">
|
<div className="card__body">
|
||||||
<div className={clsx(styles.showcaseCardHeader)}>
|
<div className={clsx(styles.showcaseCardHeader)}>
|
||||||
<Heading as="h4" className={styles.showcaseCardTitle}>
|
<Heading as="h4" className={styles.showcaseCardTitle}>
|
||||||
<Link href={user.website} className={styles.showcaseCardLink}>
|
<Link href={item.website} className={styles.showcaseCardLink}>
|
||||||
{user.title}
|
{item.title}
|
||||||
</Link>
|
</Link>
|
||||||
</Heading>
|
</Heading>
|
||||||
{user.tags.includes('favorite') && (
|
{item.tags.includes('favorite') && (
|
||||||
<FavoriteIcon size="medium" style={{marginRight: '0.25rem'}} />
|
<FavoriteIcon size="medium" style={{marginRight: '0.25rem'}} />
|
||||||
)}
|
)}
|
||||||
{user.source && (
|
{item.source && (
|
||||||
<Link
|
<Link
|
||||||
href={user.source}
|
href={item.source}
|
||||||
className={clsx(
|
className={clsx(
|
||||||
'button button--secondary button--sm',
|
'button button--secondary button--sm',
|
||||||
styles.showcaseCardSrcBtn,
|
styles.showcaseCardSrcBtn,
|
||||||
|
@ -93,10 +94,10 @@ function ShowcaseCard({user}: {user: ShowcaseItem}) {
|
||||||
</Link>
|
</Link>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
<p className={styles.showcaseCardBody}>{user.description}</p>
|
<p className={styles.showcaseCardBody}>{item.description}</p>
|
||||||
</div>
|
</div>
|
||||||
<ul className={clsx('card__footer', styles.cardFooter)}>
|
<ul className={clsx('card__footer', styles.cardFooter)}>
|
||||||
<ShowcaseCardTag tags={user.tags} />
|
<ShowcaseCardTag tags={item.tags} />
|
||||||
</ul>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
);
|
);
|
||||||
|
|
|
@ -52,12 +52,13 @@ function CardList({
|
||||||
heading?: ReactNode;
|
heading?: ReactNode;
|
||||||
items: ShowcaseItem[];
|
items: ShowcaseItem[];
|
||||||
}) {
|
}) {
|
||||||
|
console.log('CardList items:', items);
|
||||||
return (
|
return (
|
||||||
<div className="container">
|
<div className="container">
|
||||||
{heading}
|
{heading}
|
||||||
<ul className={clsx('clean-list', styles.cardList)}>
|
<ul className={clsx('clean-list', styles.cardList)}>
|
||||||
{items.map((item) => (
|
{items.map((item) => (
|
||||||
<ShowcaseCard key={item.title} user={item} />
|
<ShowcaseCard key={item.title} item={item} />
|
||||||
))}
|
))}
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
@ -76,6 +77,7 @@ function NoResultSection() {
|
||||||
|
|
||||||
export default function ShowcaseCards(): JSX.Element {
|
export default function ShowcaseCards(): JSX.Element {
|
||||||
const users = useShowcase().items;
|
const users = useShowcase().items;
|
||||||
|
console.log('ShowcaseCards users:', users);
|
||||||
|
|
||||||
const filteredUsers = useFilteredUsers(users);
|
const filteredUsers = useFilteredUsers(users);
|
||||||
|
|
||||||
|
@ -88,10 +90,12 @@ export default function ShowcaseCards(): JSX.Element {
|
||||||
const favoriteUsers = sortedUsers.filter((user: ShowcaseItem) =>
|
const favoriteUsers = sortedUsers.filter((user: ShowcaseItem) =>
|
||||||
user.tags.includes('favorite'),
|
user.tags.includes('favorite'),
|
||||||
);
|
);
|
||||||
|
console.log('favoriteUsers:', favoriteUsers);
|
||||||
|
|
||||||
const otherUsers = sortedUsers.filter(
|
const otherUsers = sortedUsers.filter(
|
||||||
(user: ShowcaseItem) => !user.tags.includes('favorite'),
|
(user: ShowcaseItem) => !user.tags.includes('favorite'),
|
||||||
);
|
);
|
||||||
|
console.log('otherUsers:', otherUsers);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<section className="margin-top--lg margin-bottom--xl">
|
<section className="margin-top--lg margin-bottom--xl">
|
||||||
|
|
|
@ -38,9 +38,8 @@ function ShowcaseHeader() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Showcase(props: Props): JSX.Element {
|
export default function Showcase(props: Props): JSX.Element {
|
||||||
const users = props.content;
|
|
||||||
return (
|
return (
|
||||||
<ShowcaseProvider content={{items: users}}>
|
<ShowcaseProvider content={{items: props.items}}>
|
||||||
<Layout title={TITLE} description={DESCRIPTION}>
|
<Layout title={TITLE} description={DESCRIPTION}>
|
||||||
<main className="margin-vert--lg">
|
<main className="margin-vert--lg">
|
||||||
<ShowcaseHeader />
|
<ShowcaseHeader />
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue