Skip to content

Commit a8c1e6d

Browse files
[Style Guide] Component Overview revamp (#26048)
* [Style Guide] Component Overview revamp * Apply suggestion from @pedrosousa Co-authored-by: Pedro Sousa <[email protected]> * Apply suggestion from @pedrosousa Co-authored-by: Pedro Sousa <[email protected]> * Apply suggestion from @pedrosousa Co-authored-by: Pedro Sousa <[email protected]> * Apply suggestion from @pedrosousa Co-authored-by: Pedro Sousa <[email protected]> * Apply suggestion from @pedrosousa Co-authored-by: Pedro Sousa <[email protected]> * Apply suggestion from @pedrosousa Co-authored-by: Pedro Sousa <[email protected]> * Apply suggestion from @pedrosousa Co-authored-by: Pedro Sousa <[email protected]> * Apply suggestion from @pedrosousa Co-authored-by: Pedro Sousa <[email protected]> * Minor improvements --------- Co-authored-by: Pedro Sousa <[email protected]>
1 parent 05eb6fb commit a8c1e6d

File tree

2 files changed

+39
-25
lines changed

2 files changed

+39
-25
lines changed
45.9 KB
Loading

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

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,40 +3,54 @@ 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+
When you are [contributing to the Cloudflare Docs](/style-guide/contributions/), you can use our custom components to add additional formatting, such as buttons, tabs, and collapsible sections.
99

10-
## What is a component?
10+
This guide 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 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/) and are written in [MDX](https://docs.astro.build/en/guides/markdown-content/), an extended version of Markdown. [Learn more about the Cloudflare Docs framework](/style-guide/how-we-docs/our-site/#site-framework).
1513

16-
## Using components
14+
## Add a component to a page
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+
To add a component to a page:
2017

21-
```mdx live
22-
import { Details, RuleID } from "~/components"
18+
1. Import the component to the page by adding this text directly below the [frontmatter](/style-guide/frontmatter/):
2319

24-
{/* Self-closing component */}
25-
<RuleID id="abcdefghijklmnopqrstuvwxyz" />
20+
```mdx
21+
import { COMPONENT_NAME } from "~/components";
22+
```
2623

27-
<br/> {/* Line break to separate rendered components */}
24+
For example, if you were to add [the `DashButton` component](/style-guide/components/dash-button/) to the [Images getting started page](/images/get-started/), the top of the MDX file corresponding to that page would look like the following:
2825

29-
{/* Component with inside content */}
30-
<Details header="Open me!">
31-
Hello, world!
32-
</Details>
33-
```
26+
```mdx
27+
---
28+
pcx_content_type: get-started
29+
title: Getting started
30+
sidebar:
31+
order: 2
3432

35-
### Importing
33+
---
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+
import { DashButton } from "~/components";
36+
```
3937

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

0 commit comments

Comments
 (0)