@ternarytech-io/gears-ui 0.3.4 → 0.5.0
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 +6 -5
- package/package.json +17 -9
- package/src/components/TChart.vue +225 -188
- package/src/components/TLightbox.vue +101 -0
- package/src/components/TPdfViewer.vue +252 -0
- package/src/components/TSeparator.vue +37 -5
- package/src/components/TStatCard.vue +69 -56
- package/src/index.ts +5 -1
- package/src/plugins/charts.ts +18 -4
- package/src/plugins/index.ts +5 -1
- package/src/plugins/pdf.ts +12 -0
- package/src/styles/gears.css +5 -0
package/README.md
CHANGED
|
@@ -101,14 +101,14 @@ add a page, add an entry to `preview/registry.ts` and a folder of examples.
|
|
|
101
101
|
|
|
102
102
|
| Group | Components |
|
|
103
103
|
| --- | --- |
|
|
104
|
-
| Elements | `TButton`, `TBadge`, `TAvatar`, `TAlert`, `TCard`, `TIcon`, `TTooltip`, `TEmpty`, `TSpinner`, `TSkeleton`, `TProgress`, `TSeparator` |
|
|
104
|
+
| Elements | `TButton`, `TBadge`, `TAvatar`, `TAlert`, `TCard`, `TIcon`, `TTooltip`, `TEmpty`, `TSpinner`, `TSkeleton`, `TProgress`, `TSeparator` (a label at the start, center or end; color, style, thickness) |
|
|
105
105
|
| Forms | `TFormField`, `TInput`, `TInputNumber`, `TTextarea`, `TSelect`, `TSelectMenu`, `TInputTags`, `TCheckbox`, `TSwitch`, `TRadioGroup` (list, cards or tiles with a picture), `TFieldGroup`, `TFileUpload`, `TImageUpload` (one image, checked for shape and size), `TIconPicker` (any Tabler icon, by name, with a search; the list is generated by `npm run icons`), `TRating` (stars, hearts or circles; no library), `TListBox` (always shown; one or several; a search), `TCheckboxTree` (parents check their children; partly checked; folding), `TCodeEditor` |
|
|
106
106
|
| Theme | `TAccentPicker`, `TFontPicker`, `TRadiusPicker`, `TThemeBasePicker` (Tabler's theme settings as pickers), `TNavPositionPicker`, `TDensityPicker`, `TContainerPicker` (layout), `TThemeScope` (applies a `ThemeSettings`' look and density to what's inside it); `themeAccents`, `themeFonts`, `themeBases`, `themeRadii`, `themeNavs`, `themeDensities`, `themeContainers` |
|
|
107
|
-
| Overlays | `TModal`, `TSlideover`, `TDropdown`, `TToaster` (with `useToast()`) |
|
|
107
|
+
| Overlays | `TModal`, `TSlideover`, `TDropdown`, `TToaster` (with `useToast()`), `TLightbox` (images shown large: previous and next, arrow keys, swipes, captions) |
|
|
108
108
|
| Navigation | `TTabs`, `TPagination`, `TSteps`, `TNav`, `TPanelList`, `TCommandPalette`, `TSearchButton` |
|
|
109
|
-
| Data | `TTable` (sorting, `selectable` rows), `TAdvancedTable` (filters by column), `TEditableTable` (editing in place, bulk actions, search, pages, column kinds; client-side or `manual`), `TDataGrid` and `TDataGridItem` (Tabler's datagrid: labels and values for detail panels), `TStatCard` (with a trend and a sparkline), `TSparkline` (Tabler's, no library), `TLogView` |
|
|
109
|
+
| Data | `TTable` (sorting, `selectable` rows), `TAdvancedTable` (filters by column), `TEditableTable` (editing in place, bulk actions, search, pages, column kinds; client-side or `manual`), `TDataGrid` and `TDataGridItem` (Tabler's datagrid: labels and values for detail panels), `TStatCard` (with a trend and a sparkline; `loading`, `clickable`), `TSparkline` (Tabler's, no library), `TLogView` |
|
|
110
110
|
| Layout | `TAppLayout` (an application's frame, laid out by its theme, with a menu button on small screens), `TScaledFrame` (a whole screen scaled to fit), `TShell`, `TTopbar`, `TPage`, `TSectionLayout`, `TSplitter`, `TAuthLayout`, `TColorModeButton` |
|
|
111
|
-
| Plugins | `TAdvancedSelect`, `TChart`, `TCopyButton`, `TColorPicker`, `TDatePicker`, `TDropzone`, `TInputMask`, `TRangeSlider`, `TSortable`, `TSortableTree`, `TVectorMap`, `TRichEditor` |
|
|
111
|
+
| Plugins | `TAdvancedSelect`, `TChart`, `TPdfViewer`, `TCopyButton`, `TColorPicker`, `TDatePicker`, `TDropzone`, `TInputMask`, `TRangeSlider`, `TSortable`, `TSortableTree`, `TVectorMap`, `TRichEditor` |
|
|
112
112
|
|
|
113
113
|
### Plugins
|
|
114
114
|
|
|
@@ -120,7 +120,8 @@ Tabler's restyling of them (`tabler-vendors.css`), which must come after.
|
|
|
120
120
|
| Component | Library | Notes |
|
|
121
121
|
| --- | --- | --- |
|
|
122
122
|
| `TAdvancedSelect` | Tom Select | One or several (`multiple`, as chips); `create` adds new values; icons and avatars beside labels. Overlaps `TSelectMenu`, which has no dependency. |
|
|
123
|
-
| `TChart` |
|
|
123
|
+
| `TChart` | Apache ECharts (Apache-2.0) | `line`, `area`, `bar` (across), `column`, `pie`, `donut`; `series` along `categories`, `stacked`, `format`, `point-click`. Colors follow the theme (and a `TThemeScope`), light or dark; `options` (ECharts options) is merged over everything for anything else. SVG by default, `renderer="canvas"` for very many points; it follows its box's size. Only the charts it uses are bundled. Before 0.4.0 it was ApexCharts, whose license no longer suits apps others use. |
|
|
124
|
+
| `TPdfViewer` | PDF.js (Mozilla, Apache-2.0) | A PDF's pages, drawn as they scroll into view; `zoom` (fit width, fit page, a percent), `v-model:page`, a toolbar with download and open in a new tab; `setPage`, `download`. Its worker is loaded with Vite's `?url`. |
|
|
124
125
|
| `TCopyButton` | Tabler's clipboard | Copies `text`, or the field `target` selects. Needs https or localhost. |
|
|
125
126
|
| `TColorPicker` | Coloris | `format`, `alpha`, `swatches`, `swatchesOnly`. The field isn't wrapped by Coloris (Vue owns it); the swatch is ours. |
|
|
126
127
|
| `TDatePicker` | Tabler's date picker, on Vanilla Calendar Pro | `single`, `multiple` or `range`; `inline`; the model is `YYYY-MM-DD`, `format` only changes the display. |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ternarytech-io/gears-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Gears UI: Vue 3 components on Tabler, used by the Gears Studio and the applications it builds.",
|
|
6
6
|
"license": "MPL-2.0",
|
|
@@ -46,18 +46,19 @@
|
|
|
46
46
|
"preview": "vite preview"
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
|
-
"monaco-editor": "^0.57.0",
|
|
50
|
-
"vue": "^3.5.0",
|
|
51
|
-
"vue-router": "^4.6.0",
|
|
52
|
-
"tom-select": "^2.6.0",
|
|
53
49
|
"@melloware/coloris": "^0.25.0",
|
|
54
|
-
"vanilla-calendar-pro": "^3.3.2",
|
|
55
50
|
"dropzone": "^6.3.0",
|
|
51
|
+
"echarts": "^6.1.0",
|
|
52
|
+
"hugerte": "^1.0.0",
|
|
56
53
|
"imask": "^7.6.0",
|
|
54
|
+
"monaco-editor": "^0.57.0",
|
|
57
55
|
"nouislider": "^15.8.0",
|
|
56
|
+
"pdfjs-dist": "^6.4.0",
|
|
58
57
|
"sortablejs": "^1.15.0",
|
|
59
|
-
"
|
|
60
|
-
"
|
|
58
|
+
"tom-select": "^2.6.0",
|
|
59
|
+
"vanilla-calendar-pro": "^3.3.2",
|
|
60
|
+
"vue": "^3.5.0",
|
|
61
|
+
"vue-router": "^4.6.0"
|
|
61
62
|
},
|
|
62
63
|
"dependencies": {
|
|
63
64
|
"@tabler/core": "1.7.1",
|
|
@@ -67,12 +68,13 @@
|
|
|
67
68
|
"@melloware/coloris": "0.25.0",
|
|
68
69
|
"@types/sortablejs": "1.15.9",
|
|
69
70
|
"@vitejs/plugin-vue": "6.0.10",
|
|
70
|
-
"apexcharts": "7.0.0",
|
|
71
71
|
"dropzone": "6.3.5",
|
|
72
|
+
"echarts": "6.1.0",
|
|
72
73
|
"hugerte": "1.0.14",
|
|
73
74
|
"imask": "7.6.1",
|
|
74
75
|
"monaco-editor": "0.57.0",
|
|
75
76
|
"nouislider": "15.8.1",
|
|
77
|
+
"pdfjs-dist": "6.4.299",
|
|
76
78
|
"sortablejs": "1.15.7",
|
|
77
79
|
"tom-select": "2.6.2",
|
|
78
80
|
"typescript": "5.9.3",
|
|
@@ -98,12 +100,18 @@
|
|
|
98
100
|
"dropzone": {
|
|
99
101
|
"optional": true
|
|
100
102
|
},
|
|
103
|
+
"echarts": {
|
|
104
|
+
"optional": true
|
|
105
|
+
},
|
|
101
106
|
"imask": {
|
|
102
107
|
"optional": true
|
|
103
108
|
},
|
|
104
109
|
"nouislider": {
|
|
105
110
|
"optional": true
|
|
106
111
|
},
|
|
112
|
+
"pdfjs-dist": {
|
|
113
|
+
"optional": true
|
|
114
|
+
},
|
|
107
115
|
"sortablejs": {
|
|
108
116
|
"optional": true
|
|
109
117
|
},
|
|
@@ -1,188 +1,225 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
// A chart,
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
// merged over everything for whatever else
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import
|
|
11
|
-
import {
|
|
12
|
-
import type {
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
probe.
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
const
|
|
88
|
-
const
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
},
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
if (!
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
// A chart, drawn by Apache ECharts: a line, area, bar (across), column (up), pie or donut.
|
|
3
|
+
// `series` are named lists of numbers along `categories` (a pie or donut uses the first series,
|
|
4
|
+
// one slice per category). Colors come from the theme (the accent first), or `colors` (named
|
|
5
|
+
// colors such as 'success', or any CSS color); they follow light and dark mode and a TThemeScope
|
|
6
|
+
// around the chart. `format` writes values on the axis and in tooltips; `options` (ECharts
|
|
7
|
+
// options) is merged over everything for whatever else ECharts does, arrays (such as `series`)
|
|
8
|
+
// replaced. ECharts loads on first use; the chart is SVG unless `renderer` is 'canvas' (better
|
|
9
|
+
// for many thousands of points), and follows its box's size.
|
|
10
|
+
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue'
|
|
11
|
+
import type { EChartsOption } from 'echarts'
|
|
12
|
+
import type { EChartsType } from 'echarts/core'
|
|
13
|
+
import { loadECharts } from '../plugins/charts'
|
|
14
|
+
import type { ChartSeries, ChartType, Color } from '../types'
|
|
15
|
+
import { toTabler } from '../types'
|
|
16
|
+
|
|
17
|
+
const props = withDefaults(defineProps<{
|
|
18
|
+
type?: ChartType
|
|
19
|
+
series: ChartSeries[]
|
|
20
|
+
categories?: (string | number)[]
|
|
21
|
+
height?: number | string
|
|
22
|
+
stacked?: boolean
|
|
23
|
+
// Shown by default with more than one series, and for pies and donuts.
|
|
24
|
+
legend?: boolean
|
|
25
|
+
colors?: (Color | string)[]
|
|
26
|
+
format?: (value: number) => string
|
|
27
|
+
// No axes, grid or legend: a small chart inside a card or a stat.
|
|
28
|
+
sparkline?: boolean
|
|
29
|
+
label?: string
|
|
30
|
+
options?: EChartsOption
|
|
31
|
+
renderer?: 'svg' | 'canvas'
|
|
32
|
+
// Vue makes a missing boolean false; undefined keeps the legend's default.
|
|
33
|
+
}>(), { type: 'line', categories: () => [], height: 240, label: 'Chart', legend: undefined, renderer: 'svg' })
|
|
34
|
+
|
|
35
|
+
const emit = defineEmits<{ 'point-click': [point: { series: number; index: number; category: string | number | undefined }] }>()
|
|
36
|
+
|
|
37
|
+
const el = ref<HTMLElement>()
|
|
38
|
+
let chart: EChartsType | null = null
|
|
39
|
+
|
|
40
|
+
// Tabler's chart colors after the accent: its named colors, in an order that keeps neighbors apart.
|
|
41
|
+
const palette = ['primary', 'green', 'orange', 'purple', 'cyan', 'pink', 'yellow', 'red', 'teal', 'indigo']
|
|
42
|
+
const named = new Set(['primary', 'neutral', 'success', 'warning', 'error', 'info'])
|
|
43
|
+
|
|
44
|
+
const round = computed(() => props.type === 'pie' || props.type === 'donut')
|
|
45
|
+
const bars = computed(() => props.type === 'bar' || props.type === 'column')
|
|
46
|
+
const cssHeight = computed(() => (typeof props.height === 'number' ? `${props.height}px` : props.height))
|
|
47
|
+
|
|
48
|
+
/** A CSS color as the browser resolves it here, inside any theme scope: `var(--tblr-primary)` → rgb(…). */
|
|
49
|
+
function resolve(color: string): string {
|
|
50
|
+
if (!el.value) return color
|
|
51
|
+
const probe = document.createElement('span')
|
|
52
|
+
probe.style.display = 'none'
|
|
53
|
+
probe.style.color = color
|
|
54
|
+
el.value.appendChild(probe)
|
|
55
|
+
const value = getComputedStyle(probe).color
|
|
56
|
+
probe.remove()
|
|
57
|
+
return value ? rgb(value) : color
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// ECharts reads hex, rgb() and hsl() colors (to lighten one on hover), and Tabler's theme colors
|
|
61
|
+
// can come back as oklch(…); painting one pixel gives any color as rgb().
|
|
62
|
+
let pixel: CanvasRenderingContext2D | null = null
|
|
63
|
+
function rgb(color: string): string {
|
|
64
|
+
if (/^(rgb|#)/i.test(color)) return color
|
|
65
|
+
pixel ??= document.createElement('canvas').getContext('2d', { willReadFrequently: true })
|
|
66
|
+
if (!pixel) return color
|
|
67
|
+
pixel.clearRect(0, 0, 1, 1)
|
|
68
|
+
pixel.fillStyle = color
|
|
69
|
+
pixel.fillRect(0, 0, 1, 1)
|
|
70
|
+
const [r, g, b, a] = pixel.getImageData(0, 0, 1, 1).data
|
|
71
|
+
return a === 255 ? `rgb(${r}, ${g}, ${b})` : `rgba(${r}, ${g}, ${b}, ${Math.round(a / 255 * 100) / 100})`
|
|
72
|
+
}
|
|
73
|
+
const cssColor = (color: string) => named.has(color) ? `var(--tblr-${toTabler(color as Color)})`
|
|
74
|
+
: /^[a-z]+$/.test(color) && palette.includes(color) ? `var(--tblr-${color})` : color
|
|
75
|
+
|
|
76
|
+
function option(): EChartsOption {
|
|
77
|
+
const count = round.value ? props.categories.length : props.series.length
|
|
78
|
+
const colors = Array.from({ length: Math.max(count, 1) }, (_, i) =>
|
|
79
|
+
resolve(cssColor((round.value ? undefined : props.series[i]?.color) ?? props.colors?.[i] ?? palette[i % palette.length]!)))
|
|
80
|
+
const text = resolve('var(--tblr-secondary)')
|
|
81
|
+
const body = resolve('var(--tblr-body-color)')
|
|
82
|
+
const border = resolve('var(--tblr-border-color)')
|
|
83
|
+
const surface = resolve('var(--tblr-bg-surface)')
|
|
84
|
+
const font = el.value ? getComputedStyle(el.value).fontFamily : 'inherit'
|
|
85
|
+
const format = props.format
|
|
86
|
+
const formatter = format ? (value: unknown) => (value == null || value === '' ? '' : format(Number(value))) : undefined
|
|
87
|
+
const spark = props.sparkline ?? false
|
|
88
|
+
const legend = !spark && (props.legend ?? (round.value || props.series.length > 1))
|
|
89
|
+
|
|
90
|
+
const valueAxis = {
|
|
91
|
+
type: 'value' as const,
|
|
92
|
+
show: !spark,
|
|
93
|
+
axisLabel: { color: text, formatter: formatter as never, hideOverlap: true },
|
|
94
|
+
splitLine: { lineStyle: { color: border, type: 'dashed' as const } },
|
|
95
|
+
axisLine: { show: false },
|
|
96
|
+
axisTick: { show: false }
|
|
97
|
+
}
|
|
98
|
+
const categoryAxis = {
|
|
99
|
+
type: 'category' as const,
|
|
100
|
+
show: !spark,
|
|
101
|
+
data: props.categories.map(String),
|
|
102
|
+
boundaryGap: bars.value,
|
|
103
|
+
// Bars across list their first category on top, as a table would.
|
|
104
|
+
inverse: props.type === 'bar',
|
|
105
|
+
axisLabel: { color: text, hideOverlap: true },
|
|
106
|
+
axisLine: { lineStyle: { color: border } },
|
|
107
|
+
axisTick: { show: false }
|
|
108
|
+
}
|
|
109
|
+
const series = round.value
|
|
110
|
+
? [{
|
|
111
|
+
type: 'pie' as const,
|
|
112
|
+
name: props.series[0]?.name,
|
|
113
|
+
radius: props.type === 'donut' ? ['55%', '78%'] : [0, '78%'],
|
|
114
|
+
center: ['50%', legend ? '44%' : '50%'],
|
|
115
|
+
data: props.categories.map((c, i) => ({ name: String(c), value: props.series[0]?.data[i] ?? 0 })),
|
|
116
|
+
label: { show: false },
|
|
117
|
+
itemStyle: { borderColor: surface, borderWidth: 2 },
|
|
118
|
+
emphasis: { scaleSize: 4 }
|
|
119
|
+
}]
|
|
120
|
+
: props.series.map(s => bars.value
|
|
121
|
+
? {
|
|
122
|
+
type: 'bar' as const, name: s.name, data: s.data, stack: props.stacked ? 'total' : undefined,
|
|
123
|
+
barMaxWidth: 32, itemStyle: { borderRadius: props.type === 'bar' ? [0, 2, 2, 0] : [2, 2, 0, 0] }
|
|
124
|
+
}
|
|
125
|
+
: {
|
|
126
|
+
type: 'line' as const, name: s.name, data: s.data, stack: props.stacked ? 'total' : undefined,
|
|
127
|
+
// Smooth, without overshooting a point (a curve never dips below a value it doesn't reach).
|
|
128
|
+
smooth: 0.35, smoothMonotone: 'x' as const, showSymbol: false, symbolSize: 6, lineStyle: { width: 2 }, connectNulls: false,
|
|
129
|
+
areaStyle: props.type === 'area' ? { opacity: 0.16 } : undefined
|
|
130
|
+
})
|
|
131
|
+
|
|
132
|
+
const base: EChartsOption = {
|
|
133
|
+
color: colors,
|
|
134
|
+
backgroundColor: 'transparent',
|
|
135
|
+
animation: false,
|
|
136
|
+
textStyle: { fontFamily: font, color: text },
|
|
137
|
+
grid: spark
|
|
138
|
+
? { left: 0, right: 0, top: 2, bottom: 2 }
|
|
139
|
+
: { left: 4, right: 12, top: 12, bottom: legend ? 36 : 4, containLabel: true },
|
|
140
|
+
tooltip: {
|
|
141
|
+
trigger: round.value ? 'item' : 'axis',
|
|
142
|
+
confine: true,
|
|
143
|
+
valueFormatter: formatter as never,
|
|
144
|
+
backgroundColor: surface,
|
|
145
|
+
borderColor: border,
|
|
146
|
+
textStyle: { color: body, fontFamily: font, fontSize: 12 },
|
|
147
|
+
extraCssText: 'box-shadow: var(--tblr-box-shadow-dropdown); border-radius: var(--tblr-border-radius);',
|
|
148
|
+
axisPointer: bars.value
|
|
149
|
+
? { type: 'shadow', shadowStyle: { color: border, opacity: 0.35 } }
|
|
150
|
+
: { type: 'line', lineStyle: { color: border } }
|
|
151
|
+
},
|
|
152
|
+
legend: {
|
|
153
|
+
show: legend, bottom: 0, icon: 'circle', itemWidth: 8, itemHeight: 8, itemGap: 16,
|
|
154
|
+
textStyle: { color: text, fontFamily: font }
|
|
155
|
+
},
|
|
156
|
+
xAxis: round.value ? undefined : props.type === 'bar' ? valueAxis : categoryAxis,
|
|
157
|
+
yAxis: round.value ? undefined : props.type === 'bar' ? categoryAxis : valueAxis,
|
|
158
|
+
series
|
|
159
|
+
}
|
|
160
|
+
return defined(merge(base, props.options ?? {}))
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
/** Without keys set to undefined (ECharts takes some of them as values, over its defaults). */
|
|
164
|
+
function defined<T>(value: T): T {
|
|
165
|
+
if (Array.isArray(value)) return value.map(defined) as T
|
|
166
|
+
if (!isObject(value)) return value
|
|
167
|
+
return Object.fromEntries(Object.entries(value).filter(([, v]) => v !== undefined).map(([k, v]) => [k, defined(v)])) as T
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/** Objects merged deeply; arrays and values replaced. */
|
|
171
|
+
function merge<T>(target: T, source: unknown): T {
|
|
172
|
+
if (!isObject(target) || !isObject(source)) return (source === undefined ? target : source) as T
|
|
173
|
+
const result: Record<string, unknown> = { ...target }
|
|
174
|
+
for (const [key, value] of Object.entries(source)) {
|
|
175
|
+
if (value === undefined) continue
|
|
176
|
+
result[key] = isObject(value) && isObject(result[key]) ? merge(result[key], value) : value
|
|
177
|
+
}
|
|
178
|
+
return result as T
|
|
179
|
+
}
|
|
180
|
+
function isObject(value: unknown): value is Record<string, unknown> {
|
|
181
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value) && typeof value !== 'function'
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
const redraw = () => chart?.setOption(option(), { notMerge: true })
|
|
185
|
+
|
|
186
|
+
// The theme can change around the chart: light and dark, or a theme scope's accent and grays.
|
|
187
|
+
let observer: MutationObserver | null = null
|
|
188
|
+
function watchTheme() {
|
|
189
|
+
observer = new MutationObserver(redraw)
|
|
190
|
+
const themedAncestors = new Set<Element>([document.documentElement])
|
|
191
|
+
for (let node = el.value?.parentElement; node; node = node.parentElement)
|
|
192
|
+
if ([...node.attributes].some(a => a.name.startsWith('data-bs-theme') || a.name === 'data-t-density')) themedAncestors.add(node)
|
|
193
|
+
for (const node of themedAncestors) observer.observe(node, { attributes: true, attributeFilter: ['data-bs-theme', 'data-bs-theme-primary', 'data-bs-theme-base', 'style', 'class'] })
|
|
194
|
+
}
|
|
195
|
+
// It follows its box's size.
|
|
196
|
+
let sized: ResizeObserver | null = null
|
|
197
|
+
|
|
198
|
+
let unmounted = false
|
|
199
|
+
onMounted(async () => {
|
|
200
|
+
const echarts = await loadECharts()
|
|
201
|
+
if (!el.value || unmounted) return
|
|
202
|
+
chart = echarts.init(el.value, null, { renderer: props.renderer })
|
|
203
|
+
chart.on('click', params => {
|
|
204
|
+
const index = params.dataIndex ?? 0
|
|
205
|
+
emit('point-click', { series: params.seriesIndex ?? 0, index, category: props.categories[index] })
|
|
206
|
+
})
|
|
207
|
+
redraw()
|
|
208
|
+
watchTheme()
|
|
209
|
+
sized = new ResizeObserver(() => chart?.resize())
|
|
210
|
+
sized.observe(el.value)
|
|
211
|
+
})
|
|
212
|
+
watch(() => [props.type, props.series, props.categories, props.stacked, props.legend, props.colors, props.options, props.sparkline, props.format],
|
|
213
|
+
redraw, { deep: true })
|
|
214
|
+
onBeforeUnmount(() => {
|
|
215
|
+
unmounted = true
|
|
216
|
+
observer?.disconnect()
|
|
217
|
+
sized?.disconnect()
|
|
218
|
+
chart?.dispose()
|
|
219
|
+
chart = null
|
|
220
|
+
})
|
|
221
|
+
</script>
|
|
222
|
+
|
|
223
|
+
<template>
|
|
224
|
+
<div ref="el" class="t-chart" role="img" :aria-label="label" :style="{ height: cssHeight }" />
|
|
225
|
+
</template>
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
// Images shown large over the page, one at a time: v-model is the one shown (its index; null when
|
|
3
|
+
// closed). Previous and next (buttons, the arrow keys, or a swipe), a counter, its caption, and
|
|
4
|
+
// close (the button, Escape, or a click beside the image). Focus moves to it while it's open and
|
|
5
|
+
// back to where it was after.
|
|
6
|
+
import { computed, nextTick, onBeforeUnmount, ref, watch } from 'vue'
|
|
7
|
+
import TIcon from './TIcon.vue'
|
|
8
|
+
|
|
9
|
+
export interface LightboxImage { src: string; alt?: string; caption?: string }
|
|
10
|
+
|
|
11
|
+
const props = withDefaults(defineProps<{ images: LightboxImage[]; loop?: boolean }>(), { loop: true })
|
|
12
|
+
const index = defineModel<number | null>({ default: null })
|
|
13
|
+
|
|
14
|
+
const open = computed(() => index.value != null && index.value >= 0 && index.value < props.images.length)
|
|
15
|
+
const image = computed(() => (open.value ? props.images[index.value!] : null))
|
|
16
|
+
const many = computed(() => props.images.length > 1)
|
|
17
|
+
|
|
18
|
+
function step(by: 1 | -1) {
|
|
19
|
+
if (index.value == null || !many.value) return
|
|
20
|
+
const next = index.value + by
|
|
21
|
+
index.value = props.loop ? (next + props.images.length) % props.images.length : Math.min(Math.max(next, 0), props.images.length - 1)
|
|
22
|
+
}
|
|
23
|
+
const close = () => { index.value = null }
|
|
24
|
+
|
|
25
|
+
function key(event: KeyboardEvent) {
|
|
26
|
+
if (!open.value) return
|
|
27
|
+
if (event.key === 'Escape') close()
|
|
28
|
+
else if (event.key === 'ArrowRight') step(1)
|
|
29
|
+
else if (event.key === 'ArrowLeft') step(-1)
|
|
30
|
+
else return
|
|
31
|
+
event.preventDefault()
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// A swipe across moves to the next or previous.
|
|
35
|
+
let startX: number | null = null
|
|
36
|
+
function touchStart(event: TouchEvent) { startX = event.touches[0]?.clientX ?? null }
|
|
37
|
+
function touchEnd(event: TouchEvent) {
|
|
38
|
+
const endX = event.changedTouches[0]?.clientX
|
|
39
|
+
if (startX != null && endX != null && Math.abs(endX - startX) > 50) step(endX < startX ? 1 : -1)
|
|
40
|
+
startX = null
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const dialog = ref<HTMLElement>()
|
|
44
|
+
let before: Element | null = null
|
|
45
|
+
watch(open, async now => {
|
|
46
|
+
if (now) {
|
|
47
|
+
before = document.activeElement
|
|
48
|
+
document.addEventListener('keydown', key)
|
|
49
|
+
await nextTick()
|
|
50
|
+
dialog.value?.focus()
|
|
51
|
+
} else {
|
|
52
|
+
document.removeEventListener('keydown', key)
|
|
53
|
+
if (before instanceof HTMLElement) before.focus()
|
|
54
|
+
}
|
|
55
|
+
}, { immediate: true })
|
|
56
|
+
onBeforeUnmount(() => document.removeEventListener('keydown', key))
|
|
57
|
+
</script>
|
|
58
|
+
|
|
59
|
+
<template>
|
|
60
|
+
<Teleport to="body">
|
|
61
|
+
<div v-if="open && image" ref="dialog" class="t-lightbox" role="dialog" aria-modal="true" :aria-label="image.alt || image.caption || 'Image'" tabindex="-1"
|
|
62
|
+
@click.self="close" @touchstart.passive="touchStart" @touchend="touchEnd">
|
|
63
|
+
<button type="button" class="t-lightbox-close" aria-label="Close" @click="close"><TIcon name="x" /></button>
|
|
64
|
+
<button v-if="many" type="button" class="t-lightbox-step start" aria-label="Previous image" @click="step(-1)"><TIcon name="chevron-left" /></button>
|
|
65
|
+
<figure class="t-lightbox-figure" @click.self="close">
|
|
66
|
+
<img :key="image.src" :src="image.src" :alt="image.alt ?? ''">
|
|
67
|
+
<figcaption v-if="image.caption || many">
|
|
68
|
+
<span v-if="many" class="t-lightbox-count">{{ index! + 1 }} / {{ images.length }}</span>
|
|
69
|
+
<span v-if="image.caption">{{ image.caption }}</span>
|
|
70
|
+
</figcaption>
|
|
71
|
+
</figure>
|
|
72
|
+
<button v-if="many" type="button" class="t-lightbox-step end" aria-label="Next image" @click="step(1)"><TIcon name="chevron-right" /></button>
|
|
73
|
+
</div>
|
|
74
|
+
</Teleport>
|
|
75
|
+
</template>
|
|
76
|
+
|
|
77
|
+
<style scoped>
|
|
78
|
+
.t-lightbox {
|
|
79
|
+
position: fixed; inset: 0; z-index: 2000; display: flex; align-items: center; justify-content: center;
|
|
80
|
+
background: rgba(10, 12, 16, 0.88); outline: none; animation: t-lightbox-in 0.15s ease-out;
|
|
81
|
+
}
|
|
82
|
+
@keyframes t-lightbox-in { from { opacity: 0; } }
|
|
83
|
+
.t-lightbox-figure { margin: 0; max-width: calc(100vw - 8rem); max-height: calc(100vh - 6rem); display: flex; flex-direction: column; align-items: center; gap: 0.75rem; }
|
|
84
|
+
.t-lightbox-figure img { max-width: 100%; max-height: calc(100vh - 9rem); object-fit: contain; border-radius: var(--tblr-border-radius); box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4); }
|
|
85
|
+
.t-lightbox-figure figcaption { display: flex; gap: 0.75rem; align-items: baseline; color: #e6e7e9; font-size: 0.875rem; text-align: center; }
|
|
86
|
+
.t-lightbox-count { color: #9aa0ac; font-variant-numeric: tabular-nums; }
|
|
87
|
+
.t-lightbox-close, .t-lightbox-step {
|
|
88
|
+
position: absolute; display: inline-flex; align-items: center; justify-content: center; width: 2.75rem; height: 2.75rem; border: 0; border-radius: 50%;
|
|
89
|
+
background: rgba(255, 255, 255, 0.1); color: #fff; font-size: 1.25rem; cursor: pointer;
|
|
90
|
+
}
|
|
91
|
+
.t-lightbox-close:hover, .t-lightbox-step:hover { background: rgba(255, 255, 255, 0.2); }
|
|
92
|
+
.t-lightbox-close:focus-visible, .t-lightbox-step:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
|
|
93
|
+
.t-lightbox-close { top: 1rem; right: 1rem; }
|
|
94
|
+
.t-lightbox-step { top: 50%; transform: translateY(-50%); }
|
|
95
|
+
.t-lightbox-step.start { left: 1rem; }
|
|
96
|
+
.t-lightbox-step.end { right: 1rem; }
|
|
97
|
+
@media (max-width: 576px) {
|
|
98
|
+
.t-lightbox-figure { max-width: 100vw; }
|
|
99
|
+
.t-lightbox-step { top: auto; bottom: 1rem; transform: none; }
|
|
100
|
+
}
|
|
101
|
+
</style>
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
// A PDF, drawn by PDF.js (loaded on first use): its pages one under another, each drawn when it
|
|
3
|
+
// scrolls into view, at a zoom that fits the width (default), fits a whole page, or a percent.
|
|
4
|
+
// The toolbar has the page (v-model:page; typing one goes there), previous and next, zoom, and
|
|
5
|
+
// download and open in a new tab. A PDF that can't be read says so, with a link to download it.
|
|
6
|
+
import { computed, nextTick, onBeforeUnmount, onMounted, ref, shallowRef, watch } from 'vue'
|
|
7
|
+
import type { PDFDocumentProxy, PDFPageProxy, RenderTask } from 'pdfjs-dist'
|
|
8
|
+
import { loadPdfJs } from '../plugins/pdf'
|
|
9
|
+
import TIcon from './TIcon.vue'
|
|
10
|
+
|
|
11
|
+
export type PdfZoom = 'width' | 'page' | number
|
|
12
|
+
|
|
13
|
+
const props = withDefaults(defineProps<{
|
|
14
|
+
src: string
|
|
15
|
+
// Fit the width, fit a page, or a percent (100 is the PDF's own size).
|
|
16
|
+
zoom?: PdfZoom
|
|
17
|
+
toolbar?: boolean
|
|
18
|
+
download?: boolean
|
|
19
|
+
// The downloaded file's name; by default the address's last part.
|
|
20
|
+
fileName?: string
|
|
21
|
+
height?: number | string
|
|
22
|
+
label?: string
|
|
23
|
+
}>(), { zoom: 'width', toolbar: true, download: true, height: 480, label: 'PDF document' })
|
|
24
|
+
|
|
25
|
+
const page = defineModel<number>('page', { default: 1 })
|
|
26
|
+
const emit = defineEmits<{ load: [info: { pages: number }]; error: [message: string] }>()
|
|
27
|
+
|
|
28
|
+
const scroller = ref<HTMLElement>()
|
|
29
|
+
const doc = shallowRef<PDFDocumentProxy | null>(null)
|
|
30
|
+
const pages = shallowRef<PDFPageProxy[]>([])
|
|
31
|
+
const loading = ref(true)
|
|
32
|
+
const problem = ref('')
|
|
33
|
+
const zoom = ref<PdfZoom>(props.zoom)
|
|
34
|
+
const scale = ref(1)
|
|
35
|
+
watch(() => props.zoom, z => { zoom.value = z })
|
|
36
|
+
|
|
37
|
+
const cssHeight = computed(() => (typeof props.height === 'number' ? `${props.height}px` : props.height))
|
|
38
|
+
const name = computed(() => props.fileName || decodeURIComponent(props.src.split(/[?#]/)[0]!.split('/').pop() || 'document.pdf'))
|
|
39
|
+
const count = computed(() => pages.value.length)
|
|
40
|
+
|
|
41
|
+
// ---- Loading ----
|
|
42
|
+
let loadingTask: { destroy: () => Promise<void> } | null = null
|
|
43
|
+
async function open() {
|
|
44
|
+
close()
|
|
45
|
+
loading.value = true
|
|
46
|
+
problem.value = ''
|
|
47
|
+
try {
|
|
48
|
+
const pdfjs = await loadPdfJs()
|
|
49
|
+
const task = pdfjs.getDocument({ url: props.src })
|
|
50
|
+
loadingTask = task
|
|
51
|
+
const opened = await task.promise
|
|
52
|
+
doc.value = opened
|
|
53
|
+
pages.value = await Promise.all(Array.from({ length: opened.numPages }, (_, i) => opened.getPage(i + 1)))
|
|
54
|
+
fit()
|
|
55
|
+
loading.value = false
|
|
56
|
+
emit('load', { pages: opened.numPages })
|
|
57
|
+
await nextTick()
|
|
58
|
+
observe()
|
|
59
|
+
if (page.value > 1) goTo(page.value)
|
|
60
|
+
} catch (e) {
|
|
61
|
+
loading.value = false
|
|
62
|
+
problem.value = e instanceof Error && /password/i.test(e.message) ? 'This PDF needs a password.' : 'This PDF couldn\'t be shown.'
|
|
63
|
+
emit('error', e instanceof Error ? e.message : problem.value)
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
function close() {
|
|
67
|
+
for (const task of tasks.values()) task.cancel()
|
|
68
|
+
tasks.clear()
|
|
69
|
+
drawn.clear()
|
|
70
|
+
observer?.disconnect()
|
|
71
|
+
void loadingTask?.destroy()
|
|
72
|
+
loadingTask = null
|
|
73
|
+
doc.value = null
|
|
74
|
+
pages.value = []
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
// ---- Zoom ----
|
|
78
|
+
const sizes = computed(() => pages.value.map(p => p.getViewport({ scale: scale.value })))
|
|
79
|
+
/** The zoom as a scale: a fit works it out from the box and the first page. */
|
|
80
|
+
function fit() {
|
|
81
|
+
const first = pages.value[0]
|
|
82
|
+
const box = scroller.value
|
|
83
|
+
if (!first || !box) return
|
|
84
|
+
const natural = first.getViewport({ scale: 1 })
|
|
85
|
+
const width = (box.clientWidth - 32) / natural.width
|
|
86
|
+
const whole = Math.min(width, (box.clientHeight - 32) / natural.height)
|
|
87
|
+
scale.value = Math.max(0.1, zoom.value === 'width' ? width : zoom.value === 'page' ? whole : zoom.value / 100)
|
|
88
|
+
}
|
|
89
|
+
watch(zoom, () => { fit(); redraw() })
|
|
90
|
+
const steps = [50, 75, 100, 125, 150, 200, 300]
|
|
91
|
+
function zoomBy(direction: 1 | -1) {
|
|
92
|
+
const now = Math.round(scale.value * 100)
|
|
93
|
+
const next = direction > 0 ? steps.find(s => s > now) ?? 400 : [...steps].reverse().find(s => s < now) ?? 25
|
|
94
|
+
zoom.value = next
|
|
95
|
+
}
|
|
96
|
+
const zoomItems = [{ label: 'Fit width', value: 'width' }, { label: 'Fit page', value: 'page' }, ...steps.map(s => ({ label: `${s}%`, value: String(s) }))]
|
|
97
|
+
const zoomChoice = computed({
|
|
98
|
+
get: () => (typeof zoom.value === 'number' ? String(zoom.value) : zoom.value),
|
|
99
|
+
set: (v: string) => { zoom.value = v === 'width' || v === 'page' ? v : Number(v) }
|
|
100
|
+
})
|
|
101
|
+
const zoomShown = computed(() => (typeof zoom.value === 'number' || !zoomItems.some(z => z.value === zoomChoice.value) ? `${Math.round(scale.value * 100)}%` : ''))
|
|
102
|
+
|
|
103
|
+
// ---- Drawing pages as they come into view ----
|
|
104
|
+
const canvases = ref<HTMLCanvasElement[]>([])
|
|
105
|
+
const tasks = new Map<number, RenderTask>()
|
|
106
|
+
const drawn = new Map<number, number>()
|
|
107
|
+
let observer: IntersectionObserver | null = null
|
|
108
|
+
function observe() {
|
|
109
|
+
observer?.disconnect()
|
|
110
|
+
observer = new IntersectionObserver(entries => {
|
|
111
|
+
for (const e of entries) if (e.isIntersecting) void draw(Number((e.target as HTMLElement).dataset.page))
|
|
112
|
+
}, { root: scroller.value, rootMargin: '400px 0px' })
|
|
113
|
+
scroller.value?.querySelectorAll('.t-pdf-page').forEach(el => observer!.observe(el))
|
|
114
|
+
}
|
|
115
|
+
async function draw(index: number) {
|
|
116
|
+
const p = pages.value[index]
|
|
117
|
+
const canvas = canvases.value[index]
|
|
118
|
+
if (!p || !canvas || drawn.get(index) === scale.value) return
|
|
119
|
+
tasks.get(index)?.cancel()
|
|
120
|
+
const ratio = window.devicePixelRatio || 1
|
|
121
|
+
const viewport = p.getViewport({ scale: scale.value * ratio })
|
|
122
|
+
canvas.width = Math.floor(viewport.width)
|
|
123
|
+
canvas.height = Math.floor(viewport.height)
|
|
124
|
+
const task = p.render({ canvas, viewport })
|
|
125
|
+
tasks.set(index, task)
|
|
126
|
+
try {
|
|
127
|
+
await task.promise
|
|
128
|
+
drawn.set(index, scale.value)
|
|
129
|
+
} catch {
|
|
130
|
+
// Cancelled by a newer drawing.
|
|
131
|
+
} finally {
|
|
132
|
+
if (tasks.get(index) === task) tasks.delete(index)
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
function redraw() {
|
|
136
|
+
drawn.clear()
|
|
137
|
+
void nextTick(() => observe())
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// ---- Pages ----
|
|
141
|
+
function goTo(n: number) {
|
|
142
|
+
const target = Math.min(Math.max(1, Math.round(n) || 1), Math.max(1, count.value))
|
|
143
|
+
page.value = target
|
|
144
|
+
const el = scroller.value?.querySelector<HTMLElement>(`[data-page="${target - 1}"]`)
|
|
145
|
+
if (el && scroller.value) scroller.value.scrollTop = el.offsetTop - 12
|
|
146
|
+
}
|
|
147
|
+
// The page shown is the one nearest the top as it scrolls.
|
|
148
|
+
function scrolled() {
|
|
149
|
+
const box = scroller.value
|
|
150
|
+
if (!box) return
|
|
151
|
+
const els = [...box.querySelectorAll<HTMLElement>('.t-pdf-page')]
|
|
152
|
+
const top = box.scrollTop + box.clientHeight * 0.25
|
|
153
|
+
let current = 1
|
|
154
|
+
for (const el of els) if (el.offsetTop <= top) current = Number(el.dataset.page) + 1
|
|
155
|
+
if (current !== page.value) page.value = current
|
|
156
|
+
}
|
|
157
|
+
const typed = ref('')
|
|
158
|
+
watch(page, p => { typed.value = String(p) }, { immediate: true })
|
|
159
|
+
watch(page, p => {
|
|
160
|
+
const box = scroller.value
|
|
161
|
+
const el = box?.querySelector<HTMLElement>(`[data-page="${p - 1}"]`)
|
|
162
|
+
if (!box || !el) return
|
|
163
|
+
// Changed from outside (not by scrolling): go there.
|
|
164
|
+
if (el.offsetTop > box.scrollTop + box.clientHeight * 0.25 || el.offsetTop + el.offsetHeight < box.scrollTop) box.scrollTop = el.offsetTop - 12
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
function downloadFile() {
|
|
168
|
+
const a = document.createElement('a')
|
|
169
|
+
a.href = props.src
|
|
170
|
+
a.download = name.value
|
|
171
|
+
document.body.appendChild(a)
|
|
172
|
+
a.click()
|
|
173
|
+
a.remove()
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
let sized: ResizeObserver | null = null
|
|
177
|
+
onMounted(() => {
|
|
178
|
+
void open()
|
|
179
|
+
sized = new ResizeObserver(() => {
|
|
180
|
+
if (zoom.value === 'width' || zoom.value === 'page') {
|
|
181
|
+
const before = scale.value
|
|
182
|
+
fit()
|
|
183
|
+
if (Math.abs(before - scale.value) > 0.01) redraw()
|
|
184
|
+
}
|
|
185
|
+
})
|
|
186
|
+
if (scroller.value) sized.observe(scroller.value)
|
|
187
|
+
})
|
|
188
|
+
watch(() => props.src, () => void open())
|
|
189
|
+
onBeforeUnmount(() => {
|
|
190
|
+
sized?.disconnect()
|
|
191
|
+
close()
|
|
192
|
+
})
|
|
193
|
+
|
|
194
|
+
defineExpose({ setPage: goTo, download: downloadFile })
|
|
195
|
+
</script>
|
|
196
|
+
|
|
197
|
+
<template>
|
|
198
|
+
<div class="t-pdf card" :style="{ height: cssHeight }" role="document" :aria-label="label">
|
|
199
|
+
<div v-if="toolbar" class="t-pdf-toolbar">
|
|
200
|
+
<button type="button" class="btn btn-sm btn-ghost-secondary btn-icon" :disabled="page <= 1 || !count" aria-label="Previous page" @click="goTo(page - 1)">
|
|
201
|
+
<TIcon name="chevron-up" />
|
|
202
|
+
</button>
|
|
203
|
+
<button type="button" class="btn btn-sm btn-ghost-secondary btn-icon" :disabled="page >= count || !count" aria-label="Next page" @click="goTo(page + 1)">
|
|
204
|
+
<TIcon name="chevron-down" />
|
|
205
|
+
</button>
|
|
206
|
+
<label class="t-pdf-page-number">
|
|
207
|
+
<input v-model="typed" class="form-control form-control-sm" inputmode="numeric" aria-label="Page" :disabled="!count"
|
|
208
|
+
@keydown.enter="goTo(Number(typed))" @blur="goTo(Number(typed))">
|
|
209
|
+
<span class="text-secondary small text-nowrap">of {{ count || '…' }}</span>
|
|
210
|
+
</label>
|
|
211
|
+
<span class="ms-auto" />
|
|
212
|
+
<button type="button" class="btn btn-sm btn-ghost-secondary btn-icon" :disabled="!count" aria-label="Zoom out" @click="zoomBy(-1)"><TIcon name="zoom-out" /></button>
|
|
213
|
+
<select v-model="zoomChoice" class="form-select form-select-sm t-pdf-zoom" aria-label="Zoom" :disabled="!count">
|
|
214
|
+
<option v-if="zoomShown" :value="zoomChoice" hidden>{{ zoomShown }}</option>
|
|
215
|
+
<option v-for="z in zoomItems" :key="z.value" :value="z.value">{{ z.label }}</option>
|
|
216
|
+
</select>
|
|
217
|
+
<button type="button" class="btn btn-sm btn-ghost-secondary btn-icon" :disabled="!count" aria-label="Zoom in" @click="zoomBy(1)"><TIcon name="zoom-in" /></button>
|
|
218
|
+
<template v-if="download">
|
|
219
|
+
<button type="button" class="btn btn-sm btn-ghost-secondary btn-icon" aria-label="Download" title="Download" @click="downloadFile"><TIcon name="download" /></button>
|
|
220
|
+
<a class="btn btn-sm btn-ghost-secondary btn-icon" :href="src" target="_blank" rel="noopener" aria-label="Open in a new tab" title="Open in a new tab">
|
|
221
|
+
<TIcon name="external-link" />
|
|
222
|
+
</a>
|
|
223
|
+
</template>
|
|
224
|
+
</div>
|
|
225
|
+
<div ref="scroller" class="t-pdf-pages" @scroll.passive="scrolled">
|
|
226
|
+
<div v-if="loading" class="t-pdf-note"><span class="spinner-border spinner-border-sm" role="status" /> Loading the PDF…</div>
|
|
227
|
+
<div v-else-if="problem" class="t-pdf-note flex-column">
|
|
228
|
+
<TIcon name="file-alert" class="text-secondary" />
|
|
229
|
+
<span>{{ problem }}</span>
|
|
230
|
+
<a v-if="download" :href="src" :download="name">Download it</a>
|
|
231
|
+
</div>
|
|
232
|
+
<template v-else>
|
|
233
|
+
<div v-for="(size, i) in sizes" :key="i" class="t-pdf-page" :data-page="i" :style="{ width: `${size.width}px`, height: `${size.height}px` }">
|
|
234
|
+
<canvas :ref="el => { canvases[i] = el as HTMLCanvasElement }" :style="{ width: `${size.width}px`, height: `${size.height}px` }"
|
|
235
|
+
:aria-label="`Page ${i + 1}`" role="img" />
|
|
236
|
+
</div>
|
|
237
|
+
</template>
|
|
238
|
+
</div>
|
|
239
|
+
</div>
|
|
240
|
+
</template>
|
|
241
|
+
|
|
242
|
+
<style scoped>
|
|
243
|
+
.t-pdf { display: flex; flex-direction: column; overflow: hidden; margin: 0; }
|
|
244
|
+
.t-pdf-toolbar { display: flex; align-items: center; gap: 0.25rem; padding: 0.375rem 0.5rem; border-bottom: 1px solid var(--tblr-border-color); }
|
|
245
|
+
.t-pdf-page-number { display: inline-flex; align-items: center; gap: 0.375rem; margin: 0 0 0 0.25rem; }
|
|
246
|
+
.t-pdf-page-number input { width: 3.25rem; text-align: center; }
|
|
247
|
+
.t-pdf-zoom { width: 7rem; }
|
|
248
|
+
.t-pdf-pages { position: relative; flex: 1; min-height: 0; overflow: auto; padding: 16px; background: var(--tblr-bg-surface-secondary); }
|
|
249
|
+
.t-pdf-page { margin: 0 auto 12px; background: #fff; box-shadow: var(--tblr-box-shadow-card, 0 1px 3px rgba(0, 0, 0, 0.15)); }
|
|
250
|
+
.t-pdf-page canvas { display: block; }
|
|
251
|
+
.t-pdf-note { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 0.5rem; color: var(--tblr-secondary); font-size: 0.875rem; }
|
|
252
|
+
</style>
|
|
@@ -1,10 +1,42 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
|
-
// A
|
|
3
|
-
|
|
2
|
+
// A line between things: across (with an optional label at the start, center or end), or upright
|
|
3
|
+
// inside a row. Its color is the border color unless given (a named color such as 'primary', one
|
|
4
|
+
// of Tabler's, or any CSS color), with a style (solid, dashed, dotted) and a thickness in pixels.
|
|
5
|
+
// `spacing` 'none' drops the space above and below.
|
|
6
|
+
import { computed } from 'vue'
|
|
7
|
+
import { toTabler, type Color } from '../types'
|
|
8
|
+
|
|
9
|
+
const props = withDefaults(defineProps<{
|
|
10
|
+
label?: string
|
|
11
|
+
orientation?: 'horizontal' | 'vertical'
|
|
12
|
+
position?: 'start' | 'center' | 'end'
|
|
13
|
+
color?: Color | string
|
|
14
|
+
variant?: 'solid' | 'dashed' | 'dotted'
|
|
15
|
+
thickness?: number
|
|
16
|
+
spacing?: 'normal' | 'none'
|
|
17
|
+
}>(), { orientation: 'horizontal', position: 'center', variant: 'solid', thickness: 1, spacing: 'normal' })
|
|
18
|
+
|
|
19
|
+
const named = new Set(['primary', 'neutral', 'success', 'warning', 'error', 'info'])
|
|
20
|
+
const tabler = new Set(['blue', 'azure', 'indigo', 'purple', 'pink', 'red', 'orange', 'yellow', 'lime', 'green', 'teal', 'cyan', 'secondary', 'muted'])
|
|
21
|
+
const line = computed(() => {
|
|
22
|
+
const c = props.color
|
|
23
|
+
const color = !c ? 'var(--tblr-border-color)' : named.has(c) ? `var(--tblr-${toTabler(c as Color)})` : tabler.has(c) ? `var(--tblr-${c})` : c
|
|
24
|
+
return { '--t-separator-color': color, '--t-separator-style': props.variant, '--t-separator-width': `${Math.max(1, Math.min(props.thickness, 12))}px` }
|
|
25
|
+
})
|
|
4
26
|
</script>
|
|
5
27
|
|
|
6
28
|
<template>
|
|
7
|
-
<div v-if="orientation === 'vertical'" class="
|
|
8
|
-
<div v-else-if="label" class="hr-text
|
|
9
|
-
|
|
29
|
+
<div v-if="orientation === 'vertical'" class="t-separator t-separator-vertical" role="separator" aria-orientation="vertical" :style="line" />
|
|
30
|
+
<div v-else-if="label" :class="['t-separator hr-text', { 'hr-text-start': position === 'start', 'hr-text-end': position === 'end', 't-separator-flush': spacing === 'none' }]"
|
|
31
|
+
role="separator" :style="line"><span>{{ label }}</span></div>
|
|
32
|
+
<hr v-else :class="['t-separator', spacing === 'none' ? 'my-0' : 'my-3']" :style="line">
|
|
10
33
|
</template>
|
|
34
|
+
|
|
35
|
+
<style scoped>
|
|
36
|
+
hr.t-separator { border: 0; border-top: var(--t-separator-width) var(--t-separator-style) var(--t-separator-color); opacity: 1; }
|
|
37
|
+
.t-separator.hr-text::before, .t-separator.hr-text::after {
|
|
38
|
+
height: 0; background: none; border-top: var(--t-separator-width) var(--t-separator-style) var(--t-separator-color);
|
|
39
|
+
}
|
|
40
|
+
.t-separator-flush { margin: 0.5rem 0; }
|
|
41
|
+
.t-separator-vertical { align-self: stretch; width: 0; min-height: 1em; border-inline-start: var(--t-separator-width) var(--t-separator-style) var(--t-separator-color); }
|
|
42
|
+
</style>
|
|
@@ -1,56 +1,69 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
// A figure on an overview page: label, value, a line under it, and an icon in a tinted square. A
|
|
3
|
-
// `trend` (the change, in percent) shows beside the value, green when it's good: up, unless
|
|
4
|
-
// `trendGood` is 'down' (costs, errors). `sparkline` draws the recent values under it.
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
</div>
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
</
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
// A figure on an overview page: label, value, a line under it, and an icon in a tinted square. A
|
|
3
|
+
// `trend` (the change, in percent) shows beside the value, green when it's good: up, unless
|
|
4
|
+
// `trendGood` is 'down' (costs, errors). `sparkline` draws the recent values under it. `loading`
|
|
5
|
+
// holds placeholders where the value and trend go; `clickable` makes the card a button that emits
|
|
6
|
+
// `click` (Enter and Space too).
|
|
7
|
+
import { computed } from 'vue'
|
|
8
|
+
import TIcon from './TIcon.vue'
|
|
9
|
+
import TSparkline from './TSparkline.vue'
|
|
10
|
+
import { toTabler, type Color } from '../types'
|
|
11
|
+
|
|
12
|
+
const props = withDefaults(defineProps<{
|
|
13
|
+
label: string
|
|
14
|
+
value: string | number
|
|
15
|
+
detail?: string
|
|
16
|
+
icon?: string
|
|
17
|
+
color?: Color
|
|
18
|
+
trend?: number | null
|
|
19
|
+
trendLabel?: string
|
|
20
|
+
trendGood?: 'up' | 'down'
|
|
21
|
+
sparkline?: number[]
|
|
22
|
+
sparklineType?: 'line' | 'bar'
|
|
23
|
+
loading?: boolean
|
|
24
|
+
clickable?: boolean
|
|
25
|
+
}>(), { color: 'primary', trendGood: 'up', sparklineType: 'line' })
|
|
26
|
+
|
|
27
|
+
const emit = defineEmits<{ click: [event: MouseEvent | KeyboardEvent] }>()
|
|
28
|
+
function press(event: MouseEvent | KeyboardEvent) {
|
|
29
|
+
if (props.clickable) emit('click', event)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
const trendText = computed(() => props.trend == null ? '' : `${Math.abs(Math.round(props.trend * 10) / 10)}%`)
|
|
33
|
+
const trendClass = computed(() => {
|
|
34
|
+
if (props.trend == null || props.trend === 0) return 'text-secondary'
|
|
35
|
+
return (props.trend > 0) === (props.trendGood === 'up') ? 'text-success' : 'text-danger'
|
|
36
|
+
})
|
|
37
|
+
const trendIcon = computed(() => !props.trend ? 'minus' : props.trend > 0 ? 'trending-up' : 'trending-down')
|
|
38
|
+
</script>
|
|
39
|
+
|
|
40
|
+
<template>
|
|
41
|
+
<div :class="['card', { 't-stat-clickable': clickable }]" :role="clickable ? 'button' : undefined" :tabindex="clickable ? 0 : undefined"
|
|
42
|
+
:aria-busy="loading || undefined" @click="press" @keydown.enter.prevent="press" @keydown.space.prevent="press">
|
|
43
|
+
<div class="card-body">
|
|
44
|
+
<div class="d-flex align-items-start justify-content-between gap-3">
|
|
45
|
+
<div class="min-w-0">
|
|
46
|
+
<div class="subheader">{{ label }}</div>
|
|
47
|
+
<div v-if="loading" class="mt-2 placeholder-glow" aria-label="Loading">
|
|
48
|
+
<span class="placeholder col-7 t-stat-placeholder" />
|
|
49
|
+
</div>
|
|
50
|
+
<div v-else class="d-flex align-items-baseline gap-2 mt-2">
|
|
51
|
+
<div class="h1 mb-0">{{ value }}</div>
|
|
52
|
+
<span v-if="trend != null" :class="['d-inline-flex align-items-center gap-1 lh-1 small fw-medium', trendClass]"
|
|
53
|
+
:title="trendLabel">
|
|
54
|
+
{{ trendText }}<TIcon :name="trendIcon" />
|
|
55
|
+
</span>
|
|
56
|
+
</div>
|
|
57
|
+
<div v-if="detail || trendLabel || $slots.detail" class="text-secondary small mt-1">
|
|
58
|
+
<slot name="detail">{{ detail ?? trendLabel }}</slot>
|
|
59
|
+
</div>
|
|
60
|
+
</div>
|
|
61
|
+
<div v-if="icon" :class="['t-stat-icon', `bg-${toTabler(color)}-lt`]">
|
|
62
|
+
<TIcon :name="icon" />
|
|
63
|
+
</div>
|
|
64
|
+
</div>
|
|
65
|
+
<TSparkline v-if="sparkline?.length && !loading" :values="sparkline" :type="sparklineType" :color="color" :width="240" :height="36"
|
|
66
|
+
class="t-stat-sparkline mt-3" :label="`${label}: recent values`" />
|
|
67
|
+
</div>
|
|
68
|
+
</div>
|
|
69
|
+
</template>
|
package/src/index.ts
CHANGED
|
@@ -33,6 +33,7 @@ import TIcon from './components/TIcon.vue'
|
|
|
33
33
|
import TIconPicker from './components/TIconPicker.vue'
|
|
34
34
|
import TImageUpload from './components/TImageUpload.vue'
|
|
35
35
|
import TInput from './components/TInput.vue'
|
|
36
|
+
import TLightbox from './components/TLightbox.vue'
|
|
36
37
|
import TInputNumber from './components/TInputNumber.vue'
|
|
37
38
|
import TInputTags from './components/TInputTags.vue'
|
|
38
39
|
import TListBox from './components/TListBox.vue'
|
|
@@ -103,6 +104,7 @@ export {
|
|
|
103
104
|
TImageUpload,
|
|
104
105
|
TInput,
|
|
105
106
|
TInputNumber,
|
|
107
|
+
TLightbox,
|
|
106
108
|
TInputTags,
|
|
107
109
|
TListBox,
|
|
108
110
|
TLogView,
|
|
@@ -143,6 +145,7 @@ export {
|
|
|
143
145
|
}
|
|
144
146
|
|
|
145
147
|
export * from './types'
|
|
148
|
+
export type { LightboxImage } from './components/TLightbox.vue'
|
|
146
149
|
export { isCustomAccent, themeAccents, themeBases, themeContainers, themeDensities, themeFonts, themeNavs, themeRadii, themeRadiusSizes } from './theme'
|
|
147
150
|
export { useColorMode, type ColorMode } from './composables/useColorMode'
|
|
148
151
|
export { useCommandPalette } from './composables/useCommandPalette'
|
|
@@ -153,7 +156,7 @@ const components = {
|
|
|
153
156
|
TAccentPicker, TAdvancedTable, TAlert, TAppLayout, TAuthLayout, TAvatar, TBadge, TButton, TCard,
|
|
154
157
|
TCheckbox, TCheckboxTree, TColorModeButton, TCommandPalette, TContainerPicker, TCopyButton, TDataGrid, TDataGridItem, TDensityPicker,
|
|
155
158
|
TDropdown, TEditableTable, TEmpty, TFieldGroup, TFileUpload, TFontPicker, TFormField, TIcon, TIconPicker, TImageUpload,
|
|
156
|
-
TInput, TInputNumber, TInputTags, TListBox, TLogView, TModal, TNav, TNavPositionPicker, TPage, TPagination,
|
|
159
|
+
TInput, TInputNumber, TInputTags, TLightbox, TListBox, TLogView, TModal, TNav, TNavPositionPicker, TPage, TPagination,
|
|
157
160
|
TPanelList, TProgress, TRadioGroup, TRadiusPicker, TRating, TScaledFrame, TSearchButton, TSectionLayout,
|
|
158
161
|
TSelect, TSelectMenu, TSeparator, TShell, TSkeleton, TSlideover, TSparkline, TSpinner, TSplitter, TStatCard,
|
|
159
162
|
TSteps, TSwitch, TTable, TTabs, TTextarea, TThemeBasePicker, TThemeScope, TToaster, TTooltip,
|
|
@@ -197,6 +200,7 @@ declare module 'vue' {
|
|
|
197
200
|
TIconPicker: typeof TIconPicker
|
|
198
201
|
TImageUpload: typeof TImageUpload
|
|
199
202
|
TInput: typeof TInput
|
|
203
|
+
TLightbox: typeof TLightbox
|
|
200
204
|
TInputNumber: typeof TInputNumber
|
|
201
205
|
TInputTags: typeof TInputTags
|
|
202
206
|
TListBox: typeof TListBox
|
package/src/plugins/charts.ts
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
// Loads
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
// Loads Apache ECharts (Apache-2.0), the first time a TChart is shown: its core, with only the
|
|
2
|
+
// charts, components and renderers TChart uses registered, so the rest isn't bundled.
|
|
3
|
+
import { once } from './once'
|
|
4
|
+
|
|
5
|
+
export const loadECharts = once(async () => {
|
|
6
|
+
const [core, charts, components, renderers] = await Promise.all([
|
|
7
|
+
import('echarts/core'),
|
|
8
|
+
import('echarts/charts'),
|
|
9
|
+
import('echarts/components'),
|
|
10
|
+
import('echarts/renderers')
|
|
11
|
+
])
|
|
12
|
+
core.use([
|
|
13
|
+
charts.LineChart, charts.BarChart, charts.PieChart,
|
|
14
|
+
components.GridComponent, components.TooltipComponent, components.LegendComponent,
|
|
15
|
+
renderers.SVGRenderer, renderers.CanvasRenderer
|
|
16
|
+
])
|
|
17
|
+
return core
|
|
18
|
+
})
|
package/src/plugins/index.ts
CHANGED
|
@@ -8,6 +8,7 @@ import TColorPicker from '../components/TColorPicker.vue'
|
|
|
8
8
|
import TDatePicker from '../components/TDatePicker.vue'
|
|
9
9
|
import TDropzone from '../components/TDropzone.vue'
|
|
10
10
|
import TInputMask from '../components/TInputMask.vue'
|
|
11
|
+
import TPdfViewer from '../components/TPdfViewer.vue'
|
|
11
12
|
import TRangeSlider from '../components/TRangeSlider.vue'
|
|
12
13
|
import TRichEditor from '../components/TRichEditor.vue'
|
|
13
14
|
import TSortable from '../components/TSortable.vue'
|
|
@@ -20,6 +21,7 @@ export {
|
|
|
20
21
|
TDatePicker,
|
|
21
22
|
TDropzone,
|
|
22
23
|
TInputMask,
|
|
24
|
+
TPdfViewer,
|
|
23
25
|
TRangeSlider,
|
|
24
26
|
TRichEditor,
|
|
25
27
|
TSortable,
|
|
@@ -27,9 +29,10 @@ export {
|
|
|
27
29
|
}
|
|
28
30
|
|
|
29
31
|
export type { RichEditorPlugin } from './richEditor'
|
|
32
|
+
export type { PdfZoom } from '../components/TPdfViewer.vue'
|
|
30
33
|
|
|
31
34
|
const components = {
|
|
32
|
-
TAdvancedSelect, TChart, TColorPicker, TDatePicker, TDropzone, TInputMask, TRangeSlider, TRichEditor,
|
|
35
|
+
TAdvancedSelect, TChart, TColorPicker, TDatePicker, TDropzone, TInputMask, TPdfViewer, TRangeSlider, TRichEditor,
|
|
33
36
|
TSortable, TSortableTree
|
|
34
37
|
}
|
|
35
38
|
|
|
@@ -47,6 +50,7 @@ declare module 'vue' {
|
|
|
47
50
|
TDatePicker: typeof TDatePicker
|
|
48
51
|
TDropzone: typeof TDropzone
|
|
49
52
|
TInputMask: typeof TInputMask
|
|
53
|
+
TPdfViewer: typeof TPdfViewer
|
|
50
54
|
TRangeSlider: typeof TRangeSlider
|
|
51
55
|
TRichEditor: typeof TRichEditor
|
|
52
56
|
TSortable: typeof TSortable
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// Loads PDF.js (Mozilla, Apache-2.0) the first time a TPdfViewer is shown, with its worker (which
|
|
2
|
+
// reads the PDF off the page's thread). The worker's address comes from the bundler (Vite's `?url`).
|
|
3
|
+
import { once } from './once'
|
|
4
|
+
|
|
5
|
+
export const loadPdfJs = once(async () => {
|
|
6
|
+
const [pdfjs, worker] = await Promise.all([
|
|
7
|
+
import('pdfjs-dist'),
|
|
8
|
+
import('pdfjs-dist/build/pdf.worker.min.mjs?url')
|
|
9
|
+
])
|
|
10
|
+
pdfjs.GlobalWorkerOptions.workerSrc = worker.default
|
|
11
|
+
return pdfjs
|
|
12
|
+
})
|
package/src/styles/gears.css
CHANGED
|
@@ -667,3 +667,8 @@
|
|
|
667
667
|
.t-chart { min-height: 1px; }
|
|
668
668
|
.t-stat-sparkline { display: block; width: 100%; }
|
|
669
669
|
.t-stat-sparkline svg { width: 100%; height: 2.25rem; }
|
|
670
|
+
/* A stat card that's a button: it lifts on hover and shows focus. */
|
|
671
|
+
.t-stat-clickable { cursor: pointer; transition: border-color 0.15s, box-shadow 0.15s; }
|
|
672
|
+
.t-stat-clickable:hover { border-color: var(--tblr-primary); }
|
|
673
|
+
.t-stat-clickable:focus-visible { outline: 2px solid var(--tblr-primary); outline-offset: 2px; }
|
|
674
|
+
.t-stat-placeholder { height: 2rem; border-radius: var(--tblr-border-radius); }
|