UNPKG

sarif-explorer

Version:

A modern SARIF report viewer that converts SARIF files into interactive, shareable HTML reports with file explorer, collapsible issue lists, and code snippets.

13 lines 1.43 kB
'use client'; import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime"; export const CodeSnippet = ({ code, language, highlightLine, startLine = 1 }) => { const lines = code.split('\n'); const maxLineNumber = startLine + lines.length - 1; const lineNumberWidth = maxLineNumber.toString().length; return (_jsxs("div", { className: "mt-6", children: [_jsxs("div", { className: "bg-gray-100 px-4 py-3 rounded-t-xl border border-gray-200 flex justify-between items-center text-sm", children: [_jsx("span", { className: "language-badge bg-gray-200 text-gray-700 px-3 py-1 rounded-full text-xs font-medium", children: language }), highlightLine && (_jsxs("span", { className: "text-gray-600", children: ["Highlighted: Line ", highlightLine] }))] }), _jsx("div", { className: "bg-white text-gray-900 rounded-b-xl border border-gray-200 overflow-hidden shadow-sm", children: _jsx("pre", { className: "p-6 m-0 font-mono text-sm leading-relaxed", children: lines.map((line, index) => { const lineNumber = startLine + index; const isHighlighted = lineNumber === highlightLine; return (_jsx("div", { className: `code-line ${isHighlighted ? 'highlighted' : ''} transition-all duration-200`, children: _jsx("span", { className: "line-content", children: line }) }, index)); }) }) })] })); }; //# sourceMappingURL=CodeSnippet.js.map