Skip to content

Commit c19df80

Browse files
committed
add README
1 parent 2259cbb commit c19df80

File tree

4 files changed

+87
-22
lines changed

4 files changed

+87
-22
lines changed

src/components/TryItOut/README.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# TryItOut Component
2+
3+
A component that displays an interactive accordion of features alongside a code sample preview.
4+
5+
## Usage
6+
7+
```astro
8+
<TryItOut
9+
codeSampleSrc="/samples/YourCodeFile.sol"
10+
accordionTabs={[
11+
{
12+
title: "Your Feature Title",
13+
text: "A brief description of what this feature does.",
14+
},
15+
]}
16+
/>
17+
```
18+
19+
## Props
20+
21+
### `codeSampleSrc` (required)
22+
23+
The file path to the code sample you want to display. This should point to a file in the `/samples/` folder.
24+
25+
**Example:** `"/samples/ChainlinkFunctions/AutomatedFunctionsConsumerExample.sol"`
26+
27+
### `accordionTabs` (required)
28+
29+
A list of expandable sections that describe different features. Each tab needs:
30+
31+
- **title**: The heading text for the accordion item
32+
- **text**: The description that appears when the accordion is expanded
33+
34+
**Example:**
35+
36+
```js
37+
;[
38+
{
39+
title: "Transfer Tokens",
40+
text: "Move tokens between different blockchains easily.",
41+
},
42+
{
43+
title: "Fetch Data",
44+
text: "Get real-time information from external sources.",
45+
},
46+
]
47+
```

src/components/TryItOut/TryItOut.astro

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ import { Button, Typography } from "@chainlink/blocks"
33
import styles from "./styles.module.css"
44
import CodeSample from "../CodeSample/CodeSample.astro"
55
import { TryItOutAccordion } from "./TryItOutAccordion"
6+
7+
interface Props {
8+
codeSampleSrc: string
9+
accordionTabs: Array<{ title: string; text: string }>
10+
}
11+
12+
const { codeSampleSrc, accordionTabs } = Astro.props
613
---
714

815
<div class={styles.container}>
@@ -11,7 +18,7 @@ import { TryItOutAccordion } from "./TryItOutAccordion"
1118

1219
<section class={styles.content}>
1320
<div class={styles.contentLeft}>
14-
<TryItOutAccordion client:only="react" />
21+
<TryItOutAccordion client:only="react" tabs={accordionTabs} />
1522

1623
<footer class={styles.contentFooter}>
1724
<Button>Create CRE account</Button>
@@ -20,7 +27,7 @@ import { TryItOutAccordion } from "./TryItOutAccordion"
2027
</div>
2128

2229
<section class={styles.image}>
23-
<CodeSample showButtons={false} src="/samples/ChainlinkFunctions/AutomatedFunctionsConsumerExample.sol" />
30+
<CodeSample showButtons={false} src={codeSampleSrc} />
2431
</section>
2532

2633
<footer class={styles.contentFooterMobile}>

src/components/TryItOut/TryItOutAccordion.tsx

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,16 @@
11
import { Accordion, AccordionContent, AccordionItem, AccordionTrigger, Typography } from "@chainlink/blocks"
22
import styles from "./styles.module.css"
33

4-
export const TryItOutAccordion = () => {
5-
const tabs = [
6-
{
7-
title: "Transfer Tokens Between Chains",
8-
text: "Use Chainlink CCIP to transfer tokens from a smart contract to an account on a different blockchain.",
9-
},
10-
{
11-
title: "Leverage MVR feeds",
12-
text: "Use Multiple-Variable Response (MVR) feeds data in your consumer contracts on EVM chains using Solidity.",
13-
},
14-
{
15-
title: "Fetch and Decode Real World Asset Streams",
16-
text: "Use the Data Streams SDK for Go/Rust to fetch and decode reports from the Data Streams Aggregation Network.",
17-
},
18-
{
19-
title: "Automate your Functions",
20-
text: "Use Chainlink Automation to trigger the same functions regularly, such as fetching weather data daily or fetching an asset price on every block.",
21-
},
22-
]
4+
interface AccordionTab {
5+
title: string
6+
text: string
7+
}
8+
9+
interface TryItOutAccordionProps {
10+
tabs: AccordionTab[]
11+
}
12+
13+
export const TryItOutAccordion = ({ tabs }: TryItOutAccordionProps) => {
2314

2415
return (
2516
<Accordion collapsible type="single">

src/pages/index.astro

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,27 @@ const formattedContentTitle = `${CONFIG.PAGE.titleFallback} | ${CONFIG.SITE.titl
2020
<JourneyCards />
2121
</div>
2222

23-
<TryItOut />
23+
<TryItOut
24+
codeSampleSrc="/samples/ChainlinkFunctions/AutomatedFunctionsConsumerExample.sol"
25+
accordionTabs={[
26+
{
27+
title: "Transfer Tokens Between Chains",
28+
text: "Use Chainlink CCIP to transfer tokens from a smart contract to an account on a different blockchain.",
29+
},
30+
{
31+
title: "Leverage MVR feeds",
32+
text: "Use Multiple-Variable Response (MVR) feeds data in your consumer contracts on EVM chains using Solidity.",
33+
},
34+
{
35+
title: "Fetch and Decode Real World Asset Streams",
36+
text: "Use the Data Streams SDK for Go/Rust to fetch and decode reports from the Data Streams Aggregation Network.",
37+
},
38+
{
39+
title: "Automate your Functions",
40+
text: "Use Chainlink Automation to trigger the same functions regularly, such as fetching weather data daily or fetching an asset price on every block.",
41+
},
42+
]}
43+
/>
2444

2545
<div class="wrapper">
2646
<Demos />

0 commit comments

Comments
 (0)