@overdoser/react-toolkit 0.13.0 → 0.14.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/index.css +1 -1
- package/index.layered.css +1 -1
- package/llms.txt +2 -0
- package/manifest.json +5 -2
- package/package.json +1 -1
- package/recipes/floating-copy-button.tsx +68 -0
package/llms.txt
CHANGED
|
@@ -151,6 +151,8 @@ Example:
|
|
|
151
151
|
<CopyButton value={shareUrl} iconOnly aria-label="Copy link" /> // icon only
|
|
152
152
|
```
|
|
153
153
|
|
|
154
|
+
Floating over content (e.g. pinned to a code snippet's corner): `secondary`/`ghost` are transparent at rest, so wrap the button in a div with a solid `background: var(--crk-color-bg)` and the button's border radius — every state then composites over that surface instead of the content underneath. Prefer `variant="secondary"` there (visible outline at rest; ghost has none). Full copy-paste version: `recipes/floating-copy-button.tsx`.
|
|
155
|
+
|
|
154
156
|
### Link
|
|
155
157
|
Import: `import { Link } from '@overdoser/react-toolkit'`
|
|
156
158
|
Element: `<a>` (forwards ref, accepts all native anchor props).
|
package/manifest.json
CHANGED
|
@@ -248,7 +248,7 @@
|
|
|
248
248
|
"element": "button",
|
|
249
249
|
"extendsNativeProps": "button (except children)",
|
|
250
250
|
"forwardsRef": true,
|
|
251
|
-
"notes": "Preconfigured ActionButton for copy-to-clipboard: clipboard icon morphs into a check, label swaps Copy \u2192 Copied, success tint, auto-reset. All ActionButton props apply. Falls back to execCommand('copy') without the Clipboard API.",
|
|
251
|
+
"notes": "Preconfigured ActionButton for copy-to-clipboard: clipboard icon morphs into a check, label swaps Copy \u2192 Copied, success tint, auto-reset. All ActionButton props apply. Falls back to execCommand('copy') without the Clipboard API. Floating over content (e.g. a code snippet): secondary/ghost are transparent at rest, so give a wrapper a solid --crk-color-bg fill + the button's radius \u2014 see recipes/floating-copy-button.tsx.",
|
|
252
252
|
"props": {
|
|
253
253
|
"value": {
|
|
254
254
|
"type": "string | (() => string | Promise<string>)",
|
|
@@ -3499,6 +3499,9 @@
|
|
|
3499
3499
|
"recipes/interactive-pie-chart.tsx",
|
|
3500
3500
|
"recipes/trading-chart.tsx",
|
|
3501
3501
|
"recipes/tag-input.tsx",
|
|
3502
|
-
"recipes/multi-select-in-modal.tsx"
|
|
3502
|
+
"recipes/multi-select-in-modal.tsx",
|
|
3503
|
+
"recipes/comparison-table.tsx",
|
|
3504
|
+
"recipes/live-timeline-feed.tsx",
|
|
3505
|
+
"recipes/floating-copy-button.tsx"
|
|
3503
3506
|
]
|
|
3504
3507
|
}
|
package/package.json
CHANGED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { CopyButton } from '@overdoser/react-toolkit';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Copy button floating over a code snippet (docs-site pattern).
|
|
5
|
+
*
|
|
6
|
+
* The two things this recipe encodes:
|
|
7
|
+
*
|
|
8
|
+
* 1. **Solid wrapper surface.** The `secondary` and `ghost` variants are
|
|
9
|
+
* transparent at rest by design, so a button floated over content would
|
|
10
|
+
* let the code text run straight under the glyph. Give the *wrapper* a
|
|
11
|
+
* solid `--crk-color-bg` fill (with the button's border radius) — every
|
|
12
|
+
* button state then composites over that surface instead of the code.
|
|
13
|
+
* 2. **`secondary` over `ghost` for floating use.** Ghost has no border in
|
|
14
|
+
* its resting state; secondary's inset outline gives the floating button
|
|
15
|
+
* a visible affordance against the snippet background.
|
|
16
|
+
*
|
|
17
|
+
* The hover/success fills themselves are opaque (they mix the accent into
|
|
18
|
+
* `--crk-color-bg`), so mid-morph the code never shines through the button.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
interface CodeSnippetProps {
|
|
22
|
+
code: string;
|
|
23
|
+
/** Language hint rendered as a class for external highlighters. @default undefined */
|
|
24
|
+
language?: string;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function CodeSnippet({ code, language }: CodeSnippetProps) {
|
|
28
|
+
return (
|
|
29
|
+
<div style={{ position: 'relative' }}>
|
|
30
|
+
<pre
|
|
31
|
+
style={{
|
|
32
|
+
margin: 0,
|
|
33
|
+
padding: '16px 20px',
|
|
34
|
+
// Keep long lines scrollable; the button stays pinned to the box.
|
|
35
|
+
overflowX: 'auto',
|
|
36
|
+
background: 'var(--crk-color-bg-muted)',
|
|
37
|
+
border: '1px solid var(--crk-color-border-hover)',
|
|
38
|
+
borderRadius: 'var(--crk-border-radius-md)',
|
|
39
|
+
fontSize: 'var(--crk-font-size-sm)',
|
|
40
|
+
lineHeight: 1.6,
|
|
41
|
+
}}
|
|
42
|
+
>
|
|
43
|
+
<code className={language ? `language-${language}` : undefined}>{code}</code>
|
|
44
|
+
</pre>
|
|
45
|
+
{/* Solid layer under the (transparent-at-rest) button — see note above. */}
|
|
46
|
+
<div
|
|
47
|
+
style={{
|
|
48
|
+
position: 'absolute',
|
|
49
|
+
top: 8,
|
|
50
|
+
right: 8,
|
|
51
|
+
background: 'var(--crk-color-bg)',
|
|
52
|
+
borderRadius: 'var(--crk-border-radius-md)',
|
|
53
|
+
}}
|
|
54
|
+
>
|
|
55
|
+
<CopyButton value={code} variant="secondary" iconOnly aria-label="Copy code" />
|
|
56
|
+
</div>
|
|
57
|
+
</div>
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export function Example() {
|
|
62
|
+
return (
|
|
63
|
+
<CodeSnippet
|
|
64
|
+
language="bash"
|
|
65
|
+
code={'npm install @overdoser/react-toolkit\n# then import the theme once:\n# import "@overdoser/react-toolkit/theme.css"'}
|
|
66
|
+
/>
|
|
67
|
+
);
|
|
68
|
+
}
|