diff --git a/playwright/e2e/element-examples/selection-buttons.spec.ts b/playwright/e2e/element-examples/selection-buttons.spec.ts new file mode 100644 index 000000000..6aa45dd19 --- /dev/null +++ b/playwright/e2e/element-examples/selection-buttons.spec.ts @@ -0,0 +1,33 @@ +/** + * Copyright (c) Siemens 2016 - 2025 + * SPDX-License-Identifier: MIT + */ +import { expect, test } from '../../support/test-helpers'; + +test.describe('selection-buttons tooltip', () => { + const example = 'buttons/selection-buttons'; + + test('icon-only with tooltip on focus', async ({ page, si }) => { + await si.visitExample(example); + + const fullScreenButton = page.getByRole('radio', { name: 'Full-screen' }); + await fullScreenButton.focus(); + + await expect(page.locator('si-tooltip')).toBeVisible(); + await expect(page.locator('si-tooltip')).toContainText('Full-screen'); + + await si.runVisualAndA11yTests('selection-button-icon-tooltip-focus'); + }); + + test('icon-only with tooltip on hover', async ({ page, si }) => { + await si.visitExample(example); + + const sidebarButton = page.getByRole('radio', { name: 'Sidebar' }); + await sidebarButton.hover(); + + await expect(page.locator('si-tooltip')).toBeVisible(); + await expect(page.locator('si-tooltip')).toContainText('Sidebar'); + + await si.runVisualAndA11yTests('selection-button-icon-tooltip-hover'); + }); +}); diff --git a/playwright/snapshots/selection-buttons.spec.ts-snapshots/buttons--selection-buttons--selection-button-icon-tooltip-focus-element-examples-chromium-dark-linux.png b/playwright/snapshots/selection-buttons.spec.ts-snapshots/buttons--selection-buttons--selection-button-icon-tooltip-focus-element-examples-chromium-dark-linux.png new file mode 100644 index 000000000..300c620c2 --- /dev/null +++ b/playwright/snapshots/selection-buttons.spec.ts-snapshots/buttons--selection-buttons--selection-button-icon-tooltip-focus-element-examples-chromium-dark-linux.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:125d6662222104e4049750e6b1cf6abad28734838260f111ace044f7a8a27fdb +size 23506 diff --git a/playwright/snapshots/selection-buttons.spec.ts-snapshots/buttons--selection-buttons--selection-button-icon-tooltip-focus-element-examples-chromium-light-linux.png b/playwright/snapshots/selection-buttons.spec.ts-snapshots/buttons--selection-buttons--selection-button-icon-tooltip-focus-element-examples-chromium-light-linux.png new file mode 100644 index 000000000..8e25c1ef2 --- /dev/null +++ b/playwright/snapshots/selection-buttons.spec.ts-snapshots/buttons--selection-buttons--selection-button-icon-tooltip-focus-element-examples-chromium-light-linux.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ec9bdb8910ba2eab2ab7f1b6668fe2f3c2e0343547e44ca20304cdb5131dd938 +size 24350 diff --git a/playwright/snapshots/selection-buttons.spec.ts-snapshots/buttons--selection-buttons--selection-button-icon-tooltip-focus.yaml b/playwright/snapshots/selection-buttons.spec.ts-snapshots/buttons--selection-buttons--selection-button-icon-tooltip-focus.yaml new file mode 100644 index 000000000..46fa1048b --- /dev/null +++ b/playwright/snapshots/selection-buttons.spec.ts-snapshots/buttons--selection-buttons--selection-button-icon-tooltip-focus.yaml @@ -0,0 +1,50 @@ +- heading "Single-select" [level=4] +- group "Basic radio toggle button group": + - radio "Day" [checked] + - text: "" + - radio "Week" + - text: "" + - radio "Month" + - text: "" +- group "Radio toggle button group with icon": + - radio "Comfort" [checked] + - text: "" + - radio "Pre-comfort" + - text: "" + - radio "Economy" + - text: "" +- group "Layout selection toggle": + - radio "Full-screen" [checked] + - radio "Sidebar" + - radio "Footer" +- heading "Sizing" [level=4] +- group "Basic radio toggle button group": + - radio "Large" [checked] + - text: "" + - radio "Group" + - text: "" + - radio "Size" + - text: "" +- group "Basic radio toggle button group": + - radio "Default" [checked] + - text: "" + - radio "Group" + - text: "" + - radio "Size" + - text: "" +- group "Basic radio toggle button group": + - radio "Small" [checked] + - text: "" + - radio "Group" + - text: "" + - radio "Size" + - text: "" +- heading "Multi-select" [level=4] +- group "Basic checkbox toggle button group": + - checkbox "€" + - text: "" + - checkbox "€€" + - text: "" + - checkbox "€€€" + - text: "" +- tooltip "Full-screen" \ No newline at end of file diff --git a/playwright/snapshots/selection-buttons.spec.ts-snapshots/buttons--selection-buttons--selection-button-icon-tooltip-hover-element-examples-chromium-dark-linux.png b/playwright/snapshots/selection-buttons.spec.ts-snapshots/buttons--selection-buttons--selection-button-icon-tooltip-hover-element-examples-chromium-dark-linux.png new file mode 100644 index 000000000..d85a625ce --- /dev/null +++ b/playwright/snapshots/selection-buttons.spec.ts-snapshots/buttons--selection-buttons--selection-button-icon-tooltip-hover-element-examples-chromium-dark-linux.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8cbf1486e4eb302b760e21b92fa7839e38ab13ef80f9979f495dab110696606f +size 23597 diff --git a/playwright/snapshots/selection-buttons.spec.ts-snapshots/buttons--selection-buttons--selection-button-icon-tooltip-hover-element-examples-chromium-light-linux.png b/playwright/snapshots/selection-buttons.spec.ts-snapshots/buttons--selection-buttons--selection-button-icon-tooltip-hover-element-examples-chromium-light-linux.png new file mode 100644 index 000000000..3e8818e1f --- /dev/null +++ b/playwright/snapshots/selection-buttons.spec.ts-snapshots/buttons--selection-buttons--selection-button-icon-tooltip-hover-element-examples-chromium-light-linux.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1571cbc242b393d6fa4e535facf96f6710b7e64da564ddd67db74cee6a7e1eae +size 24546 diff --git a/playwright/snapshots/selection-buttons.spec.ts-snapshots/buttons--selection-buttons--selection-button-icon-tooltip-hover.yaml b/playwright/snapshots/selection-buttons.spec.ts-snapshots/buttons--selection-buttons--selection-button-icon-tooltip-hover.yaml new file mode 100644 index 000000000..9d2c0410e --- /dev/null +++ b/playwright/snapshots/selection-buttons.spec.ts-snapshots/buttons--selection-buttons--selection-button-icon-tooltip-hover.yaml @@ -0,0 +1,50 @@ +- heading "Single-select" [level=4] +- group "Basic radio toggle button group": + - radio "Day" [checked] + - text: "" + - radio "Week" + - text: "" + - radio "Month" + - text: "" +- group "Radio toggle button group with icon": + - radio "Comfort" [checked] + - text: "" + - radio "Pre-comfort" + - text: "" + - radio "Economy" + - text: "" +- group "Layout selection toggle": + - radio "Full-screen" [checked] + - radio "Sidebar" + - radio "Footer" +- heading "Sizing" [level=4] +- group "Basic radio toggle button group": + - radio "Large" [checked] + - text: "" + - radio "Group" + - text: "" + - radio "Size" + - text: "" +- group "Basic radio toggle button group": + - radio "Default" [checked] + - text: "" + - radio "Group" + - text: "" + - radio "Size" + - text: "" +- group "Basic radio toggle button group": + - radio "Small" [checked] + - text: "" + - radio "Group" + - text: "" + - radio "Size" + - text: "" +- heading "Multi-select" [level=4] +- group "Basic checkbox toggle button group": + - checkbox "€" + - text: "" + - checkbox "€€" + - text: "" + - checkbox "€€€" + - text: "" +- tooltip "Sidebar" \ No newline at end of file diff --git a/playwright/snapshots/si-side-panel.spec.ts-snapshots/si-side-panel--si-side-panel--over-mode-element-examples-chromium-dark-linux.png b/playwright/snapshots/si-side-panel.spec.ts-snapshots/si-side-panel--si-side-panel--over-mode-element-examples-chromium-dark-linux.png index 11a8cf472..625643551 100644 --- a/playwright/snapshots/si-side-panel.spec.ts-snapshots/si-side-panel--si-side-panel--over-mode-element-examples-chromium-dark-linux.png +++ b/playwright/snapshots/si-side-panel.spec.ts-snapshots/si-side-panel--si-side-panel--over-mode-element-examples-chromium-dark-linux.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d9743aec423daabc616b9482098b486e76e2645d1874dfff5c5e01035d689d18 -size 71077 +oid sha256:c9690507fe2eb9d2569f8c2f512209fdfc7f20abd09b1d97c111697de377cbd0 +size 70651 diff --git a/playwright/snapshots/si-side-panel.spec.ts-snapshots/si-side-panel--si-side-panel--over-mode-element-examples-chromium-light-linux.png b/playwright/snapshots/si-side-panel.spec.ts-snapshots/si-side-panel--si-side-panel--over-mode-element-examples-chromium-light-linux.png index f428284a3..7d55177ef 100644 --- a/playwright/snapshots/si-side-panel.spec.ts-snapshots/si-side-panel--si-side-panel--over-mode-element-examples-chromium-light-linux.png +++ b/playwright/snapshots/si-side-panel.spec.ts-snapshots/si-side-panel--si-side-panel--over-mode-element-examples-chromium-light-linux.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:88a2aafb01f9f658e807ca1e34d6e875222f7dc0455b78d122929b59dc79e578 -size 74298 +oid sha256:f4dd504eeac2063283bfbb593c7228ab201f708f3827ab96c805958fd544c8d1 +size 73833 diff --git a/playwright/snapshots/si-side-panel.spec.ts-snapshots/si-side-panel--si-side-panel--over-mode-no-backdrop-element-examples-chromium-dark-linux.png b/playwright/snapshots/si-side-panel.spec.ts-snapshots/si-side-panel--si-side-panel--over-mode-no-backdrop-element-examples-chromium-dark-linux.png index 690ef4d9f..4e058538e 100644 --- a/playwright/snapshots/si-side-panel.spec.ts-snapshots/si-side-panel--si-side-panel--over-mode-no-backdrop-element-examples-chromium-dark-linux.png +++ b/playwright/snapshots/si-side-panel.spec.ts-snapshots/si-side-panel--si-side-panel--over-mode-no-backdrop-element-examples-chromium-dark-linux.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:9374ff255e62157c52d537d72094ae4dbce683597c2f9d62ea8bbff8b8fc37ad -size 71589 +oid sha256:2f223caf5888e6c671d7c67783bc9ddfb0618f1afc4e994e0474d4c689a4598f +size 70970 diff --git a/playwright/snapshots/si-side-panel.spec.ts-snapshots/si-side-panel--si-side-panel--over-mode-no-backdrop-element-examples-chromium-light-linux.png b/playwright/snapshots/si-side-panel.spec.ts-snapshots/si-side-panel--si-side-panel--over-mode-no-backdrop-element-examples-chromium-light-linux.png index 51efafa14..9a945df79 100644 --- a/playwright/snapshots/si-side-panel.spec.ts-snapshots/si-side-panel--si-side-panel--over-mode-no-backdrop-element-examples-chromium-light-linux.png +++ b/playwright/snapshots/si-side-panel.spec.ts-snapshots/si-side-panel--si-side-panel--over-mode-no-backdrop-element-examples-chromium-light-linux.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:d779fa489201fbe8223363633a3e1f38537b792512c18d31c3997b0167cb5d75 -size 72714 +oid sha256:9e649d7afaa4496c4f36e4b7b23c90b172f63e6e03394648b2e9204c6103fcc9 +size 72179 diff --git a/playwright/snapshots/si-side-panel.spec.ts-snapshots/si-side-panel--si-side-panel--over-mode-no-backdrop.yaml b/playwright/snapshots/si-side-panel.spec.ts-snapshots/si-side-panel--si-side-panel--over-mode-no-backdrop.yaml index cecc77b7f..c276b792b 100644 --- a/playwright/snapshots/si-side-panel.spec.ts-snapshots/si-side-panel--si-side-panel--over-mode-no-backdrop.yaml +++ b/playwright/snapshots/si-side-panel.spec.ts-snapshots/si-side-panel--si-side-panel--over-mode-no-backdrop.yaml @@ -4,7 +4,9 @@ - button "Hey there" [expanded] - region "Hey there": And here we have some content - button "Another one" +- region "Another one" - button "Number three" +- region "Number three" - banner: - link "Siemens logo": - /url: "#/" @@ -52,5 +54,5 @@ - text: Displays a semi-transparent overlay that blocks interactions with the main content while keeping it visible for context. Only active in over-mode (or when scroll mode is forced to over-mode on smaller screens). The backdrop can be clicked to close the side panel and can be disabled with the - code: disableBackdrop - text: input. -- switch "disableBackdrop" [checked] -- code: disableBackdrop \ No newline at end of file +- checkbox "disableBackdrop" [checked] +- text: disableBackdrop \ No newline at end of file diff --git a/playwright/snapshots/si-side-panel.spec.ts-snapshots/si-side-panel--si-side-panel--over-mode.yaml b/playwright/snapshots/si-side-panel.spec.ts-snapshots/si-side-panel--si-side-panel--over-mode.yaml index e16023459..8227d19b6 100644 --- a/playwright/snapshots/si-side-panel.spec.ts-snapshots/si-side-panel--si-side-panel--over-mode.yaml +++ b/playwright/snapshots/si-side-panel.spec.ts-snapshots/si-side-panel--si-side-panel--over-mode.yaml @@ -4,7 +4,9 @@ - button "Hey there" [expanded] - region "Hey there": And here we have some content - button "Another one" +- region "Another one" - button "Number three" +- region "Number three" - banner: - link "Siemens logo": - /url: "#/" @@ -52,5 +54,5 @@ - text: Displays a semi-transparent overlay that blocks interactions with the main content while keeping it visible for context. Only active in over-mode (or when scroll mode is forced to over-mode on smaller screens). The backdrop can be clicked to close the side panel and can be disabled with the - code: disableBackdrop - text: input. -- switch "disableBackdrop" -- code: disableBackdrop \ No newline at end of file +- checkbox "disableBackdrop" +- text: disableBackdrop \ No newline at end of file diff --git a/playwright/snapshots/si-side-panel.spec.ts-snapshots/si-side-panel--si-side-panel--scroll-mode-element-examples-chromium-dark-linux.png b/playwright/snapshots/si-side-panel.spec.ts-snapshots/si-side-panel--si-side-panel--scroll-mode-element-examples-chromium-dark-linux.png index c41d59780..59369c523 100644 --- a/playwright/snapshots/si-side-panel.spec.ts-snapshots/si-side-panel--si-side-panel--scroll-mode-element-examples-chromium-dark-linux.png +++ b/playwright/snapshots/si-side-panel.spec.ts-snapshots/si-side-panel--si-side-panel--scroll-mode-element-examples-chromium-dark-linux.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:6e0a8378fadab7a57f9765ff15d3f927f8eb0be2b15bbfd12e850252d57f5830 -size 88347 +oid sha256:e7792cc04834becad0a7e15b2840907340d5290c0086ac689d4e3ea6ce9ef93d +size 87610 diff --git a/playwright/snapshots/si-side-panel.spec.ts-snapshots/si-side-panel--si-side-panel--scroll-mode-element-examples-chromium-light-linux.png b/playwright/snapshots/si-side-panel.spec.ts-snapshots/si-side-panel--si-side-panel--scroll-mode-element-examples-chromium-light-linux.png index 71e206666..b2394bce7 100644 --- a/playwright/snapshots/si-side-panel.spec.ts-snapshots/si-side-panel--si-side-panel--scroll-mode-element-examples-chromium-light-linux.png +++ b/playwright/snapshots/si-side-panel.spec.ts-snapshots/si-side-panel--si-side-panel--scroll-mode-element-examples-chromium-light-linux.png @@ -1,3 +1,3 @@ version https://git-lfs.github.com/spec/v1 -oid sha256:c9599dceb8d83694fd0932ab9501fb1d887b0a3d198c4fe981f8e7ccb5bde479 -size 89237 +oid sha256:25f865e19733dae17ad598452f8239e95758ad5ee57a3964567f1d36f173b895 +size 88654 diff --git a/playwright/snapshots/si-side-panel.spec.ts-snapshots/si-side-panel--si-side-panel--scroll-mode.yaml b/playwright/snapshots/si-side-panel.spec.ts-snapshots/si-side-panel--si-side-panel--scroll-mode.yaml index 1a8eedbbf..41861d765 100644 --- a/playwright/snapshots/si-side-panel.spec.ts-snapshots/si-side-panel--si-side-panel--scroll-mode.yaml +++ b/playwright/snapshots/si-side-panel.spec.ts-snapshots/si-side-panel--si-side-panel--scroll-mode.yaml @@ -4,7 +4,9 @@ - button "Hey there" [expanded] - region "Hey there": And here we have some content - button "Another one" +- region "Another one" - button "Number three" +- region "Number three" - banner: - link "Siemens logo": - /url: "#/" @@ -52,5 +54,5 @@ - text: Displays a semi-transparent overlay that blocks interactions with the main content while keeping it visible for context. Only active in over-mode (or when scroll mode is forced to over-mode on smaller screens). The backdrop can be clicked to close the side panel and can be disabled with the - code: disableBackdrop - text: input. -- switch "disableBackdrop" -- code: disableBackdrop \ No newline at end of file +- checkbox "disableBackdrop" +- text: disableBackdrop \ No newline at end of file diff --git a/playwright/snapshots/static.spec.ts-snapshots/buttons--selection-buttons.yaml b/playwright/snapshots/static.spec.ts-snapshots/buttons--selection-buttons.yaml index 6eb0c0992..49d13821f 100644 --- a/playwright/snapshots/static.spec.ts-snapshots/buttons--selection-buttons.yaml +++ b/playwright/snapshots/static.spec.ts-snapshots/buttons--selection-buttons.yaml @@ -14,9 +14,9 @@ - radio "Economy" - text: "" - group "Layout selection toggle": - - radio "One pane" [checked] - - radio "Two panes" - - radio "Three panes" + - radio "Full-screen" [checked] + - radio "Sidebar" + - radio "Footer" - heading "Sizing" [level=4] - group "Basic radio toggle button group": - radio "Large" [checked] diff --git a/projects/element-theme/src/styles/bootstrap/_button-group.scss b/projects/element-theme/src/styles/bootstrap/_button-group.scss index 41b267ed8..d9d58e696 100644 --- a/projects/element-theme/src/styles/bootstrap/_button-group.scss +++ b/projects/element-theme/src/styles/bootstrap/_button-group.scss @@ -95,10 +95,11 @@ $btn-size-sm: 24px !default; &[inert] { opacity: semantic-tokens.$element-action-disabled-opacity; } -} -.btn-group .btn-check { - + .btn { + // Selection buttons + .btn-check + .btn, + label.btn:has(.btn-check) { + cursor: pointer; background: transparent; color: semantic-tokens.$element-text-primary; padding-block: calc(variables.$btn-padding-y - 1px); @@ -123,12 +124,14 @@ $btn-size-sm: 24px !default; } } - &:checked + .btn, - + .btn:hover { + .btn-check:is(:hover, :checked) + .btn, + .btn-check + .btn:hover, + label.btn:has(.btn-check:is(:hover, :checked)) { color: semantic-tokens.$element-ui-0-hover; } - &:checked + .btn { + .btn-check:checked + .btn, + label.btn:has(.btn-check:checked) { background: semantic-tokens.$element-action-secondary-active; border-color: semantic-tokens.$element-action-secondary-border-hover; z-index: 2; @@ -138,7 +141,8 @@ $btn-size-sm: 24px !default; } } - &:focus-visible + .btn { + .btn-check:focus-visible + .btn, + label.btn:has(.btn-check:focus-visible) { @include focus.make-outline-focus(); z-index: 3; } diff --git a/projects/element-theme/src/styles/bootstrap/forms/_form-check.scss b/projects/element-theme/src/styles/bootstrap/forms/_form-check.scss index b066a72ee..b7e7491e5 100644 --- a/projects/element-theme/src/styles/bootstrap/forms/_form-check.scss +++ b/projects/element-theme/src/styles/bootstrap/forms/_form-check.scss @@ -215,6 +215,19 @@ $form-check-label-start: $form-check-size + map.get(spacers.$spacers, 4); } // button group +.btn-group label:has(.btn-check) { + position: relative; + + .btn-check { + inset: 0; + z-index: 3; + cursor: pointer; + opacity: 0; + clip: auto; + pointer-events: all; + } +} + .btn-check { position: absolute; clip: rect(0, 0, 0, 0); diff --git a/src/app/examples/buttons/selection-buttons.html b/src/app/examples/buttons/selection-buttons.html index 1d242cac5..6c72153c7 100644 --- a/src/app/examples/buttons/selection-buttons.html +++ b/src/app/examples/buttons/selection-buttons.html @@ -33,19 +33,38 @@