lumina/ui/views/components/print-view.js
2025-11-29 23:13:05 +03:00

64 lines
1.5 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import React from 'react'
import './print-view.scss'
/**
* Print-friendly wrapper component
*/
export function PrintView({children, title, className = ''}) {
React.useEffect(() => {
// Add print styles
const style = document.createElement('style')
style.textContent = `
@media print {
body * {
visibility: hidden;
}
.print-content, .print-content * {
visibility: visible;
}
.print-content {
position: absolute;
left: 0;
top: 0;
width: 100%;
}
.no-print {
display: none !important;
}
}
`
document.head.appendChild(style)
return () => {
document.head.removeChild(style)
}
}, [])
return (
<div className={`print-content ${className}`}>
{title && <h1 className="print-title">{title}</h1>}
{children}
</div>
)
}
/**
* Print button component
*/
export function PrintButton({title, className = ''}) {
const handlePrint = () => {
window.print()
}
return (
<button
className={`print-button ${className}`}
onClick={handlePrint}
title="Print this page"
>
🖨️ Print
</button>
)
}