@matteoaliano/forest-ui 0.8.4 → 0.8.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,141 +1,141 @@
1
- ---
2
- name: forest-alkemy-plus
3
- description: Forest UI Design System rules for the Alkemy+ (charcoal/red) preset. Enforces correct imports, component usage, and theming with @matteoaliano/forest-ui. Use when the project uses forest-ui, forest-alkemy-plus preset, or when user builds UI components in a forest-ui project. Triggers on "forest", "forest-ui", "forest alkemy", "forest alkemy+", "@matteoaliano/forest-ui".
4
- metadata:
5
- author: Forest Design System
6
- version: 0.8.4
7
- ---
8
-
9
- # Forest UI — Alkemy+ Preset
10
-
11
- ## Golden Rules
12
-
13
- 1. **NEVER import from `@mui/material` directly.** Always import from `@matteoaliano/forest-ui`. All MUI components, layout primitives, transitions, form helpers, and hooks are re-exported. The only exception is `@mui/icons-material` — import icons from there directly.
14
- 2. **ALWAYS import the Forest font CSS at app entry** (see Setup → Step 2). The package bundles Aeonik / Aeonik Mono / AlkemyBETA as `.woff2` + `@font-face` CSS, but it does **not** auto-inject them — the consuming app must import the CSS. Skip this and `font-family: "Aeonik"` silently falls back to system sans-serif (Helvetica / Arial / DejaVu), inconsistently across machines. This is the #1 reason Forest sites "don't look right".
15
- 3. **ALWAYS wrap your app root with `<ForestProvider>`** — it applies the theme and CSS baseline.
16
- 4. **NEVER use inline colors or spacing values.** Use design tokens or MUI's `sx` prop with theme values (`p: 4`, `backgroundColor: "primary.main"`).
17
- 5. **NEVER create custom component wrappers** for things Forest UI already provides.
18
- 6. **TypeScript is required.** All components export their prop types (e.g. `type ButtonProps`).
19
- 7. **ALWAYS use the Outlined variant of MUI icons.** Import from `@mui/icons-material/*Outlined` (e.g. `CloseOutlined`, `MailOutlined`). Never use filled, Rounded, Sharp, or TwoTone variants.
20
-
21
- ## Setup
22
-
23
- ### Step 1 — Install
24
-
25
- ```bash
26
- npm install @matteoaliano/forest-ui \
27
- @mui/material@^7 @mui/icons-material@^7 \
28
- @mui/x-charts@^7 @mui/x-data-grid@^7 @mui/x-date-pickers@^8 \
29
- @emotion/react @emotion/styled dayjs
30
- ```
31
-
32
- > **Note:** Every `@mui/*` package above is a **peer dependency** of `@matteoaliano/forest-ui`. Install them at the pinned major versions shown — newer majors are not yet supported and will fail `npm install` with `ERESOLVE`. Always import components, hooks, and layout primitives from `@matteoaliano/forest-ui` (Forest UI re-exports them with branded defaults). The single exception is `@mui/icons-material` — import icons from there directly, using the Outlined variant (e.g. `import { CloseOutlined } from "@mui/icons-material"`).
33
-
34
- ### Step 2 — Load the fonts (CRITICAL — do this before anything else)
35
-
36
- The Forest preset sets `fontFamily: '"Aeonik", sans-serif'`. Without the matching `@font-face` rules, the browser cannot resolve "Aeonik" and silently falls back to a system font. **Forest UI ships the font files in the npm tarball, but the consuming app must import the CSS.** Add these three imports at the top of your root entry file:
37
-
38
- ```tsx
39
- // Next.js App Router → app/layout.tsx (above any other CSS imports)
40
- // Next.js Pages Router → pages/_app.tsx
41
- // Vite / CRA → src/main.tsx or src/index.tsx
42
- import "@matteoaliano/forest-ui/fonts/aeonik/aeonik.css";
43
- import "@matteoaliano/forest-ui/fonts/aeonik-mono/aeonik-mono.css";
44
- import "@matteoaliano/forest-ui/fonts/alkemy-beta/alkemy-beta.css";
45
- ```
46
-
47
- No `public/fonts/` copy, no `next/font/local`, no manual `@font-face` rules — the bundler resolves the relative `.woff2` URLs inside the CSS automatically.
48
-
49
- **For Next.js**, also add `transpilePackages` so Turbopack resolves the CSS subpath exports cleanly:
50
-
51
- ```ts
52
- // next.config.ts
53
- const nextConfig = {
54
- transpilePackages: ["@matteoaliano/forest-ui"],
55
- experimental: {
56
- optimizePackageImports: [
57
- "@matteoaliano/forest-ui",
58
- "@mui/material",
59
- "@mui/icons-material",
60
- ],
61
- },
62
- };
63
- export default nextConfig;
64
- ```
65
-
66
- **Verify it worked.** Open DevTools after running `next dev`:
67
-
68
- 1. **Network tab → filter "font"** — you should see `aeonik-regular.woff2` and friends loading with `200 OK` from `/_next/static/media/...` (or your bundler's asset path).
69
- 2. **Elements → Computed → font-family** on a `<Typography>` — should read `"Aeonik", sans-serif`.
70
- 3. **Elements → Rendered Fonts** (Chrome only) — should say `Aeonik — Web font`, not `Arial — Local file` or `Helvetica — Local file`.
71
-
72
- If Network shows 404s on the woff2 files, the `transpilePackages` step is missing or the bundler isn't picking up the package's subpath exports.
73
-
74
- ### Step 3 — Wrap your app
75
-
76
- ```tsx
77
- import { ForestProvider } from "@matteoaliano/forest-ui";
78
-
79
- function App() {
80
- return (
81
- <ForestProvider preset="forest-alkemy+">
82
- {/* All app content here */}
83
- </ForestProvider>
84
- );
85
- }
86
- ```
87
-
88
- ## Typography & Fonts
89
-
90
- - **Aeonik** — the default font for all UI text (headings, body, labels, buttons, etc.). Family name: `"Aeonik"`.
91
- - **Aeonik Mono** — use for numeric values: prices, stats, table figures, counters, dates, IDs, code snippets. Family name: `"Aeonik Mono"`.
92
- - **AlkemyBETA** — editorial display face for page titles / hero h1. Family name: **`"AlkemyBETA"`** (one word, no space — do not write `"Alkemy Beta"`, it will not resolve). Not auto-applied by the preset — opt in explicitly:
93
- ```tsx
94
- <Typography variant="h1" sx={{ fontFamily: '"AlkemyBETA", serif' }}>...</Typography>
95
- ```
96
-
97
- The three CSS imports in Setup → Step 2 register all of these families. If a Forest site looks like Arial or Helvetica, you skipped Step 2.
98
-
99
- ## Available Components
100
-
101
- **Inputs:** Button, ButtonGroup, TextField, Select + MenuItem, MultiSelect, Checkbox, RadioGroup + Radio, Switch, ToggleButton + ToggleButtonGroup, Fab, IconButton, Autocomplete, Search, DatePicker, Input
102
-
103
- **Data Display:** Badge, Chip, Divider, Typography, Tooltip, Logo, Table family (Table, TableHead, TableBody, TableRow, TableCell, TableContainer, TableFooter, TablePagination, TableSortLabel), DataGrid + GridColDef, List family (List, ListItem, ListItemButton, ListItemIcon, ListItemText, ListItemAvatar, ListItemSecondaryAction, ListSubheader), Avatar + AvatarGroup, ImageList + ImageListItem + ImageListItemBar, Rating
104
-
105
- **Surfaces:** Accordion family, AppBar + Toolbar + AppBarNavItem, Card family + CardActionArea, Paper, Drawer + SwipeableDrawer
106
-
107
- **Feedback:** Alert + AlertTitle, Dialog family, Backdrop, LinearProgress, CircularProgress, Skeleton, Modal, Popover, Snackbar + SnackbarContent, Slider
108
-
109
- **Navigation:** Breadcrumbs, Link, Menu + MenuList, Pagination + PaginationItem, Stepper family (Stepper, Step, StepLabel, StepButton, StepConnector, StepContent, StepIcon), Tabs + Tab + TabScrollButton, SidebarNav + SidebarItem + useSidebar, BottomNavigation + BottomNavigationAction, SpeedDial + SpeedDialAction + SpeedDialIcon, MobileStepper
110
-
111
- **Layout:** Box, Stack, Grid, Container
112
-
113
- **Form Helpers:** FormControl, FormControlLabel, FormGroup, FormHelperText, FormLabel, InputAdornment, InputBase, InputLabel, OutlinedInput, FilledInput
114
-
115
- **Transitions:** Collapse, Fade, Grow, Slide, Zoom
116
-
117
- **Utilities:** ClickAwayListener, NoSsr, Portal, Popper, TextareaAutosize, SvgIcon, ButtonBase, GlobalStyles
118
-
119
- **Hooks:** useMediaQuery, useScrollTrigger, useFormControl, useTheme
120
-
121
- **Charts:** BarChart, LineChart, PieChart, ScatterChart, Gauge, SparkLineChart, useChartColors, plus composition primitives (see components.md)
122
-
123
- See `references/components.md` for full API details, `references/patterns.md` for code examples, and `references/upgrading.md` for update / re-sync guidance.
124
-
125
- ## Tooltip vs Popover
126
-
127
- - **Tooltip** — Use for **text-only hints**. The Tooltip has a dark (black) background and is meant for short, plain-text labels or descriptions. Do not nest rich content inside a Tooltip.
128
- - **Popover** — Use when you need to display **rich or interactive content** such as Chips, lists, buttons, or any nested components. Popover renders in a neutral surface container that supports arbitrary children.
129
-
130
- **Rule of thumb:** If the overlay content is just a string, use `<Tooltip>`. If it contains components, use `<Popover>`.
131
-
132
- ## Common Anti-Patterns
133
-
134
- 1. **Missing the three font-CSS imports at app entry** — the most common Forest setup mistake. Aeonik silently falls back to system sans-serif and the UI looks "off" without any console error. See Setup → Step 2 for the imports and a DevTools verification checklist.
135
- 2. **Writing the AlkemyBETA family with a space** (`"Alkemy Beta"`) — the `@font-face` declares `"AlkemyBETA"` (one word). The spaced form fails to resolve.
136
- 3. **Importing from `@mui/material`** instead of `@matteoaliano/forest-ui` — all components, hooks, and layout primitives are available from forest-ui
137
- 4. **Hardcoded color values** (`backgroundColor: "#7f56d9"`) instead of theme tokens (`backgroundColor: "primary.main"`)
138
- 5. **Hardcoded spacing** (`padding: "16px"`) instead of theme spacing (`p: 4`)
139
- 6. **Missing `<ForestProvider>`** at the app root — theme won't apply
140
- 7. **Using filled MUI icons** (`Close`) instead of Outlined (`CloseOutlined`)
141
- 8. **Building custom multi-select** instead of using the `<MultiSelect>` component
1
+ ---
2
+ name: forest-alkemy-plus
3
+ description: Forest UI Design System rules for the Alkemy+ (charcoal/red) preset. Enforces correct imports, component usage, and theming with @matteoaliano/forest-ui. Use when the project uses forest-ui, forest-alkemy-plus preset, or when user builds UI components in a forest-ui project. Triggers on "forest", "forest-ui", "forest alkemy", "forest alkemy+", "@matteoaliano/forest-ui".
4
+ metadata:
5
+ author: Forest Design System
6
+ version: 0.8.4
7
+ ---
8
+
9
+ # Forest UI — Alkemy+ Preset
10
+
11
+ ## Golden Rules
12
+
13
+ 1. **NEVER import from `@mui/material` directly.** Always import from `@matteoaliano/forest-ui`. All MUI components, layout primitives, transitions, form helpers, and hooks are re-exported. The only exception is `@mui/icons-material` — import icons from there directly.
14
+ 2. **ALWAYS import the Forest font CSS at app entry** (see Setup → Step 2). The package bundles Aeonik / Aeonik Mono / AlkemyBETA as `.woff2` + `@font-face` CSS, but it does **not** auto-inject them — the consuming app must import the CSS. Skip this and `font-family: "Aeonik"` silently falls back to system sans-serif (Helvetica / Arial / DejaVu), inconsistently across machines. This is the #1 reason Forest sites "don't look right".
15
+ 3. **ALWAYS wrap your app root with `<ForestProvider>`** — it applies the theme and CSS baseline.
16
+ 4. **NEVER use inline colors or spacing values.** Use design tokens or MUI's `sx` prop with theme values (`p: 4`, `backgroundColor: "primary.main"`).
17
+ 5. **NEVER create custom component wrappers** for things Forest UI already provides.
18
+ 6. **TypeScript is required.** All components export their prop types (e.g. `type ButtonProps`).
19
+ 7. **ALWAYS use the Outlined variant of MUI icons.** Import from `@mui/icons-material/*Outlined` (e.g. `CloseOutlined`, `MailOutlined`). Never use filled, Rounded, Sharp, or TwoTone variants.
20
+
21
+ ## Setup
22
+
23
+ ### Step 1 — Install
24
+
25
+ ```bash
26
+ npm install @matteoaliano/forest-ui \
27
+ @mui/material@^7 @mui/icons-material@^7 \
28
+ @mui/x-charts@^7 @mui/x-data-grid@^7 @mui/x-date-pickers@^8 \
29
+ @emotion/react @emotion/styled dayjs
30
+ ```
31
+
32
+ > **Note:** Every `@mui/*` package above is a **peer dependency** of `@matteoaliano/forest-ui`. Install them at the pinned major versions shown — newer majors are not yet supported and will fail `npm install` with `ERESOLVE`. Always import components, hooks, and layout primitives from `@matteoaliano/forest-ui` (Forest UI re-exports them with branded defaults). The single exception is `@mui/icons-material` — import icons from there directly, using the Outlined variant (e.g. `import { CloseOutlined } from "@mui/icons-material"`).
33
+
34
+ ### Step 2 — Load the fonts (CRITICAL — do this before anything else)
35
+
36
+ The Forest preset sets `fontFamily: '"Aeonik", sans-serif'`. Without the matching `@font-face` rules, the browser cannot resolve "Aeonik" and silently falls back to a system font. **Forest UI ships the font files in the npm tarball, but the consuming app must import the CSS.** Add these three imports at the top of your root entry file:
37
+
38
+ ```tsx
39
+ // Next.js App Router → app/layout.tsx (above any other CSS imports)
40
+ // Next.js Pages Router → pages/_app.tsx
41
+ // Vite / CRA → src/main.tsx or src/index.tsx
42
+ import "@matteoaliano/forest-ui/fonts/aeonik/aeonik.css";
43
+ import "@matteoaliano/forest-ui/fonts/aeonik-mono/aeonik-mono.css";
44
+ import "@matteoaliano/forest-ui/fonts/alkemy-beta/alkemy-beta.css";
45
+ ```
46
+
47
+ No `public/fonts/` copy, no `next/font/local`, no manual `@font-face` rules — the bundler resolves the relative `.woff2` URLs inside the CSS automatically.
48
+
49
+ **For Next.js**, also add `transpilePackages` so Turbopack resolves the CSS subpath exports cleanly:
50
+
51
+ ```ts
52
+ // next.config.ts
53
+ const nextConfig = {
54
+ transpilePackages: ["@matteoaliano/forest-ui"],
55
+ experimental: {
56
+ optimizePackageImports: [
57
+ "@matteoaliano/forest-ui",
58
+ "@mui/material",
59
+ "@mui/icons-material",
60
+ ],
61
+ },
62
+ };
63
+ export default nextConfig;
64
+ ```
65
+
66
+ **Verify it worked.** Open DevTools after running `next dev`:
67
+
68
+ 1. **Network tab → filter "font"** — you should see `aeonik-regular.woff2` and friends loading with `200 OK` from `/_next/static/media/...` (or your bundler's asset path).
69
+ 2. **Elements → Computed → font-family** on a `<Typography>` — should read `"Aeonik", sans-serif`.
70
+ 3. **Elements → Rendered Fonts** (Chrome only) — should say `Aeonik — Web font`, not `Arial — Local file` or `Helvetica — Local file`.
71
+
72
+ If Network shows 404s on the woff2 files, the `transpilePackages` step is missing or the bundler isn't picking up the package's subpath exports.
73
+
74
+ ### Step 3 — Wrap your app
75
+
76
+ ```tsx
77
+ import { ForestProvider } from "@matteoaliano/forest-ui";
78
+
79
+ function App() {
80
+ return (
81
+ <ForestProvider preset="forest-alkemy+">
82
+ {/* All app content here */}
83
+ </ForestProvider>
84
+ );
85
+ }
86
+ ```
87
+
88
+ ## Typography & Fonts
89
+
90
+ - **Aeonik** — the default font for all UI text (headings, body, labels, buttons, etc.). Family name: `"Aeonik"`.
91
+ - **Aeonik Mono** — use for numeric values: prices, stats, table figures, counters, dates, IDs, code snippets. Family name: `"Aeonik Mono"`.
92
+ - **AlkemyBETA** — editorial display face for page titles / hero h1. Family name: **`"AlkemyBETA"`** (one word, no space — do not write `"Alkemy Beta"`, it will not resolve). Not auto-applied by the preset — opt in explicitly:
93
+ ```tsx
94
+ <Typography variant="h1" sx={{ fontFamily: '"AlkemyBETA", serif' }}>...</Typography>
95
+ ```
96
+
97
+ The three CSS imports in Setup → Step 2 register all of these families. If a Forest site looks like Arial or Helvetica, you skipped Step 2.
98
+
99
+ ## Available Components
100
+
101
+ **Inputs:** Button, ButtonGroup, TextField, Select + MenuItem, MultiSelect, Checkbox, RadioGroup + Radio, Switch, ToggleButton + ToggleButtonGroup, Fab, IconButton, Autocomplete, Search, DatePicker, Input
102
+
103
+ **Data Display:** Badge, Chip, Divider, Typography, Tooltip, Logo, Table family (Table, TableHead, TableBody, TableRow, TableCell, TableContainer, TableFooter, TablePagination, TableSortLabel), DataGrid + GridColDef, List family (List, ListItem, ListItemButton, ListItemIcon, ListItemText, ListItemAvatar, ListItemSecondaryAction, ListSubheader), Avatar + AvatarGroup, ImageList + ImageListItem + ImageListItemBar, Rating
104
+
105
+ **Surfaces:** Accordion family, AppBar + Toolbar + AppBarNavItem, Card family + CardActionArea, Paper, Drawer + SwipeableDrawer
106
+
107
+ **Feedback:** Alert + AlertTitle, Dialog family, Backdrop, LinearProgress, CircularProgress, Skeleton, Modal, Popover, Snackbar + SnackbarContent, Slider
108
+
109
+ **Navigation:** Breadcrumbs, Link, Menu + MenuList, Pagination + PaginationItem, Stepper family (Stepper, Step, StepLabel, StepButton, StepConnector, StepContent, StepIcon), Tabs + Tab + TabScrollButton, SidebarNav + SidebarItem + useSidebar, BottomNavigation + BottomNavigationAction, SpeedDial + SpeedDialAction + SpeedDialIcon, MobileStepper
110
+
111
+ **Layout:** Box, Stack, Grid, Container
112
+
113
+ **Form Helpers:** FormControl, FormControlLabel, FormGroup, FormHelperText, FormLabel, InputAdornment, InputBase, InputLabel, OutlinedInput, FilledInput
114
+
115
+ **Transitions:** Collapse, Fade, Grow, Slide, Zoom
116
+
117
+ **Utilities:** ClickAwayListener, NoSsr, Portal, Popper, TextareaAutosize, SvgIcon, ButtonBase, GlobalStyles
118
+
119
+ **Hooks:** useMediaQuery, useScrollTrigger, useFormControl, useTheme
120
+
121
+ **Charts:** BarChart, LineChart, PieChart, ScatterChart, Gauge, SparkLineChart, useChartColors, plus composition primitives (see components.md)
122
+
123
+ See `references/components.md` for full API details, `references/patterns.md` for code examples, and `references/upgrading.md` for update / re-sync guidance.
124
+
125
+ ## Tooltip vs Popover
126
+
127
+ - **Tooltip** — Use for **text-only hints**. The Tooltip has a dark (black) background and is meant for short, plain-text labels or descriptions. Do not nest rich content inside a Tooltip.
128
+ - **Popover** — Use when you need to display **rich or interactive content** such as Chips, lists, buttons, or any nested components. Popover renders in a neutral surface container that supports arbitrary children.
129
+
130
+ **Rule of thumb:** If the overlay content is just a string, use `<Tooltip>`. If it contains components, use `<Popover>`.
131
+
132
+ ## Common Anti-Patterns
133
+
134
+ 1. **Missing the three font-CSS imports at app entry** — the most common Forest setup mistake. Aeonik silently falls back to system sans-serif and the UI looks "off" without any console error. See Setup → Step 2 for the imports and a DevTools verification checklist.
135
+ 2. **Writing the AlkemyBETA family with a space** (`"Alkemy Beta"`) — the `@font-face` declares `"AlkemyBETA"` (one word). The spaced form fails to resolve.
136
+ 3. **Importing from `@mui/material`** instead of `@matteoaliano/forest-ui` — all components, hooks, and layout primitives are available from forest-ui
137
+ 4. **Hardcoded color values** (`backgroundColor: "#7f56d9"`) instead of theme tokens (`backgroundColor: "primary.main"`)
138
+ 5. **Hardcoded spacing** (`padding: "16px"`) instead of theme spacing (`p: 4`)
139
+ 6. **Missing `<ForestProvider>`** at the app root — theme won't apply
140
+ 7. **Using filled MUI icons** (`Close`) instead of Outlined (`CloseOutlined`)
141
+ 8. **Building custom multi-select** instead of using the `<MultiSelect>` component