Files
Kilo-Org_kilo/packages/kilo-docs/components/Image.tsx
T
Brendan O'Leary c0efe5f2f2 Add prelim KiloClaw docs (#5881)
* Add preli KiloClaw docs

* 🦀

* Add in what you cando with OpenClaw

* Update apps/kilocode-docs/pages/automate/kiloclaw.md

Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>

* Update apps/kilocode-docs/pages/automate/kiloclaw.md

Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>

* Update apps/kilocode-docs/pages/automate/kiloclaw.md

Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>

* Apply suggestion from @kiloconnect[bot]

Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>

* Apply suggestion from @kiloconnect[bot]

Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>

* Update apps/kilocode-docs/pages/automate/kiloclaw.md

---------

Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
2026-02-16 16:36:43 -05:00

59 lines
1.2 KiB
TypeScript

import React from "react"
interface ImageProps {
src: string
alt: string
width?: string
height?: string
caption?: string
}
// Helper to add 'px' to numeric values that don't have units
function addPxIfNeeded(value: string): string {
// If the value is purely numeric, add 'px'
if (/^\d+(\.\d+)?$/.test(value)) {
return `${value}px`
}
return value
}
export function Image({ src, alt, width, height, caption }: ImageProps) {
const imgStyle: React.CSSProperties = {
maxWidth: "100%",
height: "auto",
}
if (width) imgStyle.width = addPxIfNeeded(width)
if (height) imgStyle.height = addPxIfNeeded(height)
const figureStyle: React.CSSProperties = {
margin: "1.5rem 0",
maxWidth: "100%",
overflow: "hidden",
}
// If width is specified, apply it to the figure to constrain caption width
if (width) {
figureStyle.width = addPxIfNeeded(width)
figureStyle.maxWidth = "100%"
}
return (
<figure style={figureStyle}>
<img src={src} alt={alt} style={imgStyle} />
{caption && (
<figcaption
style={{
fontStyle: "italic",
textAlign: "center",
marginTop: "0.5rem",
color: "var(--gray-600, #6b7280)",
width: "100%",
}}>
{caption}
</figcaption>
)}
</figure>
)
}