From c6ffc81ebadece18c8cef6881070424ff3eacf3a Mon Sep 17 00:00:00 2001 From: Shevchik Igor Date: Mon, 11 May 2026 15:55:25 +0300 Subject: [PATCH] feat(Tabs): add item.color forwarded to leading Avatar MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds `color?: AvatarProps['color']` to `TabsItem` and forwards it as the default `color` to the item's leading `B24Avatar`. Explicit `item.avatar.color` still wins, since `v-bind="item.avatar"` is applied after `:color="item.color"`. No host-level color is introduced — the new prop only tints the inner Avatar. Co-Authored-By: Claude Opus 4.7 (1M context) --- docs/content/docs/2.components/tabs.md | 1 + src/runtime/components/Tabs.vue | 5 +++++ test/components/Tabs.spec.ts | 1 + .../__snapshots__/Tabs-vue.spec.ts.snap | 16 ++++++++++++++++ test/components/__snapshots__/Tabs.spec.ts.snap | 16 ++++++++++++++++ 5 files changed, 39 insertions(+) diff --git a/docs/content/docs/2.components/tabs.md b/docs/content/docs/2.components/tabs.md index 211ba97e3..39b38fed3 100644 --- a/docs/content/docs/2.components/tabs.md +++ b/docs/content/docs/2.components/tabs.md @@ -39,6 +39,7 @@ Use the `items` prop as an array of objects with the following properties: - `label?: string`{lang="ts-type"} - [`icon?: IconComponent`{lang="ts-type"}](#usage) - `avatar?: AvatarProps`{lang="ts-type"} +- `color?: AvatarProps['color']`{lang="ts-type"} - `badge?: string | number | BadgeProps`{lang="ts-type"} - `content?: string`{lang="ts-type"} - `value?: string | number`{lang="ts-type"} diff --git a/src/runtime/components/Tabs.vue b/src/runtime/components/Tabs.vue index d87864402..6136962f2 100644 --- a/src/runtime/components/Tabs.vue +++ b/src/runtime/components/Tabs.vue @@ -17,6 +17,10 @@ export interface TabsItem { */ icon?: IconComponent avatar?: AvatarProps + /** + * Default `color` for the item's leading `B24Avatar`. Overridden by `avatar.color` when set. + */ + color?: AvatarProps['color'] /** * Display a badge on the item. * `{ size: 'sm', color: 'air-primary' }`{lang="ts-type"} @@ -172,6 +176,7 @@ defineExpose({ { ['with as', { props: { ...props, as: 'section' } }], ['with class', { props: { ...props, class: 'w-96' } }], ['with b24ui', { props: { ...props, b24ui: { content: 'w-full ring ring-red-500' } } }], + ['with item color', { props: { items: [{ label: 'Engineer', avatar: { src: 'https://github.com/bitrix24.png' }, color: 'air-primary' as const, content: 'Engineer content' }, { label: 'Designer', avatar: { src: 'https://github.com/bitrix24.png' }, color: 'air-primary-success' as const, content: 'Designer content' }] } }], // Slots ['with leading slot', { props, slots: { leading: () => 'Leading slot' } }], ['with default slot', { props, slots: { default: () => 'Default slot' } }], diff --git a/test/components/__snapshots__/Tabs-vue.spec.ts.snap b/test/components/__snapshots__/Tabs-vue.spec.ts.snap index 508480fa3..e4d7cf987 100644 --- a/test/components/__snapshots__/Tabs-vue.spec.ts.snap +++ b/test/components/__snapshots__/Tabs-vue.spec.ts.snap @@ -200,6 +200,22 @@ exports[`Tabs > renders with defaultValue correctly 1`] = ` " `; +exports[`Tabs > renders with item color correctly 1`] = ` +"
+
+ +
+
Engineer content
+ +
" +`; + exports[`Tabs > renders with items correctly 1`] = ` "
diff --git a/test/components/__snapshots__/Tabs.spec.ts.snap b/test/components/__snapshots__/Tabs.spec.ts.snap index 56ad6915f..23d534fdc 100644 --- a/test/components/__snapshots__/Tabs.spec.ts.snap +++ b/test/components/__snapshots__/Tabs.spec.ts.snap @@ -200,6 +200,22 @@ exports[`Tabs > renders with defaultValue correctly 1`] = `
" `; +exports[`Tabs > renders with item color correctly 1`] = ` +"
+
+ +
+
Engineer content
+ +
" +`; + exports[`Tabs > renders with items correctly 1`] = ` "