Skip to content
Open
Show file tree
Hide file tree
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
32 changes: 32 additions & 0 deletions design-system/apps/design-lab/public/assets/bitfun-mascot.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions design-system/apps/design-lab/public/assets/openbitfun-mark.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions design-system/apps/design-lab/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { ComponentsPage } from "./pages/ComponentsPage";
import { GettingStartedPage } from "./pages/GettingStartedPage";
import { ResourcesPage } from "./pages/ResourcesPage";
import { PatternsPage } from "./pages/PatternsPage";
import { MobilePatternsPage } from "./pages/MobilePatternsPage";
import { FlowChatMockPage } from "./pages/FlowChatMockPage";
import { ColorsPage } from "./pages/ColorsPage";
import { SubagentIpPage } from "./pages/SubagentIpPage";
Expand Down Expand Up @@ -64,6 +65,7 @@ type LabRoute =
| { page: "mobile" }
| { page: "brand" }
| { page: "patterns" }
| { page: "mobile-patterns" }
| { page: "flow-chat" }
| { page: "flow-chat-mock" }
| { page: "colors" }
Expand Down Expand Up @@ -122,15 +124,20 @@ function parseRoute(hash: string): LabRoute {
return { page: "getting-started" };
}
if (route === "components") {
// The default component of this route: Web surface or Mobile surface (the rail's two tabs).
return { page: "components" };
}
if (route === "brand" || route.startsWith("brand/")) return { page: "brand" };
if (route === "mobile") {
// Same library page, mobile surface: the rail highlights the Mobile tab.
return { page: "mobile" };
}
if (route === "patterns") {
return { page: "patterns" };
}
if (route === "mobile-patterns") {
return { page: "mobile-patterns" };
}
if (route === "flow-chat") {
return { page: "flow-chat" };
}
Expand Down Expand Up @@ -264,6 +271,13 @@ export function App() {
label: t("nav.patterns"),
route: { page: "patterns" },
},
{
detail: t("scenes.mobile.label"),
icon: Smartphone,
keywords: `mobile patterns scenes phone handheld chat sidebar settings pairing ${t("nav.patterns")}`,
label: `${t("nav.patterns")} · ${t("design.mobile")}`,
route: { page: "mobile-patterns" },
},
{
detail: t("search.flowChatDetail", { count: flowChatComponents.length }),
icon: SquareTerminal,
Expand Down Expand Up @@ -600,6 +614,15 @@ export function App() {
/>
)}

{route.page === "mobile-patterns" && (
<MobilePatternsPage
colorScheme={colorScheme}
contrast={contrast}
density={density}
tokenOverrides={tokenOverrides}
/>
)}

{route.page === "flow-chat-mock" && <FlowChatMockPage />}

{route.page === "tokens" && (
Expand Down
20 changes: 11 additions & 9 deletions design-system/apps/design-lab/src/components/LabComponentIndex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@ import { useI18n } from "../i18n";
import { getComponentCategoryLabel, getComponentDescription } from "../i18n/componentMetadata";

/* The component directory belongs to the navigation, not to a second index beside it: it hangs
under the Components route in the rail, the way the Foundations chapters hang under theirs. It
keeps its own search and its own scroll region, so a list this long never pushes the other
routes out of the rail. */
export function LabComponentIndex({ selected }: { selected?: string }) {
under its route in the rail, the way the Foundations chapters hang under theirs. It keeps its own
search and its own scroll region, so a list this long never pushes the other routes out of the
rail. `scope` splits the catalog into the two surface tabs: Web and Mobile. */
export function LabComponentIndex({ scope = "all", selected }: { scope?: "all" | "mobile" | "web"; selected?: string }) {
const { t } = useI18n();
const [query, setQuery] = useState("");
const listRef = useRef<HTMLElement>(null);
const activeLinkRef = useRef<HTMLAnchorElement>(null);
const categories = Array.from(new Set(componentRegistry.map(component => component.category)));
const normalizedQuery = query.trim().toLowerCase();
const catalogComponents = componentRegistry.filter(component =>
scope === "all" ? true : scope === "mobile" ? component.category === "mobile" : component.category !== "mobile");
const categories = Array.from(new Set(catalogComponents.map(component => component.category)));
const normalizedQuery = query.trim().toLowerCase();
const results = catalogComponents.filter(component =>
`${component.name} ${component.category} ${component.description} ${getComponentDescription(component.name, component.description, t)} ${getComponentCategoryLabel(component.category, t)}`.toLowerCase().includes(normalizedQuery),
);

Expand All @@ -42,10 +44,10 @@ export function LabComponentIndex({ selected }: { selected?: string }) {
{/* The directory can be counted by looking, so the rail does not print the total — but a reader
who cannot see the list still needs the filtered count as the query changes. The region stays
live and comes off screen instead of out of the page. */}
<span className="design-sr-only" role="status">{t("design.results", { count: catalogComponents.length })}</span>
<span className="design-sr-only" role="status">{t("design.results", { count: results.length })}</span>
<nav className="design-library-list" aria-label={t("design.all")} ref={listRef}>
{categories.map(group => {
const items = catalogComponents.filter(item => item.category === group).sort((a, b) => a.name.localeCompare(b.name));
const items = results.filter(item => item.category === group).sort((a, b) => a.name.localeCompare(b.name));
if (!items.length) return null;
return (
<section className="design-library-group" key={group} aria-labelledby={`component-group-${group}`}>
Expand All @@ -65,7 +67,7 @@ export function LabComponentIndex({ selected }: { selected?: string }) {
</section>
);
})}
{catalogComponents.length === 0 && (
{results.length === 0 && (
<div className="design-library-empty">
<p>{t("design.noResults")}</p>
<Button size="sm" variant="text" onClick={() => setQuery("")}>{t("design.clear")}</Button>
Expand Down
Loading
Loading