Skip to content

Commit c16afc9

Browse files
committed
[Style Guide] Component Overview revamp
1 parent c5a4e2c commit c16afc9

File tree

2 files changed

+42
-25
lines changed

2 files changed

+42
-25
lines changed
45.9 KB
Loading

src/content/docs/style-guide/components/index.mdx

Lines changed: 42 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,57 @@ title: Components
33
sidebar:
44
order: 2
55
---
6+
import { Details } from "~/components";
67

7-
All of the components available to contributors writing content on Cloudflare's developer documentation
8-
are documented in this section.
8+
In addition to using basic Markdown, you can use our custom components to add additional formatting to the Cloudflare Docs, such as buttons, tabs, and collapsible sections.
99

10-
## What is a component?
10+
This page shows you the basics of importing and adding a component to a page. Refer to each component page in this Style Guide to learn the specific the specific props and requirements for each.
1111

12-
[Astro components](https://docs.astro.build/en/basics/astro-components/) are re-usable HTML templates which
13-
we use to reduce maintenance burden & duplicated code by returning frequently used layouts or snippets into
14-
a component that can be imported and used across various pages.
12+
Our components are based on [Astro components](https://docs.astro.build/en/basics/astro-components/).
1513

16-
## Using components
14+
[Learn more about the Cloudflare Docs framework.](https://developers.cloudflare.com/style-guide/how-we-docs/our-site/#site-framework)
1715

18-
Content is authored in [MDX](https://docs.astro.build/en/guides/markdown-content/), which allows JavaScript
19-
expressions and components to be used. They are like HTML elements, which can be self-closing.
16+
## Add a component to a page
2017

21-
```mdx live
22-
import { Details, RuleID } from "~/components"
18+
To add a component to a page, you need to import it to the page and then add it:
2319

24-
{/* Self-closing component */}
25-
<RuleID id="abcdefghijklmnopqrstuvwxyz" />
20+
1. Import the component to the page by adding this Markdown directly below the [frontmatter](/style-guide/frontmatter/):
2621

27-
<br/> {/* Line break to separate rendered components */}
22+
```mdx
23+
import { COMPONENT_NAME } from "~/components";
24+
```
2825

29-
{/* Component with inside content */}
30-
<Details header="Open me!">
31-
Hello, world!
32-
</Details>
33-
```
26+
For example, if you were to add [the `DashButton` component](https://developers.cloudflare.com/style-guide/components/dash-button/) to the [Images getting started page](https://developers.cloudflare.com/images/get-started/), here is how the top of the Markdown of that page would look:
3427

35-
### Importing
28+
```mdx
29+
---
30+
pcx_content_type: get-started
31+
title: Getting started
32+
sidebar:
33+
order: 2
3634

37-
Components need to be imported to be made available inside a MDX file. All of our components are exported from
38-
`"~/components"`, so they would be imported like this:
35+
---
3936

40-
```mdx
41-
import { Card, Render } from "~/components"
42-
```
37+
import { DashButton } from "~/components";
38+
```
39+
40+
2. Add the component to the page by adding this Markdown wherever on the page you want the component to appear:
41+
42+
```mdx
43+
<COMPONENT_NAME PROP_NAME="PROP_VALUE" />
44+
```
45+
46+
For example, if you were to add the `DashButton` component to some steps in the [Images getting started page](https://developers.cloudflare.com/images/get-started/), here is how the Markdown would look:
47+
48+
```mdx
49+
1. In the Cloudflare dashboard, go to the **Transformations** page.
50+
51+
<DashButton url="/?to=/:account/images/delivery-zones" />
52+
53+
2. Go to the specific zone where you want to enable transformations.
54+
```
55+
<Details header="This is how this example would display after it is published:">
56+
![DashButton component example](~/assets/images/style-guide/ui-elements/dashbutton-example.png)
57+
</Details>
58+
59+
Each component has its own specific props and requirements, explained in each component page in this Style Guide.

0 commit comments

Comments
 (0)