@flanksource/facet
v0.1.3
Published
Build beautiful datasheets and PDFs from React templates
Readme
@facet/core
Build beautiful, print-ready datasheets and PDFs from React templates.
@facet is a framework for creating professional datasheets, reports, and documentation using React components. It provides a rich component library optimized for print and PDF generation, along with a powerful CLI for building HTML and PDF outputs.
Features
- 📄 Print-optimized components - 47+ components designed for professional datasheets
- 🎨 React & TypeScript - Full type safety and modern React patterns
- 🔧 Zero-config CLI - Build HTML and PDF with a single command
- 🔗 Component imports -
import { StatCard } from '@facet' - ⚡ Fast builds - Powered by Vite with smart caching
- 📦 Isolated builds -
.facet/build directory (like.nextin Next.js)
Installation
npm install @facet/coreQuick Start
1. Create a Template
Create a file MyDatasheet.tsx in your project:
import React from 'react';
import {
DatasheetTemplate,
Header,
Page,
StatCard,
Section,
BulletList
} from '@facet';
export default function MyDatasheet() {
return (
<DatasheetTemplate>
<Header
title="Mission Control Platform"
subtitle="Cloud-Native Observability & Incident Management"
/>
<Page>
<Section title="Key Metrics">
<div className="grid grid-cols-3 gap-4">
<StatCard label="Response Time" value="< 2min" />
<StatCard label="Uptime" value="99.99%" />
<StatCard label="Incidents Resolved" value="1,247" />
</div>
</Section>
<Section title="Key Features">
<BulletList items={[
'Real-time incident detection and alerting',
'Automated runbook execution',
'Multi-cloud observability',
'Integrated ChatOps workflows'
]} />
</Section>
</Page>
</DatasheetTemplate>
);
}2. Build Your Datasheet
npx facet build MyDatasheet.tsxThis creates:
dist/datasheet-MyDatasheet.html- Print-ready HTMLdist/datasheet-MyDatasheet-scoped.html- Scoped for embedding in docs.facet/- Build cache directory (can be gitignored)
3. Generate PDF (Coming Soon)
npx facet pdf MyDatasheet.tsxAvailable Components
Layout Components
DatasheetTemplate- Main template wrapper with print stylesPage- Single page containerSection- Section with optional titleHeader- Title header with subtitle and logo supportFooter- Page footer with customizable content
Data Display
StatCard- Key metric display with label and valueMetricGrid- Grid of metrics with iconsCompactTable- Dense data tablesSpecificationTable- Technical specification tablesComparisonTable- Side-by-side comparisons
Content Components
BulletList- Styled bullet point listsCalloutBox- Highlighted callout sectionsTwoColumnSection- Two-column layoutsValueProposition- Value prop with icon and descriptionCapabilitySection- Feature capabilities display
Interactive Elements
IntegrationGrid- Integration logos and descriptionsSocialProof- Customer logos and testimonialsCallToAction- CTA buttons and links
Visualizations
ProgressBar- Progress indicatorsScoreGauge- Circular score gaugesKPITargetActual- Target vs actual KPI displays
Code & Terminal
SyntaxHighlighter- Syntax-highlighted code blocksTerminalOutput- Terminal-style outputQueryResponseExample- Query/response examples
Project Management
ProjectSummaryCard- Project summary displaysTaskSummarySection- Task status summariesStageIndicator- Multi-stage progress indicatorsStageSection- Stage-based content sections
Security & Compliance
SecurityChecksTable- Security check resultsVulnerabilityBreakdown- Vulnerability statisticsSeverityStatCard- Severity-based statsAlertsTable- Alert listings
See full component documentation →
CLI Commands
facet build <template>
Build HTML datasheet from a React template.
facet build MyDatasheet.tsx [options]
Options:
-o, --output-dir <dir> Output directory (default: "dist")
-v, --verbose Enable verbose logging
--no-scoped Skip generating scoped versionExample:
facet build MyDatasheet.tsx --output-dir ./build --verbosefacet pdf <template>
Generate PDF from a React template.
facet pdf MyDatasheet.tsx [options]
Options:
-d, --data <file> JSON data file
-o, --output-dir <dir> Output directory (default: "dist")
-v, --verbose Enable verbose loggingExample:
facet pdf MyDatasheet.tsx --data data.jsonHow It Works
Build Process
When you run facet build MyDatasheet.tsx:
- Setup
.facet/directory - Creates build working directory - Symlink your files - Symlinks your templates and assets into
.facet/src/ - Symlink node_modules - Links dependencies for fast access
- Generate configs - Creates
vite.config.ts,tsconfig.json,entry.tsx - Run Vite build - Compiles React + TypeScript + MDX to static bundle
- Server-side render - Renders React to static HTML
- Output files - Writes HTML to your
dist/directory
your-project/
├── MyDatasheet.tsx # Your template
├── node_modules/
│ └── @facet/ # Installed package
├── .facet/ # Build cache (auto-generated)
│ ├── src/ # Symlinks to your files
│ │ └── MyDatasheet.tsx -> ../../MyDatasheet.tsx
│ ├── node_modules/ # Symlink to ../node_modules
│ ├── entry.tsx # Generated entry point
│ ├── vite.config.ts # Generated Vite config
│ └── dist/ # Vite build output
└── dist/ # Final output
├── datasheet-MyDatasheet.html
└── datasheet-MyDatasheet-scoped.htmlWhy .facet/?
Similar to Next.js (.next/) or Nuxt (.nuxt/), the .facet/ directory:
- Isolates build artifacts - Keeps your project clean
- Enables fast rebuilds - Symlinks avoid file copying
- Supports incremental builds - Only rebuilds what changed
- Simplifies debugging - All build files in one place
Add to .gitignore:
.facet/
dist/Import Patterns
Default Import (All Components)
import { StatCard, Header, Page } from '@facet';Individual Component Imports
import StatCard from '@facet/StatCard';
import Header from '@facet/Header';TypeScript Support
All components include full TypeScript definitions:
import { StatCard } from '@facet';
<StatCard
label="Response Time" // string
value="< 2min" // string | number
trend="up" // 'up' | 'down' | 'neutral' (optional)
icon="clock" // string (optional)
/>Styling
Components use Tailwind CSS for styling. Include Tailwind in your project:
npm install -D tailwindcss autoprefixer postcsstailwind.config.js:
module.exports = {
content: [
'./MyDatasheet.tsx',
'./node_modules/@facet/core/src/components/**/*.tsx'
],
theme: {
extend: {},
},
plugins: [],
}MDX Support
Templates support MDX for content-rich pages:
// MyDatasheet.tsx
import Content from './content.mdx';
export default function MyDatasheet() {
return (
<DatasheetTemplate>
<Content />
</DatasheetTemplate>
);
}# content.mdx
## Overview
This is **MDX content** with React components:
<StatCard label="Users" value="10,000+" />
- Bullet point one
- Bullet point twoDevelopment
Component Development
Use Storybook for component development:
npm run storybookBuilding the CLI
npm run build:cliPublishing
npm run prepublishOnly # Builds CLI automatically
npm publishArchitecture
src/components/- React component library (47 components)src/styles.css- Global styles and Tailwindcli/- CLI package sourcecli/src/builders/- Build orchestrationcli/src/generators/- HTML/PDF generatorscli/src/utils/- Shared utilitiescli/src/plugins/- Vite plugins
assets/- Static assets (logos, icons)
Examples
See src/examples/ for complete working examples:
- Basic Datasheet - Simple single-page datasheet
- Multi-page Report - Complex multi-page document
- Security Report - Security-focused datasheet
- POC Evaluation - POC evaluation template
Contributing
This is an internal Flanksource package. For issues or feature requests, contact the platform team.
License
Proprietary - Flanksource Inc.
Built with ❤️ by Flanksource
