Skip to content

Commit 113579d

Browse files
p-m-pclaude
andcommitted
feat(docs): add CopyPrompt component for LLM-assisted setup
Adds a new CopyPrompt React component to the docs site that lets users copy a tailored AI prompt to their clipboard with one click. Integrates the component into every installation section across the getting-started and framework guide pages (React, Web Components, JavaScript, Svelte, Vue). The component shows a "Copy AI prompt" button with clipboard feedback and a collapsible details element to preview the prompt text. On large screens the button and details are horizontally aligned with the button on the right; on small screens they stack with the button on top. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 77c3adc commit 113579d

9 files changed

Lines changed: 240 additions & 0 deletions

File tree

packages/docs/docs/getting-started/01-installation.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
title: Installation
33
---
44

5+
import { CopyPrompt } from '@site/src/components/CopyPrompt'
6+
57
The BoxSlider library is available as React components, Web Components and
68
as a core JavaScript/TypeScript library.
79

@@ -14,6 +16,18 @@ for detailed instructions.
1416
npm install --save @boxslider/react
1517
```
1618

19+
<CopyPrompt
20+
prompt={`Help me install and set up @boxslider/react in my project.
21+
22+
Install command: npm install --save @boxslider/react
23+
24+
Please provide a quick start example showing:
25+
26+
- A basic carousel slider using the CarouselSlider component
27+
- Navigation controls using SliderControls
28+
- The minimum required CSS to make the slider display correctly`}
29+
/>
30+
1731
## Web Components
1832

1933
The Web components package can also be installed via NPM or used directly from a CDN. See the
@@ -41,6 +55,19 @@ Use from CDN
4155
</bs-slider-controls>
4256
```
4357

58+
<CopyPrompt
59+
prompt={`Help me install and set up @boxslider/components (BoxSlider Web Components) in my project.
60+
61+
Install command: npm install --save @boxslider/components
62+
Or use from CDN: <script type="module" src="https://cdn.jsdelivr.net/npm/@boxslider/components/+esm"></script>
63+
64+
Please provide a quick start example showing:
65+
66+
- A basic carousel slider using the bs-carousel web component
67+
- Navigation controls using bs-slider-controls
68+
- The minimum required CSS to make the slider display correctly`}
69+
/>
70+
4471
## JavaScript
4572

4673
The core slider package can be installed via NPM or used directly from a CDN. See the
@@ -61,3 +88,16 @@ Use directly from a CDN
6188
const slider = createFadeSlider('#slider')
6289
</script>
6390
```
91+
92+
<CopyPrompt
93+
prompt={`Help me install and set up @boxslider/slider (BoxSlider JavaScript library) in my project.
94+
95+
Install command: npm install --save @boxslider/slider
96+
Or import from CDN: import { createFadeSlider } from 'https://cdn.jsdelivr.net/npm/@boxslider/slider/+esm'
97+
98+
Please provide a quick start example showing:
99+
100+
- The required HTML structure for a carousel slider
101+
- Creating the slider using createCarouselSlider
102+
- The minimum required CSS to make the slider display correctly`}
103+
/>

packages/docs/docs/guides/01-react.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
title: React
33
---
44

5+
import { CopyPrompt } from '@site/src/components/CopyPrompt'
6+
57
BoxSlider React components are a thin wrapper around the [Web Components](/docs/guides/web-components) for each
68
slide effect and the slider controls.
79

@@ -11,6 +13,24 @@ slide effect and the slider controls.
1113
npm i --save @boxslider/react@latest
1214
```
1315

16+
<CopyPrompt
17+
prompt={`I'm setting up BoxSlider React components in my project.
18+
19+
Install: npm i --save @boxslider/react@latest
20+
21+
The package provides these components:
22+
23+
- CarouselSlider, FadeSlider, CubeSlider, TileSlider — slide effects, options passed as props
24+
- SliderControls — navigation buttons, wraps the slider component
25+
26+
Key requirements:
27+
28+
- Sliders need explicit display, height, and width CSS to function
29+
- Slider options (speed, timeout, autoScroll, pauseOnHover, loop, swipe) are passed as props
30+
31+
Please provide a complete React component example with a carousel slider wrapped in SliderControls and the required styles.`}
32+
/>
33+
1434
## Components
1535

1636
Each slide effect has a matching React component. The options for the slider and the effect are passed as props.

packages/docs/docs/guides/02-web-components.md

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
title: Web Components
33
---
44

5+
import { CopyPrompt } from '@site/src/components/CopyPrompt'
6+
57
BoxSlider Web Components provide ready to us slider elements for each slide
68
effect and the slider controls.
79

@@ -37,6 +39,24 @@ Alternatively use from CDN.
3739
</bs-slider-controls>
3840
```
3941

42+
<CopyPrompt
43+
prompt={`I'm setting up BoxSlider Web Components in my project.
44+
45+
Install: npm i --save @boxslider/components
46+
Then import in your entry file: import '@boxslider/components'
47+
48+
Or use from CDN: <script type="module" src="https://cdn.jsdelivr.net/npm/@boxslider/components/+esm"></script>
49+
50+
Available web components:
51+
52+
- bs-carousel, bs-cube, bs-fade, bs-tile — slide effects (camelCase options become kebab-case attributes, e.g. autoScroll → auto-scroll)
53+
- bs-slider-controls — navigation buttons, wraps the slider element
54+
55+
Key requirements: The slider element needs display, height, and width set via CSS.
56+
57+
Please provide a complete HTML example with a carousel slider wrapped in bs-slider-controls and the required styles.`}
58+
/>
59+
4060
To import a single component use the individual exports.
4161

4262
```ts

packages/docs/docs/guides/03-javascript.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
title: JavaScript
33
---
44

5+
import { CopyPrompt } from '@site/src/components/CopyPrompt'
6+
57
More advanced users may want to use the core JavaScript library directly. The core library provides
68
a simple API for creating a slider and manipulating it programmatically. For ready to use components
79
view the [React](/docs/guides/react) and [Web Components](/docs/guides/web-components) guides.
@@ -26,6 +28,26 @@ Alternatively use from CDN.
2628
</script>
2729
```
2830

31+
<CopyPrompt
32+
prompt={`I'm setting up the BoxSlider JavaScript library in my project.
33+
34+
Install: npm install --save @boxslider/slider
35+
Or import from CDN: import { createFadeSlider } from 'https://cdn.jsdelivr.net/npm/@boxslider/slider/+esm'
36+
37+
Available helper functions (each takes a CSS selector or element + optional options):
38+
39+
- createCarouselSlider, createFadeSlider, createCubeSlider, createTileSlider
40+
41+
Options include: speed, timeout, autoScroll, pauseOnHover, loop, swipe, swipeTolerance
42+
43+
Key requirements:
44+
45+
- Create the HTML structure with a container and slide elements
46+
- Set display, height, and width CSS on the slider container
47+
48+
Please provide a complete example with HTML, CSS, and JavaScript that creates a working carousel slider.`}
49+
/>
50+
2951
## Usage
3052

3153
Create the HTML structure for your slider content.

packages/docs/docs/guides/04-svelte.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
title: Svelte
33
---
44

5+
import { CopyPrompt } from '@site/src/components/CopyPrompt'
6+
57
Svelte applications can easily integrate the BoxSlider [Web Components](/docs/guides/web-components).
68

79
## Installation
@@ -10,6 +12,22 @@ Svelte applications can easily integrate the BoxSlider [Web Components](/docs/gu
1012
npm i --save @boxslider/components
1113
```
1214

15+
<CopyPrompt
16+
prompt={`I'm integrating BoxSlider into my Svelte application using Web Components.
17+
18+
Install: npm i --save @boxslider/components
19+
20+
In Svelte, import the package in your component script then use the web components directly in templates:
21+
22+
- bs-carousel, bs-cube, bs-fade, bs-tile — slide effects (pass options as props, e.g. speed={500})
23+
- bs-slider-controls — navigation buttons, wraps the slider element
24+
- Use bind:this to access the BoxSlider instance via the element's .slider property
25+
26+
Key requirements: Set display, height, and width on the slider element via CSS.
27+
28+
Please provide a complete Svelte component example with a carousel slider wrapped in bs-slider-controls and the required styles.`}
29+
/>
30+
1331
## Components
1432

1533
Svelte has first class support for web components and the best way to use BoxSlider is to use the web components directly

packages/docs/docs/guides/05-vue.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
title: Vue
33
---
44

5+
import { CopyPrompt } from '@site/src/components/CopyPrompt'
6+
57
Vue applications can easily integrate the BoxSlider [Web Components](/docs/guides/web-components).
68

79
## Installation
@@ -10,6 +12,22 @@ Vue applications can easily integrate the BoxSlider [Web Components](/docs/guide
1012
npm i --save @boxslider/components
1113
```
1214

15+
<CopyPrompt
16+
prompt={`I'm integrating BoxSlider into my Vue application using Web Components.
17+
18+
Install: npm i --save @boxslider/components
19+
20+
In Vue, import the package in your component setup then use the web components directly in templates:
21+
22+
- bs-carousel, bs-cube, bs-fade, bs-tile — slide effects (bind numeric/boolean options with :prop="value", strings without binding)
23+
- bs-slider-controls — navigation buttons, wraps the slider element
24+
- Use a template ref to access the BoxSlider instance via the element's .slider property
25+
26+
Key requirements: Set display, height, and width on the slider element via CSS.
27+
28+
Please provide a complete Vue component example with a carousel slider wrapped in bs-slider-controls and the required styles.`}
29+
/>
30+
1331
## Components
1432

1533
Vue has first class support for web components and the best way to use BoxSlider is to use the web components directly
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { useState, useCallback } from 'react'
2+
import { Copy, Check, ChevronDown } from 'lucide-react'
3+
import clsx from 'clsx'
4+
import { Button } from '../Button'
5+
import styles from './styles.module.css'
6+
7+
interface CopyPromptProps {
8+
prompt: string
9+
}
10+
11+
export function CopyPrompt({ prompt }: CopyPromptProps) {
12+
const [copied, setCopied] = useState(false)
13+
const [open, setOpen] = useState(false)
14+
15+
const handleCopy = useCallback(async () => {
16+
await navigator.clipboard.writeText(prompt)
17+
setCopied(true)
18+
setTimeout(() => setCopied(false), 2000)
19+
}, [prompt])
20+
21+
return (
22+
<div className={styles.container}>
23+
<Button
24+
onClick={handleCopy}
25+
aria-label={
26+
copied ? 'Prompt copied to clipboard' : 'Copy AI prompt to clipboard'
27+
}>
28+
{copied ? <Check size={14} /> : <Copy size={14} />}
29+
{copied ? 'Copied!' : 'Copy AI prompt'}
30+
</Button>
31+
<details
32+
className={styles.details}
33+
onToggle={(e) => setOpen((e.target as HTMLDetailsElement).open)}>
34+
<summary className={styles.summary}>
35+
<ChevronDown
36+
className={clsx(styles.chevron, open && styles.chevronOpen)}
37+
size={14}
38+
aria-hidden
39+
/>
40+
View prompt
41+
</summary>
42+
<pre className={styles.promptText}>{prompt}</pre>
43+
</details>
44+
</div>
45+
)
46+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { CopyPrompt } from './CopyPrompt'
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
.container {
2+
align-items: flex-start;
3+
display: flex;
4+
flex-direction: column;
5+
gap: 0.5rem;
6+
margin-block: 1.25rem;
7+
}
8+
9+
@media (min-width: 768px) {
10+
.container {
11+
flex-direction: row-reverse;
12+
gap: 1rem;
13+
}
14+
}
15+
16+
.details {
17+
flex: 1;
18+
min-width: 0;
19+
}
20+
21+
.summary {
22+
align-items: center;
23+
color: var(--ifm-color-primary);
24+
cursor: pointer;
25+
display: flex;
26+
font-size: var(--bs-text-sm);
27+
gap: 0.25rem;
28+
list-style: none;
29+
user-select: none;
30+
}
31+
32+
.summary::-webkit-details-marker {
33+
display: none;
34+
}
35+
36+
.chevron {
37+
flex-shrink: 0;
38+
transition: transform 200ms ease;
39+
}
40+
41+
.chevronOpen {
42+
transform: rotate(180deg);
43+
}
44+
45+
.promptText {
46+
background: var(--ifm-code-background);
47+
border: 1px solid var(--ifm-color-emphasis-300);
48+
border-radius: 4px;
49+
font-size: var(--bs-text-sm);
50+
line-height: 1.6;
51+
margin-block: 0.5rem 0;
52+
padding: 0.75rem 1rem;
53+
white-space: pre-wrap;
54+
word-break: break-word;
55+
}

0 commit comments

Comments
 (0)