@kolkrabbi/kol-component 0.1.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/README.md +24 -0
- package/package.json +46 -0
- package/src/atoms/Avatar.jsx +17 -0
- package/src/atoms/Button.jsx +172 -0
- package/src/atoms/ColorSwatch.jsx +126 -0
- package/src/atoms/Divider.jsx +34 -0
- package/src/atoms/Input.jsx +121 -0
- package/src/atoms/Label.jsx +12 -0
- package/src/atoms/Slider.jsx +129 -0
- package/src/atoms/Stepper.jsx +97 -0
- package/src/atoms/Textarea.jsx +70 -0
- package/src/atoms/ToggleCheckbox.jsx +40 -0
- package/src/atoms/ToggleSwitch.jsx +42 -0
- package/src/atoms/TransparentX.jsx +37 -0
- package/src/graphics/Graphic.jsx +53 -0
- package/src/graphics/svg/abstract/abstract-01.svg +3 -0
- package/src/graphics/svg/abstract/abstract-02.svg +3 -0
- package/src/graphics/svg/abstract/abstract-03.svg +3 -0
- package/src/graphics/svg/abstract/abstract-06.svg +4 -0
- package/src/graphics/svg/diagrams/.gitkeep +0 -0
- package/src/graphics/svg/diagrams/ac-structure.svg +90 -0
- package/src/graphics/svg/diagrams/rg-x-height.svg +3 -0
- package/src/graphics/svg/diagrams/structure-grid.svg +618 -0
- package/src/graphics/svg/diagrams/structure-logo.svg +23 -0
- package/src/graphics/svg/patterns/.gitkeep +0 -0
- package/src/graphics/svg/patterns/patt-01.svg +34 -0
- package/src/graphics/svg/patterns/patt-02.svg +34 -0
- package/src/graphics/svg/patterns/patt-03.svg +110 -0
- package/src/graphics/svg/patterns/patt-04.svg +10 -0
- package/src/graphics/svg/patterns/patt-05.svg +62 -0
- package/src/graphics/svg/patterns/patt-06.svg +66 -0
- package/src/graphics/svg/patterns/patt-07.svg +130 -0
- package/src/graphics/svg/patterns/patt-08.svg +434 -0
- package/src/graphics/svg/patterns/patt-09.svg +38 -0
- package/src/graphics/svg/patterns/patt-10.svg +20 -0
- package/src/graphics/svg/patterns/patt-11.svg +38 -0
- package/src/graphics/svg/patterns/patt-12.svg +58 -0
- package/src/graphics/svg/patterns/patt-13.svg +48 -0
- package/src/graphics/svg/patterns/patt-14.svg +90 -0
- package/src/graphics/svg/patterns/patt-15.svg +194 -0
- package/src/graphics/svg/patterns/patt-16.svg +12 -0
- package/src/graphics/svg/social/social-01.svg +18 -0
- package/src/graphics/svg/social/social-02.svg +18 -0
- package/src/graphics/svg/social/social-03.svg +18 -0
- package/src/graphics/svg/social/social-04.svg +18 -0
- package/src/graphics/svg/social/social-05.svg +18 -0
- package/src/graphics/svg/social/social-06.svg +18 -0
- package/src/graphics/svg/social/social-07.svg +22 -0
- package/src/graphics/svg/social/social-08.svg +22 -0
- package/src/graphics/svg/social/social-09.svg +22 -0
- package/src/graphics/svg/social/social-10.svg +6 -0
- package/src/graphics/svg/social/social-11.svg +6 -0
- package/src/graphics/svg/social/social-12.svg +6 -0
- package/src/graphics/svg/social/social-13.svg +9 -0
- package/src/graphics/svg/social/social-14.svg +9 -0
- package/src/graphics/svg/social/social-15.svg +9 -0
- package/src/graphics/svg/structure/diagram-grid-lockup-hori.svg +23 -0
- package/src/graphics/svg/structure/diagram-grid-lockup-vert.svg +25 -0
- package/src/graphics/svg/structure/diagram-grid-logomark.svg +20 -0
- package/src/graphics/svg/structure/diagram-grid-wordmark.svg +18 -0
- package/src/graphics/svg/structure/diagram-logo-lockup-hori.svg +9 -0
- package/src/graphics/svg/structure/diagram-logo-lockup-vert.svg +23 -0
- package/src/graphics/svg/structure/diagram-logo-logomark.svg +7 -0
- package/src/graphics/svg/structure/diagram-logo-wordmark.svg +3 -0
- package/src/graphics/svg/structure/diagram-x-lockup-hori.svg +5 -0
- package/src/graphics/svg/structure/diagram-x-lockup-vert.svg +10 -0
- package/src/graphics/svg/structure/diagram-x-logomark.svg +5 -0
- package/src/graphics/svg/structure/diagram-x-wordmark.svg +5 -0
- package/src/hooks/useReveal.js +28 -0
- package/src/hooks/useScrollSpy.js +56 -0
- package/src/index.js +59 -0
- package/src/molecules/Badge.jsx +51 -0
- package/src/molecules/ContentFilters.jsx +263 -0
- package/src/molecules/Dropdown.jsx +223 -0
- package/src/molecules/DropdownTagFilter.jsx +253 -0
- package/src/molecules/LabeledControl.jsx +66 -0
- package/src/molecules/MenuItem.jsx +148 -0
- package/src/molecules/MenuPopover.jsx +128 -0
- package/src/molecules/Modal.jsx +124 -0
- package/src/molecules/Pill.jsx +33 -0
- package/src/molecules/Popover.jsx +208 -0
- package/src/molecules/PropertyInput.jsx +32 -0
- package/src/molecules/QuantityInput.jsx +174 -0
- package/src/molecules/QuantityStepper.jsx +149 -0
- package/src/molecules/Section.jsx +16 -0
- package/src/molecules/SectionLabel.jsx +59 -0
- package/src/molecules/SegmentedToggle.jsx +56 -0
- package/src/molecules/Tag.jsx +79 -0
- package/src/molecules/ToggleBracket.jsx +45 -0
- package/src/molecules/ViewToggle.jsx +101 -0
- package/src/organisms/Table.jsx +46 -0
- package/src/primitives/Accordion.jsx +45 -0
- package/src/primitives/AssetPlaceholder.jsx +28 -0
- package/src/primitives/Carousel.jsx +50 -0
- package/src/primitives/CodeBlock.jsx +41 -0
- package/src/primitives/ExitPreview.jsx +12 -0
- package/src/primitives/FullscreenOverlay.jsx +39 -0
- package/src/primitives/Image.jsx +38 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { useState } from 'react'
|
|
2
|
+
|
|
3
|
+
export default function CodeBlock({ children, language }) {
|
|
4
|
+
const [copied, setCopied] = useState(false)
|
|
5
|
+
|
|
6
|
+
const onCopy = async () => {
|
|
7
|
+
try {
|
|
8
|
+
await navigator.clipboard.writeText(String(children))
|
|
9
|
+
setCopied(true)
|
|
10
|
+
setTimeout(() => setCopied(false), 1800)
|
|
11
|
+
} catch {
|
|
12
|
+
/* clipboard blocked — silent */
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<div className="kol-codeblock">
|
|
18
|
+
{language && <span className="kol-codeblock-lang">{language}</span>}
|
|
19
|
+
<button
|
|
20
|
+
type="button"
|
|
21
|
+
className="kol-codeblock-copy"
|
|
22
|
+
onClick={onCopy}
|
|
23
|
+
aria-label={copied ? 'Copied' : 'Copy to clipboard'}
|
|
24
|
+
title={copied ? 'Copied' : 'Copy'}
|
|
25
|
+
>
|
|
26
|
+
{copied ? (
|
|
27
|
+
<svg viewBox="0 0 20 20" width="14" height="14" aria-hidden="true">
|
|
28
|
+
<path d="M5 10 L9 14 L15 6" fill="none" stroke="currentColor" strokeWidth="1.6" strokeLinecap="round" strokeLinejoin="round" />
|
|
29
|
+
</svg>
|
|
30
|
+
) : (
|
|
31
|
+
<svg viewBox="0 0 20 20" width="14" height="14" aria-hidden="true">
|
|
32
|
+
<rect x="6" y="3" width="10" height="12" rx="1" fill="none" stroke="currentColor" strokeWidth="1.4" />
|
|
33
|
+
<rect x="4" y="6" width="10" height="12" rx="1" fill="none" stroke="currentColor" strokeWidth="1.4" />
|
|
34
|
+
</svg>
|
|
35
|
+
)}
|
|
36
|
+
<span className="leading-none">{copied ? 'Copied' : 'Copy'}</span>
|
|
37
|
+
</button>
|
|
38
|
+
<pre><code>{children}</code></pre>
|
|
39
|
+
</div>
|
|
40
|
+
)
|
|
41
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Link, useLocation } from 'react-router-dom'
|
|
2
|
+
|
|
3
|
+
export default function ExitPreview() {
|
|
4
|
+
const { pathname: _pathname } = useLocation()
|
|
5
|
+
|
|
6
|
+
return (
|
|
7
|
+
<Link to="/" className="kol-exit-preview" aria-label="Exit preview">
|
|
8
|
+
<span className="kol-exit-preview-icon" aria-hidden="true">×</span>
|
|
9
|
+
<span className="kol-exit-preview-label">Exit</span>
|
|
10
|
+
</Link>
|
|
11
|
+
)
|
|
12
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react'
|
|
2
|
+
|
|
3
|
+
export default function FullscreenOverlay({ open, onClose, children }) {
|
|
4
|
+
const sheetRef = useRef(null)
|
|
5
|
+
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
if (!open) return
|
|
8
|
+
const onKey = (e) => { if (e.key === 'Escape') onClose?.() }
|
|
9
|
+
document.addEventListener('keydown', onKey)
|
|
10
|
+
const prev = document.body.style.overflow
|
|
11
|
+
document.body.style.overflow = 'hidden'
|
|
12
|
+
return () => {
|
|
13
|
+
document.removeEventListener('keydown', onKey)
|
|
14
|
+
document.body.style.overflow = prev
|
|
15
|
+
}
|
|
16
|
+
}, [open, onClose])
|
|
17
|
+
|
|
18
|
+
if (!open) return null
|
|
19
|
+
|
|
20
|
+
const onBackdropClick = (e) => {
|
|
21
|
+
if (sheetRef.current && !sheetRef.current.contains(e.target)) onClose?.()
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<div className="kol-overlay" role="dialog" aria-modal="true" onMouseDown={onBackdropClick}>
|
|
26
|
+
<div ref={sheetRef} className="kol-overlay-sheet">
|
|
27
|
+
<button
|
|
28
|
+
type="button"
|
|
29
|
+
className="kol-overlay-close"
|
|
30
|
+
onClick={onClose}
|
|
31
|
+
aria-label="Close"
|
|
32
|
+
>
|
|
33
|
+
×
|
|
34
|
+
</button>
|
|
35
|
+
{children}
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
)
|
|
39
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Image — raster wrapper with graceful missing-asset fallback.
|
|
3
|
+
*
|
|
4
|
+
* Replaces raw <img> where brand raster assets may be missing. On load error,
|
|
5
|
+
* renders AssetPlaceholder with category/name labels so the slot stays
|
|
6
|
+
* visible at its intended size (aspect-ratio preserved).
|
|
7
|
+
*/
|
|
8
|
+
import { useState } from 'react'
|
|
9
|
+
import AssetPlaceholder from './AssetPlaceholder'
|
|
10
|
+
|
|
11
|
+
export default function Image({
|
|
12
|
+
src,
|
|
13
|
+
alt = '',
|
|
14
|
+
category,
|
|
15
|
+
name,
|
|
16
|
+
aspectRatio,
|
|
17
|
+
className = '',
|
|
18
|
+
loading = 'lazy',
|
|
19
|
+
...rest
|
|
20
|
+
}) {
|
|
21
|
+
const [failed, setFailed] = useState(false)
|
|
22
|
+
|
|
23
|
+
if (failed || !src) {
|
|
24
|
+
return <AssetPlaceholder category={category} name={name} aspectRatio={aspectRatio} note="missing" className={className} />
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<img
|
|
29
|
+
src={src}
|
|
30
|
+
alt={alt}
|
|
31
|
+
loading={loading}
|
|
32
|
+
className={`kol-image block max-w-full h-auto ${className}`.trim()}
|
|
33
|
+
style={aspectRatio ? { aspectRatio } : undefined}
|
|
34
|
+
onError={() => setFailed(true)}
|
|
35
|
+
{...rest}
|
|
36
|
+
/>
|
|
37
|
+
)
|
|
38
|
+
}
|