Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,38 +26,50 @@ function BreadcrumbsItemLink({
}): JSX.Element {
const className = clsx('breadcrumbs__link', styles.breadcrumbsItemLink);
return href ? (
<Link className={className} href={href}>
{children}
<Link className={className} href={href} itemProp="item">
<span itemProp="name">{children}</span>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we really need the extra span here and why?

Can't we apply "name" to the link directly?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I've experimented. Without the span, the name is not correctly recognized.

</Link>
) : (
<span className={className}>{children}</span>
<span className={className} itemProp="item name">
{children}
</span>
);
}

// TODO move to design system folder
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not even sure what "design system folder" is, and my intuition tells me I don't like this direction😅 Is that like theme-common?

Copy link
Copy Markdown
Collaborator

@slorber slorber Feb 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Josh-Cena it's a good practice to have a design system for the consistency of any React app

We already have one design system anyway: Infima, but it's a CSS one

As we are in React land, we should create a well-encapsulated abstraction on top (think "infima-react") instead of using infima class names and low-level dom elements everywhere in our theme.

This is related to the theme vision in #6649 (comment)

This is not the same as theme-common, because it's not shared

In general, we should have a good separation of micro layouts (https://web.dev/learn/design/micro-layouts/) vs macro layouts (https://web.dev/learn/design/macro-layouts/) and try to keep technical code out of these

Design system components are particularly suited to be swizzled (eject + copy)

Component users should not have to think about classes, but only props

The design system should be well-encapsulated and prevent impossible/arbitrary UI states

You might also like:
https://www.codercto.com/a/106766.html
https://blog.twitter.com/engineering/en_us/topics/infrastructure/2019/buildingfasterwithcomponents

function BreadcrumbsItem({
children,
active,
index,
}: {
children: ReactNode;
active?: boolean;
index: number;
}): JSX.Element {
return (
<li
itemScope
itemProp="itemListElement"
itemType="https://schema.org/ListItem"
className={clsx('breadcrumbs__item', {
'breadcrumbs__item--active': active,
})}>
{children}
<meta itemProp="position" content={String(index + 1)} />
</li>
);
}

function HomeBreadcrumbItem() {
const homeHref = useBaseUrl('/');
return (
<BreadcrumbsItem>
<BreadcrumbsItemLink href={homeHref}>🏠</BreadcrumbsItemLink>
</BreadcrumbsItem>
<li className="breadcrumbs__item">
Comment thread
Josh-Cena marked this conversation as resolved.
<Link
className={clsx('breadcrumbs__link', styles.breadcrumbsItemLink)}
href={homeHref}>
🏠
</Link>
</li>
);
}

Expand All @@ -76,10 +88,16 @@ export default function DocBreadcrumbs(): JSX.Element | null {
styles.breadcrumbsContainer,
)}
aria-label="breadcrumbs">
<ul className="breadcrumbs">
<ul
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

similarly, I didn't do it yet but this must be encapsulated under a <Breadcrumbs> component

className="breadcrumbs"
itemScope
itemType="https://schema.org/BreadcrumbList">
{homePageRoute && <HomeBreadcrumbItem />}
{breadcrumbs.map((item, idx) => (
<BreadcrumbsItem key={idx} active={idx === breadcrumbs.length - 1}>
<BreadcrumbsItem
key={idx}
active={idx === breadcrumbs.length - 1}
index={idx}>
<BreadcrumbsItemLink href={item.href}>
{item.label}
</BreadcrumbsItemLink>
Expand Down