athena-ui-js 2.3.0 → 2.4.1

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.
package/README.md CHANGED
@@ -5,7 +5,7 @@ layout (header, menu, content wrapper, footer) from a single `init()` call, load
5
5
  and theme, and ships the building blocks of a multipurpose application: forms, tables, charts,
6
6
  feedback, navigation, a router and more.
7
7
 
8
- Current version: **2.3.0**
8
+ Current version: **2.4.1**
9
9
 
10
10
  [Quick start](#usage) · [API](#api) · [Components](#charts) · [Themes](#themes) · [Tests](#tests) · [Release notes](#releases)
11
11
 
@@ -67,7 +67,7 @@ import { generateTable } from "athena-ui-js/table"; // or only what you u
67
67
  ```
68
68
 
69
69
  The entry points are `table`, `chart`, `dialog`, `menu`, `navigation`, `forms`, `feedback`, `components`, `inputs`, `router`, `session`, `theme`, `i18n`, `format`,
70
- `validation`, `motion`, `widgets`, `sanitize`, `csv`, `dom` and `controls`. TypeScript definitions are included (`types/`, generated from the JSDoc with `npm run types`).
70
+ `validation`, `motion`, `widgets`, `code`, `sanitize`, `csv`, `dom` and `controls`. TypeScript definitions are included (`types/`, generated from the JSDoc with `npm run types`).
71
71
  The package has `"sideEffects"` for `classic.js`, `theme-boot.js` and CSS only, so a bundler drops everything you do not import.
72
72
 
73
73
  Without npm, serve the `src` folder with any static web server and open `index.html` to see the example.
@@ -149,7 +149,7 @@ It takes the options of `init()`. The header and footer follow the settings `gen
149
149
  | `header_title_text` | `"Athena UI"` | Title in the header |
150
150
  | `header_img_url` | | Header logo URL |
151
151
  | `copyright` | placeholder text | Footer text, the version is appended |
152
- | `version` | `"2.3.0"` | Version shown in the footer |
152
+ | `version` | `"2.4.1"` | Version shown in the footer |
153
153
  | `bordered` | `true` | Draw a border around the layout blocks |
154
154
  | `generateHeader`, `generateFooter` | `true` | Generate the header / footer block |
155
155
  | `generateHeadercontent`, `generateFooterContent`, `generateWrappercontent` | `true` | Generate the content of the block |
@@ -196,6 +196,7 @@ Everything is exported from `athena-ui.js`:
196
196
  | `el`, `setContent`, `resolveElement`, `asHandle`, `createSafeBuilder` | See [Safe DOM building](#safe-dom-building) |
197
197
  | `animate`, `flip`, `stagger`, `spring`, `tween`, `transition`, `viewTransition`, `setMotion`, `prefersReducedMotion`, `easings`, `generateSkeleton` | See [Motion](#motion-animations-and-transitions) |
198
198
  | `registerWidget`, `createWidgetGrid`, `getWidgetTypes`, `placeItem`, `compact`, `findFreeSpot`, `normalize` | See [Widgets](#widgets-a-dashboard-that-can-be-built) |
199
+ | `highlightCode`, `generateCodeBlock`, `createCodeEditor`, `createDiffView`, `registerLanguage`, `tokenize`, `diffLines` | See [Code](#code-highlighting-an-editor-and-a-diff) |
199
200
  | `generateCard`, `generateSection`, `generateGrid`, `generateBadge`, `generateAvatar`, `generateStat`, `generateLink`, `generateTooltip` | See [Components](#components) |
200
201
  | `generateAutocomplete`, `generateMultiSelect`, `generateFileUpload`, `generateDropZone`, `generateStepper`, `generateDateRange`, `generateRichText`, `generateWysiwyg` | See [Inputs](#inputs) |
201
202
  | `sanitizeHtml(html)`, `htmlToText(html)`, `isSafeUrl(url)` | The allow-list sanitizer behind the rich text editor |
@@ -736,6 +737,42 @@ grid.setLayout(JSON.parse(localStorage.getItem("dashboard"))); // plain, ver
736
737
  - **Performance**: a widget is rendered only when it is first seen, `resize(context, size)` is called throttled when its body changes size, and nothing re-renders while it is out of view.
737
738
  - The grid maths (`placeItem`, `compact`, `findFreeSpot`, `normalize`, `collides`) is exported as well, for your own layouts.
738
739
 
740
+ ### Code: highlighting, an editor and a diff
741
+
742
+ `athena-ui-js/code`: no dependency, no inline style, and nothing is parsed as markup (the code is built with `el()`, so a `<img onerror>` in a comment stays text).
743
+
744
+ ```js
745
+ import { highlightCode, generateCodeBlock, createCodeEditor, createDiffView, registerLanguage } from "athena-ui-js/code";
746
+
747
+ // read only
748
+ document.body.append(highlightCode("const a = 1;", "js", { lineNumbers: true, highlightLines: [1] })); // a <pre><code> with token spans
749
+ generateCodeBlock({ parent: "docs", code: sql, language: "sql", lineNumbers: true }); // + the language label and a copy button
750
+
751
+ // an editor
752
+ const editor = createCodeEditor({
753
+ element: "editor", value: source, language: "ts", onChange: value => save(value),
754
+ markers: [{ line: 3, message: "Unexpected token", level: "error" }], // lint markers, shown in the status line
755
+ readOnlyRanges: [{ from: 1, to: 2 }], // lines that cannot be changed
756
+ provideCompletions: ({ prefix }) => words.filter(word => word.startsWith(prefix)).map(label => ({ label }))
757
+ });
758
+
759
+ // what changed
760
+ createDiffView({ parent: "review", original: before, modified: after, language: "json", mode: "split", context: 3 });
761
+ ```
762
+
763
+ - **Languages**: `javascript` (`js`), `typescript` (`ts`), `json`, `html` (`xml`, `svg`), `css` (`scss`, `less`), `sql`, `shell` (`sh`, `bash`), `yaml`, `csharp` (`c#`, `cs`), `python` (`py`).
764
+ A language is a plain object (`registerLanguage({ name, aliases, rules: [{ type, pattern }], lineComment, blockComment, pairs, indentAfter })`), so your own are one call.
765
+ The tokenizer is a set of regular expressions, not a parser: it is fast and tolerant (unfinished code still gets colours) but it does not know nested `${}` of a template string or the `<script>` inside HTML.
766
+ - **Colours** are the tokens `--athena-tok-comment`, `-string`, `-keyword` ... (light and dark); a test keeps every one at 4.5:1 contrast or more.
767
+ - **The editor is a real `<textarea>`** with the highlighted text behind it, so native input, selection, spell-check off, mobile keyboards, IME and screen readers all work.
768
+ Tab and Shift+Tab indent and outdent (also several lines), Enter keeps the indentation (and goes one level deeper after `{`, `(`, `:`), brackets and quotes are closed, stepped over, wrapped around a selection and
769
+ deleted together, Ctrl+/ comments, Alt+Up / Alt+Down move lines, Ctrl+Z / Ctrl+Y undo and redo (typing is grouped), Ctrl+F finds and Ctrl+H replaces (case, regular expression, all matches
770
+ highlighted, replace all is one undo step), Ctrl+Space suggests. The matching bracket is highlighted (CSS Custom Highlight API where the browser has it).
771
+ **Escape, then Tab, leaves the editor** (so the keyboard is never trapped); the way out is read to screen readers.
772
+ - **Size**: only the lines around a change are tokenized again, and a test checks that this gives exactly what tokenizing everything gives. On the (slow) development machine the work of the editor per key press is
773
+ about 13 ms in a 5,000 line file; the browser's own layout of two large text blocks is the larger part (about 90 ms per key at 5,000 lines; smaller files were not measured separately). Texts longer than 300,000 characters
774
+ (`maxHighlightLength`) are shown without highlighting. Not there yet: multiple cursors, minimap, folding.
775
+
739
776
  ### Safe DOM building
740
777
 
741
778
  `el(tag, { class, id, text, attrs, on, prop }, ...children)` is the way Athena builds its own pages, and it is exported. Strings are only ever inserted as **text**, children can be
@@ -826,6 +863,28 @@ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file
826
863
 
827
864
  ## Releases
828
865
 
866
+ ### 2.4.1
867
+ #### Fixed:
868
+ 1. **2.3.0 and 2.4.0 were published without two folders** (`src/libs/hephaestus/widgetGrid` and `.../codeGenerator`): `import "athena-ui-js"`, `athena-ui-js/widgets` and `athena-ui-js/code` failed with "module not found". Both folders are in the package now. **Use 2.4.1 or later**; 2.3.0 and 2.4.0 should be deprecated.
869
+ #### Added:
870
+ 1. `npm run check:package` (`scripts/check-package.mjs`): reads what `npm pack --dry-run` would publish and follows the imports of every entry point through that list; it runs in CI and in `npm test`, so a folder that is not on the `files` list fails the build instead of the users
871
+
872
+ ### 2.4.0
873
+ #### Added:
874
+ 1. `athena-ui-js/code`: `highlightCode`, `generateCodeBlock` (language label, copy button), `createDiffView`, `createCodeEditor` (a textarea over highlighted lines: indentation, closing brackets, comments, find and replace, completions, markers, read-only lines, own undo), ten languages and `registerLanguage`; token colours are theme tokens with a contrast test
875
+ 2. The Code page of the demo
876
+
877
+ ### 2.3.0
878
+ #### Added:
879
+ 1. `athena-ui-js/widgets`: `registerWidget` and `createWidgetGrid`: a dashboard of widgets that can be added, configured, moved and resized with the pointer or the keyboard, locked, undone, saved and loaded as validated JSON, with a layout per breakpoint
880
+ 2. The grid maths (`placeItem`, `compact`, `findFreeSpot`, `normalize`) as exports, and the Widgets page of the demo
881
+
882
+ ### 2.2.0
883
+ #### Added:
884
+ 1. Motion: the tokens `--athena-duration-*` and `--athena-ease-*` (0 under reduced motion), `athena-ui-js/motion` (`animate`, `flip`, `stagger`, `spring`, `tween`, `viewTransition`, `setMotion`), transitions of dialogs, toasts, popovers, the accordion and the menu, the first drawing of charts, a cross-fade of theme changes, `createRouter({ transition: true })`, `generateTable({ animateRows: true })` and `generateSkeleton`
885
+ #### Changed:
886
+ 1. The blanket `transition: none` under reduced motion is gone: the durations are 0 instead; a closed dialog or toast stays in the page for the length of its exit transition (none under reduced motion)
887
+
829
888
  ### 2.1.0
830
889
  #### Changed:
831
890
  1. The dropdown menu is a native popover (`popover="auto"`, opened by its button through `popovertarget`): it is drawn in the top layer, so no parent with `overflow: hidden` cuts it off; a click outside and Esc close it and the focus goes back to the button; `aria-expanded` follows every way of opening and closing it. Markup: the menu has the attribute `popover` and no `hidden` any more (use `:popover-open`)
package/docs/styling.md CHANGED
@@ -1,103 +1,123 @@
1
- # Styling reference
2
-
3
- Generated by `npm run docs` from `src/res/themes/default/style.css` and `tokens.css`. Do not edit by hand.
4
-
5
- All Athena UI rules are in the cascade layer `athena`: a plain rule of your application (not in a layer) always wins, whatever its specificity.
6
- Start with the tokens, they cover most of what people want to change.
7
-
8
- ## Tokens
9
-
10
- | Variable | Default (light) |
11
- | --- | --- |
12
- | `--athena-accent` | `#8e44ad` |
13
- | `--athena-radius` | `2px` |
14
- | `--athena-bg` | `#fff` |
15
- | `--athena-fg` | `#1a1a1a` |
16
- | `--athena-muted` | `#666` |
17
- | `--athena-border` | `#000` |
18
- | `--athena-line` | `#ccc` |
19
- | `--athena-surface` | `#f2f2f2` |
20
- | `--athena-surface-alt` | `#fafafa` |
21
- | `--athena-hover` | `#e8f0fe` |
22
- | `--athena-overlay` | `rgb(0 0 0 / 40%)` |
23
- | `--athena-accent` | `#2f6db5` |
24
- | `--athena-accent-fg` | `#fff` |
25
- | `--athena-focus` | `#1b4f8f` |
26
- | `--athena-danger` | `#c0392b` |
27
- | `--athena-success` | `#1e8449` |
28
- | `--athena-warning` | `#9a6700` |
29
- | `--athena-info` | `#2471a3` |
30
- | `--athena-shadow` | `0 4px 14px rgb(0 0 0 / 18%)` |
31
- | `--athena-radius` | `6px` |
32
- | `--athena-border-width` | `1px` |
33
- | `--athena-space-1` | `4px` |
34
- | `--athena-space-2` | `8px` |
35
- | `--athena-space-3` | `12px` |
36
- | `--athena-space-4` | `16px` |
37
- | `--grid-gap` | `16px` |
38
- | `--athena-focus-width` | `2px` |
39
- | `--athena-dialog-small` | `360px` |
40
- | `--athena-dialog-medium` | `480px` |
41
- | `--athena-dialog-large` | `720px` |
42
- | `--athena-row-height` | `36px` |
43
- | `--athena-duration-fast` | `120ms` |
44
- | `--athena-duration-base` | `200ms` |
45
- | `--athena-duration-slow` | `360ms` |
46
- | `--athena-ease-standard` | `cubic-bezier(0.2, 0, 0, 1)` |
47
- | `--athena-ease-in` | `cubic-bezier(0.4, 0, 1, 1)` |
48
- | `--athena-ease-out` | `cubic-bezier(0, 0, 0.2, 1)` |
49
- | `--athena-ease-spring` | `linear(0, 0.009, 0.035 2.1%, 0.141 4.4%, 0.723 12.9%, 0.938 16.7%, 1.017 19.4%, 1.077 22.8%, 1.121 26.7%, 1.149 31.2%, 1.159 36.2%, 1.138 49.9%, 1.115 56.3%, 1.043 69.7%, 1.009 81.2%, 0.998 92.1%, 1)` |
50
-
51
- Dark colours: set `data-mode="dark"` on `<html>` (or let `createThemeManager` do it); without the attribute the system decides. Themes: see `appearance.css`.
52
-
53
- ## Components
54
-
55
- | Group of rules | Classes | Variables it reads |
56
- | --- | --- | --- |
57
- | General | - | `--athena-accent` `--athena-bg` `--athena-border-width` `--athena-fg` `--athena-line` |
58
- | Header, Wrapper, Footer | `.footer-container` `.header-container` `.wrapper-container` | - |
59
- | Elements | `.container` `.default-cointainer-bordered` `.menu` | `--athena-border` |
60
- | Modal (background) | `.modal` `.modal-content` | `--athena-bg` `--athena-border-width` `--athena-fg` `--athena-line` `--athena-overlay` |
61
- | Modal close button | `.close` | `--athena-fg` `--athena-muted` |
62
- | Buttons | `.athena-button` `.button-danger` `.button-large` `.button-link` `.button-secondary` `.button-small` | `--athena-accent` `--athena-accent-fg` `--athena-danger` `--athena-fg` `--athena-line` `--athena-radius` `--athena-surface` |
63
- | Forms | `.athena-form` `.choice` `.choices` `.field` `.field-error` `.field-group` `.field-help` `.field-invalid` `.field-label` `.field-required` `.form-actions` `.form-message` `.form-message-error` `.form-message-success` | `--athena-border-width` `--athena-danger` `--athena-line` `--athena-muted` `--athena-radius` `--athena-space-1` `--athena-space-2` `--athena-space-3` `--athena-success` |
64
- | Switch: a checkbox drawn as a toggle | `.switch` `.switch-track` | `--athena-accent` `--athena-duration-fast` `--athena-ease-standard` `--athena-line` |
65
- | Spinner, alerts, toasts, progress | `.alert` `.alert-body` `.alert-close` `.alert-error` `.alert-info` `.alert-success` `.alert-warning` `.button-loading` `.progress-bar` `.progress-error` `.progress-fill` `.progress-indeterminate` `.progress-label` `.progress-success` `.progress-warning` `.spinner` `.spinner-large` `.spinner-small` `.toast` `.toast-container` | `--alert-color` `--athena-accent` `--athena-border-width` `--athena-danger` `--athena-duration-base` `--athena-ease-standard` `--athena-fg` `--athena-info` `--athena-line` `--athena-muted` `--athena-radius` `--athena-shadow` `--athena-space-2` `--athena-space-3` `--athena-success` `--athena-surface` `--athena-surface-alt` `--athena-warning` `--progress-color` |
66
- | Dialog: the native <dialog> element, opened with showModal() | `.dialog` | `--athena-bg` `--athena-border-width` `--athena-dialog-medium` `--athena-fg` `--athena-line` `--athena-overlay` `--athena-radius` `--athena-shadow` `--dialog-width` |
67
- | The content fills the dialog up to its edge, so a click on the backdrop is a click on the dialog element itself | `.dialog-body` `.dialog-close` `.dialog-footer` `.dialog-full` `.dialog-inner` `.dialog-large` `.dialog-medium` `.dialog-small` `.dialog-title` | `--athena-dialog-large` `--athena-dialog-medium` `--athena-dialog-small` `--athena-muted` `--athena-space-2` |
68
- | Tabs | `.tab` `.tab-active` `.tab-list` `.tab-panel` | `--athena-accent` `--athena-border-width` `--athena-fg` `--athena-line` |
69
- | Breadcrumbs, pagination | `.breadcrumb-item` `.breadcrumb-list` `.page-button` `.page-current` `.pagination` | `--athena-accent` `--athena-accent-fg` `--athena-bg` `--athena-border-width` `--athena-fg` `--athena-line` `--athena-muted` `--athena-space-1` |
70
- | Accordion: <details> and <summary> | `.accordion-header` `.accordion-icon` `.accordion-item` `.accordion-panel` `.sidebar-parent` | `--athena-accent` `--athena-border-width` `--athena-duration-fast` `--athena-ease-standard` `--athena-fg` `--athena-focus` `--athena-focus-width` `--athena-line` `--athena-surface` |
71
- | Dropdown | `.dropdown` `.dropdown-menu` `.dropdown-right` | `--athena-bg` `--athena-border-width` `--athena-line` `--athena-radius` `--athena-shadow` |
72
- | A popover (the dropdown menu, the tooltip) is in the top layer, placed next to its anchor by script through two variables | `.athena-popover` `.athena-popover-above` `.athena-popover-center` `.athena-popover-end` `.dropdown-divider` `.dropdown-item` `.dropdown-menu` | `--athena-fg` `--athena-hover` `--athena-line` `--athena-popover-left` `--athena-popover-top` |
73
- | Sidebar | `.accordion-icon` `.sidebar` `.sidebar-link` `.sidebar-list` `.sidebar-parent` `.sidebar-sublist` `.sidebar-toggle` | `--athena-accent` `--athena-accent-fg` `--athena-fg` `--athena-hover` `--athena-space-2` |
74
- | Cards, sections, grid | `.athena-grid` `.card` `.card-body` `.card-footer` `.card-image` `.card-title` | `--athena-bg` `--athena-border-width` `--athena-line` `--athena-radius` `--athena-surface-alt` `--grid-columns` `--grid-gap` |
75
- | Badge, avatar, stat | `.avatar` `.avatar-large` `.avatar-small` `.badge` `.badge-error` `.badge-info` `.badge-pill` `.badge-success` `.badge-warning` `.stat` `.stat-bad` `.stat-good` `.stat-label` `.stat-neutral` `.stat-value` | `--athena-accent` `--athena-accent-fg` `--athena-bg` `--athena-border-width` `--athena-danger` `--athena-fg` `--athena-info` `--athena-line` `--athena-muted` `--athena-radius` `--athena-success` `--athena-surface` `--athena-warning` |
76
- | Tooltip | `.has-tooltip` `.tooltip-text` `.tooltip-wrap` | `--athena-duration-fast` `--athena-ease-standard` |
77
- | As a popover it is only drawn while it is open, so it is always visible; the position comes from placePopover() | `.tooltip-text` | - |
78
- | Combobox (autocomplete, multi select) and chips | `.chip` `.chip-remove` `.combobox` `.combobox-active` `.combobox-chips` `.combobox-empty` `.combobox-input` `.combobox-list` `.combobox-multiple` `.combobox-option` `.combobox-selected` | `--athena-accent` `--athena-accent-fg` `--athena-bg` `--athena-border-width` `--athena-hover` `--athena-line` `--athena-muted` `--athena-radius` `--athena-shadow` `--athena-space-1` |
79
- | File upload | `.dropzone` `.dropzone-disabled` `.dropzone-input` `.dropzone-over` `.file-item` `.file-list` `.file-status` | `--athena-accent` `--athena-hover` `--athena-line` `--athena-muted` `--athena-radius` |
80
- | Stepper | `.form-actions` `.stepper` `.stepper-current` `.stepper-done` `.stepper-number` `.stepper-step` `.stepper-steps` | `--athena-accent` `--athena-accent-fg` `--athena-fg` `--athena-line` `--athena-muted` `--athena-space-2` `--athena-success` |
81
- | Tables | `.athena-table` `.athena-table-edit` `.athena-table-filter` `.athena-table-pager` `.athena-table-select` `.athena-table-wrapper` `.clickable` `.editable` `.selected` `.sortable` | `--athena-accent` `--athena-border-width` `--athena-hover` `--athena-line` `--athena-surface` `--athena-surface-alt` |
82
- | Table options: density, wrapping, alignment | `.athena-align-center` `.athena-align-right` `.athena-table` `.athena-table-compact` `.athena-table-nowrap` `.athena-table-wrap` | `--athena-focus` `--athena-focus-width` |
83
- | Charts | `.athena-chart` `.chart-axis` `.chart-bar` `.chart-grid` `.chart-legend` `.chart-slice` `.chart-tick` `.chart-title` | `--athena-bg` `--athena-fg` `--athena-line` `--athena-muted` |
84
- | Responsive | `.athena-form` `.athena-grid` `.file-item` `.file-progress` `.modal` `.modal-content` `.sidebar` `.sidebar-list` `.sidebar-open` `.sidebar-toggle` `.stepper-title` | - |
85
- | Reduced motion: a spinner and an indeterminate bar still have to say "busy", but slowly. The transitions read the duration tokens (0). | `.progress-fill` `.progress-indeterminate` `.spinner` | - |
86
- | Menu submenus | `.has-submenu` `.menu-parent` `.submenu` `.submenu-item` | `--athena-bg` `--athena-border-width` `--athena-hover` `--athena-line` `--athena-radius` `--athena-shadow` |
87
- | Table: resizable columns, virtual scrolling | `.athena-col-resizer` `.athena-table` `.athena-table-resizable` `.athena-table-scroll` `.athena-table-spacer` `.athena-table-virtual` `.resizing` | `--athena-accent` `--athena-border-width` `--athena-line` `--athena-row-height` `--row-height` |
88
- | Date range | `.daterange` `.daterange-part` | - |
89
- | Rich text editor | `.richtext` `.rt-bold` `.rt-button` `.rt-disabled` `.rt-editor` `.rt-empty` `.rt-italic` `.rt-separator` `.rt-source-view` `.rt-strike` `.rt-toolbar` `.rt-underline` `.submenu` | `--athena-accent` `--athena-accent-fg` `--athena-bg` `--athena-border-width` `--athena-fg` `--athena-hover` `--athena-line` `--athena-muted` `--athena-radius` `--athena-surface` |
90
- | Theme picker (generateThemePicker). The preview is drawn with the colours of the theme it shows. | `.theme-picker` `.theme-picker-description` `.theme-picker-group` `.theme-picker-option` `.theme-picker-options` `.theme-preview` `.theme-preview-bar` `.theme-preview-body` `.theme-preview-button` `.theme-preview-line` | `--athena-accent` `--athena-bg` `--athena-border-width` `--athena-fg` `--athena-focus` `--athena-focus-width` `--athena-line` `--athena-muted` `--athena-radius` `--athena-space-1` `--athena-space-3` `--athena-space-4` |
91
- | Tables with a data source and row actions | `.athena-button` `.athena-chart` `.athena-chart-sparkline` `.athena-table` `.athena-table-actions` `.athena-table-error` `.athena-table-is-loading` `.athena-table-loading` `.athena-visually-hidden` `.chart-area` `.chart-bar` `.chart-data` `.chart-hidden` `.chart-legend-item` `.chart-line` `.chart-point` `.chart-ring` `.chart-slice` `.chart-swatch` `.chart-tooltip` `.chart-tooltip-box` `.chart-tooltip-text` `.is-off` `.is-visible` `.s1` `.s2` `.s3` `.s4` `.s5` `.s6` `.s7` `.s8` | `--athena-bg` `--athena-danger` `--athena-fg` `--athena-focus` `--athena-focus-width` `--athena-muted` `--series-1` `--series-2` `--series-3` `--series-4` `--series-5` `--series-6` `--series-7` `--series-8` |
92
- | Menu (generateMenu): a bar, or tabs at the bottom of the screen with sheets for the groups | `.athena-menu` `.athena-menu-list` `.has-active` `.is-active` `.menu-avatar` `.menu-control` `.menu-icon` `.menu-item` `.menu-item-end` `.menu-sheet` | `--athena-accent` `--athena-accent-fg` `--athena-bg` `--athena-border-width` `--athena-fg` `--athena-focus` `--athena-focus-width` `--athena-hover` `--athena-line` `--athena-radius` `--athena-shadow` |
93
- | Tabs at the bottom (layout "responsive" switches to it under 700px) | `.athena-menu-bottom-tabs` `.athena-menu-list` `.athena-menu-responsive` `.menu-control` `.menu-item` `.menu-item-end` `.menu-sheet` | `--athena-bg` `--athena-border-width` `--athena-line` `--athena-radius` |
94
- | Menu: groups inside groups, and badges | `.athena-menu` `.athena-menu-bottom-tabs` `.athena-menu-responsive` `.athena-table-placeholder` `.athena-table-status` `.menu-badge` `.menu-badge-bad` `.menu-badge-info` `.menu-badge-ok` `.menu-badge-warn` `.menu-caret` `.menu-sheet` `.menu-sheet-nested` | `--athena-accent` `--athena-accent-fg` `--athena-danger` `--athena-info` `--athena-muted` `--athena-success` `--athena-warning` |
95
- | Charts: pointer layer, zoom | `.athena-chart` `.chart-hit` `.chart-marker` `.chart-reset` `.chart-selection` | `--athena-accent` `--athena-focus` `--athena-focus-width` `--athena-muted` |
96
- | Page header, facts, empty state, loading, stat tone and note | `.athena-popover` `.athena-popover-above` `.dialog` `.empty-icon` `.empty-message` `.empty-state` `.empty-title` `.fact` `.facts` `.facts-inline` `.is-bad` `.is-ok` `.is-warn` `.loading-state` `.page-actions` `.page-description` `.page-header` `.page-header-row` `.page-title` `.stat` `.stat-note` `.stat-value` | `--athena-danger` `--athena-duration-base` `--athena-duration-fast` `--athena-ease-out` `--athena-fg` `--athena-muted` `--athena-space-2` `--athena-space-3` `--athena-success` `--athena-warning` |
97
- | Toasts slide in from the side, and out again when they are closed | `.is-leaving` `.toast` | `--athena-duration-base` `--athena-ease-out` |
98
- | The panel of an accordion opens and closes smoothly (a browser without ::details-content opens it at once) | `.accordion-item` | `--athena-duration-base` `--athena-ease-standard` |
99
- | The mark of the active item, and hover, move gently | `.athena-menu` `.menu-control` | `--athena-duration-fast` `--athena-ease-standard` |
100
- | A place holder for what is loading: a skeleton with a shimmer (generateSkeleton) | `.athena-skeleton` `.athena-skeleton-line` | `--athena-hover` `--athena-radius` `--athena-space-2` `--athena-surface` |
101
- | A theme or mode change cross-fades instead of flashing (the theme manager sets the class for a moment) | `.athena-switching` | `--athena-duration-slow` `--athena-ease-standard` |
102
- | Page transitions of the router (router({ transition: true })) | - | `--athena-duration-base` `--athena-ease-standard` |
103
- | Charts draw themselves when they appear: bars grow, lines are drawn, slices pop in (only the first time, not when a chart streams or is zoomed) | `.athena-chart-animated` `.athena-widget-grid` `.chart-area` `.chart-bar` `.chart-line` `.chart-point` `.chart-slice` `.is-dragging` `.is-editable` `.is-failed` `.is-locked` `.is-unknown` `.widget` `.widget-action` `.widget-actions` `.widget-body` `.widget-handle` `.widget-header` `.widget-note` `.widget-resize` `.widget-resize-e` `.widget-resize-n` `.widget-resize-ne` `.widget-resize-nw` `.widget-resize-s` `.widget-resize-se` `.widget-resize-sw` `.widget-resize-w` `.widget-title` | `--athena-accent` `--athena-accent-fg` `--athena-border` `--athena-border-width` `--athena-duration-fast` `--athena-duration-slow` `--athena-ease-out` `--athena-ease-standard` `--athena-fg` `--athena-focus` `--athena-focus-width` `--athena-hover` `--athena-line` `--athena-muted` `--athena-radius` `--athena-shadow` `--athena-surface` `--athena-surface-alt` |
1
+ # Styling reference
2
+
3
+ Generated by `npm run docs` from `src/res/themes/default/style.css` and `tokens.css`. Do not edit by hand.
4
+
5
+ All Athena UI rules are in the cascade layer `athena`: a plain rule of your application (not in a layer) always wins, whatever its specificity.
6
+ Start with the tokens, they cover most of what people want to change.
7
+
8
+ ## Tokens
9
+
10
+ | Variable | Default (light) |
11
+ | --- | --- |
12
+ | `--athena-accent` | `#8e44ad` |
13
+ | `--athena-radius` | `2px` |
14
+ | `--athena-bg` | `#fff` |
15
+ | `--athena-fg` | `#1a1a1a` |
16
+ | `--athena-muted` | `#666` |
17
+ | `--athena-border` | `#000` |
18
+ | `--athena-line` | `#ccc` |
19
+ | `--athena-surface` | `#f2f2f2` |
20
+ | `--athena-surface-alt` | `#fafafa` |
21
+ | `--athena-hover` | `#e8f0fe` |
22
+ | `--athena-overlay` | `rgb(0 0 0 / 40%)` |
23
+ | `--athena-accent` | `#2f6db5` |
24
+ | `--athena-accent-fg` | `#fff` |
25
+ | `--athena-focus` | `#1b4f8f` |
26
+ | `--athena-danger` | `#c0392b` |
27
+ | `--athena-success` | `#1e8449` |
28
+ | `--athena-warning` | `#9a6700` |
29
+ | `--athena-info` | `#2471a3` |
30
+ | `--athena-shadow` | `0 4px 14px rgb(0 0 0 / 18%)` |
31
+ | `--athena-tok-comment` | `#5a6270` |
32
+ | `--athena-tok-string` | `#0b6e3a` |
33
+ | `--athena-tok-number` | `#a24b00` |
34
+ | `--athena-tok-keyword` | `#7a2a9e` |
35
+ | `--athena-tok-literal` | `#0b5fa5` |
36
+ | `--athena-tok-function` | `#1f55b0` |
37
+ | `--athena-tok-type` | `#0f6b6b` |
38
+ | `--athena-tok-property` | `#9b2c5b` |
39
+ | `--athena-tok-tag` | `#a3201f` |
40
+ | `--athena-tok-attribute` | `#8a5300` |
41
+ | `--athena-tok-variable` | `#0a6a8a` |
42
+ | `--athena-tok-selector` | `#7a2a9e` |
43
+ | `--athena-tok-meta` | `#6b4eae` |
44
+ | `--athena-tok-entity` | `#0a6a8a` |
45
+ | `--athena-tok-builtin` | `#0b5fa5` |
46
+ | `--athena-tok-operator` | `#3b4048` |
47
+ | `--athena-tok-punctuation` | `#5a6270` |
48
+ | `--athena-radius` | `6px` |
49
+ | `--athena-border-width` | `1px` |
50
+ | `--athena-space-1` | `4px` |
51
+ | `--athena-space-2` | `8px` |
52
+ | `--athena-space-3` | `12px` |
53
+ | `--athena-space-4` | `16px` |
54
+ | `--grid-gap` | `16px` |
55
+ | `--athena-focus-width` | `2px` |
56
+ | `--athena-dialog-small` | `360px` |
57
+ | `--athena-dialog-medium` | `480px` |
58
+ | `--athena-dialog-large` | `720px` |
59
+ | `--athena-row-height` | `36px` |
60
+ | `--athena-duration-fast` | `120ms` |
61
+ | `--athena-duration-base` | `200ms` |
62
+ | `--athena-duration-slow` | `360ms` |
63
+ | `--athena-ease-standard` | `cubic-bezier(0.2, 0, 0, 1)` |
64
+ | `--athena-ease-in` | `cubic-bezier(0.4, 0, 1, 1)` |
65
+ | `--athena-ease-out` | `cubic-bezier(0, 0, 0.2, 1)` |
66
+ | `--athena-ease-spring` | `linear(0, 0.009, 0.035 2.1%, 0.141 4.4%, 0.723 12.9%, 0.938 16.7%, 1.017 19.4%, 1.077 22.8%, 1.121 26.7%, 1.149 31.2%, 1.159 36.2%, 1.138 49.9%, 1.115 56.3%, 1.043 69.7%, 1.009 81.2%, 0.998 92.1%, 1)` |
67
+
68
+ Dark colours: set `data-mode="dark"` on `<html>` (or let `createThemeManager` do it); without the attribute the system decides. Themes: see `appearance.css`.
69
+
70
+ ## Components
71
+
72
+ | Group of rules | Classes | Variables it reads |
73
+ | --- | --- | --- |
74
+ | General | - | `--athena-accent` `--athena-bg` `--athena-border-width` `--athena-fg` `--athena-line` |
75
+ | Header, Wrapper, Footer | `.footer-container` `.header-container` `.wrapper-container` | - |
76
+ | Elements | `.container` `.default-cointainer-bordered` `.menu` | `--athena-border` |
77
+ | Modal (background) | `.modal` `.modal-content` | `--athena-bg` `--athena-border-width` `--athena-fg` `--athena-line` `--athena-overlay` |
78
+ | Modal close button | `.close` | `--athena-fg` `--athena-muted` |
79
+ | Buttons | `.athena-button` `.button-danger` `.button-large` `.button-link` `.button-secondary` `.button-small` | `--athena-accent` `--athena-accent-fg` `--athena-danger` `--athena-fg` `--athena-line` `--athena-radius` `--athena-surface` |
80
+ | Forms | `.athena-form` `.choice` `.choices` `.field` `.field-error` `.field-group` `.field-help` `.field-invalid` `.field-label` `.field-required` `.form-actions` `.form-message` `.form-message-error` `.form-message-success` | `--athena-border-width` `--athena-danger` `--athena-line` `--athena-muted` `--athena-radius` `--athena-space-1` `--athena-space-2` `--athena-space-3` `--athena-success` |
81
+ | Switch: a checkbox drawn as a toggle | `.switch` `.switch-track` | `--athena-accent` `--athena-duration-fast` `--athena-ease-standard` `--athena-line` |
82
+ | Spinner, alerts, toasts, progress | `.alert` `.alert-body` `.alert-close` `.alert-error` `.alert-info` `.alert-success` `.alert-warning` `.button-loading` `.progress-bar` `.progress-error` `.progress-fill` `.progress-indeterminate` `.progress-label` `.progress-success` `.progress-warning` `.spinner` `.spinner-large` `.spinner-small` `.toast` `.toast-container` | `--alert-color` `--athena-accent` `--athena-border-width` `--athena-danger` `--athena-duration-base` `--athena-ease-standard` `--athena-fg` `--athena-info` `--athena-line` `--athena-muted` `--athena-radius` `--athena-shadow` `--athena-space-2` `--athena-space-3` `--athena-success` `--athena-surface` `--athena-surface-alt` `--athena-warning` `--progress-color` |
83
+ | Dialog: the native <dialog> element, opened with showModal() | `.dialog` | `--athena-bg` `--athena-border-width` `--athena-dialog-medium` `--athena-fg` `--athena-line` `--athena-overlay` `--athena-radius` `--athena-shadow` `--dialog-width` |
84
+ | The content fills the dialog up to its edge, so a click on the backdrop is a click on the dialog element itself | `.dialog-body` `.dialog-close` `.dialog-footer` `.dialog-full` `.dialog-inner` `.dialog-large` `.dialog-medium` `.dialog-small` `.dialog-title` | `--athena-dialog-large` `--athena-dialog-medium` `--athena-dialog-small` `--athena-muted` `--athena-space-2` |
85
+ | Tabs | `.tab` `.tab-active` `.tab-list` `.tab-panel` | `--athena-accent` `--athena-border-width` `--athena-fg` `--athena-line` |
86
+ | Breadcrumbs, pagination | `.breadcrumb-item` `.breadcrumb-list` `.page-button` `.page-current` `.pagination` | `--athena-accent` `--athena-accent-fg` `--athena-bg` `--athena-border-width` `--athena-fg` `--athena-line` `--athena-muted` `--athena-space-1` |
87
+ | Accordion: <details> and <summary> | `.accordion-header` `.accordion-icon` `.accordion-item` `.accordion-panel` `.sidebar-parent` | `--athena-accent` `--athena-border-width` `--athena-duration-fast` `--athena-ease-standard` `--athena-fg` `--athena-focus` `--athena-focus-width` `--athena-line` `--athena-surface` |
88
+ | Dropdown | `.dropdown` `.dropdown-menu` `.dropdown-right` | `--athena-bg` `--athena-border-width` `--athena-line` `--athena-radius` `--athena-shadow` |
89
+ | A popover (the dropdown menu, the tooltip) is in the top layer, placed next to its anchor by script through two variables | `.athena-popover` `.athena-popover-above` `.athena-popover-center` `.athena-popover-end` `.dropdown-divider` `.dropdown-item` `.dropdown-menu` | `--athena-fg` `--athena-hover` `--athena-line` `--athena-popover-left` `--athena-popover-top` |
90
+ | Sidebar | `.accordion-icon` `.sidebar` `.sidebar-link` `.sidebar-list` `.sidebar-parent` `.sidebar-sublist` `.sidebar-toggle` | `--athena-accent` `--athena-accent-fg` `--athena-fg` `--athena-hover` `--athena-space-2` |
91
+ | Cards, sections, grid | `.athena-grid` `.card` `.card-body` `.card-footer` `.card-image` `.card-title` | `--athena-bg` `--athena-border-width` `--athena-line` `--athena-radius` `--athena-surface-alt` `--grid-columns` `--grid-gap` |
92
+ | Badge, avatar, stat | `.avatar` `.avatar-large` `.avatar-small` `.badge` `.badge-error` `.badge-info` `.badge-pill` `.badge-success` `.badge-warning` `.stat` `.stat-bad` `.stat-good` `.stat-label` `.stat-neutral` `.stat-value` | `--athena-accent` `--athena-accent-fg` `--athena-bg` `--athena-border-width` `--athena-danger` `--athena-fg` `--athena-info` `--athena-line` `--athena-muted` `--athena-radius` `--athena-success` `--athena-surface` `--athena-warning` |
93
+ | Tooltip | `.has-tooltip` `.tooltip-text` `.tooltip-wrap` | `--athena-duration-fast` `--athena-ease-standard` |
94
+ | As a popover it is only drawn while it is open, so it is always visible; the position comes from placePopover() | `.tooltip-text` | - |
95
+ | Combobox (autocomplete, multi select) and chips | `.chip` `.chip-remove` `.combobox` `.combobox-active` `.combobox-chips` `.combobox-empty` `.combobox-input` `.combobox-list` `.combobox-multiple` `.combobox-option` `.combobox-selected` | `--athena-accent` `--athena-accent-fg` `--athena-bg` `--athena-border-width` `--athena-hover` `--athena-line` `--athena-muted` `--athena-radius` `--athena-shadow` `--athena-space-1` |
96
+ | File upload | `.dropzone` `.dropzone-disabled` `.dropzone-input` `.dropzone-over` `.file-item` `.file-list` `.file-status` | `--athena-accent` `--athena-hover` `--athena-line` `--athena-muted` `--athena-radius` |
97
+ | Stepper | `.form-actions` `.stepper` `.stepper-current` `.stepper-done` `.stepper-number` `.stepper-step` `.stepper-steps` | `--athena-accent` `--athena-accent-fg` `--athena-fg` `--athena-line` `--athena-muted` `--athena-space-2` `--athena-success` |
98
+ | Tables | `.athena-table` `.athena-table-edit` `.athena-table-filter` `.athena-table-pager` `.athena-table-select` `.athena-table-wrapper` `.clickable` `.editable` `.selected` `.sortable` | `--athena-accent` `--athena-border-width` `--athena-hover` `--athena-line` `--athena-surface` `--athena-surface-alt` |
99
+ | Table options: density, wrapping, alignment | `.athena-align-center` `.athena-align-right` `.athena-table` `.athena-table-compact` `.athena-table-nowrap` `.athena-table-wrap` | `--athena-focus` `--athena-focus-width` |
100
+ | Charts | `.athena-chart` `.chart-axis` `.chart-bar` `.chart-grid` `.chart-legend` `.chart-slice` `.chart-tick` `.chart-title` | `--athena-bg` `--athena-fg` `--athena-line` `--athena-muted` |
101
+ | Responsive | `.athena-form` `.athena-grid` `.file-item` `.file-progress` `.modal` `.modal-content` `.sidebar` `.sidebar-list` `.sidebar-open` `.sidebar-toggle` `.stepper-title` | - |
102
+ | Reduced motion: a spinner and an indeterminate bar still have to say "busy", but slowly. The transitions read the duration tokens (0). | `.progress-fill` `.progress-indeterminate` `.spinner` | - |
103
+ | Menu submenus | `.has-submenu` `.menu-parent` `.submenu` `.submenu-item` | `--athena-bg` `--athena-border-width` `--athena-hover` `--athena-line` `--athena-radius` `--athena-shadow` |
104
+ | Table: resizable columns, virtual scrolling | `.athena-col-resizer` `.athena-table` `.athena-table-resizable` `.athena-table-scroll` `.athena-table-spacer` `.athena-table-virtual` `.resizing` | `--athena-accent` `--athena-border-width` `--athena-line` `--athena-row-height` `--row-height` |
105
+ | Date range | `.daterange` `.daterange-part` | - |
106
+ | Rich text editor | `.richtext` `.rt-bold` `.rt-button` `.rt-disabled` `.rt-editor` `.rt-empty` `.rt-italic` `.rt-separator` `.rt-source-view` `.rt-strike` `.rt-toolbar` `.rt-underline` `.submenu` | `--athena-accent` `--athena-accent-fg` `--athena-bg` `--athena-border-width` `--athena-fg` `--athena-hover` `--athena-line` `--athena-muted` `--athena-radius` `--athena-surface` |
107
+ | Theme picker (generateThemePicker). The preview is drawn with the colours of the theme it shows. | `.theme-picker` `.theme-picker-description` `.theme-picker-group` `.theme-picker-option` `.theme-picker-options` `.theme-preview` `.theme-preview-bar` `.theme-preview-body` `.theme-preview-button` `.theme-preview-line` | `--athena-accent` `--athena-bg` `--athena-border-width` `--athena-fg` `--athena-focus` `--athena-focus-width` `--athena-line` `--athena-muted` `--athena-radius` `--athena-space-1` `--athena-space-3` `--athena-space-4` |
108
+ | Tables with a data source and row actions | `.athena-button` `.athena-chart` `.athena-chart-sparkline` `.athena-table` `.athena-table-actions` `.athena-table-error` `.athena-table-is-loading` `.athena-table-loading` `.athena-visually-hidden` `.chart-area` `.chart-bar` `.chart-data` `.chart-hidden` `.chart-legend-item` `.chart-line` `.chart-point` `.chart-ring` `.chart-slice` `.chart-swatch` `.chart-tooltip` `.chart-tooltip-box` `.chart-tooltip-text` `.is-off` `.is-visible` `.s1` `.s2` `.s3` `.s4` `.s5` `.s6` `.s7` `.s8` | `--athena-bg` `--athena-danger` `--athena-fg` `--athena-focus` `--athena-focus-width` `--athena-muted` `--series-1` `--series-2` `--series-3` `--series-4` `--series-5` `--series-6` `--series-7` `--series-8` |
109
+ | Menu (generateMenu): a bar, or tabs at the bottom of the screen with sheets for the groups | `.athena-menu` `.athena-menu-list` `.has-active` `.is-active` `.menu-avatar` `.menu-control` `.menu-icon` `.menu-item` `.menu-item-end` `.menu-sheet` | `--athena-accent` `--athena-accent-fg` `--athena-bg` `--athena-border-width` `--athena-fg` `--athena-focus` `--athena-focus-width` `--athena-hover` `--athena-line` `--athena-radius` `--athena-shadow` |
110
+ | Tabs at the bottom (layout "responsive" switches to it under 700px) | `.athena-menu-bottom-tabs` `.athena-menu-list` `.athena-menu-responsive` `.menu-control` `.menu-item` `.menu-item-end` `.menu-sheet` | `--athena-bg` `--athena-border-width` `--athena-line` `--athena-radius` |
111
+ | Menu: groups inside groups, and badges | `.athena-menu` `.athena-menu-bottom-tabs` `.athena-menu-responsive` `.athena-table-placeholder` `.athena-table-status` `.menu-badge` `.menu-badge-bad` `.menu-badge-info` `.menu-badge-ok` `.menu-badge-warn` `.menu-caret` `.menu-sheet` `.menu-sheet-nested` | `--athena-accent` `--athena-accent-fg` `--athena-danger` `--athena-info` `--athena-muted` `--athena-success` `--athena-warning` |
112
+ | Charts: pointer layer, zoom | `.athena-chart` `.chart-hit` `.chart-marker` `.chart-reset` `.chart-selection` | `--athena-accent` `--athena-focus` `--athena-focus-width` `--athena-muted` |
113
+ | Page header, facts, empty state, loading, stat tone and note | `.athena-popover` `.athena-popover-above` `.dialog` `.empty-icon` `.empty-message` `.empty-state` `.empty-title` `.fact` `.facts` `.facts-inline` `.is-bad` `.is-ok` `.is-warn` `.loading-state` `.page-actions` `.page-description` `.page-header` `.page-header-row` `.page-title` `.stat` `.stat-note` `.stat-value` | `--athena-danger` `--athena-duration-base` `--athena-duration-fast` `--athena-ease-out` `--athena-fg` `--athena-muted` `--athena-space-2` `--athena-space-3` `--athena-success` `--athena-warning` |
114
+ | Toasts slide in from the side, and out again when they are closed | `.is-leaving` `.toast` | `--athena-duration-base` `--athena-ease-out` |
115
+ | The panel of an accordion opens and closes smoothly (a browser without ::details-content opens it at once) | `.accordion-item` | `--athena-duration-base` `--athena-ease-standard` |
116
+ | The mark of the active item, and hover, move gently | `.athena-menu` `.menu-control` | `--athena-duration-fast` `--athena-ease-standard` |
117
+ | A place holder for what is loading: a skeleton with a shimmer (generateSkeleton) | `.athena-skeleton` `.athena-skeleton-line` | `--athena-hover` `--athena-radius` `--athena-space-2` `--athena-surface` |
118
+ | A theme or mode change cross-fades instead of flashing (the theme manager sets the class for a moment) | `.athena-switching` | `--athena-duration-slow` `--athena-ease-standard` |
119
+ | Page transitions of the router (router({ transition: true })) | - | `--athena-duration-base` `--athena-ease-standard` |
120
+ | Charts draw themselves when they appear: bars grow, lines are drawn, slices pop in (only the first time, not when a chart streams or is zoomed) | `.athena-chart-animated` `.athena-code` `.athena-widget-grid` `.chart-area` `.chart-bar` `.chart-line` `.chart-point` `.chart-slice` `.code-digits-1` `.code-digits-2` `.code-digits-3` `.code-digits-4` `.code-digits-5` `.code-digits-6` `.code-digits-7` `.code-editor` `.code-editor-input` `.code-line` `.code-tab-1` `.code-tab-10` `.code-tab-11` `.code-tab-12` `.code-tab-13` `.code-tab-14` `.code-tab-15` `.code-tab-16` `.code-tab-2` `.code-tab-3` `.code-tab-4` `.code-tab-5` `.code-tab-6` `.code-tab-7` `.code-tab-8` `.code-tab-9` `.code-wrap` `.has-line-numbers` `.is-dragging` `.is-editable` `.is-failed` `.is-highlighted` `.is-locked` `.is-unknown` `.tok-attribute` `.tok-builtin` `.tok-comment` `.tok-entity` `.tok-function` `.tok-keyword` `.tok-literal` `.tok-meta` `.tok-number` `.tok-operator` `.tok-property` `.tok-punctuation` `.tok-selector` `.tok-string` `.tok-tag` `.tok-type` `.tok-variable` `.widget` `.widget-action` `.widget-actions` `.widget-body` `.widget-handle` `.widget-header` `.widget-note` `.widget-resize` `.widget-resize-e` `.widget-resize-n` `.widget-resize-ne` `.widget-resize-nw` `.widget-resize-s` `.widget-resize-se` `.widget-resize-sw` `.widget-resize-w` `.widget-title` | `--athena-accent` `--athena-accent-fg` `--athena-border` `--athena-border-width` `--athena-duration-fast` `--athena-duration-slow` `--athena-ease-out` `--athena-ease-standard` `--athena-fg` `--athena-focus` `--athena-focus-width` `--athena-hover` `--athena-line` `--athena-muted` `--athena-radius` `--athena-shadow` `--athena-surface` `--athena-surface-alt` `--athena-tok-attribute` `--athena-tok-builtin` `--athena-tok-comment` `--athena-tok-entity` `--athena-tok-function` `--athena-tok-keyword` `--athena-tok-literal` `--athena-tok-meta` `--athena-tok-number` `--athena-tok-operator` `--athena-tok-property` `--athena-tok-punctuation` `--athena-tok-selector` `--athena-tok-string` `--athena-tok-tag` `--athena-tok-type` `--athena-tok-variable` `--code-gutter` |
121
+ | A block: the language, a copy button, the code | `.athena-code` `.code-block` `.code-block-copy` `.code-block-header` `.code-find-button` `.code-find-input` | `--athena-bg` `--athena-border-width` `--athena-fg` `--athena-focus` `--athena-focus-width` `--athena-hover` `--athena-line` `--athena-muted` `--athena-radius` `--athena-surface` |
122
+ | The editor | `.code-completion` `.code-completion-detail` `.code-completions` `.code-editor` `.code-editor-highlight` `.code-editor-input` `.code-editor-scroll` `.code-editor-status` `.code-find` `.code-find-button` `.code-find-count` `.code-find-input` `.code-find-row` `.code-line` `.code-wrap` `.has-line-numbers` `.has-marker` `.is-active` `.is-current` `.is-locked-line` `.is-plain` `.is-readonly` `.marker-error` `.marker-info` `.marker-warning` | `--athena-accent` `--athena-accent-fg` `--athena-bg` `--athena-border` `--athena-border-width` `--athena-danger` `--athena-fg` `--athena-focus` `--athena-focus-width` `--athena-info` `--athena-line` `--athena-muted` `--athena-radius` `--athena-shadow` `--athena-surface` `--athena-surface-alt` `--athena-warning` `--code-completion-left` `--code-completion-top` `--code-editor-max-height` `--code-editor-min-height` `--code-gutter` |
123
+ | The diff view | `.code-diff` `.code-diff-body` `.code-diff-cell` `.code-diff-code` `.code-diff-empty` `.code-diff-header` `.code-diff-mark` `.code-diff-number` `.code-diff-row` `.code-diff-skip` `.code-diff-stat` `.code-line` `.is-added` `.is-empty` `.is-removed` `.is-skip` `.is-split` | `--athena-accent` `--athena-border-width` `--athena-danger` `--athena-line` `--athena-muted` `--athena-radius` `--athena-success` `--athena-surface` |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "athena-ui-js",
3
- "version": "2.3.0",
3
+ "version": "2.4.1",
4
4
  "description": "A small, dependency-free UI framework: forms, tables, charts, menus, dialogs, themes and a router, written as ES modules.",
5
5
  "type": "module",
6
6
  "main": "./src/athena-ui.js",
@@ -8,6 +8,7 @@
8
8
  "test": "node --test tests/*.test.js",
9
9
  "test:browser": "node tests/browser/run.mjs",
10
10
  "docs": "node scripts/styling-docs.mjs",
11
+ "check:package": "node scripts/check-package.mjs",
11
12
  "types": "tsc -p tsconfig.types.json",
12
13
  "test:demo": "node --test --test-timeout=600000 demo/tests/demo.test.mjs demo/tests/browser.test.mjs",
13
14
  "demo": "node demo/server.mjs",
@@ -95,6 +96,10 @@
95
96
  "types": "./types/widgets.d.ts",
96
97
  "default": "./src/widgets.js"
97
98
  },
99
+ "./code": {
100
+ "types": "./types/code.d.ts",
101
+ "default": "./src/code.js"
102
+ },
98
103
  "./sanitize": {
99
104
  "types": "./types/sanitize.d.ts",
100
105
  "default": "./src/sanitize.js"
@@ -131,6 +136,8 @@
131
136
  "src/libs/hephaestus/chartGenerator",
132
137
  "src/libs/hephaestus/tableGenerator",
133
138
  "src/libs/hephaestus/modalGenerator",
139
+ "src/libs/hephaestus/widgetGrid",
140
+ "src/libs/hephaestus/codeGenerator",
134
141
  "src/res",
135
142
  "src/*.js",
136
143
  "!src/example.js",
package/src/athena-ui.js CHANGED
@@ -2,7 +2,7 @@
2
2
  //Author: Csaba Tóth https://github.com/csabatibortoth/
3
3
  //LICENCE: MIT
4
4
  //Repository: https://github.com/csabatibortoth/athena-ui
5
- //Version: 2.3.0
5
+ //Version: 2.4.1
6
6
 
7
7
  // The whole API as ES module exports. There are no side effects: importing this file does not touch the page, does not load a script and does not
8
8
  // put anything on globalThis. For pages that need globals use `athena-ui-js/classic`, and to download only what you use import from the entry points
@@ -126,6 +126,10 @@ export * from "./libs/core/format.js";
126
126
  export * from "./libs/core/motion.js";
127
127
  export * from "./libs/hephaestus/widgetGrid/widgetGrid.js";
128
128
  export * from "./libs/core/gridLayout.js";
129
+ export * from "./libs/hephaestus/codeGenerator/codeGenerator.js";
130
+ export * from "./libs/hephaestus/codeGenerator/codeEditor.js";
131
+ export * from "./libs/core/codeLanguages.js";
132
+ export * from "./libs/core/codeDiff.js";
129
133
  export * from "./libs/hephaestus/modalGenerator/modalGenerator.js";
130
134
  export * from "./libs/core/theme.js";
131
135
  export * from "./libs/hephaestus/componentGenerator/themePicker.js";
package/src/code.js ADDED
@@ -0,0 +1,9 @@
1
+ //code entry of Athena UI: highlightCode, generateCodeBlock, createCodeEditor, createDiffView and the languages
2
+ //Import only what you use: `import { highlightCode, createCodeEditor } from "athena-ui-js/code"`.
3
+ //LICENCE: MIT
4
+ //Repository: https://github.com/csabatibortoth/athena-ui
5
+
6
+ export * from "./libs/hephaestus/codeGenerator/codeGenerator.js";
7
+ export * from "./libs/hephaestus/codeGenerator/codeEditor.js";
8
+ export * from "./libs/core/codeLanguages.js";
9
+ export * from "./libs/core/codeDiff.js";
@@ -6,7 +6,7 @@
6
6
  export const BORDERED_CLASS = "default-cointainer-bordered";
7
7
 
8
8
  export const defaults = Object.freeze({
9
- version: "2.3.0",
9
+ version: "2.4.1",
10
10
  container_class: "container",
11
11
  header_class: "header-container",
12
12
  header_menu_class: "header-menu menu",
@@ -0,0 +1,119 @@
1
+ //Line diff of Athena UI (no DOM): the shortest edit script between two lists of lines (Myers), after the common start and end are cut off.
2
+ //LICENCE: MIT
3
+ //Repository: https://github.com/csabatibortoth/athena-ui
4
+
5
+ /**
6
+ * @typedef {{type: "equal", a: number, b: number} | {type: "remove", a: number} | {type: "add", b: number}} DiffOp
7
+ */
8
+
9
+ /** Splits text into lines the way an editor counts them (a text that ends with a newline has a last empty line). */
10
+ export const splitLines = text => String(text ?? "").replace(/\r\n?/g, "\n").split("\n");
11
+
12
+ /**
13
+ * The difference between two lists of lines, as operations in order. `a` and `b` are indexes into the two lists.
14
+ * When the two lists differ by more than `maxEdits` lines the result is coarse (everything removed, then everything added) instead of slow.
15
+ *
16
+ * @param {string[]} oldLines
17
+ * @param {string[]} newLines
18
+ * @param {{maxEdits?: number}} [options]
19
+ * @returns {DiffOp[]}
20
+ */
21
+ export function diffLines(oldLines, newLines, { maxEdits = 3000 } = {}) {
22
+ let start = 0;
23
+ while (start < oldLines.length && start < newLines.length && oldLines[start] === newLines[start]) start++;
24
+ let endOld = oldLines.length;
25
+ let endNew = newLines.length;
26
+ while (endOld > start && endNew > start && oldLines[endOld - 1] === newLines[endNew - 1]) {
27
+ endOld--;
28
+ endNew--;
29
+ }
30
+ const ops = [];
31
+ for (let i = 0; i < start; i++) ops.push({ type: "equal", a: i, b: i });
32
+ for (const op of myers(oldLines.slice(start, endOld), newLines.slice(start, endNew), maxEdits)) {
33
+ ops.push(op.type === "equal" ? { type: "equal", a: op.a + start, b: op.b + start } : op.type === "remove" ? { type: "remove", a: op.a + start } : { type: "add", b: op.b + start });
34
+ }
35
+ for (let i = 0; i < oldLines.length - endOld; i++) ops.push({ type: "equal", a: endOld + i, b: endNew + i });
36
+ return ops;
37
+ }
38
+
39
+ function myers(A, B, maxEdits) {
40
+ const N = A.length;
41
+ const M = B.length;
42
+ if (!N || !M || N + M === 0) return [...A.map((_, a) => ({ type: "remove", a })), ...B.map((_, b) => ({ type: "add", b }))];
43
+ const max = N + M;
44
+ const offset = max + 1;
45
+ const v = new Int32Array(2 * max + 3);
46
+ const trace = [];
47
+ let found = -1;
48
+ search: for (let d = 0; d <= max; d++) {
49
+ if (d > maxEdits) return [...A.map((_, a) => ({ type: "remove", a })), ...B.map((_, b) => ({ type: "add", b }))];
50
+ trace.push(v.slice(offset - d - 1, offset + d + 2));
51
+ for (let k = -d; k <= d; k += 2) {
52
+ let x = k === -d || (k !== d && v[offset + k - 1] < v[offset + k + 1]) ? v[offset + k + 1] : v[offset + k - 1] + 1;
53
+ let y = x - k;
54
+ while (x < N && y < M && A[x] === B[y]) {
55
+ x++;
56
+ y++;
57
+ }
58
+ v[offset + k] = x;
59
+ if (x >= N && y >= M) {
60
+ found = d;
61
+ break search;
62
+ }
63
+ }
64
+ }
65
+ const ops = [];
66
+ let x = N;
67
+ let y = M;
68
+ for (let d = found; d > 0; d--) {
69
+ const before = k => trace[d][k + d + 1];
70
+ const k = x - y;
71
+ const previousK = k === -d || (k !== d && before(k - 1) < before(k + 1)) ? k + 1 : k - 1;
72
+ const previousX = before(previousK);
73
+ const previousY = previousX - previousK;
74
+ while (x > previousX && y > previousY) {
75
+ ops.push({ type: "equal", a: x - 1, b: y - 1 });
76
+ x--;
77
+ y--;
78
+ }
79
+ ops.push(x === previousX ? { type: "add", b: y - 1 } : { type: "remove", a: x - 1 });
80
+ x = previousX;
81
+ y = previousY;
82
+ }
83
+ while (x > 0 && y > 0) {
84
+ ops.push({ type: "equal", a: x - 1, b: y - 1 });
85
+ x--;
86
+ y--;
87
+ }
88
+ return ops.reverse();
89
+ }
90
+
91
+ /**
92
+ * Groups the operations into hunks that show `context` unchanged lines around each change (Infinity: everything is one hunk).
93
+ * @returns {{ops: DiffOp[], skippedBefore: number}[]} `skippedBefore` is the number of unchanged lines left out before the hunk
94
+ */
95
+ export function hunksOf(ops, context = 3) {
96
+ if (!Number.isFinite(context)) return [{ ops, skippedBefore: 0 }];
97
+ const keep = new Array(ops.length).fill(false);
98
+ ops.forEach((op, index) => {
99
+ if (op.type === "equal") return;
100
+ for (let i = Math.max(0, index - context); i <= Math.min(ops.length - 1, index + context); i++) keep[i] = true;
101
+ });
102
+ const hunks = [];
103
+ let skipped = 0;
104
+ let current = null;
105
+ ops.forEach((op, index) => {
106
+ if (!keep[index]) {
107
+ skipped++;
108
+ current = null;
109
+ return;
110
+ }
111
+ if (!current) {
112
+ current = { ops: [], skippedBefore: skipped };
113
+ hunks.push(current);
114
+ skipped = 0;
115
+ }
116
+ current.ops.push(op);
117
+ });
118
+ return hunks;
119
+ }