Skip to content

Commit

Permalink
Badge docs + preview
Browse files Browse the repository at this point in the history
  • Loading branch information
quietbits committed Sep 27, 2023
1 parent ee42785 commit 240d9d1
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"label": "Accents",
"link": {
"type": "generated-index"
}
}
19 changes: 19 additions & 0 deletions @stellar/design-system-website/docs/components/accents/badge.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
slug: /badge
---

# Badge

<ComponentDescription componentName="Badge" />

## Example

```tsx live
<PreviewBlock componentName="Badge">
<Badge>Label</Badge>
</PreviewBlock>
```

## Props

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

export const badgePreview: ComponentPreview = {
options: [
{
type: "select",
prop: "variant",
options: [
{
value: "default",
label: "Default",
},
{
value: "success",
label: "Success",
},
{
value: "warning",
label: "Warning",
},
{
value: "pending",
label: "Pending",
},
{
value: "error",
label: "Error",
},
],
},
],
};
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { captionPreview } from "@site/src/componentPreview/captionPreview";
import { paragraphPreview } from "@site/src/componentPreview/paragraphPreview";
import { titlePreview } from "@site/src/componentPreview/titlePreview";
import { notificationPreview } from "@site/src/componentPreview/notificationPreview ";
import { badgePreview } from "@site/src/componentPreview/badgePreview";

// =============================================================================
// Component previews
Expand All @@ -27,6 +28,7 @@ const previews: { [key: string]: ComponentPreview } = {
Paragraph: paragraphPreview,
Title: titlePreview,
Notification: notificationPreview,
Badge: badgePreview,
};

type Theme = "sds-theme-light" | "sds-theme-dark";
Expand Down
8 changes: 7 additions & 1 deletion @stellar/design-system/src/components/Badge/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,17 @@
import React from "react";
import "./styles.scss";

interface BadgeProps {
/** */
export interface BadgeProps {
/** Variant of the badge @defaultValue `default` */
variant?: "default" | "success" | "warning" | "pending" | "error";
/** Label of the badge */
children: string;
}

/**
* `Badge` is used to label or categorize an item. There are five variants: `default`, `success`, `warning`, `pending`, and `error`.
*/
export const Badge: React.FC<BadgeProps> = ({
variant = "default",
children,
Expand Down

0 comments on commit 240d9d1

Please sign in to comment.