@falkara/presentation

中文文档
0.10.0发布于 2026/11/11MITTypeScriptES Module零依赖构建来源已验证近 30 天下载 2131

An Effect-based TypeScript library for interface design that derives each value from established standards, save one declared choice.

原始使用文档
文档目录8 节
  1. Spotlight
  2. Modules
  3. Groundwork
  4. Web Platform
  5. WCAG
  6. USWDS
  7. Utopia
  8. License

Falkara Presentation

Falkara Presentation is an Effect-based TypeScript library for interface design. It derives each value from established standards, save one declared choice, the widest viewport its values grow to, and refuses any that would break them to keep the design consistent as it scales.

It has always nagged at us that most interfaces resize in jumps at breakpoints while every screen between them makes do. We tied every value to shared ratios so each one grows smoothly in step with the rest. Every screen up to a desktop gets values of its own, even the ones nobody designed for.

Decisions shift from every number to the few choices that state the intent. Everything that follows from that intent is worked out once and carries its reason with it, so none of it rests on anyone's taste. No value that would leave a reader behind ever reaches a screen. What remains is the part worth arguing about: how the interface should feel.

Spotlight

Nothing shows the idea better than a fluid type scale. Three choices go in and out comes either a whole scale or a precise no for anything past the standards.

import { Effect, Rational } from 'effect';
import * as Fluid from '@falkara/presentation/Fluid';
import * as Typography from '@falkara/presentation/Typography';

// Intent: how sharply headings rise on narrow and wide screens, and how large body text gets.
const intent = {
  minimumFactor: Rational.makeUnsafe(6n, 5n),
  maximumFactor: Rational.makeUnsafe(5n, 4n),
  maximumBodyFontSize: Rational.fromBigInt(20n), // CSS pixels
};

Effect.gen(function* () {
  const steps = yield* Typography.scale(intent);
  return yield* Effect.forEach(steps, Fluid.clamp);
});
// Success: [
//   'clamp(0.83333rem, 0.77778rem + 0.27778vw, 1rem)',       position −1
//   'clamp(1rem, 0.91667rem + 0.41667vw, 1.25rem)',          position 0, body text
//   …
//   'clamp(2.98598rem, 2.39185rem + 2.97065vw, 4.76837rem)', position 6
// ]

Typography.scale({ ...intent, maximumBodyFontSize: Rational.fromBigInt(30n) });
// Failure: SchemaError(Expected a body font size of at most 25.6 px, so that text can be enlarged
//   to 200 %, as WCAG 2.2 Resize Text requires, within the 300 % page zoom of Safari, the lowest
//   maximum among the Baseline core browsers
//   at ["maximumBodyFontSize"])

Without Effect the same call returns a plain value that reads right away.

import { Exit, Option } from 'effect';

const scale = Typography.scale(intent);

if (Exit.isSuccess(scale)) {
  scale.value; // the steps
} else {
  Option.getOrUndefined(Exit.findErrorOption(scale))?.message; // every reason, each followed by its path
}

Intent kept as JSON reads through the JSON codec of the same schema, each number written in a string as a fraction or a whole number.

import { Schema } from 'effect';

Schema.decodeUnknownExit(Schema.toCodecJson(Typography.ScaleOptions))(
  JSON.parse('{ "minimumFactor": "6/5", "maximumFactor": "5/4", "maximumBodyFontSize": "20" }'),
);
// Success: the same intent, ready for Typography.scale

Every schema the modules export, such as Typography.ScaleOptions, works with validators outside Effect too once it passes through Schema.toStandardSchemaV1.

Modules

  • Typography turns three choices into a fluid type scale where every step stays resizable.
  • Space grows every gap with body text from that same intent.
  • Color measures each pair against the size of the text it carries and finds the closest legible shade of a brand color.
  • Layout holds lines to lengths that follow the font.

Viewport, Length and Colorimetry hold the facts the rest stands on, and Fluid writes the values as CSS lengths that grow with the viewport.

Every module works exactly, with no floating point: in the Rational numbers of Effect, and for an irrational number such as a root, a logarithm or a cosine, in bounds that narrow until each decision is certain. Exactness costs time, milliseconds where floating point takes microseconds, so the library is meant for build time, working each value out once and writing it as CSS, not for the browser.

Groundwork

We build only on what the industry already agrees on and let a handful of them settle every decision that is not a matter of taste.

Utopia stands on USWDS, which stands on WCAG, which stands on the Web Platform.

Web Platform

Facts and opinions come built in. Only facts that hold for every reader in every Baseline core browser are kept, and opinions give way to derived values, save one declared choice: a maximum viewport width of 1280 px, as WCAG sets none and fluid values need one to stay resizable.

Baseline Widely Available

WCAG

Promises to readers are on record. Values keep every promise within their reach and that goes well past what the European Accessibility Act in the EU and Section 508 of the Rehabilitation Act in the United States demand.

Values meet the success criteria of WCAG 2.2 up to Level AAA that they decide: Contrast (Enhanced) for text, Resize Text, Reflow, Text Spacing and Visual Presentation. Criteria they feed without deciding, such as the contrast of interface components and focus indicators or the size of targets, rest with the interface that uses them.

USWDS

Conventions earn trust by surviving real use. Values borrow them only where the guidelines fall silent and only from USWDS 3, the design system the United States government builds its websites with, which supports dozens of its agencies and nearly 200 of their sites.

Utopia

Good models make hard things simple. Values follow Utopia for fluid type and space and hold it to every limit from the layers below.

License

Falkara Presentation is licensed under MIT.

Baseline logos by Google, licensed under CC BY-ND 4.0.

版本与发布记录

@falkara/presentation 共发布 12 个版本,首次发布于 2026/10/29;过去 12 个月发布了 12 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.10.0latest2026/11/113 天前
0.9.02026/11/113 天前
0.8.02026/11/103 天前
0.7.02026/10/3014 天前
0.6.02026/10/3015 天前
0.5.02026/10/3015 天前

关于 @falkara/presentation 的常见问题

@falkara/presentation 是什么?

An Effect-based TypeScript library for interface design that derives each value from established standards, save one declared choice.

如何安装 @falkara/presentation?

在项目目录运行 npm install @falkara/presentation,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:effect(^4.1.3)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@falkara/presentation 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@falkara/presentation 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@falkara/presentation 可以商用吗?

@falkara/presentation 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@falkara/presentation 的下载量有多少?

根据 npm 官方下载统计,@falkara/presentation 在 2026/10/14 – 2026/11/12 这 30 天内被下载 2,131 次,日均约 71 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@falkara/presentation 还在维护吗?

最新版本 0.10.0 发布于 2026/11/11(3 天前);至今共发布 12 个版本,其中过去 12 个月发布了 12 个;首次发布于 2026/10/29。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。