@thekestongroup/ui 0.19.0 → 0.20.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thekestongroup/ui",
3
- "version": "0.19.0",
3
+ "version": "0.20.0",
4
4
  "description": "Keston UI — Vue 3 + Reka UI + Tailwind CSS component library",
5
5
  "license": "SEE LICENSE IN LICENSE",
6
6
  "repository": {
@@ -120,7 +120,7 @@ function linkAttrs(link: FooterLink) {
120
120
  side by side), labelled for screen readers. -->
121
121
  <div v-if="showLanguages || themeSwitcher" class="flex flex-wrap items-center gap-2">
122
122
  <LanguageSwitcher v-if="showLanguages" hide-label class="w-44" />
123
- <ThemeSwitcher v-if="themeSwitcher" hide-label appearance="segmented" />
123
+ <ThemeSwitcher v-if="themeSwitcher" hide-label appearance="icons" />
124
124
  </div>
125
125
  <p v-if="appName || version || build" class="flex flex-wrap items-baseline gap-x-1.5">
126
126
  <span v-if="appName" class="font-bold text-ink/80">{{ appName }}</span>
@@ -2,6 +2,7 @@
2
2
  import { computed, useId, type Component, type HTMLAttributes } from 'vue'
3
3
  import { RadioGroupItem, RadioGroupRoot } from 'reka-ui'
4
4
  import { cn } from '../../lib/cn'
5
+ import Tooltip from '../Tooltip/Tooltip.vue'
5
6
 
6
7
  /**
7
8
  * One choice from two to four short options, shown as a row of tab-like
@@ -30,7 +31,7 @@ export interface SegmentedControlProps {
30
31
  options: SegmentedOption[]
31
32
  /**
32
33
  * Icons only: each option's label becomes its accessible name and shows
33
- * as a tooltip-style title. Every option needs an icon.
34
+ * in a Tooltip on hover or keyboard focus. Every option needs an icon.
34
35
  */
35
36
  iconOnly?: boolean
36
37
  size?: 'sm' | 'md'
@@ -67,27 +68,29 @@ const itemSize = computed(() => (props.iconOnly ? `${sizes[props.size].icon} jus
67
68
  class="inline-flex w-max max-w-full gap-0.5 rounded-lg bg-ink/5 p-0.5"
68
69
  >
69
70
  <!-- The chosen one is raised like a basic button (control colours: a
70
- step above the track in light and dark). -->
71
- <RadioGroupItem
72
- v-for="option in options"
73
- :key="option.value"
74
- :value="option.value"
75
- :disabled="option.disabled"
76
- :aria-label="iconOnly ? option.label : undefined"
77
- :title="iconOnly ? option.label : undefined"
78
- :class="
79
- cn(
80
- 'inline-flex shrink-0 cursor-pointer items-center rounded-md font-bold whitespace-nowrap text-ink/65 outline-2 outline-offset-1 outline-transparent transition-colors duration-150 motion-reduce:transition-none',
81
- 'not-disabled:hover:text-ink focus-visible:outline-focus',
82
- 'data-[state=checked]:bg-control data-[state=checked]:text-ink data-[state=checked]:shadow-xs',
83
- 'disabled:cursor-not-allowed disabled:opacity-40',
84
- itemSize
85
- )
86
- "
87
- >
88
- <component :is="option.icon" v-if="option.icon" aria-hidden="true" />
89
- <span v-if="!iconOnly">{{ option.label }}</span>
90
- </RadioGroupItem>
71
+ step above the track in light and dark). Keyed off aria-checked,
72
+ not data-state, which the Tooltip's trigger sets to its own. -->
73
+ <!-- Icons only: the name in a tooltip (on hover and keyboard focus),
74
+ as well as for screen readers. -->
75
+ <Tooltip v-for="option in options" :key="option.value" :text="option.label" :disabled="!iconOnly" side="top">
76
+ <RadioGroupItem
77
+ :value="option.value"
78
+ :disabled="option.disabled"
79
+ :aria-label="iconOnly ? option.label : undefined"
80
+ :class="
81
+ cn(
82
+ 'inline-flex shrink-0 cursor-pointer items-center rounded-md font-bold whitespace-nowrap text-ink/65 outline-2 outline-offset-1 outline-transparent transition-colors duration-150 motion-reduce:transition-none',
83
+ 'not-disabled:hover:text-ink focus-visible:outline-focus',
84
+ 'aria-checked:bg-control aria-checked:text-ink aria-checked:shadow-xs',
85
+ 'disabled:cursor-not-allowed disabled:opacity-40',
86
+ itemSize
87
+ )
88
+ "
89
+ >
90
+ <component :is="option.icon" v-if="option.icon" aria-hidden="true" />
91
+ <span v-if="!iconOnly">{{ option.label }}</span>
92
+ </RadioGroupItem>
93
+ </Tooltip>
91
94
  </RadioGroupRoot>
92
95
  </div>
93
96
  </template>
@@ -20,3 +20,12 @@ type Story = StoryObj<typeof meta>;
20
20
  export const Default: Story = {};
21
21
 
22
22
  export const HiddenLabel: Story = { args: { hideLabel: true } };
23
+
24
+ /** Light / Dark / System side by side, with labels. */
25
+ export const Segmented: Story = { args: { appearance: "segmented", hideLabel: true } };
26
+
27
+ /**
28
+ * Only the icons, each named in a tooltip on hover or keyboard focus (and
29
+ * for screen readers): the smallest, as in the Footer.
30
+ */
31
+ export const Icons: Story = { args: { appearance: "icons", hideLabel: true } };
@@ -20,9 +20,10 @@ export interface ThemeSwitcherProps {
20
20
  disabled?: boolean
21
21
  /**
22
22
  * select: a dropdown (Settings, the account menu). segmented: Light / Dark
23
- * / System side by side with icons, small: for the footer.
23
+ * / System side by side with icons, small. icons: the same with only the
24
+ * sun, moon and monitor, each named in a tooltip: for the footer.
24
25
  */
25
- appearance?: 'select' | 'segmented'
26
+ appearance?: 'select' | 'segmented' | 'icons'
26
27
  class?: HTMLAttributes['class']
27
28
  }
28
29
 
@@ -34,7 +35,8 @@ const options = computed(() => [
34
35
  { label: t('ui.themeSwitcher.light'), value: 'light', icon: Sun },
35
36
  { label: t('ui.themeSwitcher.dark'), value: 'dark', icon: Moon },
36
37
  {
37
- // "System" fits the row; the dropdown has room for "Match device".
38
+ // "System" fits the row; the dropdown and the tooltip have room for
39
+ // "Match device".
38
40
  label: props.appearance === 'segmented' ? t('ui.themeSwitcher.systemShort') : t('ui.themeSwitcher.system'),
39
41
  value: 'system',
40
42
  icon: Monitor
@@ -49,9 +51,10 @@ const model = computed({
49
51
 
50
52
  <template>
51
53
  <SegmentedControl
52
- v-if="appearance === 'segmented'"
54
+ v-if="appearance !== 'select'"
53
55
  v-model="model"
54
56
  size="sm"
57
+ :icon-only="appearance === 'icons'"
55
58
  :label="label ?? t('ui.themeSwitcher.label')"
56
59
  :hide-label="hideLabel"
57
60
  :options="options"