@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.
Files changed (98) hide show
  1. package/README.md +24 -0
  2. package/package.json +46 -0
  3. package/src/atoms/Avatar.jsx +17 -0
  4. package/src/atoms/Button.jsx +172 -0
  5. package/src/atoms/ColorSwatch.jsx +126 -0
  6. package/src/atoms/Divider.jsx +34 -0
  7. package/src/atoms/Input.jsx +121 -0
  8. package/src/atoms/Label.jsx +12 -0
  9. package/src/atoms/Slider.jsx +129 -0
  10. package/src/atoms/Stepper.jsx +97 -0
  11. package/src/atoms/Textarea.jsx +70 -0
  12. package/src/atoms/ToggleCheckbox.jsx +40 -0
  13. package/src/atoms/ToggleSwitch.jsx +42 -0
  14. package/src/atoms/TransparentX.jsx +37 -0
  15. package/src/graphics/Graphic.jsx +53 -0
  16. package/src/graphics/svg/abstract/abstract-01.svg +3 -0
  17. package/src/graphics/svg/abstract/abstract-02.svg +3 -0
  18. package/src/graphics/svg/abstract/abstract-03.svg +3 -0
  19. package/src/graphics/svg/abstract/abstract-06.svg +4 -0
  20. package/src/graphics/svg/diagrams/.gitkeep +0 -0
  21. package/src/graphics/svg/diagrams/ac-structure.svg +90 -0
  22. package/src/graphics/svg/diagrams/rg-x-height.svg +3 -0
  23. package/src/graphics/svg/diagrams/structure-grid.svg +618 -0
  24. package/src/graphics/svg/diagrams/structure-logo.svg +23 -0
  25. package/src/graphics/svg/patterns/.gitkeep +0 -0
  26. package/src/graphics/svg/patterns/patt-01.svg +34 -0
  27. package/src/graphics/svg/patterns/patt-02.svg +34 -0
  28. package/src/graphics/svg/patterns/patt-03.svg +110 -0
  29. package/src/graphics/svg/patterns/patt-04.svg +10 -0
  30. package/src/graphics/svg/patterns/patt-05.svg +62 -0
  31. package/src/graphics/svg/patterns/patt-06.svg +66 -0
  32. package/src/graphics/svg/patterns/patt-07.svg +130 -0
  33. package/src/graphics/svg/patterns/patt-08.svg +434 -0
  34. package/src/graphics/svg/patterns/patt-09.svg +38 -0
  35. package/src/graphics/svg/patterns/patt-10.svg +20 -0
  36. package/src/graphics/svg/patterns/patt-11.svg +38 -0
  37. package/src/graphics/svg/patterns/patt-12.svg +58 -0
  38. package/src/graphics/svg/patterns/patt-13.svg +48 -0
  39. package/src/graphics/svg/patterns/patt-14.svg +90 -0
  40. package/src/graphics/svg/patterns/patt-15.svg +194 -0
  41. package/src/graphics/svg/patterns/patt-16.svg +12 -0
  42. package/src/graphics/svg/social/social-01.svg +18 -0
  43. package/src/graphics/svg/social/social-02.svg +18 -0
  44. package/src/graphics/svg/social/social-03.svg +18 -0
  45. package/src/graphics/svg/social/social-04.svg +18 -0
  46. package/src/graphics/svg/social/social-05.svg +18 -0
  47. package/src/graphics/svg/social/social-06.svg +18 -0
  48. package/src/graphics/svg/social/social-07.svg +22 -0
  49. package/src/graphics/svg/social/social-08.svg +22 -0
  50. package/src/graphics/svg/social/social-09.svg +22 -0
  51. package/src/graphics/svg/social/social-10.svg +6 -0
  52. package/src/graphics/svg/social/social-11.svg +6 -0
  53. package/src/graphics/svg/social/social-12.svg +6 -0
  54. package/src/graphics/svg/social/social-13.svg +9 -0
  55. package/src/graphics/svg/social/social-14.svg +9 -0
  56. package/src/graphics/svg/social/social-15.svg +9 -0
  57. package/src/graphics/svg/structure/diagram-grid-lockup-hori.svg +23 -0
  58. package/src/graphics/svg/structure/diagram-grid-lockup-vert.svg +25 -0
  59. package/src/graphics/svg/structure/diagram-grid-logomark.svg +20 -0
  60. package/src/graphics/svg/structure/diagram-grid-wordmark.svg +18 -0
  61. package/src/graphics/svg/structure/diagram-logo-lockup-hori.svg +9 -0
  62. package/src/graphics/svg/structure/diagram-logo-lockup-vert.svg +23 -0
  63. package/src/graphics/svg/structure/diagram-logo-logomark.svg +7 -0
  64. package/src/graphics/svg/structure/diagram-logo-wordmark.svg +3 -0
  65. package/src/graphics/svg/structure/diagram-x-lockup-hori.svg +5 -0
  66. package/src/graphics/svg/structure/diagram-x-lockup-vert.svg +10 -0
  67. package/src/graphics/svg/structure/diagram-x-logomark.svg +5 -0
  68. package/src/graphics/svg/structure/diagram-x-wordmark.svg +5 -0
  69. package/src/hooks/useReveal.js +28 -0
  70. package/src/hooks/useScrollSpy.js +56 -0
  71. package/src/index.js +59 -0
  72. package/src/molecules/Badge.jsx +51 -0
  73. package/src/molecules/ContentFilters.jsx +263 -0
  74. package/src/molecules/Dropdown.jsx +223 -0
  75. package/src/molecules/DropdownTagFilter.jsx +253 -0
  76. package/src/molecules/LabeledControl.jsx +66 -0
  77. package/src/molecules/MenuItem.jsx +148 -0
  78. package/src/molecules/MenuPopover.jsx +128 -0
  79. package/src/molecules/Modal.jsx +124 -0
  80. package/src/molecules/Pill.jsx +33 -0
  81. package/src/molecules/Popover.jsx +208 -0
  82. package/src/molecules/PropertyInput.jsx +32 -0
  83. package/src/molecules/QuantityInput.jsx +174 -0
  84. package/src/molecules/QuantityStepper.jsx +149 -0
  85. package/src/molecules/Section.jsx +16 -0
  86. package/src/molecules/SectionLabel.jsx +59 -0
  87. package/src/molecules/SegmentedToggle.jsx +56 -0
  88. package/src/molecules/Tag.jsx +79 -0
  89. package/src/molecules/ToggleBracket.jsx +45 -0
  90. package/src/molecules/ViewToggle.jsx +101 -0
  91. package/src/organisms/Table.jsx +46 -0
  92. package/src/primitives/Accordion.jsx +45 -0
  93. package/src/primitives/AssetPlaceholder.jsx +28 -0
  94. package/src/primitives/Carousel.jsx +50 -0
  95. package/src/primitives/CodeBlock.jsx +41 -0
  96. package/src/primitives/ExitPreview.jsx +12 -0
  97. package/src/primitives/FullscreenOverlay.jsx +39 -0
  98. 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
+ }