From 5a1f92fb7ef231876f09cd73d36c6fcd80964fdd Mon Sep 17 00:00:00 2001 From: Andrei Zhaleznichenka Date: Tue, 29 Sep 2026 08:40:19 +0200 Subject: [PATCH] chore: Adds internal style api v2 to popover and tooltip --- pages/popover/style-api-v2.page.tsx | 64 +++++++++++++ pages/popover/style-api-v2.scss | 29 ++++++ pages/tooltip/style-api-v2.page.tsx | 36 +++++++ pages/tooltip/style-api-v2.scss | 13 +++ .../__snapshots__/style-docs.test.ts.snap | 94 +++++++++++++++++++ src/internal/styles/style-api.scss | 4 +- src/popover/__tests__/style-api.test.tsx | 40 ++++++++ src/popover/arrow.scss | 11 ++- src/popover/body.scss | 1 + src/popover/body.tsx | 3 + src/popover/container.scss | 20 ++-- src/popover/internal.tsx | 10 ++ src/popover/style-api.scss | 13 +++ src/popover/styles.scss | 11 +++ src/tooltip/__tests__/style-api.test.tsx | 27 ++++++ src/tooltip/internal.tsx | 9 +- src/tooltip/styles.scss | 8 ++ 17 files changed, 380 insertions(+), 13 deletions(-) create mode 100644 pages/popover/style-api-v2.page.tsx create mode 100644 pages/popover/style-api-v2.scss create mode 100644 pages/tooltip/style-api-v2.page.tsx create mode 100644 pages/tooltip/style-api-v2.scss create mode 100644 src/popover/__tests__/style-api.test.tsx create mode 100644 src/popover/style-api.scss create mode 100644 src/tooltip/__tests__/style-api.test.tsx diff --git a/pages/popover/style-api-v2.page.tsx b/pages/popover/style-api-v2.page.tsx new file mode 100644 index 0000000000..ee43cf2e0c --- /dev/null +++ b/pages/popover/style-api-v2.page.tsx @@ -0,0 +1,64 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +import React, { useContext } from 'react'; + +import { Checkbox, KeyValuePairs, Popover } from '~components'; + +import AppContext, { AppContextType } from '../app/app-context'; +import { SimplePage } from '../app/templates'; + +import styles from './style-api-v2.scss'; + +const brand = { popover: styles['popover-brand'], dismissButton: styles['popover-brand-dismiss'] }; + +type PageContext = React.Context< + AppContextType<{ + renderWithPortal: boolean; + }> +>; + +export default function () { + const { + urlParams: { renderWithPortal = true }, + setUrlParams, + } = useContext(AppContext as PageContext); + const shared = { header: 'Popover header', content: 'Popover content', renderWithPortal }; + return ( + setUrlParams({ renderWithPortal: detail.checked })} + > + renderWithPortal + + } + > + + Open popover + + ), + }, + { + type: 'pair', + label: 'Borderless', + value: ( + + Open popover + + ), + }, + ]} + /> + + ); +} diff --git a/pages/popover/style-api-v2.scss b/pages/popover/style-api-v2.scss new file mode 100644 index 0000000000..50293a238a --- /dev/null +++ b/pages/popover/style-api-v2.scss @@ -0,0 +1,29 @@ +/* + Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. + SPDX-License-Identifier: Apache-2.0 +*/ + +@use '../style-api/palette' as palette; + +.popover-brand { + --awsui-style-color: #{palette.$genai-text}; + --awsui-style-background: #{palette.$genai-surface}; + --awsui-style-border-color: #{palette.$genai}; + --awsui-style-border-width: 3px; + --awsui-style-border-radius: 8px; +} + +.popover-borderless { + --awsui-style-background: #{palette.$subtle}; + --awsui-style-border-width: 0px; + --awsui-style-border-radius: 4px; +} + +.popover-brand-dismiss { + --awsui-style-color: #{palette.$genai}; + --awsui-style-focus-ring-color: #{palette.$genai}; + + &:hover { + --awsui-style-color: #{palette.$genai-hover}; + } +} diff --git a/pages/tooltip/style-api-v2.page.tsx b/pages/tooltip/style-api-v2.page.tsx new file mode 100644 index 0000000000..f1823835bd --- /dev/null +++ b/pages/tooltip/style-api-v2.page.tsx @@ -0,0 +1,36 @@ +// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. +// SPDX-License-Identifier: Apache-2.0 +import React, { useRef, useState } from 'react'; + +import { Button, Tooltip } from '~components'; + +import { SimplePage } from '../app/templates'; + +import styles from './style-api-v2.scss'; + +export default function () { + const triggerRef = useRef(null); + const [open, setOpen] = useState(false); + return ( + +
+ setOpen(true)} + onMouseLeave={() => setOpen(false)} + onFocus={() => setOpen(true)} + onBlur={() => setOpen(false)} + > +