0.25.0
CodeBlock ships about 23 Shiki chunks instead of 300, plus a Figma parity pass
CodeBlock now loads Shiki through its core, with a fixed set of languages and the JavaScript regex engine, so apps that use the kit build about 23 Shiki chunks instead of about 300 and no WASM. Languages and themes outside the built-in set have to be registered first. A Figma parity pass aligns Card, Badge, ThemeIcon, Button, Table and the pink and green ramps with the 42 UI Kit, and Switch and Checkbox now align to their label line when a description sits below.
Changes
2 breaking changes
- CodeBlock:
languageloads only the built-in languages by name (see Languages and themes); any other name renders as plain text until its grammar is passed toregisterLanguage - CodeBlock:
themesloads onlygithub-lightandgithub-dark-defaultby name; any other theme falls back to the default until it is passed toregisterTheme
1added
9changed
3fixed
- breaking2
- CodeBlock#442
languageloads only the built-in languages by name (see Languages and themes); any other name renders as plain text until its grammar is passed toregisterLanguage - CodeBlock#442
themesloads onlygithub-lightandgithub-dark-defaultby name; any other theme falls back to the default until it is passed toregisterTheme - added1
- CodeBlock#442
CodeBlockLanguagetype: the built-in language names and aliases for autocomplete, plus any registered name - changed9
- CodeBlock#442
Shiki loads through its core with the JavaScript regex engine: a consumer build emits about 23 Shiki chunks instead of about 300, and no Oniguruma WASM
- CardChoice Card Group#438
The dark hairline is white 8 %, Figma's
border-primary(was 15 %) - Badge#438
The edge is Figma's 0.5px stroke, drawn as an inset ring instead of a border
- ThemeIcon#438
The glyph is 12 / 14 / 16 / 18 / 22px as in Figma;
outlineandsubtledraw the neutral glyph in full white;default's edge is white 16 % - Colors#438
The pink and green ramps take Figma's primitives: pink is now a mauve (
#c86cb6at 500) - AmbientBackground#438
The dark sky is tuned against Figma's Background / Cosmos: the first violet cloud and the grain are retuned
- Button#438
outline's edge is its colour at 35 %, likelight's - TableDataTable#438
The table is a card: Card's surface and edge at a 12px radius, with a clear header and pagination
- #439
- fixed3
- CodeBlock#442
An unknown
languagerenders as plain text with a development warning, instead of leaving the block unhighlighted - ThemeIcon#438
lighttints the tile with the solid shade at 30 %, so brand and purple no longer read as black squares, andclassNamerecolours the glyph - SwitchCheckbox#439
With a
labeland adescriptionorerror, the control aligns to the label line instead of centering on the whole text stack
Upgrading CodeBlock
language resolves these names on its own, each loaded on first use:
| Language | Names |
|---|---|
| C | c |
| C++ | cpp, c++ |
| Python | python, py |
| Shell | shellscript, bash, sh, shell, zsh |
| JavaScript | javascript, js, cjs, mjs, jsx |
| TypeScript | typescript, ts, cts, mts, tsx |
| JSON | json |
| YAML | yaml, yml |
| Markdown | markdown, md |
| HTML | html |
| CSS | css |
| SQL | sql |
| Go | go |
| Rust | rust, rs |
| Java | java |
| Makefile | make, makefile |
| Dockerfile | docker, dockerfile |
| Diff | diff |
Any other name now renders as plain text, with a warning in development. To keep a language you relied on, register its grammar once, before the first CodeBlock that uses it. Any of Shiki's grammars works:
import { registerLanguage } from '@42-central/ui-react/code-block';
await registerLanguage((await import('shiki/langs/haskell.mjs')).default);
// later:
<CodeBlock language="haskell" code="main = print 1" />Themes work the same way: github-light and github-dark-default are built in, and any other theme must go through registerTheme before themes names it. See Languages and themes.