// Use rfp-bg-code-bg instead
```
**Theme-Aware Third-Party Libraries:**
For libraries with theme props (e.g., `react-syntax-highlighter`), use `useResolvedTheme()`:
```tsx
import { useResolvedTheme } from '@eternalheart/react-file-preview';
import { Prism as SyntaxHighlighter } from 'react-syntax-highlighter';
import { vscDarkPlus, vs } from 'react-syntax-highlighter/dist/esm/styles/prism';
export const CodeRenderer = forwardRef
((props, ref) => {
const resolvedTheme = useResolvedTheme(); // 'dark' | 'light'
return (
{code}
);
});
```
**Testing:**
Always test your custom renderer in both Light and Dark themes:
```tsx
```
Verify:
- Text is readable in both themes (no white-on-white or black-on-black)
- Borders and dividers are visible
- Hover states have sufficient contrast
- Code blocks follow theme (not always dark)
##
Custom Styling
The component is built with Tailwind CSS. You can customize styles by overriding CSS variables:
```css
/* Custom theme colors */
:root {
--primary-color: #8b5cf6;
--secondary-color: #ec4899;
}
```
##
Keyboard Shortcuts
- `ESC` - Close preview
- `←` - Previous file
- `→` - Next file
- `Mouse Wheel` - Zoom image (image preview only)
##
Documentation
- [Online Demo](https://wh131462.github.io/file-preview) - Live demo
##
Context7 Support
This project supports [Context7](https://context7.com) MCP Server. If you are using AI coding assistants (such as Claude Code, Cursor, etc.), you can configure the Context7 MCP Server to get the latest documentation and code examples for `@eternalheart/react-file-preview`, enabling a better AI-assisted development experience.
### How to Use
1. Add the Context7 MCP Server to your AI tool configuration
2. When interacting with AI, Context7 will automatically provide up-to-date API docs and usage examples for this library
3. Get more accurate code suggestions and answers without manually looking up documentation
> For more details on configuring Context7, please visit [Context7 official documentation](https://github.com/upstash/context7).
##
Development
### For Library Development
```bash
# Clone repository
git clone https://github.com/wh131462/file-preview.git
# Install dependencies
pnpm install
# Start dev server (demo app)
pnpm dev
# Build library (for npm)
pnpm build:lib
# Build demo app (for GitHub Pages)
pnpm build:demo
```
### Project Structure
```
react-file-preview/
├── src/
│ ├── index.ts # Library entry point
│ ├── FilePreviewModal.tsx # Main component
│ ├── types.ts # Type definitions
│ ├── utils/ # Utility functions
│ ├── renderers/ # File type renderers
│ ├── App.tsx # Demo app
│ └── main.tsx # Demo app entry
├── lib/ # Built library (npm package)
├── dist/ # Built demo app (GitHub Pages)
└── vite.config.lib.ts # Library build config
```
##
License
[MIT](./LICENSE) © [EternalHeart](https://github.com/wh131462)
##
Contributing
Issues and Pull Requests are welcome!
##
Links
- [GitHub](https://github.com/wh131462/file-preview)
- [npm](https://www.npmjs.com/package/@eternalheart/react-file-preview)
- [Online Demo](https://wh131462.github.io/file-preview)
- [Issue Tracker](https://github.com/wh131462/file-preview/issues)