@ternarytech-io/gears-ui 0.9.0 → 0.10.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 +1 -1
- package/package.json +1 -1
- package/src/components/TAppLayout.vue +91 -88
- package/src/components/TContainerPicker.vue +23 -22
- package/src/styles/gears.css +2 -0
- package/src/theme.ts +51 -50
- package/src/types.ts +3 -1
package/README.md
CHANGED
|
@@ -105,7 +105,7 @@ add a page, add an entry to `preview/registry.ts` and a folder of examples.
|
|
|
105
105
|
| --- | --- |
|
|
106
106
|
| Elements | `TButton`, `TButtonGroup` (joined buttons, across or down; a tooltip each; `click` names the button), `TBadge`, `TMethodBadge` (an HTTP method, each in its own color, of one width), `TAvatar`, `TAlert`, `TCard`, `TIcon`, `TTooltip`, `TEmpty`, `TSpinner`, `TSkeleton`, `TProgress`, `TSeparator` (a label at the start, center or end; color, style, thickness) |
|
|
107
107
|
| 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` |
|
|
108
|
-
| Theme | `TAccentPicker`, `TFontPicker`, `TRadiusPicker`, `TThemeBasePicker` (Tabler's theme settings as pickers), `TNavPositionPicker`, `TDensityPicker`, `TContainerPicker` (
|
|
108
|
+
| Theme | `TAccentPicker`, `TFontPicker`, `TRadiusPicker`, `TThemeBasePicker` (Tabler's theme settings as pickers), `TNavPositionPicker`, `TDensityPicker`, `TContainerPicker` (the page's width: default, fluid or boxed), `TThemeScope` (applies a `ThemeSettings`' look and density to what's inside it); `themeAccents`, `themeFonts`, `themeBases`, `themeRadii`, `themeNavs`, `themeDensities`, `themeContainers` |
|
|
109
109
|
| Overlays | `TModal`, `TSlideover`, `TDropdown`, `TSplitButton` (a main action and a menu of others), `TToaster` (with `useToast()`: neutral, success, warning, error or a custom `accent` color; a corner or the middle of the top or bottom, per toast or for all; `onClick`, `onClose`), `TLightbox` (images shown large: previous and next, arrow keys, swipes, captions) |
|
|
110
110
|
| Navigation | `TTabs`, `TPagination`, `TSteps`, `TNav`, `TPanelList`, `TCommandPalette`, `TSearchButton` |
|
|
111
111
|
| 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`, `TCodeBlock` (JSON or YAML to read and copy: light highlighting by `codeTokens()`, wrapping, a header with actions; no editor, so no Monaco) |
|
package/package.json
CHANGED
|
@@ -1,88 +1,91 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
// An application's frame, laid out by a theme's layout settings (`theme`): the navigation down the
|
|
3
|
-
// left (it can fold to icons) or across the top (it can stay at the top as the page scrolls, and
|
|
4
|
-
// float apart from the edges), and the page
|
|
5
|
-
//
|
|
6
|
-
//
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
const
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
<
|
|
43
|
-
<
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
|
|
88
|
-
</
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
// An application's frame, laid out by a theme's layout settings (`theme`): the navigation down the
|
|
3
|
+
// left (it can fold to icons) or across the top (it can stay at the top as the page scrolls, and
|
|
4
|
+
// float apart from the edges), and the page's width (`container`): default, the content capped and
|
|
5
|
+
// centered with the navigation at the window's edge (a top bar runs the full width, its links within
|
|
6
|
+
// the content's width), as Tabler lays out; fluid, the full width; boxed, the whole page, navigation
|
|
7
|
+
// too, in a centered box with the background around it. Without a setting, it's default.
|
|
8
|
+
// The brand is the logo and name, or the `brand` slot; the links are `items` (TNav), or the `nav`
|
|
9
|
+
// slot for links of your own. `actions` go at the top bar's end, or at the foot of the sidebar.
|
|
10
|
+
// Tabler's page, navbar and layout-boxed classes do the work, so it looks like Tabler's layouts.
|
|
11
|
+
// On small screens the links fold away behind a menu button, and close again on navigating.
|
|
12
|
+
import { computed, ref, watch } from 'vue'
|
|
13
|
+
import { useRoute } from 'vue-router'
|
|
14
|
+
import TIcon from './TIcon.vue'
|
|
15
|
+
import TNav from './TNav.vue'
|
|
16
|
+
import type { NavItem, ThemeSettings } from '../types'
|
|
17
|
+
|
|
18
|
+
const props = withDefaults(defineProps<{
|
|
19
|
+
theme?: ThemeSettings
|
|
20
|
+
items?: NavItem[]
|
|
21
|
+
brand?: string
|
|
22
|
+
logo?: string
|
|
23
|
+
}>(), { theme: () => ({}), items: () => [] })
|
|
24
|
+
|
|
25
|
+
const folded = defineModel<boolean>('folded', { default: false })
|
|
26
|
+
|
|
27
|
+
const top = computed(() => props.theme.nav === 'top')
|
|
28
|
+
const boxed = computed(() => props.theme.container === 'boxed')
|
|
29
|
+
const foldable = computed(() => !top.value && props.theme.navFoldable === true)
|
|
30
|
+
const container = computed(() => props.theme.container === 'fluid' ? 'container-fluid' : 'container-xl')
|
|
31
|
+
|
|
32
|
+
const menuOpen = ref(false)
|
|
33
|
+
const route = useRoute()
|
|
34
|
+
watch(() => route.fullPath, () => { menuOpen.value = false })
|
|
35
|
+
</script>
|
|
36
|
+
|
|
37
|
+
<template>
|
|
38
|
+
<div :class="['t-app', { 'layout-boxed': boxed }]">
|
|
39
|
+
<div class="page">
|
|
40
|
+
<aside v-if="!top" :class="['navbar navbar-vertical navbar-expand-lg t-app-sidebar', { 'navbar-folded': foldable && folded }]">
|
|
41
|
+
<div class="container-fluid">
|
|
42
|
+
<button type="button" class="navbar-toggler" :aria-expanded="menuOpen" aria-label="Menu" @click="menuOpen = !menuOpen">
|
|
43
|
+
<span class="navbar-toggler-icon" />
|
|
44
|
+
</button>
|
|
45
|
+
<div class="navbar-brand">
|
|
46
|
+
<slot name="brand" :folded="foldable && folded">
|
|
47
|
+
<img v-if="logo" :src="logo" alt="" class="t-app-logo">
|
|
48
|
+
<span v-if="brand && !(foldable && folded)" class="text-truncate">{{ brand }}</span>
|
|
49
|
+
</slot>
|
|
50
|
+
</div>
|
|
51
|
+
<button v-if="foldable" type="button" class="t-fold-toggle d-none d-lg-grid" :aria-label="folded ? 'Expand the menu' : 'Fold the menu'"
|
|
52
|
+
@click="folded = !folded">
|
|
53
|
+
<TIcon :name="folded ? 'chevron-right' : 'chevron-left'" />
|
|
54
|
+
</button>
|
|
55
|
+
<div :class="['collapse navbar-collapse', { show: menuOpen }]">
|
|
56
|
+
<slot name="nav" orientation="vertical" :folded="foldable && folded">
|
|
57
|
+
<TNav :items="items" :folded="foldable && folded" class="pt-lg-3" />
|
|
58
|
+
</slot>
|
|
59
|
+
<div v-if="$slots.actions" class="navbar-footer"><slot name="actions" /></div>
|
|
60
|
+
</div>
|
|
61
|
+
</div>
|
|
62
|
+
</aside>
|
|
63
|
+
<header v-else :class="['navbar navbar-expand-md t-app-topbar', { 'sticky-top': theme.navSticky, 't-app-floating': theme.navFloating }]">
|
|
64
|
+
<div :class="[container, 'gap-3']">
|
|
65
|
+
<button type="button" class="navbar-toggler" :aria-expanded="menuOpen" aria-label="Menu" @click="menuOpen = !menuOpen">
|
|
66
|
+
<span class="navbar-toggler-icon" />
|
|
67
|
+
</button>
|
|
68
|
+
<div class="navbar-brand">
|
|
69
|
+
<slot name="brand" :folded="false">
|
|
70
|
+
<img v-if="logo" :src="logo" alt="" class="t-app-logo">
|
|
71
|
+
<span v-if="brand" class="text-truncate">{{ brand }}</span>
|
|
72
|
+
</slot>
|
|
73
|
+
</div>
|
|
74
|
+
<div :class="['collapse navbar-collapse', { show: menuOpen }]">
|
|
75
|
+
<slot name="nav" orientation="horizontal" :folded="false">
|
|
76
|
+
<TNav :items="items" />
|
|
77
|
+
</slot>
|
|
78
|
+
</div>
|
|
79
|
+
<div v-if="$slots.actions" class="ms-auto d-flex align-items-center gap-2"><slot name="actions" /></div>
|
|
80
|
+
</div>
|
|
81
|
+
</header>
|
|
82
|
+
<div class="page-wrapper">
|
|
83
|
+
<div class="page-body">
|
|
84
|
+
<div :class="container">
|
|
85
|
+
<slot />
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|
|
88
|
+
</div>
|
|
89
|
+
</div>
|
|
90
|
+
</div>
|
|
91
|
+
</template>
|
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
<span class="t-sketch-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
</
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
// How wide an application's page runs: default (the content capped and centered, the navigation at
|
|
3
|
+
// the edge), fluid (the full width) or boxed (the whole page in a centered box, the background
|
|
4
|
+
// around it). Each tile is a sketch of the page.
|
|
5
|
+
import TRadioGroup from './TRadioGroup.vue'
|
|
6
|
+
import { themeContainers } from '../theme'
|
|
7
|
+
import type { ThemeContainer } from '../types'
|
|
8
|
+
|
|
9
|
+
defineProps<{ disabled?: boolean; legend?: string }>()
|
|
10
|
+
|
|
11
|
+
const model = defineModel<ThemeContainer | null | undefined>()
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<template>
|
|
15
|
+
<TRadioGroup v-model="model" :items="themeContainers" variant="tiles" tile-width="8rem" :disabled="disabled" :legend="legend">
|
|
16
|
+
<template #preview="{ item }">
|
|
17
|
+
<span :class="['t-sketch t-sketch-left', { 't-sketch-boxed': item.value === 'boxed', 't-sketch-default': item.value === 'default' }]">
|
|
18
|
+
<span class="t-sketch-nav" />
|
|
19
|
+
<span class="t-sketch-page"><span /><span /><span /></span>
|
|
20
|
+
</span>
|
|
21
|
+
</template>
|
|
22
|
+
</TRadioGroup>
|
|
23
|
+
</template>
|
package/src/styles/gears.css
CHANGED
|
@@ -785,6 +785,8 @@
|
|
|
785
785
|
.t-sketch-page span { height: 0.375rem; border-radius: 1px; background: color-mix(in oklab, var(--tblr-body-color) 15%, transparent); }
|
|
786
786
|
.t-sketch-page span:first-child { width: 60%; background: var(--tblr-primary); opacity: 0.7; }
|
|
787
787
|
.t-sketch-boxed { padding: 3px 0.75rem; background: color-mix(in oklab, var(--tblr-body-color) 18%, transparent); }
|
|
788
|
+
/* Default: the navigation at the edge, the content narrower and centered beside it. */
|
|
789
|
+
.t-sketch-default .t-sketch-page { margin-inline: 0.625rem; }
|
|
788
790
|
.t-sketch-rows { display: flex; flex-direction: column; justify-content: center; width: 5.5rem; height: 3.5rem; }
|
|
789
791
|
.t-sketch-rows span { height: 0.3125rem; border-radius: 1px; background: color-mix(in oklab, var(--tblr-body-color) 25%, transparent); }
|
|
790
792
|
.t-sketch-compact { gap: 2px; }
|
package/src/theme.ts
CHANGED
|
@@ -1,50 +1,51 @@
|
|
|
1
|
-
// The choices an application's theme offers, with their labels: Tabler's theme settings
|
|
2
|
-
// (tabler-themes.css) in the order its own theme settings list them, then layout.
|
|
3
|
-
import type { SelectItem, ThemeBase, ThemeContainer, ThemeDensity, ThemeFont, ThemeNav, ThemeRadius } from './types'
|
|
4
|
-
|
|
5
|
-
export const themeAccents = [
|
|
6
|
-
'blue', 'azure', 'indigo', 'purple', 'pink', 'red', 'orange', 'yellow', 'lime', 'green', 'teal', 'cyan'
|
|
7
|
-
] as const
|
|
8
|
-
|
|
9
|
-
export const themeFonts: SelectItem<ThemeFont>[] = [
|
|
10
|
-
{ label: 'Sans-serif', value: 'sans-serif' },
|
|
11
|
-
{ label: 'Serif', value: 'serif' },
|
|
12
|
-
{ label: 'Monospace', value: 'monospace' },
|
|
13
|
-
{ label: 'Comic', value: 'comic' }
|
|
14
|
-
]
|
|
15
|
-
|
|
16
|
-
export const themeBases: SelectItem<ThemeBase>[] = [
|
|
17
|
-
{ label: 'Slate', value: 'slate' },
|
|
18
|
-
{ label: 'Gray', value: 'gray' },
|
|
19
|
-
{ label: 'Zinc', value: 'zinc' },
|
|
20
|
-
{ label: 'Neutral', value: 'neutral' },
|
|
21
|
-
{ label: 'Stone', value: 'stone' },
|
|
22
|
-
{ label: 'Mist', value: 'mist' }
|
|
23
|
-
]
|
|
24
|
-
|
|
25
|
-
// The corner radius: the theme's base radius is one of Tabler's sizes (0, xs, sm, md, lg, xl), and
|
|
26
|
-
// the other corners follow in proportion. 1.5 (md, 6px) is Tabler's own.
|
|
27
|
-
export const themeRadiusSizes: Record<ThemeRadius, string> = { '0': '0px', '0.5': '2px', '1': '4px', '1.5': '6px', '2': '8px', '2.5': '16px' }
|
|
28
|
-
const radiusNames: Record<ThemeRadius, string> = { '0': 'None', '0.5': 'Extra small', '1': 'Small', '1.5': 'Medium', '2': 'Large', '2.5': 'Extra large' }
|
|
29
|
-
export const themeRadii: SelectItem<ThemeRadius>[] = (['0', '0.5', '1', '1.5', '2', '2.5'] as ThemeRadius[])
|
|
30
|
-
.map(r => ({ label: r, value: r, description: `${radiusNames[r]}, ${themeRadiusSizes[r]}` }))
|
|
31
|
-
|
|
32
|
-
// Layout choices (not Tabler theme settings; TThemeScope and TAppLayout apply them).
|
|
33
|
-
export const themeNavs: SelectItem<ThemeNav>[] = [
|
|
34
|
-
{ label: 'Left', value: 'left' },
|
|
35
|
-
{ label: 'Top', value: 'top' }
|
|
36
|
-
]
|
|
37
|
-
|
|
38
|
-
export const themeDensities: SelectItem<ThemeDensity>[] = [
|
|
39
|
-
{ label: 'Compact', value: 'compact' },
|
|
40
|
-
{ label: 'Comfortable', value: 'comfortable' },
|
|
41
|
-
{ label: 'Spacious', value: 'spacious' }
|
|
42
|
-
]
|
|
43
|
-
|
|
44
|
-
export const themeContainers: SelectItem<ThemeContainer>[] = [
|
|
45
|
-
{ label: '
|
|
46
|
-
{ label: 'Fluid', value: 'fluid' }
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
1
|
+
// The choices an application's theme offers, with their labels: Tabler's theme settings
|
|
2
|
+
// (tabler-themes.css) in the order its own theme settings list them, then layout.
|
|
3
|
+
import type { SelectItem, ThemeBase, ThemeContainer, ThemeDensity, ThemeFont, ThemeNav, ThemeRadius } from './types'
|
|
4
|
+
|
|
5
|
+
export const themeAccents = [
|
|
6
|
+
'blue', 'azure', 'indigo', 'purple', 'pink', 'red', 'orange', 'yellow', 'lime', 'green', 'teal', 'cyan'
|
|
7
|
+
] as const
|
|
8
|
+
|
|
9
|
+
export const themeFonts: SelectItem<ThemeFont>[] = [
|
|
10
|
+
{ label: 'Sans-serif', value: 'sans-serif' },
|
|
11
|
+
{ label: 'Serif', value: 'serif' },
|
|
12
|
+
{ label: 'Monospace', value: 'monospace' },
|
|
13
|
+
{ label: 'Comic', value: 'comic' }
|
|
14
|
+
]
|
|
15
|
+
|
|
16
|
+
export const themeBases: SelectItem<ThemeBase>[] = [
|
|
17
|
+
{ label: 'Slate', value: 'slate' },
|
|
18
|
+
{ label: 'Gray', value: 'gray' },
|
|
19
|
+
{ label: 'Zinc', value: 'zinc' },
|
|
20
|
+
{ label: 'Neutral', value: 'neutral' },
|
|
21
|
+
{ label: 'Stone', value: 'stone' },
|
|
22
|
+
{ label: 'Mist', value: 'mist' }
|
|
23
|
+
]
|
|
24
|
+
|
|
25
|
+
// The corner radius: the theme's base radius is one of Tabler's sizes (0, xs, sm, md, lg, xl), and
|
|
26
|
+
// the other corners follow in proportion. 1.5 (md, 6px) is Tabler's own.
|
|
27
|
+
export const themeRadiusSizes: Record<ThemeRadius, string> = { '0': '0px', '0.5': '2px', '1': '4px', '1.5': '6px', '2': '8px', '2.5': '16px' }
|
|
28
|
+
const radiusNames: Record<ThemeRadius, string> = { '0': 'None', '0.5': 'Extra small', '1': 'Small', '1.5': 'Medium', '2': 'Large', '2.5': 'Extra large' }
|
|
29
|
+
export const themeRadii: SelectItem<ThemeRadius>[] = (['0', '0.5', '1', '1.5', '2', '2.5'] as ThemeRadius[])
|
|
30
|
+
.map(r => ({ label: r, value: r, description: `${radiusNames[r]}, ${themeRadiusSizes[r]}` }))
|
|
31
|
+
|
|
32
|
+
// Layout choices (not Tabler theme settings; TThemeScope and TAppLayout apply them).
|
|
33
|
+
export const themeNavs: SelectItem<ThemeNav>[] = [
|
|
34
|
+
{ label: 'Left', value: 'left' },
|
|
35
|
+
{ label: 'Top', value: 'top' }
|
|
36
|
+
]
|
|
37
|
+
|
|
38
|
+
export const themeDensities: SelectItem<ThemeDensity>[] = [
|
|
39
|
+
{ label: 'Compact', value: 'compact' },
|
|
40
|
+
{ label: 'Comfortable', value: 'comfortable' },
|
|
41
|
+
{ label: 'Spacious', value: 'spacious' }
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
export const themeContainers: SelectItem<ThemeContainer>[] = [
|
|
45
|
+
{ label: 'Default', value: 'default' },
|
|
46
|
+
{ label: 'Fluid', value: 'fluid' },
|
|
47
|
+
{ label: 'Boxed', value: 'boxed' }
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
/** Whether an accent is a custom color (#rrggbb) rather than one of Tabler's named colors. */
|
|
51
|
+
export const isCustomAccent = (accent: string | undefined) => !!accent && accent.startsWith('#')
|
package/src/types.ts
CHANGED
|
@@ -211,7 +211,9 @@ export type ThemeAccent = 'blue' | 'azure' | 'indigo' | 'purple' | 'pink' | 'red
|
|
|
211
211
|
// get, and whether the page sits in a box.
|
|
212
212
|
export type ThemeNav = 'left' | 'top'
|
|
213
213
|
export type ThemeDensity = 'compact' | 'comfortable' | 'spacious'
|
|
214
|
-
|
|
214
|
+
// default: the content capped and centered, the navigation at the window's edge (Tabler's own layout);
|
|
215
|
+
// fluid: the full width; boxed: the whole page, navigation too, in a centered box.
|
|
216
|
+
export type ThemeContainer = 'default' | 'fluid' | 'boxed'
|
|
215
217
|
|
|
216
218
|
export interface ThemeSettings {
|
|
217
219
|
accent?: ThemeAccent
|