@motifx-community/ui 0.1.0-beta.5 → 0.1.0-beta.6
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/CHANGELOG.md +87 -0
- package/README.md +7 -4
- package/dist/components/appbar/AppBar.d.ts +88 -0
- package/dist/components/appbar/app-bar-navigation-click-event-args.d.ts +9 -0
- package/dist/components/appbar/app-bar-navigation.d.ts +2 -0
- package/dist/components/appbar/app-bar-position.d.ts +2 -0
- package/dist/components/appbar/app-bar-props.d.ts +49 -0
- package/dist/components/appbar/app-bar-scroll-behavior.d.ts +2 -0
- package/dist/components/appbar/app-bar-title-align.d.ts +2 -0
- package/dist/components/appbar/app-bar-tone.d.ts +2 -0
- package/dist/components/appbar/index.d.ts +8 -0
- package/dist/components/barcode/Barcode.d.ts +62 -0
- package/dist/components/barcode/barcode-export-options.d.ts +9 -0
- package/dist/components/barcode/barcode-failed-event-args.d.ts +9 -0
- package/dist/components/barcode/barcode-props.d.ts +25 -0
- package/dist/components/barcode/index.d.ts +5 -0
- package/dist/components/bargauge/BarGauge.d.ts +120 -0
- package/dist/components/bargauge/bar-gauge-props.d.ts +38 -0
- package/dist/components/bargauge/index.d.ts +2 -0
- package/dist/components/bottomnavigation/BottomNavigation.d.ts +101 -0
- package/dist/components/bottomnavigation/bottom-navigation-item-click-event-args.d.ts +9 -0
- package/dist/components/bottomnavigation/bottom-navigation-item.d.ts +35 -0
- package/dist/components/bottomnavigation/bottom-navigation-label-mode.d.ts +2 -0
- package/dist/components/bottomnavigation/bottom-navigation-position.d.ts +2 -0
- package/dist/components/bottomnavigation/bottom-navigation-props.d.ts +31 -0
- package/dist/components/bottomnavigation/bottom-navigation-selecting-event-args.d.ts +5 -0
- package/dist/components/bottomnavigation/bottom-navigation-selection-changed-event-args.d.ts +11 -0
- package/dist/components/bottomnavigation/index.d.ts +8 -0
- package/dist/components/chart/Chart.d.ts +229 -0
- package/dist/components/chart/ChartLegend.d.ts +24 -0
- package/dist/components/chart/ChartPlot.d.ts +161 -0
- package/dist/components/chart/ChartTable.d.ts +68 -0
- package/dist/components/chart/ChartTooltip.d.ts +22 -0
- package/dist/components/chart/PartsPlot.d.ts +39 -0
- package/dist/components/chart/RadarPlot.d.ts +34 -0
- package/dist/components/chart/chart-axis-kind.d.ts +2 -0
- package/dist/components/chart/chart-axis.d.ts +31 -0
- package/dist/components/chart/chart-data-error-event-args.d.ts +7 -0
- package/dist/components/chart/chart-export-options.d.ts +7 -0
- package/dist/components/chart/chart-export.d.ts +12 -0
- package/dist/components/chart/chart-field.d.ts +2 -0
- package/dist/components/chart/chart-labels.d.ts +2 -0
- package/dist/components/chart/chart-legend-options.d.ts +10 -0
- package/dist/components/chart/chart-legend-position.d.ts +2 -0
- package/dist/components/chart/chart-look.d.ts +25 -0
- package/dist/components/chart/chart-mode-changed-event-args.d.ts +7 -0
- package/dist/components/chart/chart-mode.d.ts +2 -0
- package/dist/components/chart/chart-model.d.ts +105 -0
- package/dist/components/chart/chart-point-event-args.d.ts +9 -0
- package/dist/components/chart/chart-point-selection.d.ts +2 -0
- package/dist/components/chart/chart-point.d.ts +23 -0
- package/dist/components/chart/chart-props.d.ts +76 -0
- package/dist/components/chart/chart-reference.d.ts +12 -0
- package/dist/components/chart/chart-selection-changed-event-args.d.ts +8 -0
- package/dist/components/chart/chart-series-toggled-event-args.d.ts +10 -0
- package/dist/components/chart/chart-series-type.d.ts +6 -0
- package/dist/components/chart/chart-series.d.ts +55 -0
- package/dist/components/chart/chart-stacked.d.ts +2 -0
- package/dist/components/chart/chart-tooltip-context.d.ts +10 -0
- package/dist/components/chart/chart-tooltip-options.d.ts +10 -0
- package/dist/components/chart/chart-zoom-changed-event-args.d.ts +8 -0
- package/dist/components/chart/index.d.ts +21 -0
- package/dist/components/chart/legend-entry.d.ts +13 -0
- package/dist/components/chart/plot-text.d.ts +10 -0
- package/dist/components/chart/plot-view.d.ts +61 -0
- package/dist/components/datagrid/grid-settings.d.ts +3 -3
- package/dist/components/datagrid/model/GridData.d.ts +22 -3
- package/dist/components/gauge/Gauge.d.ts +179 -0
- package/dist/components/gauge/gauge-mark.d.ts +9 -0
- package/dist/components/gauge/gauge-marker.d.ts +2 -0
- package/dist/components/gauge/gauge-needle-shape.d.ts +2 -0
- package/dist/components/gauge/gauge-orientation.d.ts +2 -0
- package/dist/components/gauge/gauge-props.d.ts +58 -0
- package/dist/components/gauge/gauge-range.d.ts +11 -0
- package/dist/components/gauge/gauge-scale.d.ts +2 -0
- package/dist/components/gauge/gauge-shape.d.ts +43 -0
- package/dist/components/gauge/gauge-type.d.ts +2 -0
- package/dist/components/gauge/index.d.ts +9 -0
- package/dist/components/otpinput/OtpInput.d.ts +73 -0
- package/dist/components/otpinput/index.d.ts +4 -0
- package/dist/components/otpinput/otp-charset.d.ts +2 -0
- package/dist/components/otpinput/otp-completed-event-args.d.ts +8 -0
- package/dist/components/otpinput/otp-input-props.d.ts +32 -0
- package/dist/components/qrcode/QRCode.d.ts +58 -0
- package/dist/components/qrcode/index.d.ts +5 -0
- package/dist/components/qrcode/qr-code-export-options.d.ts +9 -0
- package/dist/components/qrcode/qr-code-failed-event-args.d.ts +7 -0
- package/dist/components/qrcode/qr-code-props.d.ts +23 -0
- package/dist/components/signature/Signature.d.ts +100 -0
- package/dist/components/signature/index.d.ts +5 -0
- package/dist/components/signature/signature-draw.d.ts +15 -0
- package/dist/components/signature/signature-export-options.d.ts +11 -0
- package/dist/components/signature/signature-props.d.ts +30 -0
- package/dist/components/signature/signature-stroke-event-args.d.ts +9 -0
- package/dist/components/signature/signature-stroke.d.ts +11 -0
- package/dist/components/sparkline/Sparkline.d.ts +85 -0
- package/dist/components/sparkline/index.d.ts +4 -0
- package/dist/components/sparkline/sparkline-highlight.d.ts +2 -0
- package/dist/components/sparkline/sparkline-props.d.ts +34 -0
- package/dist/components/sparkline/sparkline-type.d.ts +2 -0
- package/dist/components/validationsummary/ValidationSummary.d.ts +1 -0
- package/dist/core/fonts-loaded.d.ts +2 -0
- package/dist/core/scroll-watch.d.ts +13 -0
- package/dist/core/ui-strings.d.ts +38 -0
- package/dist/generated/tokens.d.ts +3023 -863
- package/dist/index.d.ts +10 -0
- package/dist/index.js +55999 -47313
- package/dist/index.js.map +1 -1
- package/dist/locales/en.json +37 -1
- package/dist/locales/tr.json +37 -1
- package/dist/parts/chart/chart-paths.d.ts +30 -0
- package/dist/parts/chart/chart-scale.d.ts +13 -0
- package/dist/parts/chart/chart-text.d.ts +12 -0
- package/dist/parts/chart/nice-ticks.d.ts +6 -0
- package/dist/parts/chart/svg-parts.d.ts +12 -0
- package/dist/parts/chart/thin-out.d.ts +6 -0
- package/dist/parts/chart/time-ticks.d.ts +7 -0
- package/dist/parts/chart/token-lengths.d.ts +16 -0
- package/dist/parts/chart/value-motion.d.ts +16 -0
- package/dist/parts/code/barcode-encode.d.ts +23 -0
- package/dist/parts/code/code-image.d.ts +35 -0
- package/dist/parts/code/qr-encode.d.ts +10 -0
- package/dist/parts/field/Field.d.ts +2 -0
- package/dist/styles.css +3043 -9
- package/dist/tokens/index.d.ts +3212 -967
- package/dist/tokens/index.js +3023 -863
- package/dist/tokens/index.js.map +1 -1
- package/dist/{tr-C5IXRzAH.js → tr-DhIFcH3c.js} +75 -3
- package/dist/{tr-C5IXRzAH.js.map → tr-DhIFcH3c.js.map} +1 -1
- package/docs/accordion.md +1 -1
- package/docs/actionsheet.md +1 -1
- package/docs/appbar.md +194 -0
- package/docs/avatar.md +1 -1
- package/docs/badge.md +1 -1
- package/docs/bar-gauge-angles.md +87 -0
- package/docs/bar-gauge-data.md +122 -0
- package/docs/bar-gauge-labels.md +78 -0
- package/docs/bar-gauge.md +98 -0
- package/docs/barcode.md +193 -0
- package/docs/bottomnavigation.md +258 -0
- package/docs/bottomsheet.md +1 -1
- package/docs/breadcrumb.md +1 -1
- package/docs/button.md +1 -1
- package/docs/buttongroup.md +1 -1
- package/docs/buttons.md +169 -0
- package/docs/calendar.md +1 -1
- package/docs/card.md +1 -1
- package/docs/chart-bars.md +142 -0
- package/docs/chart-candles.md +164 -0
- package/docs/chart-funnel.md +115 -0
- package/docs/chart-heatmap.md +93 -0
- package/docs/chart-lines.md +128 -0
- package/docs/chart-live.md +62 -0
- package/docs/chart-pie.md +125 -0
- package/docs/chart-radar.md +124 -0
- package/docs/chart-ranges.md +127 -0
- package/docs/chart-references.md +126 -0
- package/docs/chart-scatter.md +139 -0
- package/docs/chart-waterfall.md +111 -0
- package/docs/chart-zoom.md +95 -0
- package/docs/chart.md +427 -0
- package/docs/checkbox.md +1 -1
- package/docs/chip.md +1 -1
- package/docs/choice.md +151 -0
- package/docs/colorbox.md +1 -1
- package/docs/combobox.md +1 -1
- package/docs/control.md +1 -1
- package/docs/data.md +127 -0
- package/docs/datagrid-api.md +1 -1
- package/docs/datagrid-bands.md +1 -1
- package/docs/datagrid-drag-select.md +1 -1
- package/docs/datagrid-drag.md +1 -1
- package/docs/datagrid-editing.md +1 -1
- package/docs/datagrid-filtering.md +1 -1
- package/docs/datagrid-forms.md +1 -1
- package/docs/datagrid-grouping.md +62 -2
- package/docs/datagrid-layout.md +2 -2
- package/docs/datagrid-lookups.md +1 -1
- package/docs/datagrid-master-detail.md +1 -1
- package/docs/datagrid-scrolling.md +1 -1
- package/docs/datagrid-selection.md +1 -1
- package/docs/datagrid.md +1 -1
- package/docs/datebox.md +1 -1
- package/docs/daterangebox.md +1 -1
- package/docs/display.md +148 -0
- package/docs/draggable.md +1 -1
- package/docs/drawer.md +1 -1
- package/docs/dropdown.md +1 -1
- package/docs/editors.md +157 -0
- package/docs/feedback.md +138 -0
- package/docs/fileuploader.md +1 -1
- package/docs/filterbuilder.md +1 -1
- package/docs/formlayout.md +1 -1
- package/docs/foundations.md +79 -0
- package/docs/gallery.md +1 -1
- package/docs/gauge-base.md +78 -0
- package/docs/gauge-circular.md +101 -0
- package/docs/gauge-dashboards.md +134 -0
- package/docs/gauge-linear.md +84 -0
- package/docs/gauge-markers.md +135 -0
- package/docs/gauge-marks.md +108 -0
- package/docs/gauge-ranges.md +133 -0
- package/docs/gauge-scales.md +117 -0
- package/docs/gauge.md +152 -0
- package/docs/home.md +1 -1
- package/docs/keyboard.md +1 -1
- package/docs/language.md +1 -1
- package/docs/layout.md +1 -1
- package/docs/listbox.md +1 -1
- package/docs/loadpanel.md +1 -1
- package/docs/lookup.md +1 -1
- package/docs/menus.md +1 -1
- package/docs/multiview.md +1 -1
- package/docs/navigation.md +143 -0
- package/docs/numberbox.md +1 -1
- package/docs/otpinput.md +197 -0
- package/docs/pagination.md +1 -1
- package/docs/popover.md +1 -1
- package/docs/progress.md +1 -1
- package/docs/qrcode.md +179 -0
- package/docs/radiogroup.md +1 -1
- package/docs/rating.md +1 -1
- package/docs/resizable.md +1 -1
- package/docs/scheduler-agenda.md +1 -1
- package/docs/scheduler-big-data.md +1 -1
- package/docs/scheduler-editing.md +1 -1
- package/docs/scheduler-form.md +1 -1
- package/docs/scheduler-icalendar.md +1 -1
- package/docs/scheduler-mobile.md +1 -1
- package/docs/scheduler-recurrence.md +1 -1
- package/docs/scheduler-resources.md +1 -1
- package/docs/scheduler-timeline.md +1 -1
- package/docs/scheduler.md +1 -1
- package/docs/scrollview.md +1 -1
- package/docs/showcase-home.md +31 -0
- package/docs/showcase.md +1 -1
- package/docs/signature.md +208 -0
- package/docs/skeleton.md +1 -1
- package/docs/slider.md +1 -1
- package/docs/sortable.md +1 -1
- package/docs/sparkline.md +119 -0
- package/docs/speeddial.md +1 -1
- package/docs/splitter.md +1 -1
- package/docs/stepper.md +1 -1
- package/docs/switch.md +1 -1
- package/docs/tabdocs-dock.md +1 -1
- package/docs/tabdocs-drag.md +1 -1
- package/docs/tabdocs-menus.md +1 -1
- package/docs/tabdocs-mobile.md +1 -1
- package/docs/tabdocs-tabs.md +1 -1
- package/docs/tabdocs-windows.md +1 -1
- package/docs/tabdocs-workspace.md +1 -1
- package/docs/tabdocs.md +1 -1
- package/docs/tabs.md +1 -1
- package/docs/tagbox.md +1 -1
- package/docs/textarea.md +1 -1
- package/docs/textbox.md +1 -1
- package/docs/tileview.md +1 -1
- package/docs/timeline.md +1 -1
- package/docs/toast.md +1 -1
- package/docs/tokens.md +450 -1
- package/docs/toolbar.md +1 -1
- package/docs/tooltip.md +1 -1
- package/docs/treeview.md +1 -1
- package/docs/validationsummary.md +1 -1
- package/docs/window.md +1 -1
- package/docs/wizard.md +1 -1
- package/llms-full.txt +6724 -98
- package/llms.txt +50 -1
- package/package.json +5 -5
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
# BottomNavigation
|
|
2
|
+
|
|
3
|
+
> Navigation · @motifx-community/ui 0.1.0-beta.6
|
|
4
|
+
|
|
5
|
+
The destinations of an application at the bottom of the screen, each an icon with a label. The bar is one Tab stop, marks the selected item for screen readers and keeps clear of the home indicator of a phone.
|
|
6
|
+
|
|
7
|
+
## Import
|
|
8
|
+
|
|
9
|
+
```tsx
|
|
10
|
+
import { BottomNavigation } from '@motifx-community/ui';
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Destinations
|
|
14
|
+
|
|
15
|
+
`items` defines the destinations, and `x-model` binds the selected one. `badge` shows a count on the icon, `dot` shows a dot, and `activeGlyph` changes the glyph while the item is selected.
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import { reactive } from '@motifx/core';
|
|
19
|
+
import { BottomNavigation, Stack } from '@motifx-community/ui';
|
|
20
|
+
|
|
21
|
+
/** Three destinations bound to a value, with a count on one of them. */
|
|
22
|
+
export default function Basic() {
|
|
23
|
+
const s = reactive({ page: 'home', unread: 3 });
|
|
24
|
+
return (
|
|
25
|
+
<Stack gap="md" style="inline-size: 100%; max-inline-size: 420px">
|
|
26
|
+
<BottomNavigation
|
|
27
|
+
class="bn-basic"
|
|
28
|
+
position="static"
|
|
29
|
+
x-model={() => s.page}
|
|
30
|
+
items={[
|
|
31
|
+
{ value: 'home', text: 'Home', glyph: 'star', activeGlyph: 'star-filled' },
|
|
32
|
+
{ value: 'inbox', text: 'Inbox', glyph: 'file', badge: () => s.unread },
|
|
33
|
+
{ value: 'calendar', text: 'Calendar', glyph: 'calendar' },
|
|
34
|
+
{ value: 'profile', text: 'Profile', glyph: 'person', dot: true }
|
|
35
|
+
]}
|
|
36
|
+
/>
|
|
37
|
+
<output class="bn-told">{() => `Page: ${s.page}`}</output>
|
|
38
|
+
</Stack>
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Labels
|
|
44
|
+
|
|
45
|
+
`labelMode` shows the labels always, only on the selected item, or never. A label out of view stays as the accessible name of the item.
|
|
46
|
+
|
|
47
|
+
```tsx
|
|
48
|
+
import { reactive } from '@motifx/core';
|
|
49
|
+
import { BottomNavigation, ButtonGroup, Stack } from '@motifx-community/ui';
|
|
50
|
+
|
|
51
|
+
const ITEMS = [
|
|
52
|
+
{ value: 'home', text: 'Home', glyph: 'star' },
|
|
53
|
+
{ value: 'search', text: 'Search', glyph: 'search' },
|
|
54
|
+
{ value: 'alarms', text: 'Alarms', glyph: 'clock' },
|
|
55
|
+
{ value: 'locked', text: 'Locked', glyph: 'lock', enabled: false }
|
|
56
|
+
];
|
|
57
|
+
|
|
58
|
+
/** `labelMode`: a label out of view stays as the accessible name of the item. */
|
|
59
|
+
export default function Labels() {
|
|
60
|
+
const s = reactive({ mode: 'active' as 'always' | 'active' | 'never', page: 'home' });
|
|
61
|
+
return (
|
|
62
|
+
<Stack gap="md" style="inline-size: 100%; max-inline-size: 420px">
|
|
63
|
+
<ButtonGroup
|
|
64
|
+
label="Label mode"
|
|
65
|
+
x-model={() => s.mode}
|
|
66
|
+
items={[
|
|
67
|
+
{ value: 'always', text: 'Always' },
|
|
68
|
+
{ value: 'active', text: 'Active' },
|
|
69
|
+
{ value: 'never', text: 'Never' }
|
|
70
|
+
]}
|
|
71
|
+
/>
|
|
72
|
+
<BottomNavigation class="bn-labels" label="Sections" position="static" labelMode={() => s.mode} x-model={() => s.page} items={ITEMS} />
|
|
73
|
+
</Stack>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## Refusing a change
|
|
79
|
+
|
|
80
|
+
`onSelecting` occurs before the selection changes, and setting `cancel` keeps the current item.
|
|
81
|
+
|
|
82
|
+
```tsx
|
|
83
|
+
import { reactive } from '@motifx/core';
|
|
84
|
+
import { BottomNavigation, Stack, Switch } from '@motifx-community/ui';
|
|
85
|
+
|
|
86
|
+
/** `onSelecting` keeps the page while there are unsaved changes. */
|
|
87
|
+
export default function Guarded() {
|
|
88
|
+
const s = reactive({ page: 'edit', dirty: true, told: '' });
|
|
89
|
+
return (
|
|
90
|
+
<Stack gap="md" style="inline-size: 100%; max-inline-size: 420px">
|
|
91
|
+
<Switch label="Unsaved changes" x-model={() => s.dirty} />
|
|
92
|
+
<BottomNavigation
|
|
93
|
+
class="bn-guarded"
|
|
94
|
+
label="Document"
|
|
95
|
+
position="static"
|
|
96
|
+
x-model={() => s.page}
|
|
97
|
+
onSelecting={e => {
|
|
98
|
+
e.cancel = s.dirty;
|
|
99
|
+
s.told = s.dirty ? 'Save your changes first.' : '';
|
|
100
|
+
}}
|
|
101
|
+
items={[
|
|
102
|
+
{ value: 'edit', text: 'Edit', glyph: 'pencil' },
|
|
103
|
+
{ value: 'files', text: 'Files', glyph: 'file' },
|
|
104
|
+
{ value: 'share', text: 'Share', glyph: 'upload' }
|
|
105
|
+
]}
|
|
106
|
+
/>
|
|
107
|
+
<output class="bn-guard-told">{() => s.told}</output>
|
|
108
|
+
</Stack>
|
|
109
|
+
);
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## In a screen
|
|
114
|
+
|
|
115
|
+
By default, the bar is fixed to the bottom of the viewport. In a box that scrolls, use `position='sticky'`. `hideOnScroll` moves it away while scrolling down.
|
|
116
|
+
|
|
117
|
+
```tsx
|
|
118
|
+
import { reactive } from '@motifx/core';
|
|
119
|
+
import { AppBar, BottomNavigation } from '@motifx-community/ui';
|
|
120
|
+
|
|
121
|
+
const ROWS = Array.from({ length: 30 }, (_, i) => `Message ${i + 1}`);
|
|
122
|
+
|
|
123
|
+
/** A phone screen: the two bars around a box that scrolls. Scrolling down moves the bottom bar away. */
|
|
124
|
+
export default function Screen() {
|
|
125
|
+
const s = reactive({ page: 'mail' });
|
|
126
|
+
return (
|
|
127
|
+
<div class="bn-screen" tabindex="0" style="position: relative; inline-size: min(100%, 390px); block-size: 420px; overflow: auto; border: 1px solid var(--mx-color-stroke-divider)">
|
|
128
|
+
<AppBar title="Messages" navigation="menu" />
|
|
129
|
+
{ROWS.map(row => (
|
|
130
|
+
<p key={row} style="margin: 0; padding: 12px 16px">
|
|
131
|
+
{row}
|
|
132
|
+
</p>
|
|
133
|
+
))}
|
|
134
|
+
<BottomNavigation
|
|
135
|
+
class="bn-scroll"
|
|
136
|
+
label="Screens"
|
|
137
|
+
position="sticky"
|
|
138
|
+
hideOnScroll
|
|
139
|
+
x-model={() => s.page}
|
|
140
|
+
items={[
|
|
141
|
+
{ value: 'mail', text: 'Messages', glyph: 'file' },
|
|
142
|
+
{ value: 'calendar', text: 'Calendar', glyph: 'calendar' },
|
|
143
|
+
{ value: 'profile', text: 'Profile', glyph: 'person' }
|
|
144
|
+
]}
|
|
145
|
+
/>
|
|
146
|
+
</div>
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## Programmatic use
|
|
152
|
+
|
|
153
|
+
`new BottomNavigation(props)` creates the bar without JSX. Each prop is also a property.
|
|
154
|
+
|
|
155
|
+
```tsx
|
|
156
|
+
import { Component } from '@motifx/core';
|
|
157
|
+
import { BottomNavigation, Button, Stack } from '@motifx-community/ui';
|
|
158
|
+
|
|
159
|
+
/** A bar created programmatically. Each prop is also a property that can be set later. */
|
|
160
|
+
export default class Programmatic extends Component<HTMLDivElement> {
|
|
161
|
+
constructor() {
|
|
162
|
+
super('div');
|
|
163
|
+
const bar = new BottomNavigation({
|
|
164
|
+
label: 'Search pages',
|
|
165
|
+
position: 'static',
|
|
166
|
+
value: 'home',
|
|
167
|
+
items: [
|
|
168
|
+
{ value: 'home', text: 'Home', glyph: 'star' },
|
|
169
|
+
{ value: 'search', text: 'Search', glyph: 'search' }
|
|
170
|
+
]
|
|
171
|
+
});
|
|
172
|
+
const go = new Button({ text: 'Go to Search', variant: 'outline', onclick: () => (bar.value = 'search') });
|
|
173
|
+
const stack = new Stack({ gap: 'md' });
|
|
174
|
+
stack.controls.add(bar, go);
|
|
175
|
+
this.controls.add(stack);
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
## API reference
|
|
181
|
+
|
|
182
|
+
### Props
|
|
183
|
+
|
|
184
|
+
| Prop | Type | Default | Description |
|
|
185
|
+
| --- | --- | --- | --- |
|
|
186
|
+
| `items` | `Bind<readonly BottomNavigationItem[]>` | `[]` | The destinations. The bar is designed for three to five; use a `Drawer` for more. |
|
|
187
|
+
| `value` | `Bind<string \| number \| null>` | `null` | The `value` of the selected item. `x-model` provides two-way binding. |
|
|
188
|
+
| `label` | `Bind<string>` | The kit string “Navigation” | The accessible name of the bar. |
|
|
189
|
+
| `labelMode` | `Bind<'always' \| 'active' \| 'never'>` | `'always'` | When items show their labels. A label out of view stays as the accessible name of the item. |
|
|
190
|
+
| `position` | `Bind<'fixed' \| 'sticky' \| 'static'>` | `'fixed'` | How the bar stays on the page. |
|
|
191
|
+
| `hideOnScroll` | `Bind<boolean>` | `false` | Moves the bar away while scrolling down, and brings it back while scrolling up. |
|
|
192
|
+
| `scrollTarget` | `Bind<HTMLElement \| null>` | The nearest ancestor that scrolls | What `hideOnScroll` watches. Without a scrolling ancestor, it is the page. |
|
|
193
|
+
|
|
194
|
+
### Item fields
|
|
195
|
+
|
|
196
|
+
| Prop | Type | Default | Description |
|
|
197
|
+
| --- | --- | --- | --- |
|
|
198
|
+
| `value` | `string \| number` | Its position | What `value` is when this item is selected. |
|
|
199
|
+
| `text` | `Bind<string>` | — | The label, which is also the accessible name. |
|
|
200
|
+
| `glyph, activeGlyph` | `Bind<string>` | `''` | The glyph, and the glyph while selected. |
|
|
201
|
+
| `icon, activeIcon` | `Bind<IconSource \| null>` | `null` | An image, an element or a component, used instead of a glyph. |
|
|
202
|
+
| `href, rel, target` | `Bind<string>` | `''` | Make the item a link. Use `rel: 'router'` for routed pages. |
|
|
203
|
+
| `badge` | `Bind<number \| null>` | `null` | A count in a badge on the icon. |
|
|
204
|
+
| `dot` | `Bind<boolean>` | `false` | A dot on the icon instead of a count. |
|
|
205
|
+
| `enabled, visible` | `Bind<boolean>` | `true` | A disabled item is dimmed and cannot be selected. A hidden item is removed. |
|
|
206
|
+
| `click` | `(e) => void` | — | Occurs when the item is pressed. |
|
|
207
|
+
| `data` | `unknown` | — | A custom application value for the item. |
|
|
208
|
+
|
|
209
|
+
### Properties and methods
|
|
210
|
+
|
|
211
|
+
| Member | Type | Description |
|
|
212
|
+
| --- | --- | --- |
|
|
213
|
+
| `selectedItem` | `BottomNavigationItem \| null` | The selected item. |
|
|
214
|
+
| `focus()` | `boolean` | Moves focus to the item Tab reaches. |
|
|
215
|
+
|
|
216
|
+
### Events
|
|
217
|
+
|
|
218
|
+
| Event | Type | Description |
|
|
219
|
+
| --- | --- | --- |
|
|
220
|
+
| `onSelecting` | `{ value, previous, item, previousItem, originalEvent, source, cancel }` | Occurs before the selection changes. Setting `cancel` keeps the current item, and a link is not followed. |
|
|
221
|
+
| `onSelectionChanged` | `{ value, previous, item, previousItem, originalEvent, source }` | Occurs after the selection changes. |
|
|
222
|
+
| `onItemClick` | `{ item, value, originalEvent, source }` | Occurs when an item is pressed, after its own `click`. |
|
|
223
|
+
|
|
224
|
+
### Keyboard
|
|
225
|
+
|
|
226
|
+
| Key | Description |
|
|
227
|
+
| --- | --- |
|
|
228
|
+
| `Tab` | Moves focus into the bar, to the selected item, and out of it. |
|
|
229
|
+
| `Left, Right` | Moves between the items, wrapping around at the ends. The direction follows the page. |
|
|
230
|
+
| `Home, End` | Moves to the first or the last item. |
|
|
231
|
+
| `Enter, Space` | Selects the focused item. |
|
|
232
|
+
|
|
233
|
+
### Accessibility
|
|
234
|
+
|
|
235
|
+
| Topic | Details |
|
|
236
|
+
| --- | --- |
|
|
237
|
+
| `Landmark` | The bar is a `<nav>` with an accessible name. |
|
|
238
|
+
| `Selected item` | `aria-current="page"` marks it for screen readers. |
|
|
239
|
+
| `Disabled item` | `aria-disabled="true"`; the arrow keys pass over it. |
|
|
240
|
+
| `Focus` | A bar moved away by `hideOnScroll` comes back when focus enters it. |
|
|
241
|
+
|
|
242
|
+
### Styling hooks
|
|
243
|
+
|
|
244
|
+
| Hook | Description |
|
|
245
|
+
| --- | --- |
|
|
246
|
+
| `.mx-bottom-navigation` | The bar. `data-label-mode`, `data-position` and `data-hidden` describe its state. |
|
|
247
|
+
| `.mx-bottom-navigation__list, .mx-bottom-navigation__item` | The row and an item. `data-selected` and `aria-disabled` describe an item. |
|
|
248
|
+
| `.mx-bottom-navigation__indicator, .mx-bottom-navigation__icon-host, .mx-bottom-navigation__glyph, .mx-bottom-navigation__icon, .mx-bottom-navigation__label, .mx-bottom-navigation__badge` | The mark of the selected item, the box of the icon, its glyph or icon, the label and the badge. |
|
|
249
|
+
|
|
250
|
+
### Design tokens
|
|
251
|
+
|
|
252
|
+
| Token | Description |
|
|
253
|
+
| --- | --- |
|
|
254
|
+
| `bottom-navigation.bar, .list, .item, .indicator, .icon-host, .label` | Units: the bar, the row, an item (`hover`, `pressed`, `focus`, `selected`, `disabled`), the mark (`selected`), the box of the icon and the label (`selected`). |
|
|
255
|
+
|
|
256
|
+
## Feedback
|
|
257
|
+
|
|
258
|
+
Loading issues…
|
package/docs/bottomsheet.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# BottomSheet
|
|
2
2
|
|
|
3
|
-
> Navigation · @motifx-community/ui 0.1.0-beta.
|
|
3
|
+
> Navigation · @motifx-community/ui 0.1.0-beta.6
|
|
4
4
|
|
|
5
5
|
A panel that slides up from the bottom of the page or a container and stops at set heights: peek, half, full, the height of its content, or custom values. Users can drag it by its handle and title, flick it, and swipe down to close it. It can be modal or non-modal, and the back button closes it on phones.
|
|
6
6
|
|
package/docs/breadcrumb.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Breadcrumb
|
|
2
2
|
|
|
3
|
-
> Navigation · @motifx-community/ui 0.1.0-beta.
|
|
3
|
+
> Navigation · @motifx-community/ui 0.1.0-beta.6
|
|
4
4
|
|
|
5
5
|
Shows the path to the current page. Each step is a link or button, and the current page comes last. Steps that do not fit move into a menu after the first step.
|
|
6
6
|
|
package/docs/button.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Button
|
|
2
2
|
|
|
3
|
-
> Buttons · @motifx-community/ui 0.1.0-beta.
|
|
3
|
+
> Buttons · @motifx-community/ui 0.1.0-beta.6
|
|
4
4
|
|
|
5
5
|
A native `<button>` styled with design tokens. It comes in three variants, three tones and three sizes, and supports an icon and an `&` access key. A button can act as a toggle, indicate that work is in progress, and open a menu or any other content, either from the whole button or from an arrow next to it with `split`, so the button keeps its own action.
|
|
6
6
|
|
package/docs/buttongroup.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# ButtonGroup
|
|
2
2
|
|
|
3
|
-
> Buttons · @motifx-community/ui 0.1.0-beta.
|
|
3
|
+
> Buttons · @motifx-community/ui 0.1.0-beta.6
|
|
4
4
|
|
|
5
5
|
A set of related buttons, used as a segmented selection of one or more options or as a row of actions. The buttons are standard kit buttons and are attached by default.
|
|
6
6
|
|
package/docs/buttons.md
ADDED
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
# Buttons
|
|
2
|
+
|
|
3
|
+
> Buttons · @motifx-community/ui 0.1.0-beta.6
|
|
4
|
+
|
|
5
|
+
Buttons start commands. The group covers single buttons, groups of them, toolbars that keep commands in reach at any width, application and context menus, and a floating button for the main action of a screen.
|
|
6
|
+
|
|
7
|
+
## Commands of an editor
|
|
8
|
+
|
|
9
|
+
A menu bar, a toolbar with toggles and a menu, a segmented choice for the view, a split button for saving, a context menu on the text and a speed dial for new items, all working on one document. Alt with an underlined letter runs a command.
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
import { reactive, type Component } from '@motifx/core';
|
|
13
|
+
import { Button, ButtonGroup, MenuBar, SpeedDial, Toolbar, attachContextMenu, type MenuItem, type ToolbarItem } from '@motifx-community/ui';
|
|
14
|
+
|
|
15
|
+
const icon = (name: string) => () => <span class="mx-glyph" data-icon={name} />;
|
|
16
|
+
|
|
17
|
+
/** The commands of a small editor: a menu bar, a toolbar, a segmented choice, a split button, a context menu and a speed dial. */
|
|
18
|
+
export default function ButtonsDemo() {
|
|
19
|
+
const s = reactive({ bold: false, italic: false, view: 'edit' as unknown, saved: 0, log: 'Ready.' });
|
|
20
|
+
const did = (what: string) => (s.log = what);
|
|
21
|
+
const save = () => {
|
|
22
|
+
s.saved++;
|
|
23
|
+
did(`Saved, version ${s.saved}.`);
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const menus: MenuItem[] = [
|
|
27
|
+
{
|
|
28
|
+
text: '&File',
|
|
29
|
+
items: [
|
|
30
|
+
{ text: '&New', shortcut: 'Ctrl+N', click: () => did('A new document.') },
|
|
31
|
+
{ text: '&Save', shortcut: 'Ctrl+S', click: save },
|
|
32
|
+
{ text: 'Export as &PDF', beginGroup: true, click: () => did('Exported as PDF.') }
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
text: '&Edit',
|
|
37
|
+
items: [
|
|
38
|
+
{ text: '&Undo', shortcut: 'Ctrl+Z', click: () => did('Undone.') },
|
|
39
|
+
{ text: '&Redo', shortcut: 'Ctrl+Y', click: () => did('Done again.') }
|
|
40
|
+
]
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
text: '&View',
|
|
44
|
+
items: [
|
|
45
|
+
{ text: '&Edit', group: 'view', checked: () => s.view === 'edit', click: () => (s.view = 'edit') },
|
|
46
|
+
{ text: '&Preview', group: 'view', checked: () => s.view === 'preview', click: () => (s.view = 'preview') }
|
|
47
|
+
]
|
|
48
|
+
}
|
|
49
|
+
];
|
|
50
|
+
|
|
51
|
+
const tools: ToolbarItem[] = [
|
|
52
|
+
{ icon: icon('undo'), hint: 'Undo', click: () => did('Undone.') },
|
|
53
|
+
{ icon: icon('search'), hint: 'Find', click: () => did('Find.') },
|
|
54
|
+
{ type: 'separator' },
|
|
55
|
+
{ type: 'toggle', text: 'Bold', pressed: () => s.bold, click: () => (s.bold = !s.bold) },
|
|
56
|
+
{ type: 'toggle', text: 'Italic', pressed: () => s.italic, click: () => (s.italic = !s.italic) },
|
|
57
|
+
{ type: 'separator' },
|
|
58
|
+
{
|
|
59
|
+
type: 'menu',
|
|
60
|
+
text: 'Insert',
|
|
61
|
+
menu: [
|
|
62
|
+
{ text: '&Table', click: () => did('A table inserted.') },
|
|
63
|
+
{ text: '&Chart', click: () => did('A chart inserted.') },
|
|
64
|
+
{ text: '&Picture', click: () => did('A picture inserted.') }
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
];
|
|
68
|
+
|
|
69
|
+
const attach = (page: Component<HTMLDivElement>) =>
|
|
70
|
+
page.motif.setDisposable(
|
|
71
|
+
attachContextMenu(page, () => [
|
|
72
|
+
{ text: 'Cu&t', shortcut: 'Ctrl+X', click: () => did('Cut.') },
|
|
73
|
+
{ text: '&Copy', shortcut: 'Ctrl+C', click: () => did('Copied.') },
|
|
74
|
+
{ text: '&Paste', shortcut: 'Ctrl+V', click: () => did('Pasted.') },
|
|
75
|
+
{ text: '&Bold', beginGroup: true, checked: () => s.bold, click: () => (s.bold = !s.bold) }
|
|
76
|
+
])
|
|
77
|
+
);
|
|
78
|
+
|
|
79
|
+
return (
|
|
80
|
+
<div class="ov-frame ov-buttons">
|
|
81
|
+
<MenuBar label="Editor" items={menus} />
|
|
82
|
+
<div class="ov-bar">
|
|
83
|
+
<Toolbar label="Format" items={tools} style="flex: 1 1 18rem" />
|
|
84
|
+
<ButtonGroup label="View" items={[{ value: 'edit', text: 'Edit' }, { value: 'preview', text: 'Preview' }]} x-model={() => s.view} size="sm" />
|
|
85
|
+
<Button
|
|
86
|
+
text="Sa&ve"
|
|
87
|
+
tone="accent"
|
|
88
|
+
split
|
|
89
|
+
onclick={save}
|
|
90
|
+
menu={[
|
|
91
|
+
{ text: 'Save &as…', click: () => did('Save as…') },
|
|
92
|
+
{ text: 'Save a ©', click: () => did('A copy saved.') }
|
|
93
|
+
]}
|
|
94
|
+
/>
|
|
95
|
+
</div>
|
|
96
|
+
<div
|
|
97
|
+
class="ov-page"
|
|
98
|
+
tabindex="0"
|
|
99
|
+
onBuilt={attach}
|
|
100
|
+
style={() => `font-weight: ${s.bold ? 600 : 400}; font-style: ${s.italic ? 'italic' : 'normal'}`}
|
|
101
|
+
>
|
|
102
|
+
{() =>
|
|
103
|
+
s.view === 'edit'
|
|
104
|
+
? 'Quarterly report. Right-click here, or focus this text and press the Menu key, for the context menu. Bold and Italic in the toolbar change this text.'
|
|
105
|
+
: 'Preview of the quarterly report: the page as it will print.'
|
|
106
|
+
}
|
|
107
|
+
</div>
|
|
108
|
+
<div class="ov-status">
|
|
109
|
+
<output class="ov-buttons-log">{() => s.log}</output>
|
|
110
|
+
<SpeedDial
|
|
111
|
+
position="inline"
|
|
112
|
+
direction="start"
|
|
113
|
+
text="New"
|
|
114
|
+
actions={[
|
|
115
|
+
{ text: 'New page', glyph: 'file', click: () => did('A new page.') },
|
|
116
|
+
{ text: 'New comment', glyph: 'pencil', click: () => did('A new comment.') },
|
|
117
|
+
{ text: 'Upload', glyph: 'upload', click: () => did('Upload.') }
|
|
118
|
+
]}
|
|
119
|
+
/>
|
|
120
|
+
</div>
|
|
121
|
+
</div>
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
## Components in this group
|
|
127
|
+
|
|
128
|
+
Each component has its own page with its examples and its full API.
|
|
129
|
+
|
|
130
|
+
| Component | For |
|
|
131
|
+
| --- | --- |
|
|
132
|
+
| `[Button](button.md)` | One command, with an icon, a menu or a split part; a toggle; a busy state while the command runs. |
|
|
133
|
+
| `[ButtonGroup](buttongroup.md)` | A few related buttons side by side: one or several pressed, or plain actions. |
|
|
134
|
+
| `[Toolbar](toolbar.md)` | A row of commands that moves what does not fit into a menu. |
|
|
135
|
+
| `[SpeedDial](speeddial.md)` | A floating button for the main action, opening related actions in a line or a circle. |
|
|
136
|
+
| `[MenuBar and ContextMenu](menus.md)` | The menus of an application and the menu of an element, with shortcuts, check items and access keys. |
|
|
137
|
+
|
|
138
|
+
## Choosing a component
|
|
139
|
+
|
|
140
|
+
Several components can do the same job; this table points to the one that reads best for it.
|
|
141
|
+
|
|
142
|
+
| To | Use |
|
|
143
|
+
| --- | --- |
|
|
144
|
+
| `Run one command` | [Button](button.md) |
|
|
145
|
+
| `Show a choice of a few options at once` | [ButtonGroup](buttongroup.md), or [RadioGroup](radiogroup.md) in a form |
|
|
146
|
+
| `Keep many commands in one bar at any width` | [Toolbar](toolbar.md) |
|
|
147
|
+
| `Offer the commands of a whole application` | [MenuBar](menus.md) |
|
|
148
|
+
| `Act on what is under the pointer` | [ContextMenu](menus.md) |
|
|
149
|
+
| `Give a screen one main action, on a phone too` | [SpeedDial](speeddial.md) |
|
|
150
|
+
|
|
151
|
+
## What they share
|
|
152
|
+
|
|
153
|
+
A command's text takes an access key: an `&` before a letter underlines it, and Alt with that letter runs the command. Menus open from the keyboard, move with the arrow keys and close with Escape.
|
|
154
|
+
|
|
155
|
+
Icons come from any element or image address. A button with only an icon is named by its `hint`, which also shows as its tooltip.
|
|
156
|
+
|
|
157
|
+
`variant`, `tone` and `size` set the look in every component of the group, and the design language draws the rest.
|
|
158
|
+
|
|
159
|
+
## Accessibility
|
|
160
|
+
|
|
161
|
+
| Topic | Details |
|
|
162
|
+
| --- | --- |
|
|
163
|
+
| `Roles` | Buttons, toggle buttons with their pressed state, menus and menu bars, toolbars with one Tab stop. |
|
|
164
|
+
| `Keyboard` | Enter and Space press a button; the arrow keys move inside a toolbar, a group and a menu; Escape closes a menu. |
|
|
165
|
+
| `Focus` | A disabled command can stay focusable, so readers still find it and learn why it is off. |
|
|
166
|
+
|
|
167
|
+
## Feedback
|
|
168
|
+
|
|
169
|
+
Loading issues…
|
package/docs/calendar.md
CHANGED
package/docs/card.md
CHANGED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
# Chart: Bars
|
|
2
|
+
|
|
3
|
+
> Charts · @motifx-community/ui 0.1.0-beta.6
|
|
4
|
+
|
|
5
|
+
Bars compare amounts. They stand on a common baseline, so lengths compare exactly, side by side, stacked, or on their side for long names.
|
|
6
|
+
|
|
7
|
+
## Grouped and stacked bars
|
|
8
|
+
|
|
9
|
+
Bars are grouped side by side by default. `stacked` places them on top of each other, as values or as percentages. Use `stack` on a series to assign it to a named stack.
|
|
10
|
+
|
|
11
|
+
```tsx
|
|
12
|
+
/** Twelve months of made-up figures, shared by the examples. */
|
|
13
|
+
export const SALES = [
|
|
14
|
+
{ month: 'Jan', online: 4200, stores: 6100, returns: 310 },
|
|
15
|
+
{ month: 'Feb', online: 4600, stores: 5800, returns: 280 },
|
|
16
|
+
{ month: 'Mar', online: 5900, stores: 6400, returns: 420 },
|
|
17
|
+
{ month: 'Apr', online: 6300, stores: 6000, returns: 390 },
|
|
18
|
+
{ month: 'May', online: 7100, stores: 6600, returns: 450 },
|
|
19
|
+
{ month: 'Jun', online: 7600, stores: 7000, returns: 520 },
|
|
20
|
+
{ month: 'Jul', online: 8200, stores: 6800, returns: 610 },
|
|
21
|
+
{ month: 'Aug', online: 8000, stores: 6500, returns: 580 },
|
|
22
|
+
{ month: 'Sep', online: 8900, stores: 7200, returns: 640 },
|
|
23
|
+
{ month: 'Oct', online: 9400, stores: 7600, returns: 700 },
|
|
24
|
+
{ month: 'Nov', online: 11200, stores: 8800, returns: 930 },
|
|
25
|
+
{ month: 'Dec', online: 12800, stores: 10100, returns: 1100 }
|
|
26
|
+
];
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
## Horizontal charts
|
|
30
|
+
|
|
31
|
+
`horizontal` suits long category names and rankings. Rows keep the order in which they are provided.
|
|
32
|
+
|
|
33
|
+
```tsx
|
|
34
|
+
import { Chart } from '@motifx-community/ui';
|
|
35
|
+
|
|
36
|
+
const TEAMS = [
|
|
37
|
+
{ team: 'Customer support', tickets: 412 },
|
|
38
|
+
{ team: 'Platform engineering', tickets: 318 },
|
|
39
|
+
{ team: 'Finance and accounting operations', tickets: 205 },
|
|
40
|
+
{ team: 'Sales', tickets: 164 },
|
|
41
|
+
{ team: 'Design', tickets: 96 }
|
|
42
|
+
];
|
|
43
|
+
|
|
44
|
+
/** On its side, for long names and a ranking. The labels carry the values. */
|
|
45
|
+
export default function Horizontal() {
|
|
46
|
+
return <Chart class="ch-horizontal" horizontal title="Open tickets" data={TEAMS} xField="team" yAxis={{ grid: false, labels: false }} series={[{ type: 'bar', yField: 'tickets', name: 'Tickets', labels: 'all' }]} />;
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
## Negative values
|
|
51
|
+
|
|
52
|
+
Bars extend in both directions from zero. A label that does not fit or that would cover another label is omitted, and its value remains available in the tooltip and the table view.
|
|
53
|
+
|
|
54
|
+
```tsx
|
|
55
|
+
import { Chart } from '@motifx-community/ui';
|
|
56
|
+
|
|
57
|
+
const QUARTERS = [
|
|
58
|
+
{ quarter: 'Q1 2025', profit: 120 },
|
|
59
|
+
{ quarter: 'Q2 2025', profit: -45 },
|
|
60
|
+
{ quarter: 'Q3 2025', profit: 80 },
|
|
61
|
+
{ quarter: 'Q4 2025', profit: -110 },
|
|
62
|
+
{ quarter: 'Q1 2026', profit: 160 }
|
|
63
|
+
];
|
|
64
|
+
|
|
65
|
+
/** Bars grow both ways from zero, each rounded at its far end. */
|
|
66
|
+
export default function Negative() {
|
|
67
|
+
return <Chart class="ch-negative" title="Quarterly result" data={QUARTERS} xField="quarter" series={[{ type: 'bar', yField: 'profit', name: 'Result', labels: 'all' }]} />;
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## API reference
|
|
72
|
+
|
|
73
|
+
| Field | Type | Default | Description |
|
|
74
|
+
| --- | --- | --- | --- |
|
|
75
|
+
| `stack` | `string \| boolean` | The chart's `stacked` | Series with the same name stack on each other. |
|
|
76
|
+
| `labels` | `'none' \| 'last' \| 'extremes' \| 'all'` | `'none'` | The values that show a label. A label that does not fit is omitted. |
|
|
77
|
+
|
|
78
|
+
Every other prop, member and event is on the [Overview](chart.md#api).
|
|
79
|
+
|
|
80
|
+
## Feedback
|
|
81
|
+
|
|
82
|
+
Loading issues…
|
|
83
|
+
|
|
84
|
+
## Example files
|
|
85
|
+
|
|
86
|
+
`Stacked.tsx`
|
|
87
|
+
|
|
88
|
+
```tsx
|
|
89
|
+
import { reactive } from '@motifx/core';
|
|
90
|
+
import { ButtonGroup, Chart, Stack, type ChartStacked } from '@motifx-community/ui';
|
|
91
|
+
import { SALES } from './sales';
|
|
92
|
+
|
|
93
|
+
/** The same bars side by side, stacked, and as shares of a hundred. */
|
|
94
|
+
export default function Stacked() {
|
|
95
|
+
const s = reactive({ mode: 'none' });
|
|
96
|
+
const stacked = (): ChartStacked => (s.mode === 'none' ? false : (s.mode as ChartStacked));
|
|
97
|
+
return (
|
|
98
|
+
<Stack class="docs-wide" gap="md">
|
|
99
|
+
<ButtonGroup
|
|
100
|
+
label="Stacking"
|
|
101
|
+
x-model={() => s.mode}
|
|
102
|
+
items={[
|
|
103
|
+
{ value: 'none', text: 'Side by side' },
|
|
104
|
+
{ value: 'normal', text: 'Stacked' },
|
|
105
|
+
{ value: 'percent', text: 'Percent' }
|
|
106
|
+
]}
|
|
107
|
+
/>
|
|
108
|
+
<Chart
|
|
109
|
+
class="ch-stacked"
|
|
110
|
+
data={SALES.slice(0, 6)}
|
|
111
|
+
xField="month"
|
|
112
|
+
label="Sales by channel"
|
|
113
|
+
stacked={stacked}
|
|
114
|
+
series={[
|
|
115
|
+
{ type: 'bar', yField: 'online', name: 'Online' },
|
|
116
|
+
{ type: 'bar', yField: 'stores', name: 'Stores' }
|
|
117
|
+
]}
|
|
118
|
+
/>
|
|
119
|
+
</Stack>
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
`sales.ts`
|
|
125
|
+
|
|
126
|
+
```tsx
|
|
127
|
+
/** Twelve months of made-up figures, shared by the examples. */
|
|
128
|
+
export const SALES = [
|
|
129
|
+
{ month: 'Jan', online: 4200, stores: 6100, returns: 310 },
|
|
130
|
+
{ month: 'Feb', online: 4600, stores: 5800, returns: 280 },
|
|
131
|
+
{ month: 'Mar', online: 5900, stores: 6400, returns: 420 },
|
|
132
|
+
{ month: 'Apr', online: 6300, stores: 6000, returns: 390 },
|
|
133
|
+
{ month: 'May', online: 7100, stores: 6600, returns: 450 },
|
|
134
|
+
{ month: 'Jun', online: 7600, stores: 7000, returns: 520 },
|
|
135
|
+
{ month: 'Jul', online: 8200, stores: 6800, returns: 610 },
|
|
136
|
+
{ month: 'Aug', online: 8000, stores: 6500, returns: 580 },
|
|
137
|
+
{ month: 'Sep', online: 8900, stores: 7200, returns: 640 },
|
|
138
|
+
{ month: 'Oct', online: 9400, stores: 7600, returns: 700 },
|
|
139
|
+
{ month: 'Nov', online: 11200, stores: 8800, returns: 930 },
|
|
140
|
+
{ month: 'Dec', online: 12800, stores: 10100, returns: 1100 }
|
|
141
|
+
];
|
|
142
|
+
```
|