From 6b93f3dd75c45de43e35ba232debf8f4031714ee Mon Sep 17 00:00:00 2001 From: Vidit Kushwaha <120644015+Vidit-Kushwaha@users.noreply.github.com> Date: Mon, 4 Nov 2024 09:28:26 +0000 Subject: [PATCH 1/4] Add CustomTooltip component to the sistent components page Signed-off-by: Vidit Kushwaha <120644015+Vidit-Kushwaha@users.noreply.github.com> --- src/components/SistentNavigation/content.js | 17 +- .../sistent/components/customTooltip/code.js | 8 + .../components/customTooltip/guidance.js | 8 + .../sistent/components/customTooltip/index.js | 8 + .../Sistent/components/customTooltip/code.js | 358 ++++++++++++++++++ .../components/customTooltip/guidance.js | 185 +++++++++ .../Sistent/components/customTooltip/index.js | 196 ++++++++++ .../Projects/Sistent/components/index.js | 9 +- 8 files changed, 787 insertions(+), 2 deletions(-) create mode 100644 src/pages/projects/sistent/components/customTooltip/code.js create mode 100644 src/pages/projects/sistent/components/customTooltip/guidance.js create mode 100644 src/pages/projects/sistent/components/customTooltip/index.js create mode 100644 src/sections/Projects/Sistent/components/customTooltip/code.js create mode 100644 src/sections/Projects/Sistent/components/customTooltip/guidance.js create mode 100644 src/sections/Projects/Sistent/components/customTooltip/index.js diff --git a/src/components/SistentNavigation/content.js b/src/components/SistentNavigation/content.js index 1932e1dc9356..ea703082ba21 100644 --- a/src/components/SistentNavigation/content.js +++ b/src/components/SistentNavigation/content.js @@ -87,5 +87,20 @@ export const content = [ id: 23, link: "/projects/sistent/components/text-field/code", text: "Text Field", - } + }, + { + id: 24, + link: "/projects/sistent/components/customTooltip", + text: "Custom Tooltip", + }, + { + id: 25, + link: "/projects/sistent/components/customTooltip/guidance", + text: "Custom Tooltip", + }, + { + id: 26, + link: "/projects/sistent/components/customTooltip/code", + text: "Custom Tooltip", + }, ]; diff --git a/src/pages/projects/sistent/components/customTooltip/code.js b/src/pages/projects/sistent/components/customTooltip/code.js new file mode 100644 index 000000000000..faac99940766 --- /dev/null +++ b/src/pages/projects/sistent/components/customTooltip/code.js @@ -0,0 +1,8 @@ +import React from "react"; +import CustomTooltipCode from "../../../../../sections/Projects/Sistent/components/customTooltip/code"; + +const CustomTooltipCodePage = () => { + return ; +}; + +export default CustomTooltipCodePage; diff --git a/src/pages/projects/sistent/components/customTooltip/guidance.js b/src/pages/projects/sistent/components/customTooltip/guidance.js new file mode 100644 index 000000000000..233c8002581c --- /dev/null +++ b/src/pages/projects/sistent/components/customTooltip/guidance.js @@ -0,0 +1,8 @@ +import React from "react"; +import CustomTooltipGuidance from "../../../../../sections/Projects/Sistent/components/customTooltip/guidance"; + +const CustomTooltipGuidancePage = () => { + return ; +}; + +export default CustomTooltipGuidancePage; diff --git a/src/pages/projects/sistent/components/customTooltip/index.js b/src/pages/projects/sistent/components/customTooltip/index.js new file mode 100644 index 000000000000..01737e2c38fe --- /dev/null +++ b/src/pages/projects/sistent/components/customTooltip/index.js @@ -0,0 +1,8 @@ +import React from "react"; +import SistentCustomTooltip from "../../../../../sections/Projects/Sistent/components/customTooltip"; + +const SistentCustomTooltipPage = () => { + return ; +}; + +export default SistentCustomTooltipPage; diff --git a/src/sections/Projects/Sistent/components/customTooltip/code.js b/src/sections/Projects/Sistent/components/customTooltip/code.js new file mode 100644 index 000000000000..7140031741c3 --- /dev/null +++ b/src/sections/Projects/Sistent/components/customTooltip/code.js @@ -0,0 +1,358 @@ +import React from "react"; +import { navigate } from "gatsby"; +import { useLocation } from "@reach/router"; +import { + SistentThemeProvider, + Button, + Box, + Grid, + CustomTooltip, +} from "@layer5/sistent"; +import { SistentLayout } from "../../sistent-layout"; +import { CodeBlock } from "../button/code-block"; +import TabButton from "../../../../../reusecore/Button"; +import { useStyledDarkMode } from "../../../../../theme/app/useStyledDarkMode"; + +const codes = [ + ` + + + + + + + + + + + + + + + + +
+ + + +
+ + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +
`, + ` + *": { + m: 1, + }, + }} + > + + + + + + + +`, + ` + + + +`, + ` + + + +`, +]; + +const CustomTooltipCode = () => { + const { isDark } = useStyledDarkMode(); + const location = useLocation(); + + return ( + +
+ +

Custom Tooltip

+
+

+ The CustomTooltip component displays informative text when users hover + over, focus on, or tap an element. Tooltips are designed to enhance + accessibility and user understanding of interface elements. +

+
+ + navigate("/projects/sistent/components/customTooltip") + } + title="Overview" + /> + + navigate("/projects/sistent/components/customTooltip/guidance") + } + title="Guidance" + /> + + navigate("/projects/sistent/components/customTooltip/code") + } + title="Code" + /> +
+
+

+ The CustomTooltip component displays informative text when users + hover over, focus on, or tap an element. Tooltips are designed to + enhance accessibility and user understanding of interface elements. +

+ +

Basic CustomTooltip

+
+
+
+ + +
+ +
+ +

Positioned Example

+
+

+ You can specify the position of the Popper using the{" "} + placement prop. Here's an example of a CustomTooltip + positioned above its anchor: +

+
+
+ + + + + + + + + + + + + + + + + + + + +
+ + + +
+ + + +
+ + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + +
+
+
+ +
+ +

Variable width

+
+

+ The variant prop in CustomTooltip allows you to control the tooltips + size with predefined styles (standard or small). This makes it + easier to adjust the tooltip to fit various UI requirements quickly + and consistently. +

+
+
+ + *": { + m: 1, + }, + }} + > + + + + + + + + +
+ +
+ +

Follow Cursor

+
+

+ Tooltips can be configured to follow the cursor, making it easier to + read the content. +

+
+
+ + + + + +
+ +
+ +

Showing and Hiding

+
+

+ A delay in showing or hiding the tooltip can be added through the{" "} + enterDelay and leaveDelay props. +

+
+
+ + + + + +
+ +
+
+
+
+ ); +}; + +export default CustomTooltipCode; diff --git a/src/sections/Projects/Sistent/components/customTooltip/guidance.js b/src/sections/Projects/Sistent/components/customTooltip/guidance.js new file mode 100644 index 000000000000..37bac3191614 --- /dev/null +++ b/src/sections/Projects/Sistent/components/customTooltip/guidance.js @@ -0,0 +1,185 @@ +import React from "react"; +import { navigate } from "gatsby"; +import { useLocation } from "@reach/router"; +import { SistentLayout } from "../../sistent-layout"; +import { SistentThemeProvider, Button, Typography, Tooltip } from "@layer5/sistent"; +import { Row } from "../../../../../reusecore/Layout"; +import TabButton from "../../../../../reusecore/Button"; +import { useStyledDarkMode } from "../../../../../theme/app/useStyledDarkMode"; + +const CustomTooltipGuidance = () => { + const { isDark } = useStyledDarkMode(); + const location = useLocation(); + + return ( + +
+ +

Custom Tooltip

+
+

+ The Tooltip component displays informative text when users hover over, + focus on, or tap an element. Tooltips are designed to enhance + accessibility and user understanding of interface elements. +

+
+ + navigate("/projects/sistent/components/customTooltip") + } + title="Overview" + /> + + navigate("/projects/sistent/components/customTooltip/guidance") + } + title="Guidance" + /> + + navigate("/projects/sistent/components/customTooltip/code") + } + title="Code" + /> +
+
+

+ The Tooltip component displays informative text when users hover + over, focus on, or tap an element. Tooltips are designed to enhance + accessibility and user understanding of interface elements. +

+ + +

Positioning

+
+

+ The positioning of the CustomTooltip is critical for usability. Use + the `placement` prop to control where the CustomTooltip appears + relative to its anchor element. Options include: +

+
    +
  • top
  • +
  • bottom
  • +
  • left
  • +
  • right
  • +
  • top-start
  • +
  • top-end
  • +
  • bottom-start
  • +
  • bottom-end
  • +
  • left-start
  • +
  • left-end
  • +
  • right-start
  • +
  • right-end
  • +
+

+ Choosing the right position helps to prevent overlap with other + interface elements and improves readability. +

+ + +

Styling

+
+

+ The CustomTooltip component inherits styles from the Sistent theme. + You can customize the appearance by applying styles to the content + inside the CustomTooltip. For instance: +

+ + +
+
+
+ ); +}; + +export default CustomTooltipGuidance; diff --git a/src/sections/Projects/Sistent/components/customTooltip/index.js b/src/sections/Projects/Sistent/components/customTooltip/index.js new file mode 100644 index 000000000000..ad4c8fb7cdd7 --- /dev/null +++ b/src/sections/Projects/Sistent/components/customTooltip/index.js @@ -0,0 +1,196 @@ +import React from "react"; +import { navigate } from "gatsby"; +import { useLocation } from "@reach/router"; +import { + SistentThemeProvider, + Button, + CustomTooltip, + Box, +} from "@layer5/sistent"; +import TabButton from "../../../../../reusecore/Button"; +import { SistentLayout } from "../../sistent-layout"; +import { Row } from "../../../../../reusecore/Layout"; +import { useStyledDarkMode } from "../../../../../theme/app/useStyledDarkMode"; + +const SistentCustomTooltip = () => { + const location = useLocation(); + const { isDark } = useStyledDarkMode(); + + return ( + +
+ +

Custom Tooltip

+
+

+ The CustomTooltip component displays informative text when users hover + over, focus on, or tap an element. Tooltips are designed to enhance + accessibility and user understanding of interface elements. +

+
+ + navigate("/projects/sistent/components/customTooltip") + } + title="Overview" + /> + + navigate("/projects/sistent/components/customTooltip/guidance") + } + title="Guidance" + /> + + navigate("/projects/sistent/components/customTooltip/code") + } + title="Code" + /> +
+
+

+ The CustomTooltip component displays informative text when users + hover over, focus on, or tap an element. Tooltips are designed to + enhance accessibility and user understanding of interface elements. +

+ +

Basic Tooltip

+
+

+ A simple tooltip that displays helpful information when hovering + over an icon button. +

+ + + + + + + + +

Disabled Elements

+

+ By default disabled elements like button do not trigger user + interactions so a Tooltip will not activate on normal + events like hover. To accommodate disabled elements, add a simple + wrapper element, such as a span. +

+ + + + + + + + + + + +

Variable width

+
+

+ The variant prop in CustomTooltip allows you to control the tooltips + size with predefined styles (standard or small). This makes it + easier to adjust the tooltip to fit various UI requirements quickly + and consistently. +

+ + + *": { + m: 1, + }, + }} + > + + + + + + + + + + + +

Follow Cursor

+
+

+ Tooltips can be configured to follow the cursor, making it easier to + read the content. +

+ + + + + + + + + +

Showing and Hiding

+
+

+ The CustomTooltip is normally shown immediately when the user's + mouse hovers over the element, and hides immediately when the user's + mouse leaves. A delay in showing or hiding the tooltip can be added + through the enterDelay and leaveDelay{" "} + props. +

+ + + + + + + +
+
+
+ ); +}; + +export default SistentCustomTooltip; diff --git a/src/sections/Projects/Sistent/components/index.js b/src/sections/Projects/Sistent/components/index.js index fa716d565a50..4a35e3453d4a 100644 --- a/src/sections/Projects/Sistent/components/index.js +++ b/src/sections/Projects/Sistent/components/index.js @@ -50,7 +50,14 @@ const componentsData = [ description: "The TextField component is a versatile input field used to capture user input in forms and user interfaces.", url: "/projects/sistent/components/text-field", - } + }, + { + id: 8, + name: "Custom Tooltip", + description: + "The Tooltip component is a small pop-up box that appears when a user hovers over an element.", + url: "/projects/sistent/components/customTooltip", + }, ]; const SistentComponents = () => { From 85639cedb3479bea9d854cf7089f868f3f0b2557 Mon Sep 17 00:00:00 2001 From: Vidit Kushwaha <120644015+Vidit-Kushwaha@users.noreply.github.com> Date: Mon, 11 Nov 2024 04:52:46 +0000 Subject: [PATCH 2/4] Change customTooltip to tooltip, remove sistentheme layer from code, added triggers, html support in guidance.js Signed-off-by: Vidit Kushwaha <120644015+Vidit-Kushwaha@users.noreply.github.com> --- src/components/SistentNavigation/content.js | 12 +- .../sistent/components/customTooltip/code.js | 8 - .../components/customTooltip/guidance.js | 8 - .../sistent/components/customTooltip/index.js | 8 - .../sistent/components/tooltip/code.js | 8 + .../sistent/components/tooltip/guidance.js | 8 + .../sistent/components/tooltip/index.js | 8 + .../Sistent/components/customTooltip/code.js | 358 -------------- .../components/customTooltip/guidance.js | 185 ------- .../Projects/Sistent/components/index.js | 4 +- .../Sistent/components/tooltip/code.js | 463 ++++++++++++++++++ .../Sistent/components/tooltip/guidance.js | 249 ++++++++++ .../{customTooltip => tooltip}/index.js | 124 +++-- 13 files changed, 827 insertions(+), 616 deletions(-) delete mode 100644 src/pages/projects/sistent/components/customTooltip/code.js delete mode 100644 src/pages/projects/sistent/components/customTooltip/guidance.js delete mode 100644 src/pages/projects/sistent/components/customTooltip/index.js create mode 100644 src/pages/projects/sistent/components/tooltip/code.js create mode 100644 src/pages/projects/sistent/components/tooltip/guidance.js create mode 100644 src/pages/projects/sistent/components/tooltip/index.js delete mode 100644 src/sections/Projects/Sistent/components/customTooltip/code.js delete mode 100644 src/sections/Projects/Sistent/components/customTooltip/guidance.js create mode 100644 src/sections/Projects/Sistent/components/tooltip/code.js create mode 100644 src/sections/Projects/Sistent/components/tooltip/guidance.js rename src/sections/Projects/Sistent/components/{customTooltip => tooltip}/index.js (61%) diff --git a/src/components/SistentNavigation/content.js b/src/components/SistentNavigation/content.js index ea703082ba21..311bc0f0c7ce 100644 --- a/src/components/SistentNavigation/content.js +++ b/src/components/SistentNavigation/content.js @@ -90,17 +90,17 @@ export const content = [ }, { id: 24, - link: "/projects/sistent/components/customTooltip", - text: "Custom Tooltip", + link: "/projects/sistent/components/tooltip", + text: "Tooltip", }, { id: 25, - link: "/projects/sistent/components/customTooltip/guidance", - text: "Custom Tooltip", + link: "/projects/sistent/components/tooltip/guidance", + text: "Tooltip", }, { id: 26, - link: "/projects/sistent/components/customTooltip/code", - text: "Custom Tooltip", + link: "/projects/sistent/components/tooltip/code", + text: "Tooltip", }, ]; diff --git a/src/pages/projects/sistent/components/customTooltip/code.js b/src/pages/projects/sistent/components/customTooltip/code.js deleted file mode 100644 index faac99940766..000000000000 --- a/src/pages/projects/sistent/components/customTooltip/code.js +++ /dev/null @@ -1,8 +0,0 @@ -import React from "react"; -import CustomTooltipCode from "../../../../../sections/Projects/Sistent/components/customTooltip/code"; - -const CustomTooltipCodePage = () => { - return ; -}; - -export default CustomTooltipCodePage; diff --git a/src/pages/projects/sistent/components/customTooltip/guidance.js b/src/pages/projects/sistent/components/customTooltip/guidance.js deleted file mode 100644 index 233c8002581c..000000000000 --- a/src/pages/projects/sistent/components/customTooltip/guidance.js +++ /dev/null @@ -1,8 +0,0 @@ -import React from "react"; -import CustomTooltipGuidance from "../../../../../sections/Projects/Sistent/components/customTooltip/guidance"; - -const CustomTooltipGuidancePage = () => { - return ; -}; - -export default CustomTooltipGuidancePage; diff --git a/src/pages/projects/sistent/components/customTooltip/index.js b/src/pages/projects/sistent/components/customTooltip/index.js deleted file mode 100644 index 01737e2c38fe..000000000000 --- a/src/pages/projects/sistent/components/customTooltip/index.js +++ /dev/null @@ -1,8 +0,0 @@ -import React from "react"; -import SistentCustomTooltip from "../../../../../sections/Projects/Sistent/components/customTooltip"; - -const SistentCustomTooltipPage = () => { - return ; -}; - -export default SistentCustomTooltipPage; diff --git a/src/pages/projects/sistent/components/tooltip/code.js b/src/pages/projects/sistent/components/tooltip/code.js new file mode 100644 index 000000000000..631d5b7bd683 --- /dev/null +++ b/src/pages/projects/sistent/components/tooltip/code.js @@ -0,0 +1,8 @@ +import React from "react"; +import TooltipCode from "../../../../../sections/Projects/Sistent/components/tooltip/code"; + +const TooltipCodePage = () => { + return ; +}; + +export default TooltipCodePage; diff --git a/src/pages/projects/sistent/components/tooltip/guidance.js b/src/pages/projects/sistent/components/tooltip/guidance.js new file mode 100644 index 000000000000..05ae335dfa53 --- /dev/null +++ b/src/pages/projects/sistent/components/tooltip/guidance.js @@ -0,0 +1,8 @@ +import React from "react"; +import TooltipGuidance from "../../../../../sections/Projects/Sistent/components/tooltip/guidance"; + +const TooltipGuidancePage = () => { + return ; +}; + +export default TooltipGuidancePage; diff --git a/src/pages/projects/sistent/components/tooltip/index.js b/src/pages/projects/sistent/components/tooltip/index.js new file mode 100644 index 000000000000..f655f7a58ac8 --- /dev/null +++ b/src/pages/projects/sistent/components/tooltip/index.js @@ -0,0 +1,8 @@ +import React from "react"; +import SistentTooltip from "../../../../../sections/Projects/Sistent/components/tooltip"; + +const SistentTooltipPage = () => { + return ; +}; + +export default SistentTooltipPage; diff --git a/src/sections/Projects/Sistent/components/customTooltip/code.js b/src/sections/Projects/Sistent/components/customTooltip/code.js deleted file mode 100644 index 7140031741c3..000000000000 --- a/src/sections/Projects/Sistent/components/customTooltip/code.js +++ /dev/null @@ -1,358 +0,0 @@ -import React from "react"; -import { navigate } from "gatsby"; -import { useLocation } from "@reach/router"; -import { - SistentThemeProvider, - Button, - Box, - Grid, - CustomTooltip, -} from "@layer5/sistent"; -import { SistentLayout } from "../../sistent-layout"; -import { CodeBlock } from "../button/code-block"; -import TabButton from "../../../../../reusecore/Button"; -import { useStyledDarkMode } from "../../../../../theme/app/useStyledDarkMode"; - -const codes = [ - ` - - - - - - - - - - - - - - - - -
- - - -
- - - -
- - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - - -
`, - ` - *": { - m: 1, - }, - }} - > - - - - - - - -`, - ` - - - -`, - ` - - - -`, -]; - -const CustomTooltipCode = () => { - const { isDark } = useStyledDarkMode(); - const location = useLocation(); - - return ( - -
- -

Custom Tooltip

-
-

- The CustomTooltip component displays informative text when users hover - over, focus on, or tap an element. Tooltips are designed to enhance - accessibility and user understanding of interface elements. -

-
- - navigate("/projects/sistent/components/customTooltip") - } - title="Overview" - /> - - navigate("/projects/sistent/components/customTooltip/guidance") - } - title="Guidance" - /> - - navigate("/projects/sistent/components/customTooltip/code") - } - title="Code" - /> -
-
-

- The CustomTooltip component displays informative text when users - hover over, focus on, or tap an element. Tooltips are designed to - enhance accessibility and user understanding of interface elements. -

- -

Basic CustomTooltip

-
-
-
- - -
- -
- -

Positioned Example

-
-

- You can specify the position of the Popper using the{" "} - placement prop. Here's an example of a CustomTooltip - positioned above its anchor: -

-
-
- - - - - - - - - - - - - - - - - - - - -
- - - -
- - - -
- - - - - - - - - - - - - - - - - -
- - - - - - - - - - - - - -
-
-
- -
- -

Variable width

-
-

- The variant prop in CustomTooltip allows you to control the tooltips - size with predefined styles (standard or small). This makes it - easier to adjust the tooltip to fit various UI requirements quickly - and consistently. -

-
-
- - *": { - m: 1, - }, - }} - > - - - - - - - - -
- -
- -

Follow Cursor

-
-

- Tooltips can be configured to follow the cursor, making it easier to - read the content. -

-
-
- - - - - -
- -
- -

Showing and Hiding

-
-

- A delay in showing or hiding the tooltip can be added through the{" "} - enterDelay and leaveDelay props. -

-
-
- - - - - -
- -
-
-
-
- ); -}; - -export default CustomTooltipCode; diff --git a/src/sections/Projects/Sistent/components/customTooltip/guidance.js b/src/sections/Projects/Sistent/components/customTooltip/guidance.js deleted file mode 100644 index 37bac3191614..000000000000 --- a/src/sections/Projects/Sistent/components/customTooltip/guidance.js +++ /dev/null @@ -1,185 +0,0 @@ -import React from "react"; -import { navigate } from "gatsby"; -import { useLocation } from "@reach/router"; -import { SistentLayout } from "../../sistent-layout"; -import { SistentThemeProvider, Button, Typography, Tooltip } from "@layer5/sistent"; -import { Row } from "../../../../../reusecore/Layout"; -import TabButton from "../../../../../reusecore/Button"; -import { useStyledDarkMode } from "../../../../../theme/app/useStyledDarkMode"; - -const CustomTooltipGuidance = () => { - const { isDark } = useStyledDarkMode(); - const location = useLocation(); - - return ( - -
- -

Custom Tooltip

-
-

- The Tooltip component displays informative text when users hover over, - focus on, or tap an element. Tooltips are designed to enhance - accessibility and user understanding of interface elements. -

-
- - navigate("/projects/sistent/components/customTooltip") - } - title="Overview" - /> - - navigate("/projects/sistent/components/customTooltip/guidance") - } - title="Guidance" - /> - - navigate("/projects/sistent/components/customTooltip/code") - } - title="Code" - /> -
-
-

- The Tooltip component displays informative text when users hover - over, focus on, or tap an element. Tooltips are designed to enhance - accessibility and user understanding of interface elements. -

- - -

Positioning

-
-

- The positioning of the CustomTooltip is critical for usability. Use - the `placement` prop to control where the CustomTooltip appears - relative to its anchor element. Options include: -

-
    -
  • top
  • -
  • bottom
  • -
  • left
  • -
  • right
  • -
  • top-start
  • -
  • top-end
  • -
  • bottom-start
  • -
  • bottom-end
  • -
  • left-start
  • -
  • left-end
  • -
  • right-start
  • -
  • right-end
  • -
-

- Choosing the right position helps to prevent overlap with other - interface elements and improves readability. -

- - -

Styling

-
-

- The CustomTooltip component inherits styles from the Sistent theme. - You can customize the appearance by applying styles to the content - inside the CustomTooltip. For instance: -

- - -
-
-
- ); -}; - -export default CustomTooltipGuidance; diff --git a/src/sections/Projects/Sistent/components/index.js b/src/sections/Projects/Sistent/components/index.js index 5948cb506204..48375f9bf745 100644 --- a/src/sections/Projects/Sistent/components/index.js +++ b/src/sections/Projects/Sistent/components/index.js @@ -67,10 +67,10 @@ const componentsData = [ }, { id: 9, - name: "Custom Tooltip", + name: "Tooltip", description: "The Tooltip component is a small pop-up box that appears when a user hovers over an element.", - url: "/projects/sistent/components/customTooltip", + url: "/projects/sistent/components/tooltip", }, ]; diff --git a/src/sections/Projects/Sistent/components/tooltip/code.js b/src/sections/Projects/Sistent/components/tooltip/code.js new file mode 100644 index 000000000000..a537bf3e9590 --- /dev/null +++ b/src/sections/Projects/Sistent/components/tooltip/code.js @@ -0,0 +1,463 @@ +import React from "react"; +import { navigate } from "gatsby"; +import { useLocation } from "@reach/router"; +import { + SistentThemeProvider, + Button, + Box, + Grid, + CustomTooltip, +} from "@layer5/sistent"; +import { SistentLayout } from "../../sistent-layout"; +import { CodeBlock } from "../button/code-block"; +import TabButton from "../../../../../reusecore/Button"; +import { useStyledDarkMode } from "../../../../../theme/app/useStyledDarkMode"; + +const codes = [ + ` + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +`, + ` + + + +`, + ` + + + + + + + + +`, + ` + + + +`, + ` + + + +`, +]; + +const TooltipCode = () => { + const { isDark } = useStyledDarkMode(); + const location = useLocation(); + + return ( + +
+ +

Tooltip

+
+

+ The Tooltip component displays informative text when users hover over, + focus on, or tap an element. Tooltips are designed to enhance + accessibility and user understanding of interface elements. +

+
+ + navigate("/projects/sistent/components/tooltip") + } + title="Overview" + /> + + navigate("/projects/sistent/components/tooltip/guidance") + } + title="Guidance" + /> + + navigate("/projects/sistent/components/tooltip/code") + } + title="Code" + /> +
+
+

+ The Tooltip component displays informative text when users hover + over, focus on, or tap an element. Tooltips are designed to enhance + accessibility and user understanding of interface elements. +

+ +

Basic Tooltip

+
+
+
+ + + +
+ +
+ +

Positioned Example

+
+

+ You can specify the position of the Popper using the{" "} + placement prop. Here's an example of a Tooltip + positioned above its anchor: +

+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + +
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + +
+ + + + + + + + + + + + + + + + + + + +
+
+
+ +
+ +

Distance from anchor

+
+

+ To adjust the distance between the tooltip and its anchor, you can + use the slotProps prop to modify the offset of the popper. +

+
+
+ + + + + + + +
+ +
+ +

Variable width

+
+

+ The variant prop in Tooltip allows you to control the tooltips size + with predefined styles (standard or small). This makes it easier to + adjust the tooltip to fit various UI requirements quickly and + consistently. +

+
+
+ + *": { + m: 1, + }, + }} + > + + + + + + + + + + + + +
+ +
+ +

Follow Cursor

+
+

+ Tooltips can be configured to follow the cursor, making it easier to + read the content. +

+
+
+ + + + + + + +
+ +
+ +

Showing and Hiding

+
+

+ A delay in showing or hiding the tooltip can be added through the{" "} + enterDelay and leaveDelay props. +

+
+
+ + + + + + + +
+ +
+
+
+
+ ); +}; + +export default TooltipCode; diff --git a/src/sections/Projects/Sistent/components/tooltip/guidance.js b/src/sections/Projects/Sistent/components/tooltip/guidance.js new file mode 100644 index 000000000000..a61079d44ec8 --- /dev/null +++ b/src/sections/Projects/Sistent/components/tooltip/guidance.js @@ -0,0 +1,249 @@ +import React from "react"; +import { navigate } from "gatsby"; +import { useLocation } from "@reach/router"; +import { SistentLayout } from "../../sistent-layout"; +import { + SistentThemeProvider, + Button, + Typography, + CustomTooltip, + Grid, +} from "@layer5/sistent"; +import { Row } from "../../../../../reusecore/Layout"; +import TabButton from "../../../../../reusecore/Button"; +import { useStyledDarkMode } from "../../../../../theme/app/useStyledDarkMode"; + +const TooltipGuidance = () => { + const { isDark } = useStyledDarkMode(); + const location = useLocation(); + + return ( + +
+ +

Tooltip

+
+

+ The Tooltip component displays informative text when users hover over, + focus on, or tap an element. Tooltips are designed to enhance + accessibility and user understanding of interface elements. +

+
+ navigate("/projects/sistent/components/tooltip")} + title="Overview" + /> + + navigate("/projects/sistent/components/tooltip/guidance") + } + title="Guidance" + /> + + navigate("/projects/sistent/components/tooltip/code") + } + title="Code" + /> +
+
+

+ The Tooltip component displays informative text when users hover + over, focus on, or tap an element. Tooltips are designed to enhance + accessibility and user understanding of interface elements. +

+ + +

Positioning

+
+

+ The positioning of the Tooltip is critical for usability. Use the + `placement` prop to control where the Tooltip appears relative to + its anchor element. Options include: +

+
    +
  • top
  • +
  • bottom
  • +
  • left
  • +
  • right
  • +
  • top-start
  • +
  • top-end
  • +
  • bottom-start
  • +
  • bottom-end
  • +
  • left-start
  • +
  • left-end
  • +
  • right-start
  • +
  • right-end
  • +
+

+ Choosing the right position helps to prevent overlap with other + interface elements and improves readability. +

+ + +

Styling

+
+

+ The Tooltip component inherits styles from the Sistent theme. You + can customize the appearance by applying styles to the content + inside the Tooltip. For instance: +

+ + + Custom Tooltip} + > + + + + + + + + + + + + + + + + + + + + + + + + +

Accessibility

+
+

+ It’s important to ensure that the Tooltip component is accessible to + all users. Here are some key considerations: +

+
    +
  • + By default, tooltips are designed to label their child element + rather than describe it. This differs from the title{" "} + attribute, which can either label or describe the child element + based on whether it already has an accessible label. +
  • +
  • + Using describeChild : When you want the tooltip to + act as an accessible description (adding additional context), you + can enable the describeChild prop. Use describeChild only if the + tooltip provides supplementary information and the child element + already has an accessible label. +
  • +
  • + Avoiding Accessibility Violations: Do not use describeChild if the + tooltip is the only visible label for the child element, as this + would prevent the child from having an accessible name. +
  • +
+ + +

Performance Tips

+
+

+ When using the Tooltip component, consider the following to optimize + performance: +

+
    +
  • + Use the `placement` prop to control the position of the Tooltip + and prevent overlap with other interface elements. +
  • +
  • + Ensure that the Tooltip is keyboard navigable, allowing users to + open/close it using keyboard shortcuts. +
  • +
+
+
+
+ ); +}; + +export default TooltipGuidance; diff --git a/src/sections/Projects/Sistent/components/customTooltip/index.js b/src/sections/Projects/Sistent/components/tooltip/index.js similarity index 61% rename from src/sections/Projects/Sistent/components/customTooltip/index.js rename to src/sections/Projects/Sistent/components/tooltip/index.js index ad4c8fb7cdd7..97d9606f46a4 100644 --- a/src/sections/Projects/Sistent/components/customTooltip/index.js +++ b/src/sections/Projects/Sistent/components/tooltip/index.js @@ -12,63 +12,60 @@ import { SistentLayout } from "../../sistent-layout"; import { Row } from "../../../../../reusecore/Layout"; import { useStyledDarkMode } from "../../../../../theme/app/useStyledDarkMode"; -const SistentCustomTooltip = () => { +const SistentTooltip = () => { const location = useLocation(); const { isDark } = useStyledDarkMode(); return ( - +
-

Custom Tooltip

+

Tooltip

- The CustomTooltip component displays informative text when users hover - over, focus on, or tap an element. Tooltips are designed to enhance + The Tooltip component displays informative text when users hover over, + focus on, or tap an element. Tooltips are designed to enhance accessibility and user understanding of interface elements.

- navigate("/projects/sistent/components/customTooltip") - } + onClick={() => navigate("/projects/sistent/components/tooltip")} title="Overview" /> - navigate("/projects/sistent/components/customTooltip/guidance") + navigate("/projects/sistent/components/tooltip/guidance") } title="Guidance" /> - navigate("/projects/sistent/components/customTooltip/code") + navigate("/projects/sistent/components/tooltip/code") } title="Code" />

- The CustomTooltip component displays informative text when users - hover over, focus on, or tap an element. Tooltips are designed to - enhance accessibility and user understanding of interface elements. + The Tooltip component displays informative text when users hover + over, focus on, or tap an element. Tooltips are designed to enhance + accessibility and user understanding of interface elements.

Basic Tooltip

@@ -80,7 +77,9 @@ const SistentCustomTooltip = () => { - + + + @@ -118,14 +119,47 @@ const SistentCustomTooltip = () => { +
+

Distance from anchor

+
+

+ To adjust the distance between the tooltip and its anchor, you can + use the slotProps prop to modify the offset of the popper. +

+ + + + + + + + + +

Variable width

- The variant prop in CustomTooltip allows you to control the tooltips - size with predefined styles (standard or small). This makes it - easier to adjust the tooltip to fit various UI requirements quickly - and consistently. + The variant prop in Tooltip allows you to control the tooltips size + with predefined styles (standard or small). This makes it easier to + adjust the tooltip to fit various UI requirements quickly and + consistently.

@@ -138,14 +172,18 @@ const SistentCustomTooltip = () => { }} > - + + + - + + + @@ -161,9 +199,11 @@ const SistentCustomTooltip = () => { - + + + @@ -172,18 +212,20 @@ const SistentCustomTooltip = () => {

Showing and Hiding

- The CustomTooltip is normally shown immediately when the user's - mouse hovers over the element, and hides immediately when the user's - mouse leaves. A delay in showing or hiding the tooltip can be added + The Tooltip is normally shown immediately when the user's mouse + hovers over the element, and hides immediately when the user's mouse + leaves. A delay in showing or hiding the tooltip can be added through the enterDelay and leaveDelay{" "} props.

- + + + @@ -193,4 +235,4 @@ const SistentCustomTooltip = () => { ); }; -export default SistentCustomTooltip; +export default SistentTooltip; From 9e32414eda57771fd8ff2864b29f316a7a69e240 Mon Sep 17 00:00:00 2001 From: Vidit Kushwaha <120644015+Vidit-Kushwaha@users.noreply.github.com> Date: Tue, 12 Nov 2024 10:26:11 +0000 Subject: [PATCH 3/4] added markdown support Signed-off-by: Vidit Kushwaha <120644015+Vidit-Kushwaha@users.noreply.github.com> --- .../Sistent/components/tooltip/guidance.js | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/sections/Projects/Sistent/components/tooltip/guidance.js b/src/sections/Projects/Sistent/components/tooltip/guidance.js index a61079d44ec8..c6771a52c969 100644 --- a/src/sections/Projects/Sistent/components/tooltip/guidance.js +++ b/src/sections/Projects/Sistent/components/tooltip/guidance.js @@ -132,7 +132,7 @@ const TooltipGuidance = () => { Tooltip with Markdown {"And here's"} {"some"}{" "} - {"amazing content"}. {"It's very engaging. Right?"} + {"amazing content"}. {"It's very engaging. Right?"} } > @@ -143,6 +143,27 @@ const TooltipGuidance = () => {
+

Markdown Support

+

+ The Tooltip component supports Markdown content, allowing you to + include rich text, links, and other elements inside the tooltip. By + passing Markdown content as the title prop, you can create more + engaging and informative tooltips. +

+ + + + +