From 02c3ddfc0d91402371793ccd5da31bf0763a082a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Kry=C5=A1p=C3=ADn?= Date: Thu, 23 Nov 2023 16:37:57 +0100 Subject: [PATCH] Feat(web): Extend Tooltip Floating UI example, deprecate CSS modifiers and side corners names #DS-618 --- .../web/src/scss/components/Tooltip/README.md | 71 ++++++-- .../src/scss/components/Tooltip/_Tooltip.scss | 28 ++- .../Tooltip/floating-ui-example.mjs | 86 +++++++++- .../src/scss/components/Tooltip/index.html | 160 +++++++++++------- .../web/src/scss/settings/_dictionaries.scss | 8 +- .../web/src/scss/settings/_feature-flags.scss | 1 + .../tools/__tests__/_dictionaries.test.scss | 26 ++- .../scss/tools/__tests__/_placement.test.scss | 100 ++++++++++- .../web/src/scss/tools/_dictionaries.scss | 8 + packages/web/src/scss/tools/_placement.scss | 119 +++++++++++-- 10 files changed, 492 insertions(+), 115 deletions(-) diff --git a/packages/web/src/scss/components/Tooltip/README.md b/packages/web/src/scss/components/Tooltip/README.md index 5476f7a1b7..5169bdd90b 100644 --- a/packages/web/src/scss/components/Tooltip/README.md +++ b/packages/web/src/scss/components/Tooltip/README.md @@ -3,12 +3,32 @@ Bare Tooltip HTML: ```html -
+
Hello there!
``` +## Feature Flag: Data Selector Placement + +Tooltip placement is currently using CSS modifiers. In the future it will be using `data-spirit-placement` +attribute in order to make the placement independent of the component and compatible with Floating UI. +To enable this behavior now you can use the feature flag, either set the `$tooltip-enable-data-placement` +feature flag to `true` or use the `spirit-feature-tooltip-enable-data-placement` CSS class on any parent of the Tooltip. + +For more info, see main [README][readme-feature-flags]. + +## ⚠️ DEPRECATION NOTICE + +CSS modifiers `Tooltip--top`, `Tooltip--rightTop`, `Tooltip--bottom`, etc. are deprecated and will be +removed in the next major release. Use `data-spirit-placement` attribute instead. + +Also both axis side placements are renamed from `top-left`, `top-right`, `right-top`, `right-bottom`, +etc. to `top-start`, `top-end`, `right-start`, `right-end`, etc. Old names are deprecated and will be +removed in the next major release. + +[What are deprecations?][readme-deprecations] + ## Linking with Content To display a Tooltip along your content, simply place it in the DOM next to it. @@ -32,7 +52,7 @@ improved accessibility. ```html
I have a tooltip! -
+
Hello there!
@@ -41,14 +61,14 @@ improved accessibility. ## Placement -Tooltip implements the [Placement Dictionary][dictionary-placement] for placement. The dictionary values are used as CSS -modifiers in the camelCase format: `Tooltip--top`, `Tooltip--rightTop`, `Tooltip--leftBottom`, etc. +Tooltip implements the [Placement Dictionary][dictionary-placement] for placement. The dictionary values are used as +a value of data attribute `data-spirit-placement`, e.g. `data-spirit-placement="top"`, `data-spirit-placement="right-end"`, etc. -For JS-controlled positioning please use the `data-spirit-placement` attribute instead of CSS modifiers (more on that -[below](#advanced-positioning)). +For JS-controlled positioning please use the `data-spirit-placement-controlled` attribute instead of specifying the placement +using the `data-spirit-placement` modifiers (more on that [below](#advanced-positioning)). ```html -
+
Tooltip on right
@@ -65,7 +85,7 @@ Tooltip HTML right after it. ```html
I have a tooltip! -
+
Hello there!
@@ -78,7 +98,7 @@ Add `tabindex="0"` to non-focusable elements to ensure keyboard accessibility. ```html
I have a tooltip! -
+
Hello there!
@@ -95,7 +115,7 @@ Tooltip. As a workaround, you'll want to trigger the Tooltip from a wrapper
-
+
Hello there!
@@ -114,7 +134,7 @@ kind of task Tooltip responds to interaction classes `is-hidden` and
I have an externally-triggered tooltip
-