Skip to content
This repository was archived by the owner on Oct 28, 2025. It is now read-only.

Commit bfd4a2b

Browse files
authored
Merge pull request #27 from alexaveldanez/dynamic-code-block
(#440) Created dynamic code block component
2 parents 90e819d + a9fe49c commit bfd4a2b

File tree

5 files changed

+404
-381
lines changed

5 files changed

+404
-381
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ The Chocolatey Design System has all information relating to Astro Components an
3737
* Learn about Astro and how to use [Components in `.mdx` and `.astro`](https://design.chocolatey.org/foundations/astro) file types.
3838
* Learn how to use the [`<Callout />` Component](https://design.chocolatey.org/components/callouts) to display notes and important information.
3939
* Learn how to use the [`<CollapseButton />` Component](https://design.chocolatey.org/collapse-button) to display a button that triggers a collapsed element.
40+
* Learn how to use the [`<DynamicCodeBlock />` and `<DynamicCodeBlockInput />` Components](https://design.chocolatey.org/components/dynamic-code-block) to display a code block with variables that can be replaced with values from inputs.
4041
* Learn how to use the [`<Iframe />` Component](https://design.chocolatey.org/components/iframe) to display videos with defined aspect ratios.
4142
* Learn how to use the [`<Tabs />` Component](https://design.chocolatey.org/components/tabs) to display content in tabbed interface.
4243
* Learn how to use the [`<Xref />` Component](https://design.chocolatey.org/components/xref) to link to other documents within this repository.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "choco-astro",
3-
"version": "0.2.4",
3+
"version": "0.3.0",
44
"packageManager": "yarn@4.2.2",
55
"type": "module",
66
"description": "A global set of dependencies to be used on Chocolatey Software Astro projects.",
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
const generateRandomClass = () => {
3+
const randomNumber = Math.floor(Math.random() * 1000);
4+
return `dynamic-code-block-${randomNumber}`;
5+
};
6+
---
7+
8+
<div class="dynamic-code-block-container copy-command">
9+
<pre class="language-powershell"><code class={generateRandomClass()}>
10+
<slot />
11+
</code></pre>
12+
</div>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
const { name, defaultValue, placeholder } = Astro.props;
3+
---
4+
5+
<input class="form-control w-50 mb-3 dynamic-code-block-input" type="text" name={name} data-default-value={defaultValue} placeholder={placeholder} />

0 commit comments

Comments
 (0)