Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Component Documentation #550

Merged
merged 15 commits into from
Dec 13, 2024
Merged
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
7 changes: 7 additions & 0 deletions .changeset/shiny-mugs-sit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@hopper-ui/styled-system": patch
"@hopper-ui/components": patch
"@hopper-ui/icons": patch
---

Updated peer dependency versions range
17 changes: 11 additions & 6 deletions apps/docs/app/components/[...slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface PageProps {
};
}

async function findComponentFromSlug(params : { slug: string[] }) {
function findComponentFromSlug(params : { slug: string[] }) {
const [type] = params.slug;

const component = allComponents.find(x => x.slug === type);
Expand Down Expand Up @@ -73,14 +73,19 @@ export default async function ComponentPage({ params }: PageProps) {
}

export async function generateMetadata({ params }: PageProps) {
const component = await findComponentFromSlug(params);
const component = findComponentFromSlug(params);

if (component) {
const title = component?.title;

return {
title: `${title}`
const metadata: Record<string, string> = {
title: component.title
};

if (component.description) {
metadata.description = component.description;
}


return metadata;
}

return {
Expand Down
3 changes: 2 additions & 1 deletion apps/docs/app/components/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ async function ComponentsLayout({ children }: { children: ReactNode }) {
"pickers",
"status",
"content",
"placeholders"
"placeholders",
"internal-parts"
],
// the components paths are slightly different than the other pages
// we want the URLS to be /components/ComponentName
Expand Down
17 changes: 15 additions & 2 deletions apps/docs/app/getting-started/[...slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,22 @@ export async function generateStaticParams() {
}

export async function generateMetadata({ params }: PageProps) {
const page = await findPageFromSlug(params.slug);
const page = findPageFromSlug(params.slug);

if (page) {
const metadata: Record<string, string> = {
title: page.title
};

if (page.description) {
metadata.description = page.description;
}


return metadata;
}

return {
title: page ? `${page.title}` : null
title: null
};
}
17 changes: 15 additions & 2 deletions apps/docs/app/icons/[...slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,22 @@ export async function generateStaticParams() {
}

export async function generateMetadata({ params }: PageProps) {
const page = await findPageFromSlug(params.slug);
const page = findPageFromSlug(params.slug);

if (page) {
const metadata: Record<string, string> = {
title: page.title
};

if (page.description) {
metadata.description = page.description;
}


return metadata;
}

return {
title: page ? `${page.title}` : null
title: null
};
}
13 changes: 10 additions & 3 deletions apps/docs/app/tokens/[...slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ export async function generateStaticParams() {

// The sections are Overview, Semantic and Core. we want all title in "Core" to be "Core " + "Color"(the token type) + " Tokens"
export async function generateMetadata({ params }: PageProps) {
const page = await findPageFromSlug(params.slug);
const page = findPageFromSlug(params.slug);

if (!page) {
return {
title: null
};
}

const { title, section } = page;
const { title, section, description } = page;

let pageTitle = `${title}`;
if (section === "core") {
Expand All @@ -61,7 +61,14 @@ export async function generateMetadata({ params }: PageProps) {
pageTitle = `Semantic ${title} Tokens`;
}

return {
const metadata: Record<string, string> = {
title: pageTitle
};

if (description) {
metadata.description = description;
}


return metadata;
}
4 changes: 3 additions & 1 deletion apps/docs/app/ui/components/overview/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ const sortOrder = [
"overlays",
"pickers",
"status",
"content"
"content",
"placeholders",
"internal-parts"
];

const categories = Array.from(new Set(allComponents.map(component => component.category))).filter(x => x && !ignoreCategories.includes(x)).sort((a, b) => {
Expand Down
1 change: 0 additions & 1 deletion apps/docs/app/ui/layout/mobileMenu/MobileMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import HopperLogo from "./assets/hopper-logo.svg";

import "./mobileMenu.css";


interface MobileMenuProps {
onClose?: () => void;
isOpen: boolean;
Expand Down
12 changes: 2 additions & 10 deletions apps/docs/content/components/buttons/Button.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,9 @@ links:

## Anatomy

<FeatureFlag flag="rc">
TODO: We have anatomy screenshots from the Figma, we could most likely use them here

### Concepts

- [Client Side Routing](./client-side-routing)
</FeatureFlag>

### Composed Components

A `Button` uses the following components.
A `Button` uses the following components:

<ComposedComponents components={["Icon", "IconList", "Text"] }/>

Expand Down Expand Up @@ -74,7 +66,7 @@ A button can be expanded to full width to fill its parent container.
<Example src="buttons/docs/button/layout" />

### Icon Only
A button can contain only an icon.
A button can contain only an icon. An accessible name must be provided through [aria-label](https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-label) prop. See also [WCAG practices](https://www.w3.org/TR/WCAG20-TECHS/ARIA6.html).

<Example src="buttons/docs/button/icon" />

Expand Down
22 changes: 11 additions & 11 deletions apps/docs/content/components/buttons/ButtonGroup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,10 @@ links:

A `ButtonGroup` uses the following component.

<ComposedComponents components={["Button"]}/>
<ComposedComponents components={["Button", "LinkButton"]}/>

## Usage

### Disabled
A button group can be disabled.

<Example src="buttons/docs/buttonGroup/disabled" />

### Fluid
A button group can be fluid.

<Example src="buttons/docs/buttonGroup/fluid" />

### Orientation
A button group can render his items vertically.

Expand All @@ -57,6 +47,16 @@ A button group can change the alignment of his items.

<Example src="buttons/docs/buttonGroup/alignment" />

### Disabled
A button group can be disabled.

<Example src="buttons/docs/buttonGroup/disabled" />

### Fluid
A button group can be fluid.

<Example src="buttons/docs/buttonGroup/fluid" />

### Sizes
A button group can be of different sizes.

Expand Down
19 changes: 9 additions & 10 deletions apps/docs/content/components/buttons/LinkButton.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,15 @@ links:

## Anatomy

<FeatureFlag flag="rc">
TODO: We have anatomy screenshots from the Figma, we could most likely use them here
### Concepts

### Concepts
*LinkButton* makes use of the following concepts:

- [Client Side Routing](./client-side-routing)
</FeatureFlag>
- [Client Side Routing](./client-side-routing)

### Composed Components

A `LinkButton` uses the following components.
A *LinkButton* uses the following components:

<ComposedComponents components={["Icon", "IconList", "Text"]}/>

Expand Down Expand Up @@ -64,13 +62,11 @@ A link button can be disabled.
<Example src="buttons/docs/linkButton/state" />

### External

Add `rel="noopener noreferrer"` and `target="_blank"` attributes to render and external link button.

<Example src="buttons/docs/linkButton/external" />

### No Href

When a link button link does not have an href prop, it is rendered as a `<span role="link">` instead of an `<a>`. Events will need to be handled in JavaScript with the `onPress` prop.

Note: this will not behave like a native link. Browser features like context menus and open in a new tab will not apply.
Expand All @@ -87,6 +83,11 @@ A link button can contain only an icon.

<Example src="buttons/docs/linkButton/icon" />

### Router Link
A link button can be used with any Router. For more information, see the [Client Side Routing](../concepts/client-side-routing) article.

<Example src="buttons/docs/linkButton/reactRouterLink" />

### Icon
A link button can contain icons.

Expand All @@ -97,8 +98,6 @@ Nonstandard end icons can be provided to handle special cases. However, think tw

<Example src="buttons/docs/linkButton/endIcon" />

<Example src="buttons/docs/linkButton/reactRouterLink" />

<FeatureFlag flag="next">
## Advanced customization

Expand Down
8 changes: 7 additions & 1 deletion apps/docs/content/components/collections/Listbox.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ links:

#### ListBox

A `ListBox` uses the following components.
A `ListBox` uses the following components:

<ComposedComponents components={["Avatar", "Badge", "Header", "Icon", "Text"]}/>

Expand Down Expand Up @@ -69,6 +69,12 @@ A list box can have sections and section headers.

<Example src="ListBox/docs/section" />

### Dividers

A list box can have dividers.

<Example src="ListBox/docs/divider" />

### Avatar

A ListBox can contain an avatar.
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/components/collections/TagGroup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ links:

### Composed Components

A `TagGroup` uses the following components.
A `TagGroup` uses the following components:

<ComposedComponents components={["Avatar", "Badge", "Icon", "IconList", "Text"]}/>

Expand Down
1 change: 1 addition & 0 deletions apps/docs/content/components/concepts/controlled-mode.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
title: Controlled Mode
description: Learn how to use controlled and uncontrolled modes to customize Hopper components.
order: 5
---
When working with Hopper components, you can customize a component's behavior using **controlled** or **uncontrolled** properties, depending on your needs. This flexibility is the foundation for **building custom components** on top of Hopper, enabling you to implement interactive features or modify the default behavior of components while preserving their visual style and structure.
Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/components/content/Card.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ links:

### Composed Components

A `Card` uses the following components.
A `Card` uses the following components:

<ComposedComponents components={["Header", "Content", "Footer"]}/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ links:

### Composed Components

A `IllustratedMessage` uses the following components.
A `IllustratedMessage` uses the following components:

<ComposedComponents components={["Image", "Heading", "Content", "ButtonGroup", "Button"]}/>

Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/components/forms/Checkbox.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ links:

### Composed Components

A `Checkbox` uses the following components.
A `Checkbox` uses the following components:

<ComposedComponents components={["Icon", "IconList", "Text"]}/>

Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/components/forms/CheckboxGroup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ links:

### Composed Components

A `CheckboxGroup` uses the following components.
A `CheckboxGroup` uses the following components:

<ComposedComponents components={["Checkbox"]}/>

Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/components/forms/Form.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ links:

### Composed Components

A `Form` uses the following components.
A `Form` uses the following components:

<ComposedComponents components={["Button", "ButtonGroup", "ErrorMessage", "HelperMessage", "NumberField", "PasswordField", "TextField"]}/>

Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/components/forms/RadioGroup.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ links:

### Composed Components

A `RadioGroup` uses the following components.
A `RadioGroup` uses the following components:

<ComposedComponents components={["Icon", "IconList", "Text"]}/>

Expand Down
2 changes: 1 addition & 1 deletion apps/docs/content/components/forms/Switch.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ links:

### Composed Components

A `Switch` uses the following components.
A `Switch` uses the following components:

<ComposedComponents components={["Icon", "IconList", "Text"]}/>

Expand Down
8 changes: 4 additions & 4 deletions apps/docs/content/components/icons/Icon.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,10 @@ import { Icon, type CreatedIconProps } from "@hopper-ui/icons";
function CustomIcon(props: CreatedIconProps) {
return (
<Icon
src16={CustomIcon16}
src24={CustomIcon24}
src32={CustomIcon32}
{...props} />
src16={CustomIcon16}
src24={CustomIcon24}
src32={CustomIcon32}
{...props} />
)
}
```
Expand Down
Loading
Loading