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

Typography docs + preview #166

Merged
merged 4 commits into from
Sep 11, 2023
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

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"label": "Typography",
"link": {
"type": "generated-index",
"description": "Typography (including headings, paragraph, and other text types) examples and documentation. These components don’t have any special props, and inherit their native HTML attributes."
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
slug: /caption
---

# Caption

<ComponentDescription componentName="Caption" />

## Example

```tsx live
<PreviewBlock componentName="Caption">
<Caption size="xs">Caption</Caption>
</PreviewBlock>
```

## Props

<ComponentProps componentName="Caption" />
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
slug: /heading
---

# Heading

<ComponentDescription componentName="Heading" />

## Example

```tsx live
<PreviewBlock componentName="Heading">
<Heading as="h1" size="xs">
Heading
</Heading>
</PreviewBlock>
```

## Props

<ComponentProps componentName="Heading" />
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
slug: /paragraph
---

# Paragraph

<ComponentDescription componentName="Paragraph" />

## Example

```tsx live
<PreviewBlock componentName="Paragraph">
<Paragraph size="xs">Paragraph</Paragraph>
</PreviewBlock>
```

## Props

<ComponentProps componentName="Paragraph" />
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
slug: /title
---

# Title

<ComponentDescription componentName="Title" />

## Example

```tsx live
<PreviewBlock componentName="Title">
<Title size="xs">Title</Title>
</PreviewBlock>
```

## Props

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

export const captionPreview: ComponentPreview = {
options: [
{
type: "select",
prop: "size",
options: [
{
value: "xs",
label: "XS",
},
{
value: "sm",
label: "SM",
},
{
value: "md",
label: "MD",
},
{
value: "lg",
label: "LG",
},
],
},
],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { ComponentPreview } from "@site/src/components/PreviewBlock";

export const headingPreview: ComponentPreview = {
options: [
{
type: "select",
prop: "as",
options: [
{
value: "h1",
label: "h1",
},
{
value: "h2",
label: "h2",
},
{
value: "h3",
label: "h3",
},
{
value: "h4",
label: "h4",
},
{
value: "h5",
label: "h5",
},
{
value: "h6",
label: "h6",
},
],
},
{
type: "select",
prop: "size",
options: [
{
value: "xs",
label: "XS",
},
{
value: "sm",
label: "SM",
},
{
value: "md",
label: "MD",
},
{
value: "lg",
label: "LG",
},
{
value: "xl",
label: "XL",
},
{
value: "xxl",
label: "XXL",
},
],
},
],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { ComponentPreview } from "@site/src/components/PreviewBlock";

export const paragraphPreview: ComponentPreview = {
options: [
{
type: "select",
prop: "size",
options: [
{
value: "xs",
label: "XS",
},
{
value: "sm",
label: "SM",
},
{
value: "md",
label: "MD",
},
{
value: "lg",
label: "LG",
},
],
},
{
type: "checkbox",
prop: "asDiv",
label: "As div",
},
],
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { ComponentPreview } from "@site/src/components/PreviewBlock";

export const titlePreview: ComponentPreview = {
options: [
{
type: "select",
prop: "size",
options: [
{
value: "xs",
label: "XS",
},
{
value: "sm",
label: "SM",
},
{
value: "md",
label: "MD",
},
{
value: "lg",
label: "LG",
},
],
},
],
};
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,29 @@ import reactElementToJSXString from "react-element-to-jsx-string";
import { PlaygroundEditor } from "@site/src/theme/Playground";
import "./styles.css";

// Previews
// =============================================================================
// Preview imports
// =============================================================================
import { buttonPreview } from "@site/src/componentPreview/buttonPreview";
import { linkPreview } from "@site/src/componentPreview/linkPreview";
import { projectLogoPreview } from "@site/src/componentPreview/projectLogoPreview";
import { headingPreview } from "@site/src/componentPreview/headingPreview";
import { captionPreview } from "@site/src/componentPreview/captionPreview";
import { paragraphPreview } from "@site/src/componentPreview/paragraphPreview";
import { titlePreview } from "@site/src/componentPreview/titlePreview";

// =============================================================================
// Component previews
// =============================================================================
const previews: { [key: string]: ComponentPreview } = {
Button: buttonPreview,
Link: linkPreview,
ProjectLogo: projectLogoPreview,
Heading: headingPreview,
Caption: captionPreview,
Paragraph: paragraphPreview,
Title: titlePreview,
};

type Theme = "sds-theme-light" | "sds-theme-dark";

Expand Down Expand Up @@ -62,13 +81,6 @@ export const PreviewBlock = ({

const [theme, setTheme] = useState<Theme>("sds-theme-light");

// All component previews
const previews: { [key: string]: ComponentPreview } = {
Button: buttonPreview,
Link: linkPreview,
ProjectLogo: projectLogoPreview,
};

const compPreview = previews[componentName];

if (!compPreview) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,20 @@
}
}

/* Overrides */
/* ========================================================================== */
/* SDS overrides
/* ========================================================================== */
.PreviewBlock .Link--underline {
text-decoration: underline !important;
}

.PreviewBlock .Heading,
.PreviewBlock .Caption,
.PreviewBlock .Paragraph,
.PreviewBlock .Title {
color: var(--color-gray-90);
}

.PreviewBlock .Heading {
margin: 0 !important;
}
Loading