Skip to content

Commit

Permalink
NavButton docs + preview
Browse files Browse the repository at this point in the history
  • Loading branch information
quietbits committed Oct 3, 2023
1 parent a0a836a commit 399e1b4
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
---
slug: /nav-button
---

# Navigation button

<ComponentDescription componentName="NavButton" />

## Example

```tsx live
<PreviewBlock componentName="NavButton">
<NavButton
icon={<Icon.Menu />}
id="nav-button"
onClick={() => {}}
title="Menu"
/>
</PreviewBlock>
```

## Props

<ComponentProps componentName="NavButton" />
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { ComponentPreview } from "@site/src/components/PreviewBlock";

export const navButtonPreview: ComponentPreview = {
options: [
{
type: "checkbox",
prop: "disabled",
label: "Disabled",
},
{
type: "checkbox",
prop: "showBorder",
label: "Show border",
},
],
};
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import { iconButtonPreview } from "@site/src/componentPreview/iconButtonPreview"
import { inputPreview } from "@site/src/componentPreview/inputPreview";
import { linkPreview } from "@site/src/componentPreview/linkPreview";
import { loaderPreview } from "@site/src/componentPreview/loaderPreview";
import { navButtonPreview } from "@site/src/componentPreview/navButtonPreview";
import { notificationPreview } from "@site/src/componentPreview/notificationPreview ";
import { paragraphPreview } from "@site/src/componentPreview/paragraphPreview";
import { profilePreview } from "@site/src/componentPreview/profilePreview";
Expand Down Expand Up @@ -47,6 +48,7 @@ const previews: { [key: string]: ComponentPreview } = {
Input: inputPreview,
Link: linkPreview,
Loader: loaderPreview,
NavButton: navButtonPreview,
Notification: notificationPreview,
Paragraph: paragraphPreview,
Profile: profilePreview,
Expand Down
14 changes: 12 additions & 2 deletions @stellar/design-system/src/components/NavButton/index.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
import React from "react";
import "./styles.scss";

interface NavButtonProps {
/** */
export interface NavButtonProps {
/** ID of the component should be unique */
id: string;
/** Title or label to show on hover */
title: string;
/** Action to trigger on click */
onClick: () => void;
/** Icon of the component */
icon: React.ReactNode;
/** Disable the component */
disabled?: boolean;
/** Show border around the component */
showBorder?: boolean;
}

/**
* `NavButton` is used to trigger actions like toggle dark and light mode, close a modal, and toggle side navigation.
*/
export const NavButton: React.FC<NavButtonProps> = ({
id,
title,
onClick,
icon,
disabled,
showBorder,
}) => (
}: NavButtonProps) => (
<button
id={id}
className={`NavButton ${showBorder ? "NavButton--border" : ""}`}
Expand Down

0 comments on commit 399e1b4

Please sign in to comment.