@gotipe/theme
v0.1.5
Published
Styles, design tokens and light and dark themes of the ready GoTipe editors.
Maintainers
Readme
@gotipe/theme
The styles and design tokens of the ready GoTipe editors: the document and UI style sheets,
light and dark palettes as --gt-* custom properties, and a small API to switch the theme. It
is used by @gotipe/block-editor.
Docs · Website · Repository
Install
npm install @gotipe/theme @gotipe/coreUsage
Import the style sheets once, before your own CSS:
import "@gotipe/theme/base.css";
import "@gotipe/theme/theme.css";| File | Contents |
|---|---|
| @gotipe/theme/base.css | The document in every view: text, blocks, lists, tables, code |
| @gotipe/theme/theme.css | Menus, panels, review cards and the loading, error and read-only states |
| @gotipe/theme/tokens.css | Only the tokens: light and dark palettes and the views |
| @gotipe/theme/page.css | base.css and theme.css in one import |
Switch light and dark mode, or follow the operating system:
import { getTheme, onThemeChange, setTheme } from "@gotipe/theme";
const stopFollowing = setTheme("system");
const unsubscribe = onThemeChange((mode, resolved) => console.log(mode, resolved));
console.log(getTheme()); // { mode: "system", resolved: "dark" }Pass your application's colors by overriding tokens on a container around the editor:
.app-editor {
--gt-page-bg: var(--app-canvas);
--gt-text: var(--app-text);
--gt-accent: var(--app-brand);
--gt-font-ui: var(--app-font);
}setTheme(mode, root?),getTheme(root?),onThemeChange(listener, root?): the mode ("light","dark"or"system") asdata-themeonroot(default<html>).applyTheme(config, root?): writesconfig.tokensas--gt-*properties.defineTheme(config),lightTheme,darkTheme: typedThemeConfigpalettes.
License
The GoTipe Commercial License, see LICENSE-COMMERCIAL and licensing. It is free for personal, non-profit, educational and open-source projects, for organizations whose gross revenue was under USD 1,000,000 in the last 12 months, and for evaluation and development; other production use needs a commercial license per product.
