@jskit-ai/shell-web 0.2.9 → 0.2.11

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.
Files changed (69) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/fixtures/adaptive-shell/src/App.vue +2 -0
  3. package/fixtures/adaptive-shell/src/RecordListPage.vue +22 -0
  4. package/fixtures/adaptive-shell/src/RecordPage.vue +30 -0
  5. package/fixtures/adaptive-shell/src/ScreenPage.vue +7 -3
  6. package/fixtures/adaptive-shell/src/SettingsPage.vue +24 -0
  7. package/fixtures/adaptive-shell/src/main.js +60 -55
  8. package/fixtures/adaptive-shell/src/records.js +13 -0
  9. package/fixtures/adaptive-shell/src/theme/index.js +3 -0
  10. package/locales/en.json +1 -0
  11. package/package.json +17 -5
  12. package/patterns/application-shell/PATTERN.md +3 -1
  13. package/patterns/application-shell/example/expected-existing/src/pages/home/index.vue +5 -18
  14. package/patterns/application-shell/example/expected-existing/src/views/NotFound.vue +14 -0
  15. package/patterns/application-shell/example/src/pages/home/index.vue +21 -57
  16. package/patterns/application-shell/example/src/pages/home/settings/general/index.vue +24 -19
  17. package/patterns/application-shell/example/src/pages/home/settings.vue +27 -84
  18. package/patterns/application-shell/example/src/views/NotFound.vue +15 -0
  19. package/patterns/page-and-placement/example/src/components/SyncStatusElement.vue +2 -2
  20. package/patterns/page-and-placement/example/src/pages/home/reports/activity.vue +1 -1
  21. package/patterns/page-and-placement/example/src/pages/home/reports/overview.vue +1 -1
  22. package/patterns/page-and-placement/example/src/pages/home/reports.vue +6 -3
  23. package/patterns/page-and-placement/example/src/placement.js +1 -1
  24. package/src/client/components/ShellErrorHost.vue +13 -15
  25. package/src/client/components/ShellLayout.vue +388 -186
  26. package/src/client/components/ShellListDetail.vue +77 -0
  27. package/src/client/components/ShellMenuLinkItem.vue +10 -24
  28. package/src/client/components/ShellNavigationItem.vue +175 -0
  29. package/src/client/components/ShellNavigationScope.vue +18 -0
  30. package/src/client/components/ShellOutlet.vue +1 -1
  31. package/src/client/components/ShellOutletMenuWidget.vue +2 -2
  32. package/src/client/components/ShellPageAction.vue +91 -0
  33. package/src/client/components/ShellPageActions.vue +32 -0
  34. package/src/client/components/ShellSurfaceAwareMenuLinkItem.vue +10 -24
  35. package/src/client/components/ShellTabLinkItem.vue +77 -3
  36. package/src/client/composables/useShellDrawer.js +28 -18
  37. package/src/client/composables/useShellPageTitle.js +15 -0
  38. package/src/client/composables/useShellRouteTransition.js +1 -1
  39. package/src/client/composables/useShellWindowSizeClass.js +21 -0
  40. package/src/client/error/presentation.js +3 -5
  41. package/src/client/index.js +7 -0
  42. package/src/client/lib/menuIcons.js +21 -65
  43. package/src/client/navigation/documentNavigation.js +38 -0
  44. package/src/client/navigation/shellNavigationRuntime.js +480 -0
  45. package/src/client/navigation/useShellNavigation.js +94 -0
  46. package/src/client/providers/ShellWebClientProvider.js +11 -0
  47. package/src/client/support/drawerPresentation.js +9 -4
  48. package/src/client/support/drawerWidth.js +18 -1
  49. package/src/client/support/navigationPresentation.js +40 -0
  50. package/src/client/support/shellLayoutClass.js +6 -25
  51. package/src/client/support/windowSizeClass.js +29 -0
  52. package/src/test/adaptiveShellSmoke.js +43 -16
  53. package/src/test/shellNavigation.js +32 -0
  54. package/test/adaptiveShell.browser.test.js +207 -111
  55. package/test/clientUpdate.test.js +6 -1
  56. package/test/drawerPresentation.test.js +7 -7
  57. package/test/errorPresentation.test.js +4 -5
  58. package/test/materialBaselines.browser.test.js +96 -0
  59. package/test/menuIcons.test.js +14 -22
  60. package/test/outletMenuWidgetContract.test.js +2 -3
  61. package/test/playwrightContract.test.js +3 -1
  62. package/test/provider.test.js +9 -1
  63. package/test/settingsPlacementContract.test.js +33 -28
  64. package/test/shellGestureSupport.test.js +21 -9
  65. package/test/translation.test.js +2 -2
  66. package/test/useShellDrawer.test.js +20 -5
  67. package/test/useShellRouteTransition.test.js +3 -3
  68. package/patterns/application-shell/example/src/pages/home/settings/index.vue +0 -7
  69. package/src/client/components/ShellNavigationTooltip.vue +0 -39
@@ -0,0 +1,77 @@
1
+ <script setup>
2
+ import { computed, onBeforeUnmount, watch } from "vue";
3
+ import { useShellWindowSizeClass } from "../composables/useShellWindowSizeClass.js";
4
+ import { useShellNavigationRuntime } from "../navigation/useShellNavigation.js";
5
+
6
+ // Material 3's list-detail layout. Expanded and large windows show the list pane beside the detail pane, so the
7
+ // detail page needs no Up arrow to reach the list, and with nothing open the detail pane shows the page's own landing
8
+ // child (a placeholder) if it has one. Compact and medium windows show one pane at a time, the detail (with its arrow
9
+ // back to the list) while one is open. The detail page declares the list page as its parent.
10
+ const props = defineProps({
11
+ // Whether a detail page is open, such as `route.name !== "settings"`.
12
+ detailOpen: {
13
+ type: Boolean,
14
+ default: false
15
+ }
16
+ });
17
+
18
+ const runtime = useShellNavigationRuntime();
19
+ const { isExpanded, isLarge } = useShellWindowSizeClass();
20
+ const twoPane = computed(() => isExpanded.value || isLarge.value);
21
+ let releaseParentPane = null;
22
+
23
+ function releasePane() {
24
+ releaseParentPane?.();
25
+ releaseParentPane = null;
26
+ }
27
+
28
+ watch(
29
+ () => twoPane.value && props.detailOpen,
30
+ (parentVisible) => {
31
+ if (parentVisible && !releaseParentPane) {
32
+ releaseParentPane = runtime.showParentPane();
33
+ } else if (!parentVisible) {
34
+ releasePane();
35
+ }
36
+ },
37
+ { immediate: true }
38
+ );
39
+
40
+ onBeforeUnmount(releasePane);
41
+ </script>
42
+
43
+ <template>
44
+ <div
45
+ class="shell-list-detail"
46
+ :class="{ 'shell-list-detail--two-pane': twoPane }"
47
+ data-testid="jskit-shell-list-detail"
48
+ >
49
+ <section v-show="twoPane || !props.detailOpen" class="shell-list-detail__list">
50
+ <slot name="list" />
51
+ </section>
52
+ <section v-if="twoPane || props.detailOpen" class="shell-list-detail__detail">
53
+ <slot name="detail" />
54
+ </section>
55
+ </div>
56
+ </template>
57
+
58
+ <style scoped>
59
+ .shell-list-detail {
60
+ display: grid;
61
+ gap: 24px;
62
+ grid-template-columns: minmax(0, 1fr);
63
+ }
64
+
65
+ .shell-list-detail--two-pane {
66
+ grid-template-columns: 360px minmax(0, 1fr);
67
+ }
68
+
69
+ .shell-list-detail__list,
70
+ .shell-list-detail__detail {
71
+ min-width: 0;
72
+ }
73
+
74
+ .shell-list-detail:not(.shell-list-detail--two-pane) .shell-list-detail__list {
75
+ max-width: 840px;
76
+ }
77
+ </style>
@@ -3,8 +3,7 @@ import { computed } from "vue";
3
3
  import { useWebPlacementContext } from "../placement/index.js";
4
4
  import { resolveMenuLinkIcon } from "../lib/menuIcons.js";
5
5
  import { resolveMenuLinkHref } from "../support/menuLinkTarget.js";
6
- import { activateShellNavigationLinkOnSpace } from "../support/navigationLinkKeyboard.js";
7
- import ShellNavigationTooltip from "./ShellNavigationTooltip.vue";
6
+ import ShellNavigationItem from "./ShellNavigationItem.vue";
8
7
  import { useJskitText } from "../i18n.js";
9
8
 
10
9
  // The label may be a message key, { key, fallback } or plain text.
@@ -48,26 +47,13 @@ const resolvedIcon = computed(() =>
48
47
  </script>
49
48
 
50
49
  <template>
51
- <ShellNavigationTooltip v-if="resolvedTarget.href" :label="resolvedLabel">
52
- <template #default="{ activatorProps }">
53
- <v-list-item
54
- v-bind="activatorProps"
55
- class="shell-menu-link-item"
56
- :title="resolvedLabel"
57
- :to="resolvedTarget.sameOrigin ? resolvedTarget.href : undefined"
58
- :href="resolvedTarget.sameOrigin ? undefined : resolvedTarget.href"
59
- :prepend-icon="resolvedIcon || undefined"
60
- :disabled="props.disabled"
61
- :exact="props.exact"
62
- :aria-label="resolvedLabel"
63
- @keydown.space="activateShellNavigationLinkOnSpace"
64
- />
65
- </template>
66
- </ShellNavigationTooltip>
50
+ <ShellNavigationItem
51
+ v-if="resolvedTarget.href"
52
+ :label="resolvedLabel"
53
+ :href="resolvedTarget.href"
54
+ :same-origin="resolvedTarget.sameOrigin"
55
+ :icon="resolvedIcon"
56
+ :disabled="props.disabled"
57
+ :exact="props.exact"
58
+ />
67
59
  </template>
68
-
69
- <style scoped>
70
- .shell-menu-link-item {
71
- min-height: 48px;
72
- }
73
- </style>
@@ -0,0 +1,175 @@
1
+ <script setup>
2
+ import { computed, inject } from "vue";
3
+ import { useLink } from "vue-router";
4
+ import {
5
+ NO_SHELL_NAVIGATION_PRESENTATION,
6
+ NO_VUETIFY_ICONS,
7
+ SHELL_NAVIGATION_PRESENTATION_KEY,
8
+ VUETIFY_ICONS_KEY,
9
+ filledIconAlias
10
+ } from "../support/navigationPresentation.js";
11
+ import { activateShellNavigationLinkOnSpace } from "../support/navigationLinkKeyboard.js";
12
+
13
+ // One navigation destination as Material 3 draws it where it sits: a drawer item (a 56dp pill), a rail item (icon in a
14
+ // 56x32 indicator with its label below) or a list item. The active destination's icon is filled.
15
+ const props = defineProps({
16
+ label: {
17
+ type: String,
18
+ default: ""
19
+ },
20
+ href: {
21
+ type: String,
22
+ default: ""
23
+ },
24
+ sameOrigin: {
25
+ type: Boolean,
26
+ default: true
27
+ },
28
+ icon: {
29
+ type: String,
30
+ default: ""
31
+ },
32
+ disabled: {
33
+ type: Boolean,
34
+ default: false
35
+ },
36
+ exact: {
37
+ type: Boolean,
38
+ default: false
39
+ }
40
+ });
41
+
42
+ /** @type {{ value: string }} */
43
+ const presentation = inject(SHELL_NAVIGATION_PRESENTATION_KEY, NO_SHELL_NAVIGATION_PRESENTATION);
44
+ /** @type {{ aliases?: Record<string, unknown> }} */
45
+ const iconOptions = inject(VUETIFY_ICONS_KEY, NO_VUETIFY_ICONS);
46
+ const link = useLink({ to: computed(() => (props.sameOrigin && props.href) || "/") });
47
+ const active = computed(() =>
48
+ props.sameOrigin && Boolean(props.exact ? link.isExactActive.value : link.isActive.value)
49
+ );
50
+ const displayIcon = computed(() => (active.value ? filledIconAlias(props.icon, iconOptions.aliases) : props.icon));
51
+ const rail = computed(() => presentation.value === "rail");
52
+ </script>
53
+
54
+ <template>
55
+ <v-list-item
56
+ v-if="rail"
57
+ class="shell-menu-link-item shell-menu-link-item--rail"
58
+ :to="props.sameOrigin ? props.href : undefined"
59
+ :href="props.sameOrigin ? undefined : props.href"
60
+ :active="active"
61
+ :disabled="props.disabled"
62
+ :ripple="false"
63
+ @keydown.space="activateShellNavigationLinkOnSpace"
64
+ >
65
+ <span class="shell-menu-link-item__indicator">
66
+ <v-icon v-if="displayIcon" :icon="displayIcon" />
67
+ </span>
68
+ <span class="shell-menu-link-item__rail-label">{{ props.label }}</span>
69
+ </v-list-item>
70
+ <v-list-item
71
+ v-else
72
+ class="shell-menu-link-item"
73
+ :title="props.label"
74
+ :to="props.sameOrigin ? props.href : undefined"
75
+ :href="props.sameOrigin ? undefined : props.href"
76
+ :prepend-icon="displayIcon || undefined"
77
+ :active="active"
78
+ :disabled="props.disabled"
79
+ @keydown.space="activateShellNavigationLinkOnSpace"
80
+ />
81
+ </template>
82
+
83
+ <style scoped>
84
+ .shell-menu-link-item {
85
+ --v-activated-opacity: 0;
86
+ border-radius: 9999px;
87
+ color: rgb(var(--v-theme-on-surface-variant));
88
+ min-height: 56px;
89
+ }
90
+
91
+ .shell-menu-link-item :deep(.v-list-item-title) {
92
+ font-size: 0.875rem;
93
+ font-weight: 500;
94
+ letter-spacing: 0.00625rem;
95
+ line-height: 1.25rem;
96
+ }
97
+
98
+ .shell-menu-link-item:not(.shell-menu-link-item--rail).v-list-item--active {
99
+ background: rgb(var(--v-theme-secondary-container));
100
+ color: rgb(var(--v-theme-on-secondary-container));
101
+ }
102
+
103
+ .shell-menu-link-item :deep(.v-list-item__prepend > .v-icon) {
104
+ opacity: 1;
105
+ }
106
+
107
+ .shell-menu-link-item--rail {
108
+ background: transparent;
109
+ border-radius: 0;
110
+ min-height: 56px;
111
+ padding: 0;
112
+ }
113
+
114
+ .shell-menu-link-item--rail > :deep(.v-list-item__overlay) {
115
+ display: none;
116
+ }
117
+
118
+ .shell-menu-link-item--rail :deep(.v-list-item__content) {
119
+ align-items: center;
120
+ display: flex;
121
+ flex-direction: column;
122
+ gap: 4px;
123
+ overflow: visible;
124
+ }
125
+
126
+ .shell-menu-link-item__indicator {
127
+ align-items: center;
128
+ border-radius: 16px;
129
+ display: flex;
130
+ height: 32px;
131
+ justify-content: center;
132
+ overflow: hidden;
133
+ position: relative;
134
+ width: 56px;
135
+ }
136
+
137
+ .shell-menu-link-item__indicator::before {
138
+ background: currentColor;
139
+ content: "";
140
+ inset: 0;
141
+ opacity: 0;
142
+ position: absolute;
143
+ transition: opacity 200ms cubic-bezier(0.2, 0, 0, 1);
144
+ }
145
+
146
+ .shell-menu-link-item--rail:hover .shell-menu-link-item__indicator::before {
147
+ opacity: var(--v-hover-opacity);
148
+ }
149
+
150
+ .shell-menu-link-item--rail:focus-visible .shell-menu-link-item__indicator::before,
151
+ .shell-menu-link-item--rail:active .shell-menu-link-item__indicator::before {
152
+ opacity: var(--v-focus-opacity);
153
+ }
154
+
155
+ .shell-menu-link-item--rail.v-list-item--active .shell-menu-link-item__indicator {
156
+ background: rgb(var(--v-theme-secondary-container));
157
+ color: rgb(var(--v-theme-on-secondary-container));
158
+ }
159
+
160
+ .shell-menu-link-item__rail-label {
161
+ font-size: 0.75rem;
162
+ font-weight: 500;
163
+ letter-spacing: 0.03125rem;
164
+ line-height: 1rem;
165
+ max-width: 72px;
166
+ overflow: hidden;
167
+ text-align: center;
168
+ text-overflow: ellipsis;
169
+ white-space: nowrap;
170
+ }
171
+
172
+ .shell-menu-link-item--rail.v-list-item--active .shell-menu-link-item__rail-label {
173
+ color: rgb(var(--v-theme-on-surface));
174
+ }
175
+ </style>
@@ -0,0 +1,18 @@
1
+ <script setup>
2
+ import { provide, toRef } from "vue";
3
+ import { SHELL_NAVIGATION_PRESENTATION_KEY } from "../support/navigationPresentation.js";
4
+
5
+ // Tells the navigation items inside it how to present: as a "rail" or a "drawer".
6
+ const props = defineProps({
7
+ presentation: {
8
+ type: String,
9
+ default: "drawer"
10
+ }
11
+ });
12
+
13
+ provide(SHELL_NAVIGATION_PRESENTATION_KEY, toRef(props, "presentation"));
14
+ </script>
15
+
16
+ <template>
17
+ <slot />
18
+ </template>
@@ -74,7 +74,7 @@ const resolvedTargetId = computed(() => {
74
74
  return String(props.target || "").trim();
75
75
  });
76
76
 
77
- const resolvedLayoutClass = computed(() => resolveShellLayoutClass(display.name.value));
77
+ const resolvedLayoutClass = computed(() => resolveShellLayoutClass(display.width.value));
78
78
 
79
79
  const placements = computed(() => {
80
80
  void revision.value;
@@ -1,5 +1,4 @@
1
1
  <script setup>
2
- import { mdiCogOutline } from "@mdi/js";
3
2
  import ShellOutlet from "./ShellOutlet.vue";
4
3
  import { useJskitText } from "../i18n.js";
5
4
 
@@ -12,7 +11,7 @@ const props = defineProps({
12
11
  },
13
12
  icon: {
14
13
  type: String,
15
- default: mdiCogOutline
14
+ default: "$settings"
16
15
  },
17
16
  // Defaults to the translated "Tools"; a passed label may be a message key.
18
17
  ariaLabel: {
@@ -41,6 +40,7 @@ const props = defineProps({
41
40
  v-bind="activatorProps"
42
41
  icon
43
42
  variant="text"
43
+ color="on-surface-variant"
44
44
  :aria-label="props.ariaLabel === undefined ? t('jskit.shell.layout.tools') : text(props.ariaLabel)"
45
45
  >
46
46
  <v-icon :icon="props.icon" />
@@ -0,0 +1,91 @@
1
+ <script setup>
2
+ import { computed } from "vue";
3
+ import { useShellWindowSizeClass } from "../composables/useShellWindowSizeClass.js";
4
+ import { useJskitText } from "../i18n.js";
5
+
6
+ // One page action in the top app bar. On compact windows a secondary action shows as an icon button named by its
7
+ // label; the page's primary action (`primary`, at most one) keeps its label as a filled button. Native button
8
+ // attributes such as `type="submit"` and `form` pass through, so an app bar Save can submit the page's form.
9
+ const props = defineProps({
10
+ // A message key, { key, fallback } or plain text.
11
+ label: {
12
+ type: [String, Object],
13
+ required: true
14
+ },
15
+ icon: {
16
+ type: String,
17
+ default: ""
18
+ },
19
+ to: {
20
+ type: [String, Object],
21
+ default: undefined
22
+ },
23
+ // A link outside the app (another origin); `to` is for the app's own pages.
24
+ href: {
25
+ type: String,
26
+ default: undefined
27
+ },
28
+ primary: {
29
+ type: Boolean,
30
+ default: false
31
+ },
32
+ disabled: {
33
+ type: Boolean,
34
+ default: false
35
+ },
36
+ loading: {
37
+ type: Boolean,
38
+ default: false
39
+ }
40
+ });
41
+ const emit = defineEmits(["click"]);
42
+
43
+ const { text } = useJskitText();
44
+ const { isCompact } = useShellWindowSizeClass();
45
+ const resolvedLabel = computed(() => text(props.label));
46
+ const iconOnly = computed(() => Boolean(props.icon) && isCompact.value && !props.primary);
47
+
48
+ function handleClick(event) {
49
+ emit("click", event);
50
+ }
51
+ </script>
52
+
53
+ <template>
54
+ <v-tooltip v-if="iconOnly" :text="resolvedLabel" location="bottom">
55
+ <template #activator="{ props: tooltipProps }">
56
+ <v-btn
57
+ v-bind="tooltipProps"
58
+ class="shell-page-action"
59
+ :icon="props.icon"
60
+ variant="text"
61
+ color="on-surface-variant"
62
+ :to="props.to"
63
+ :href="props.href"
64
+ :disabled="props.disabled"
65
+ :loading="props.loading"
66
+ :aria-label="resolvedLabel"
67
+ @click="handleClick"
68
+ />
69
+ </template>
70
+ </v-tooltip>
71
+ <v-btn
72
+ v-else
73
+ class="shell-page-action shell-page-action--labelled"
74
+ :variant="props.primary ? 'flat' : 'text'"
75
+ :color="props.primary ? 'primary' : 'on-surface-variant'"
76
+ :prepend-icon="props.icon || undefined"
77
+ :to="props.to"
78
+ :href="props.href"
79
+ :disabled="props.disabled"
80
+ :loading="props.loading"
81
+ @click="handleClick"
82
+ >
83
+ {{ resolvedLabel }}
84
+ </v-btn>
85
+ </template>
86
+
87
+ <style scoped>
88
+ .shell-page-action--labelled {
89
+ margin-inline: 4px;
90
+ }
91
+ </style>
@@ -0,0 +1,32 @@
1
+ <script setup>
2
+ import { inject } from "vue";
3
+ import {
4
+ NO_SHELL_PAGE_ACTIONS_TARGET,
5
+ SHELL_PAGE_ACTIONS_TARGET_KEY
6
+ } from "../support/navigationPresentation.js";
7
+
8
+ /**
9
+ * The app bar's actions target. The current page's actions show in the shell's top app bar after the page title
10
+ * (Material 3 puts a page's actions there); put ShellPageAction buttons inside. Outside a ShellLayout they render
11
+ * where they are written.
12
+ * @type {string}
13
+ */
14
+ const target = inject(SHELL_PAGE_ACTIONS_TARGET_KEY, NO_SHELL_PAGE_ACTIONS_TARGET);
15
+ </script>
16
+
17
+ <template>
18
+ <Teleport defer :to="target || 'body'" :disabled="!target">
19
+ <div class="shell-page-actions" data-testid="jskit-shell-page-actions">
20
+ <slot />
21
+ </div>
22
+ </Teleport>
23
+ </template>
24
+
25
+ <style scoped>
26
+ .shell-page-actions {
27
+ align-items: center;
28
+ display: flex;
29
+ flex: 0 0 auto;
30
+ gap: 0;
31
+ }
32
+ </style>
@@ -3,34 +3,20 @@ import {
3
3
  shellNavigationLinkProps,
4
4
  useShellNavigationLink
5
5
  } from "../composables/useShellNavigationLink.js";
6
- import { activateShellNavigationLinkOnSpace } from "../support/navigationLinkKeyboard.js";
7
- import ShellNavigationTooltip from "./ShellNavigationTooltip.vue";
6
+ import ShellNavigationItem from "./ShellNavigationItem.vue";
8
7
 
9
8
  const props = defineProps(shellNavigationLinkProps);
10
9
  const { resolvedLabel, resolvedTarget, resolvedIcon } = useShellNavigationLink(props);
11
10
  </script>
12
11
 
13
12
  <template>
14
- <ShellNavigationTooltip v-if="resolvedTarget.href" :label="resolvedLabel">
15
- <template #default="{ activatorProps }">
16
- <v-list-item
17
- v-bind="activatorProps"
18
- class="shell-menu-link-item"
19
- :title="resolvedLabel"
20
- :to="resolvedTarget.sameOrigin ? resolvedTarget.href : undefined"
21
- :href="resolvedTarget.sameOrigin ? undefined : resolvedTarget.href"
22
- :prepend-icon="resolvedIcon || undefined"
23
- :disabled="props.disabled"
24
- :exact="props.exact"
25
- :aria-label="resolvedLabel"
26
- @keydown.space="activateShellNavigationLinkOnSpace"
27
- />
28
- </template>
29
- </ShellNavigationTooltip>
13
+ <ShellNavigationItem
14
+ v-if="resolvedTarget.href"
15
+ :label="resolvedLabel"
16
+ :href="resolvedTarget.href"
17
+ :same-origin="resolvedTarget.sameOrigin"
18
+ :icon="resolvedIcon"
19
+ :disabled="props.disabled"
20
+ :exact="props.exact"
21
+ />
30
22
  </template>
31
-
32
- <style scoped>
33
- .shell-menu-link-item {
34
- min-height: 48px;
35
- }
36
- </style>
@@ -1,41 +1,115 @@
1
1
  <script setup>
2
+ import { computed, inject } from "vue";
3
+ import { useLink } from "vue-router";
2
4
  import {
3
5
  shellNavigationLinkProps,
4
6
  useShellNavigationLink
5
7
  } from "../composables/useShellNavigationLink.js";
8
+ import { NO_VUETIFY_ICONS, VUETIFY_ICONS_KEY, filledIconAlias } from "../support/navigationPresentation.js";
6
9
  import { useJskitText } from "../i18n.js";
7
10
 
11
+ // A Material 3 navigation bar destination: the icon in a 64x32 indicator with its label below; the active one's
12
+ // indicator is filled and so is its icon.
8
13
  const props = defineProps(shellNavigationLinkProps);
9
14
  const { t } = useJskitText();
10
15
  const { resolvedLabel, resolvedTarget, resolvedIcon } = useShellNavigationLink(props);
16
+ /** @type {{ aliases?: Record<string, unknown> }} */
17
+ const iconOptions = inject(VUETIFY_ICONS_KEY, NO_VUETIFY_ICONS);
18
+ const link = useLink({ to: computed(() => (resolvedTarget.value.sameOrigin && resolvedTarget.value.href) || "/") });
19
+ const active = computed(() =>
20
+ resolvedTarget.value.sameOrigin && Boolean(props.exact ? link.isExactActive.value : link.isActive.value)
21
+ );
22
+ const displayIcon = computed(() =>
23
+ active.value ? filledIconAlias(resolvedIcon.value, iconOptions.aliases) : resolvedIcon.value
24
+ );
11
25
  </script>
12
26
 
13
27
  <template>
14
28
  <v-btn
15
29
  v-if="resolvedTarget.href"
16
30
  class="tab-link-item text-none"
31
+ :class="{ 'tab-link-item--active': active }"
17
32
  :to="resolvedTarget.sameOrigin ? resolvedTarget.href : undefined"
18
33
  :href="resolvedTarget.sameOrigin ? undefined : resolvedTarget.href"
34
+ :active="active"
19
35
  :disabled="props.disabled"
20
36
  :exact="props.exact"
21
- min-width="72"
37
+ :ripple="false"
38
+ min-width="0"
22
39
  stacked
23
40
  >
24
- <v-icon v-if="resolvedIcon" :icon="resolvedIcon" />
41
+ <span class="tab-link-item__indicator">
42
+ <v-icon v-if="displayIcon" :icon="displayIcon" />
43
+ </span>
25
44
  <span class="tab-link-item__label">{{ resolvedLabel || t("jskit.shell.layout.tab") }}</span>
26
45
  </v-btn>
27
46
  </template>
28
47
 
29
48
  <style scoped>
30
49
  .tab-link-item {
31
- flex: 0 0 auto;
50
+ color: rgb(var(--v-theme-on-surface-variant));
51
+ flex: 1 1 0;
52
+ height: 100%;
32
53
  min-height: 48px;
54
+ padding-inline: 0;
55
+ }
56
+
57
+ .tab-link-item > :deep(.v-btn__overlay),
58
+ .tab-link-item > :deep(.v-btn__underlay) {
59
+ display: none;
60
+ }
61
+
62
+ .tab-link-item :deep(.v-btn__content) {
63
+ flex-direction: column;
64
+ gap: 4px;
65
+ }
66
+
67
+ .tab-link-item__indicator {
68
+ align-items: center;
69
+ border-radius: 16px;
70
+ display: flex;
71
+ height: 32px;
72
+ justify-content: center;
73
+ overflow: hidden;
74
+ position: relative;
75
+ width: 64px;
76
+ }
77
+
78
+ .tab-link-item__indicator::before {
79
+ background: currentColor;
80
+ content: "";
81
+ inset: 0;
82
+ opacity: 0;
83
+ position: absolute;
84
+ transition: opacity 200ms cubic-bezier(0.2, 0, 0, 1);
85
+ }
86
+
87
+ .tab-link-item:hover .tab-link-item__indicator::before {
88
+ opacity: var(--v-hover-opacity);
89
+ }
90
+
91
+ .tab-link-item:focus-visible .tab-link-item__indicator::before,
92
+ .tab-link-item:active .tab-link-item__indicator::before {
93
+ opacity: var(--v-focus-opacity);
94
+ }
95
+
96
+ .tab-link-item--active .tab-link-item__indicator {
97
+ background: rgb(var(--v-theme-secondary-container));
98
+ color: rgb(var(--v-theme-on-secondary-container));
33
99
  }
34
100
 
35
101
  .tab-link-item__label {
102
+ font-size: 0.75rem;
103
+ font-weight: 500;
104
+ letter-spacing: 0.03125rem;
105
+ line-height: 1rem;
36
106
  max-width: 5.5rem;
37
107
  overflow: hidden;
38
108
  text-overflow: ellipsis;
39
109
  white-space: nowrap;
40
110
  }
111
+
112
+ .tab-link-item--active .tab-link-item__label {
113
+ color: rgb(var(--v-theme-on-surface));
114
+ }
41
115
  </style>