diff --git a/package.json b/package.json index 8dbb4c74a5..db7b06ac2b 100644 --- a/package.json +++ b/package.json @@ -181,7 +181,7 @@ { "path": "lib/components/internal/widget-exports.js", "brotli": false, - "limit": "1400 kB", + "limit": "1605 kB", "ignore": "react-dom" } ], diff --git a/pages/side-navigation/collapsed.page.tsx b/pages/side-navigation/collapsed.page.tsx index 7d35fe90d0..cce0ba6d4e 100644 --- a/pages/side-navigation/collapsed.page.tsx +++ b/pages/side-navigation/collapsed.page.tsx @@ -1,67 +1,397 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -import React, { useRef, useState } from 'react'; +import React, { useContext, useRef, useState } from 'react'; import { useReducedMotion } from '@cloudscape-design/component-toolkit/internal'; -import { Box, Button, Icon, SpaceBetween } from '~components'; +import { Box, Button, Icon, RadioGroup, SpaceBetween, Toggle } from '~components'; import SideNavigation, { SideNavigationProps } from '~components/side-navigation'; import { colorBorderDividerDefault } from '~design-tokens'; -const items: SideNavigationProps.Item[] = [ +import AppContext, { AppContextType } from '../app/app-context'; + +type CollapsedNavDemoContext = React.Context< + AppContextType<{ + itemsSet: string; + }> +>; + +const cubeIcon = ( + + + + } + /> +); + +const kitchenSink: SideNavigationProps.Item[] = [ + { type: 'link', text: 'Dashboard', href: '#/dashboard', icon: }, { type: 'link', text: 'Calendar', href: '#/calendar', icon: }, { type: 'link', text: 'Settings', href: '#/settings', icon: }, + { + type: 'link-group', + text: 'Account', + icon: , + href: '#/account', + items: [ + { type: 'link', text: 'Billing', href: '#/account/billing' }, + { type: 'link', text: 'Users', href: '#/account/users' }, + { type: 'link', text: 'Access keys', href: '#/account/access-keys' }, + ], + }, + { + type: 'expandable-link-group', + text: 'Buckets', + href: '#/buckets', + icon: , + items: [ + { type: 'link', text: 'Photos backup', href: '#/buckets/photos-backup' }, + { type: 'link', text: 'Static assets', href: '#/buckets/static-assets' }, + { type: 'link', text: 'Server logs', href: '#/buckets/server-logs' }, + ], + }, + { type: 'divider' }, { type: 'section', - text: 'Section', + text: 'Monitoring', items: [ - { type: 'link', text: 'Announcements', href: '#/announcements', icon: }, - { type: 'link', text: 'Team', href: '#/team', icon: }, - { type: 'link', text: 'Networking', href: '#/networking', icon: }, + { type: 'link', text: 'Alarms', href: '#/monitoring/alarms', icon: }, + { type: 'link', text: 'Dashboards', href: '#/monitoring/dashboards', icon: }, + { type: 'link', text: 'Metrics', href: '#/monitoring/metrics', icon: }, + { + type: 'link-group', + text: 'Log groups', + icon: , + href: '#/monitoring/log-groups', + items: [ + { type: 'link', text: 'API access logs', href: '#/monitoring/log-groups/api-access' }, + { type: 'link', text: 'Application logs', href: '#/monitoring/log-groups/application' }, + { type: 'link', text: 'Audit logs', href: '#/monitoring/log-groups/audit' }, + ], + }, ], }, + { type: 'link', text: 'Documentation', href: '#/docs', external: true }, { type: 'divider' }, { - type: 'link-group', - text: 'Link group', - href: '#/', + type: 'section-group', + title: 'Data management', items: [ - { type: 'link', text: 'Announcements', href: '#/announcements3', icon: }, - { type: 'link', text: 'Team', href: '#/team3', icon: }, - { type: 'link', text: 'Networking', href: '#/networking3', icon: }, + { type: 'link', text: 'Replication rules', href: '#/data/replication-rules', icon: }, + { type: 'link', text: 'Lifecycle rules', href: '#/data/lifecycle-rules', icon: }, + { type: 'link', text: 'Transfer jobs', href: '#/data/transfer-jobs', icon: }, + { + type: 'section', + text: 'Backups', + items: [ + { type: 'link', text: 'Backup plans', href: '#/data/backups/plans', icon: }, + { type: 'link', text: 'Backup vaults', href: '#/data/backups/vaults', icon: }, + { type: 'link', text: 'Restore jobs', href: '#/data/backups/restore-jobs', icon: }, + { + type: 'expandable-link-group', + href: '#/data/backups/schedules', + text: 'Schedules', + icon: , + items: [ + { type: 'link', text: 'Daily snapshot', href: '#/data/backups/schedules/daily' }, + { type: 'link', text: 'Weekly snapshot', href: '#/data/backups/schedules/weekly' }, + { type: 'link', text: 'Monthly snapshot', href: '#/data/backups/schedules/monthly' }, + { + type: 'expandable-link-group', + href: '#/data/backups/schedules/retention', + text: 'Retention policies', + icon: , + items: [ + { type: 'link', text: 'Short-term policy', href: '#/data/backups/schedules/retention/short-term' }, + { type: 'link', text: 'Long-term policy', href: '#/data/backups/schedules/retention/long-term' }, + { type: 'link', text: 'Compliance policy', href: '#/data/backups/schedules/retention/compliance' }, + ], + }, + ], + }, + ], + }, ], }, +]; + +const simpleItems: SideNavigationProps.Item[] = [ + { + type: 'link', + text: 'Dashboard', + href: '#/dashboard', + icon: , + }, + { + type: 'link', + text: 'Storage', + href: '#/storage', + icon: ( + + + + } + /> + ), + }, + { + type: 'link', + text: 'Metrics', + href: '#/page3', + icon: ( + + + + } + /> + ), + }, + { type: 'divider' }, + { + type: 'link', + text: 'Notifications', + href: '#/notifications', + icon: , + }, + { + type: 'link', + text: 'Support', + href: 'https://example.com', + external: true, + icon: , + }, +]; + +const navWithSections: SideNavigationProps.Item[] = [ + { + type: 'link', + text: 'Dashboard', + href: '#/dashboard', + icon: , + }, + { + type: 'link', + text: 'Instances', + href: '#/instances', + icon: cubeIcon, + }, + { + type: 'section', + text: 'Reports and Analytics', + items: [ + { + type: 'link', + text: 'Usage', + href: '#/page4', + icon: ( + + + + } + /> + ), + }, + { + type: 'link', + text: 'Alarms', + href: '#/page5', + icon: , + }, + { + type: 'link', + text: 'Logs', + href: '#/page6', + icon: , + }, + ], + }, + { + type: 'section', + text: 'Security', + items: [ + { + type: 'link', + text: 'API Keys', + href: '#/page7', + icon: , + }, + { + type: 'link', + text: 'Encryption', + href: '#/page8', + icon: , + }, + { + type: 'link', + text: 'Authentication', + href: '#/page9', + icon: , + }, + ], + }, +]; + +const navWithELGs: SideNavigationProps.Item[] = [ + { + type: 'link', + text: 'Dashboard', + href: '#/dashboard', + icon: ( + + + + + } + /> + ), + }, + { + type: 'link', + text: 'Deployments', + href: '#/page2', + icon: cubeIcon, + }, { type: 'expandable-link-group', - text: 'Expandable link group', - href: '#/projects', - icon: , + text: 'Projects', + href: '#/group1', + icon: , + defaultExpanded: true, items: [ - { type: 'link', text: 'Project 1', href: '#/projects/1' }, - { type: 'link', text: 'Project 2', href: '#/projects/2' }, - { type: 'link', text: 'Project 3', href: '#/projects/3' }, + { + type: 'link', + text: 'Project 1', + href: '#/page4', + }, + { + type: 'link', + text: 'Project 2', + href: '#/page5', + }, + { + type: 'link', + text: 'Project 3', + href: '#/page6', + }, ], }, - { type: 'link', text: 'Documentation', href: '#/docs', external: true }, { - type: 'section-group', - title: 'Section group', + type: 'expandable-link-group', + text: 'Groups', + href: '#/group2', + icon: , + defaultExpanded: true, items: [ - { type: 'link', text: 'Announcements', href: '#/announcements2', icon: }, - { type: 'link', text: 'Team', href: '#/team2', icon: }, - { type: 'link', text: 'Networking', href: '#/networking2', icon: }, + { + type: 'link', + text: 'My team', + href: '#/page7', + }, + { + type: 'link', + text: 'My org', + href: '#/page8', + }, + { + type: 'link', + text: 'My company', + href: '#/page9', + }, ], }, + { type: 'divider' }, + { + type: 'link', + text: 'Help and support', + href: 'https://example.com', + icon: , + }, + { + type: 'link', + text: 'Feedback', + href: '#/notifications', + icon: , + }, ]; +function stripIcons(items: ReadonlyArray): SideNavigationProps.Item[] { + return items.map((item): SideNavigationProps.Item => { + switch (item.type) { + case 'divider': + return item; + case 'link': + return { ...item, icon: undefined }; + case 'section': + return { ...item, items: stripIcons(item.items) }; + case 'link-group': + return { ...item, icon: undefined, items: stripIcons(item.items) }; + case 'expandable-link-group': + return { ...item, icon: undefined, items: stripIcons(item.items) }; + case 'section-group': + return { + ...item, + items: stripIcons(item.items) as Array< + | SideNavigationProps.Section + | SideNavigationProps.Link + | SideNavigationProps.LinkGroup + | SideNavigationProps.ExpandableLinkGroup + >, + }; + } + }); +} + const COLLAPSED_WIDTH = 52; const EXPANDED_WIDTH = 220; +const itemsByRadioValue: Record = { + first: simpleItems, + second: navWithSections, + third: navWithELGs, + fourth: kitchenSink, +}; + export default function SideNavigationCollapsedPage() { - const [activeHref, setActiveHref] = useState('#/calendar'); + const { urlParams, setUrlParams } = useContext(AppContext as CollapsedNavDemoContext); + const { itemsSet = 'first' } = urlParams; + const [activeHref, setActiveHref] = useState('#/dashboard'); const [collapsed, setCollapsed] = useState(false); const [panelWidth, setPanelWidth] = useState(EXPANDED_WIDTH); + const [iconLayout, setIconLayout] = useState(true); + const items = itemsByRadioValue[itemsSet]; const navRef = useRef(null); const toggleRef = useRef(null); const reducedMotion = useReducedMotion(navRef); @@ -99,7 +429,8 @@ export default function SideNavigationCollapsedPage() { {/* Toggle button at top */}
Product name}
diff --git a/src/__integ__/__snapshots__/themes.test.ts.snap b/src/__integ__/__snapshots__/themes.test.ts.snap index f19634ea03..44de4f484a 100644 --- a/src/__integ__/__snapshots__/themes.test.ts.snap +++ b/src/__integ__/__snapshots__/themes.test.ts.snap @@ -801,6 +801,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "compact" 1`] = "motion-duration-avatar-gen-ai-gradient": "3600ms", "motion-duration-avatar-loading-dots": "1200ms", "motion-duration-complex": "270ms", + "motion-duration-expandable-content-enter": "180ms", "motion-duration-expressive": "180ms", "motion-duration-extra-slow": "270ms", "motion-duration-fast": "90ms", @@ -813,6 +814,9 @@ exports[`CSS Custom Properties match previous snapshot for mode "compact" 1`] = "motion-duration-rotate-90": "135ms", "motion-duration-show-paced": "180ms", "motion-duration-show-quick": "135ms", + "motion-duration-side-navigation-content-enter-fade": "0ms", + "motion-duration-side-navigation-content-exit": "0ms", + "motion-duration-side-navigation-content-exit-fade": "0ms", "motion-duration-slow": "180ms", "motion-duration-tooltip-enter": "0ms", "motion-duration-transition-quick": "90ms", @@ -820,6 +824,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "compact" 1`] = "motion-duration-transition-show-quick": "90ms", "motion-easing-avatar-gen-ai-gradient": "cubic-bezier(0.7, 0, 0.3, 1)", "motion-easing-ease-out-quart": "cubic-bezier(0.165, 0.84, 0.44, 1)", + "motion-easing-expandable-content-enter": "ease-out", "motion-easing-expressive": "ease-out", "motion-easing-refresh-only-a": "cubic-bezier(0, 0, 0, 1)", "motion-easing-refresh-only-b": "cubic-bezier(1, 0, 0.83, 1)", @@ -829,6 +834,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "compact" 1`] = "motion-easing-rotate-90": "cubic-bezier(0.165, 0.84, 0.44, 1)", "motion-easing-show-paced": "ease-out", "motion-easing-show-quick": "ease-out", + "motion-easing-side-navigation-content-exit": "ease-out", "motion-easing-sticky": "ease-out", "motion-easing-tooltip-enter": "cubic-bezier(0, 0, 0, 1)", "motion-easing-transition-quick": "linear", @@ -861,6 +867,8 @@ exports[`CSS Custom Properties match previous snapshot for mode "compact" 1`] = "size-icon-large": "48px", "size-icon-medium": "16px", "size-icon-normal": "16px", + "size-side-navigation-collapsed-width": "52px", + "size-side-navigation-item-collapsed": "28px", "size-side-navigation-item-height": "24px", "size-table-selection-horizontal": "54px", "size-vertical-input": "28px", @@ -1165,7 +1173,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "dark" 1`] = ` "color-background-segment-wrapper": "#2a2e33", "color-background-side-navigation-item-active": "transparent", "color-background-side-navigation-item-active-collapsed": "#00a1c9", - "color-background-side-navigation-item-icon-hover": "#414750", + "color-background-side-navigation-item-icon-hover": "#12293b", "color-background-skeleton": "#2a2e33", "color-background-skeleton-wave": "#414750", "color-background-slider-handle-active": "#44b9d6", @@ -1784,6 +1792,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "dark" 1`] = ` "motion-duration-avatar-gen-ai-gradient": "3600ms", "motion-duration-avatar-loading-dots": "1200ms", "motion-duration-complex": "270ms", + "motion-duration-expandable-content-enter": "180ms", "motion-duration-expressive": "180ms", "motion-duration-extra-slow": "270ms", "motion-duration-fast": "90ms", @@ -1796,6 +1805,9 @@ exports[`CSS Custom Properties match previous snapshot for mode "dark" 1`] = ` "motion-duration-rotate-90": "135ms", "motion-duration-show-paced": "180ms", "motion-duration-show-quick": "135ms", + "motion-duration-side-navigation-content-enter-fade": "0ms", + "motion-duration-side-navigation-content-exit": "0ms", + "motion-duration-side-navigation-content-exit-fade": "0ms", "motion-duration-slow": "180ms", "motion-duration-tooltip-enter": "0ms", "motion-duration-transition-quick": "90ms", @@ -1803,6 +1815,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "dark" 1`] = ` "motion-duration-transition-show-quick": "90ms", "motion-easing-avatar-gen-ai-gradient": "cubic-bezier(0.7, 0, 0.3, 1)", "motion-easing-ease-out-quart": "cubic-bezier(0.165, 0.84, 0.44, 1)", + "motion-easing-expandable-content-enter": "ease-out", "motion-easing-expressive": "ease-out", "motion-easing-refresh-only-a": "cubic-bezier(0, 0, 0, 1)", "motion-easing-refresh-only-b": "cubic-bezier(1, 0, 0.83, 1)", @@ -1812,6 +1825,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "dark" 1`] = ` "motion-easing-rotate-90": "cubic-bezier(0.165, 0.84, 0.44, 1)", "motion-easing-show-paced": "ease-out", "motion-easing-show-quick": "ease-out", + "motion-easing-side-navigation-content-exit": "ease-out", "motion-easing-sticky": "ease-out", "motion-easing-tooltip-enter": "cubic-bezier(0, 0, 0, 1)", "motion-easing-transition-quick": "linear", @@ -1844,6 +1858,8 @@ exports[`CSS Custom Properties match previous snapshot for mode "dark" 1`] = ` "size-icon-large": "48px", "size-icon-medium": "16px", "size-icon-normal": "16px", + "size-side-navigation-collapsed-width": "52px", + "size-side-navigation-item-collapsed": "30px", "size-side-navigation-item-height": "28px", "size-table-selection-horizontal": "54px", "size-vertical-input": "32px", @@ -2767,6 +2783,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "light" 1`] = ` "motion-duration-avatar-gen-ai-gradient": "3600ms", "motion-duration-avatar-loading-dots": "1200ms", "motion-duration-complex": "270ms", + "motion-duration-expandable-content-enter": "180ms", "motion-duration-expressive": "180ms", "motion-duration-extra-slow": "270ms", "motion-duration-fast": "90ms", @@ -2779,6 +2796,9 @@ exports[`CSS Custom Properties match previous snapshot for mode "light" 1`] = ` "motion-duration-rotate-90": "135ms", "motion-duration-show-paced": "180ms", "motion-duration-show-quick": "135ms", + "motion-duration-side-navigation-content-enter-fade": "0ms", + "motion-duration-side-navigation-content-exit": "0ms", + "motion-duration-side-navigation-content-exit-fade": "0ms", "motion-duration-slow": "180ms", "motion-duration-tooltip-enter": "0ms", "motion-duration-transition-quick": "90ms", @@ -2786,6 +2806,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "light" 1`] = ` "motion-duration-transition-show-quick": "90ms", "motion-easing-avatar-gen-ai-gradient": "cubic-bezier(0.7, 0, 0.3, 1)", "motion-easing-ease-out-quart": "cubic-bezier(0.165, 0.84, 0.44, 1)", + "motion-easing-expandable-content-enter": "ease-out", "motion-easing-expressive": "ease-out", "motion-easing-refresh-only-a": "cubic-bezier(0, 0, 0, 1)", "motion-easing-refresh-only-b": "cubic-bezier(1, 0, 0.83, 1)", @@ -2795,6 +2816,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "light" 1`] = ` "motion-easing-rotate-90": "cubic-bezier(0.165, 0.84, 0.44, 1)", "motion-easing-show-paced": "ease-out", "motion-easing-show-quick": "ease-out", + "motion-easing-side-navigation-content-exit": "ease-out", "motion-easing-sticky": "ease-out", "motion-easing-tooltip-enter": "cubic-bezier(0, 0, 0, 1)", "motion-easing-transition-quick": "linear", @@ -2827,6 +2849,8 @@ exports[`CSS Custom Properties match previous snapshot for mode "light" 1`] = ` "size-icon-large": "48px", "size-icon-medium": "16px", "size-icon-normal": "16px", + "size-side-navigation-collapsed-width": "52px", + "size-side-navigation-item-collapsed": "30px", "size-side-navigation-item-height": "28px", "size-table-selection-horizontal": "54px", "size-vertical-input": "32px", @@ -3750,6 +3774,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "reduced-motion" "motion-duration-avatar-gen-ai-gradient": "0ms", "motion-duration-avatar-loading-dots": "0ms", "motion-duration-complex": "0ms", + "motion-duration-expandable-content-enter": "0ms", "motion-duration-expressive": "0ms", "motion-duration-extra-slow": "0ms", "motion-duration-fast": "0ms", @@ -3762,6 +3787,9 @@ exports[`CSS Custom Properties match previous snapshot for mode "reduced-motion" "motion-duration-rotate-90": "0ms", "motion-duration-show-paced": "0ms", "motion-duration-show-quick": "0ms", + "motion-duration-side-navigation-content-enter-fade": "0ms", + "motion-duration-side-navigation-content-exit": "0ms", + "motion-duration-side-navigation-content-exit-fade": "0ms", "motion-duration-slow": "0ms", "motion-duration-tooltip-enter": "0ms", "motion-duration-transition-quick": "0ms", @@ -3769,6 +3797,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "reduced-motion" "motion-duration-transition-show-quick": "0ms", "motion-easing-avatar-gen-ai-gradient": "cubic-bezier(0.7, 0, 0.3, 1)", "motion-easing-ease-out-quart": "cubic-bezier(0.165, 0.84, 0.44, 1)", + "motion-easing-expandable-content-enter": "ease-out", "motion-easing-expressive": "ease-out", "motion-easing-refresh-only-a": "cubic-bezier(0, 0, 0, 1)", "motion-easing-refresh-only-b": "cubic-bezier(1, 0, 0.83, 1)", @@ -3778,6 +3807,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "reduced-motion" "motion-easing-rotate-90": "cubic-bezier(0.165, 0.84, 0.44, 1)", "motion-easing-show-paced": "ease-out", "motion-easing-show-quick": "ease-out", + "motion-easing-side-navigation-content-exit": "ease-out", "motion-easing-sticky": "ease-out", "motion-easing-tooltip-enter": "cubic-bezier(0, 0, 0, 1)", "motion-easing-transition-quick": "linear", @@ -3810,6 +3840,8 @@ exports[`CSS Custom Properties match previous snapshot for mode "reduced-motion" "size-icon-large": "48px", "size-icon-medium": "16px", "size-icon-normal": "16px", + "size-side-navigation-collapsed-width": "52px", + "size-side-navigation-item-collapsed": "30px", "size-side-navigation-item-height": "28px", "size-table-selection-horizontal": "54px", "size-vertical-input": "32px", @@ -4733,6 +4765,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "visual-refresh" "motion-duration-avatar-gen-ai-gradient": "3600ms", "motion-duration-avatar-loading-dots": "1200ms", "motion-duration-complex": "250ms", + "motion-duration-expandable-content-enter": "180ms", "motion-duration-expressive": "165ms", "motion-duration-extra-slow": "270ms", "motion-duration-fast": "90ms", @@ -4745,6 +4778,9 @@ exports[`CSS Custom Properties match previous snapshot for mode "visual-refresh" "motion-duration-rotate-90": "135ms", "motion-duration-show-paced": "180ms", "motion-duration-show-quick": "135ms", + "motion-duration-side-navigation-content-enter-fade": "0ms", + "motion-duration-side-navigation-content-exit": "0ms", + "motion-duration-side-navigation-content-exit-fade": "0ms", "motion-duration-slow": "180ms", "motion-duration-tooltip-enter": "115ms", "motion-duration-transition-quick": "90ms", @@ -4752,6 +4788,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "visual-refresh" "motion-duration-transition-show-quick": "90ms", "motion-easing-avatar-gen-ai-gradient": "cubic-bezier(0.7, 0, 0.3, 1)", "motion-easing-ease-out-quart": "cubic-bezier(0.165, 0.84, 0.44, 1)", + "motion-easing-expandable-content-enter": "ease-out", "motion-easing-expressive": "cubic-bezier(0.84, 0, 0.16, 1)", "motion-easing-refresh-only-a": "cubic-bezier(0, 0, 0, 1)", "motion-easing-refresh-only-b": "cubic-bezier(1, 0, 0.83, 1)", @@ -4761,6 +4798,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "visual-refresh" "motion-easing-rotate-90": "cubic-bezier(0.165, 0.84, 0.44, 1)", "motion-easing-show-paced": "ease-out", "motion-easing-show-quick": "ease-out", + "motion-easing-side-navigation-content-exit": "ease-out", "motion-easing-sticky": "cubic-bezier(1, 0, 0.83, 1)", "motion-easing-tooltip-enter": "cubic-bezier(0, 0, 0, 1)", "motion-easing-transition-quick": "linear", @@ -4793,6 +4831,8 @@ exports[`CSS Custom Properties match previous snapshot for mode "visual-refresh" "size-icon-large": "48px", "size-icon-medium": "20px", "size-icon-normal": "16px", + "size-side-navigation-collapsed-width": "52px", + "size-side-navigation-item-collapsed": "30px", "size-side-navigation-item-height": "28px", "size-table-selection-horizontal": "40px", "size-vertical-input": "32px", @@ -5716,6 +5756,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "visual-refresh- "motion-duration-avatar-gen-ai-gradient": "3600ms", "motion-duration-avatar-loading-dots": "1200ms", "motion-duration-complex": "250ms", + "motion-duration-expandable-content-enter": "180ms", "motion-duration-expressive": "165ms", "motion-duration-extra-slow": "270ms", "motion-duration-fast": "90ms", @@ -5728,6 +5769,9 @@ exports[`CSS Custom Properties match previous snapshot for mode "visual-refresh- "motion-duration-rotate-90": "135ms", "motion-duration-show-paced": "180ms", "motion-duration-show-quick": "135ms", + "motion-duration-side-navigation-content-enter-fade": "0ms", + "motion-duration-side-navigation-content-exit": "0ms", + "motion-duration-side-navigation-content-exit-fade": "0ms", "motion-duration-slow": "180ms", "motion-duration-tooltip-enter": "115ms", "motion-duration-transition-quick": "90ms", @@ -5735,6 +5779,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "visual-refresh- "motion-duration-transition-show-quick": "90ms", "motion-easing-avatar-gen-ai-gradient": "cubic-bezier(0.7, 0, 0.3, 1)", "motion-easing-ease-out-quart": "cubic-bezier(0.165, 0.84, 0.44, 1)", + "motion-easing-expandable-content-enter": "ease-out", "motion-easing-expressive": "cubic-bezier(0.84, 0, 0.16, 1)", "motion-easing-refresh-only-a": "cubic-bezier(0, 0, 0, 1)", "motion-easing-refresh-only-b": "cubic-bezier(1, 0, 0.83, 1)", @@ -5744,6 +5789,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "visual-refresh- "motion-easing-rotate-90": "cubic-bezier(0.165, 0.84, 0.44, 1)", "motion-easing-show-paced": "ease-out", "motion-easing-show-quick": "ease-out", + "motion-easing-side-navigation-content-exit": "ease-out", "motion-easing-sticky": "cubic-bezier(1, 0, 0.83, 1)", "motion-easing-tooltip-enter": "cubic-bezier(0, 0, 0, 1)", "motion-easing-transition-quick": "linear", @@ -5776,6 +5822,8 @@ exports[`CSS Custom Properties match previous snapshot for mode "visual-refresh- "size-icon-large": "48px", "size-icon-medium": "20px", "size-icon-normal": "16px", + "size-side-navigation-collapsed-width": "52px", + "size-side-navigation-item-collapsed": "28px", "size-side-navigation-item-height": "24px", "size-table-selection-horizontal": "40px", "size-vertical-input": "28px", @@ -6080,7 +6128,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "visual-refresh- "color-background-segment-wrapper": "#0f141a", "color-background-side-navigation-item-active": "transparent", "color-background-side-navigation-item-active-collapsed": "#42b4ff", - "color-background-side-navigation-item-icon-hover": "#333843", + "color-background-side-navigation-item-icon-hover": "#001129", "color-background-skeleton": "#232b37", "color-background-skeleton-wave": "#333843", "color-background-slider-handle-active": "#75cfff", @@ -6699,6 +6747,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "visual-refresh- "motion-duration-avatar-gen-ai-gradient": "3600ms", "motion-duration-avatar-loading-dots": "1200ms", "motion-duration-complex": "250ms", + "motion-duration-expandable-content-enter": "180ms", "motion-duration-expressive": "165ms", "motion-duration-extra-slow": "270ms", "motion-duration-fast": "90ms", @@ -6711,6 +6760,9 @@ exports[`CSS Custom Properties match previous snapshot for mode "visual-refresh- "motion-duration-rotate-90": "135ms", "motion-duration-show-paced": "180ms", "motion-duration-show-quick": "135ms", + "motion-duration-side-navigation-content-enter-fade": "0ms", + "motion-duration-side-navigation-content-exit": "0ms", + "motion-duration-side-navigation-content-exit-fade": "0ms", "motion-duration-slow": "180ms", "motion-duration-tooltip-enter": "115ms", "motion-duration-transition-quick": "90ms", @@ -6718,6 +6770,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "visual-refresh- "motion-duration-transition-show-quick": "90ms", "motion-easing-avatar-gen-ai-gradient": "cubic-bezier(0.7, 0, 0.3, 1)", "motion-easing-ease-out-quart": "cubic-bezier(0.165, 0.84, 0.44, 1)", + "motion-easing-expandable-content-enter": "ease-out", "motion-easing-expressive": "cubic-bezier(0.84, 0, 0.16, 1)", "motion-easing-refresh-only-a": "cubic-bezier(0, 0, 0, 1)", "motion-easing-refresh-only-b": "cubic-bezier(1, 0, 0.83, 1)", @@ -6727,6 +6780,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "visual-refresh- "motion-easing-rotate-90": "cubic-bezier(0.165, 0.84, 0.44, 1)", "motion-easing-show-paced": "ease-out", "motion-easing-show-quick": "ease-out", + "motion-easing-side-navigation-content-exit": "ease-out", "motion-easing-sticky": "cubic-bezier(1, 0, 0.83, 1)", "motion-easing-tooltip-enter": "cubic-bezier(0, 0, 0, 1)", "motion-easing-transition-quick": "linear", @@ -6759,6 +6813,8 @@ exports[`CSS Custom Properties match previous snapshot for mode "visual-refresh- "size-icon-large": "48px", "size-icon-medium": "20px", "size-icon-normal": "16px", + "size-side-navigation-collapsed-width": "52px", + "size-side-navigation-item-collapsed": "30px", "size-side-navigation-item-height": "28px", "size-table-selection-horizontal": "40px", "size-vertical-input": "32px", @@ -7063,7 +7119,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "visual-refresh- "color-background-segment-wrapper": "#161d26", "color-background-side-navigation-item-active": "transparent", "color-background-side-navigation-item-active-collapsed": "#42b4ff", - "color-background-side-navigation-item-icon-hover": "#333843", + "color-background-side-navigation-item-icon-hover": "#001129", "color-background-skeleton": "#232b37", "color-background-skeleton-wave": "#333843", "color-background-slider-handle-active": "#75cfff", @@ -7682,6 +7738,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "visual-refresh- "motion-duration-avatar-gen-ai-gradient": "3600ms", "motion-duration-avatar-loading-dots": "1200ms", "motion-duration-complex": "250ms", + "motion-duration-expandable-content-enter": "180ms", "motion-duration-expressive": "165ms", "motion-duration-extra-slow": "270ms", "motion-duration-fast": "90ms", @@ -7694,6 +7751,9 @@ exports[`CSS Custom Properties match previous snapshot for mode "visual-refresh- "motion-duration-rotate-90": "135ms", "motion-duration-show-paced": "180ms", "motion-duration-show-quick": "135ms", + "motion-duration-side-navigation-content-enter-fade": "0ms", + "motion-duration-side-navigation-content-exit": "0ms", + "motion-duration-side-navigation-content-exit-fade": "0ms", "motion-duration-slow": "180ms", "motion-duration-tooltip-enter": "115ms", "motion-duration-transition-quick": "90ms", @@ -7701,6 +7761,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "visual-refresh- "motion-duration-transition-show-quick": "90ms", "motion-easing-avatar-gen-ai-gradient": "cubic-bezier(0.7, 0, 0.3, 1)", "motion-easing-ease-out-quart": "cubic-bezier(0.165, 0.84, 0.44, 1)", + "motion-easing-expandable-content-enter": "ease-out", "motion-easing-expressive": "cubic-bezier(0.84, 0, 0.16, 1)", "motion-easing-refresh-only-a": "cubic-bezier(0, 0, 0, 1)", "motion-easing-refresh-only-b": "cubic-bezier(1, 0, 0.83, 1)", @@ -7710,6 +7771,7 @@ exports[`CSS Custom Properties match previous snapshot for mode "visual-refresh- "motion-easing-rotate-90": "cubic-bezier(0.165, 0.84, 0.44, 1)", "motion-easing-show-paced": "ease-out", "motion-easing-show-quick": "ease-out", + "motion-easing-side-navigation-content-exit": "ease-out", "motion-easing-sticky": "cubic-bezier(1, 0, 0.83, 1)", "motion-easing-tooltip-enter": "cubic-bezier(0, 0, 0, 1)", "motion-easing-transition-quick": "linear", @@ -7742,6 +7804,8 @@ exports[`CSS Custom Properties match previous snapshot for mode "visual-refresh- "size-icon-large": "48px", "size-icon-medium": "20px", "size-icon-normal": "16px", + "size-side-navigation-collapsed-width": "52px", + "size-side-navigation-item-collapsed": "30px", "size-side-navigation-item-height": "28px", "size-table-selection-horizontal": "40px", "size-vertical-input": "32px", diff --git a/src/__tests__/snapshot-tests/__snapshots__/design-tokens.test.ts.snap b/src/__tests__/snapshot-tests/__snapshots__/design-tokens.test.ts.snap index 2de90ad51c..7b0c44c509 100644 --- a/src/__tests__/snapshot-tests/__snapshots__/design-tokens.test.ts.snap +++ b/src/__tests__/snapshot-tests/__snapshots__/design-tokens.test.ts.snap @@ -3357,6 +3357,20 @@ exports[`Design tokens artifacts Design tokens JSON for classic matches the snap "light": "0px 4px 8px rgba(0, 28, 36, 0.45)", }, }, + "size-side-navigation-collapsed-width": { + "$description": "The default width of the collapsed side navigation rail.", + "$value": { + "comfortable": "52px", + "compact": "52px", + }, + }, + "size-side-navigation-item-collapsed": { + "$description": "The square size of collapsed side navigation items.", + "$value": { + "comfortable": "30px", + "compact": "28px", + }, + }, "size-side-navigation-item-height": { "$description": "The minimum height of side navigation items.", "$value": { @@ -7000,6 +7014,20 @@ exports[`Design tokens artifacts Design tokens JSON for classic matches the snap "light": "0px 4px 8px rgba(0, 28, 36, 0.45)", }, }, + "size-side-navigation-collapsed-width": { + "$description": "The default width of the collapsed side navigation rail.", + "$value": { + "comfortable": "52px", + "compact": "52px", + }, + }, + "size-side-navigation-item-collapsed": { + "$description": "The square size of collapsed side navigation items.", + "$value": { + "comfortable": "30px", + "compact": "28px", + }, + }, "size-side-navigation-item-height": { "$description": "The minimum height of side navigation items.", "$value": { @@ -10643,6 +10671,20 @@ exports[`Design tokens artifacts Design tokens JSON for classic matches the snap "light": "0px 4px 8px rgba(0, 28, 36, 0.45)", }, }, + "size-side-navigation-collapsed-width": { + "$description": "The default width of the collapsed side navigation rail.", + "$value": { + "comfortable": "52px", + "compact": "52px", + }, + }, + "size-side-navigation-item-collapsed": { + "$description": "The square size of collapsed side navigation items.", + "$value": { + "comfortable": "30px", + "compact": "28px", + }, + }, "size-side-navigation-item-height": { "$description": "The minimum height of side navigation items.", "$value": { @@ -14286,6 +14328,20 @@ exports[`Design tokens artifacts Design tokens JSON for classic matches the snap "light": "0px 4px 8px rgba(0, 28, 36, 0.45)", }, }, + "size-side-navigation-collapsed-width": { + "$description": "The default width of the collapsed side navigation rail.", + "$value": { + "comfortable": "52px", + "compact": "52px", + }, + }, + "size-side-navigation-item-collapsed": { + "$description": "The square size of collapsed side navigation items.", + "$value": { + "comfortable": "30px", + "compact": "28px", + }, + }, "size-side-navigation-item-height": { "$description": "The minimum height of side navigation items.", "$value": { @@ -17929,6 +17985,20 @@ exports[`Design tokens artifacts Design tokens JSON for classic matches the snap "light": "0px 4px 8px rgba(0, 28, 36, 0.45)", }, }, + "size-side-navigation-collapsed-width": { + "$description": "The default width of the collapsed side navigation rail.", + "$value": { + "comfortable": "52px", + "compact": "52px", + }, + }, + "size-side-navigation-item-collapsed": { + "$description": "The square size of collapsed side navigation items.", + "$value": { + "comfortable": "30px", + "compact": "28px", + }, + }, "size-side-navigation-item-height": { "$description": "The minimum height of side navigation items.", "$value": { @@ -21572,6 +21642,20 @@ exports[`Design tokens artifacts Design tokens JSON for classic matches the snap "light": "0px 4px 8px rgba(0, 28, 36, 0.45)", }, }, + "size-side-navigation-collapsed-width": { + "$description": "The default width of the collapsed side navigation rail.", + "$value": { + "comfortable": "52px", + "compact": "52px", + }, + }, + "size-side-navigation-item-collapsed": { + "$description": "The square size of collapsed side navigation items.", + "$value": { + "comfortable": "30px", + "compact": "28px", + }, + }, "size-side-navigation-item-height": { "$description": "The minimum height of side navigation items.", "$value": { @@ -25215,6 +25299,20 @@ exports[`Design tokens artifacts Design tokens JSON for classic matches the snap "light": "0px 4px 8px rgba(0, 28, 36, 0.45)", }, }, + "size-side-navigation-collapsed-width": { + "$description": "The default width of the collapsed side navigation rail.", + "$value": { + "comfortable": "52px", + "compact": "52px", + }, + }, + "size-side-navigation-item-collapsed": { + "$description": "The square size of collapsed side navigation items.", + "$value": { + "comfortable": "30px", + "compact": "28px", + }, + }, "size-side-navigation-item-height": { "$description": "The minimum height of side navigation items.", "$value": { @@ -28863,6 +28961,20 @@ exports[`Design tokens artifacts Design tokens JSON for visual-refresh matches t "light": "0px 1px 1px 1px #e9ebed, 0px 6px 36px #0007161a", }, }, + "size-side-navigation-collapsed-width": { + "$description": "The default width of the collapsed side navigation rail.", + "$value": { + "comfortable": "52px", + "compact": "52px", + }, + }, + "size-side-navigation-item-collapsed": { + "$description": "The square size of collapsed side navigation items.", + "$value": { + "comfortable": "30px", + "compact": "28px", + }, + }, "size-side-navigation-item-height": { "$description": "The minimum height of side navigation items.", "$value": { @@ -32506,6 +32618,20 @@ exports[`Design tokens artifacts Design tokens JSON for visual-refresh matches t "light": "0px 1px 1px 1px #e9ebed, 0px 6px 36px #0007161a", }, }, + "size-side-navigation-collapsed-width": { + "$description": "The default width of the collapsed side navigation rail.", + "$value": { + "comfortable": "52px", + "compact": "52px", + }, + }, + "size-side-navigation-item-collapsed": { + "$description": "The square size of collapsed side navigation items.", + "$value": { + "comfortable": "30px", + "compact": "28px", + }, + }, "size-side-navigation-item-height": { "$description": "The minimum height of side navigation items.", "$value": { @@ -36149,6 +36275,20 @@ exports[`Design tokens artifacts Design tokens JSON for visual-refresh matches t "light": "0px 1px 1px 1px #e9ebed, 0px 6px 36px #0007161a", }, }, + "size-side-navigation-collapsed-width": { + "$description": "The default width of the collapsed side navigation rail.", + "$value": { + "comfortable": "52px", + "compact": "52px", + }, + }, + "size-side-navigation-item-collapsed": { + "$description": "The square size of collapsed side navigation items.", + "$value": { + "comfortable": "30px", + "compact": "28px", + }, + }, "size-side-navigation-item-height": { "$description": "The minimum height of side navigation items.", "$value": { @@ -39792,6 +39932,20 @@ exports[`Design tokens artifacts Design tokens JSON for visual-refresh matches t "light": "0px 1px 1px 1px #e9ebed, 0px 6px 36px #0007161a", }, }, + "size-side-navigation-collapsed-width": { + "$description": "The default width of the collapsed side navigation rail.", + "$value": { + "comfortable": "52px", + "compact": "52px", + }, + }, + "size-side-navigation-item-collapsed": { + "$description": "The square size of collapsed side navigation items.", + "$value": { + "comfortable": "30px", + "compact": "28px", + }, + }, "size-side-navigation-item-height": { "$description": "The minimum height of side navigation items.", "$value": { @@ -43435,6 +43589,20 @@ exports[`Design tokens artifacts Design tokens JSON for visual-refresh matches t "light": "0px 1px 1px 1px #e9ebed, 0px 6px 36px #0007161a", }, }, + "size-side-navigation-collapsed-width": { + "$description": "The default width of the collapsed side navigation rail.", + "$value": { + "comfortable": "52px", + "compact": "52px", + }, + }, + "size-side-navigation-item-collapsed": { + "$description": "The square size of collapsed side navigation items.", + "$value": { + "comfortable": "30px", + "compact": "28px", + }, + }, "size-side-navigation-item-height": { "$description": "The minimum height of side navigation items.", "$value": { @@ -47078,6 +47246,20 @@ exports[`Design tokens artifacts Design tokens JSON for visual-refresh matches t "light": "0px 1px 1px 1px #e9ebed, 0px 6px 36px #0007161a", }, }, + "size-side-navigation-collapsed-width": { + "$description": "The default width of the collapsed side navigation rail.", + "$value": { + "comfortable": "52px", + "compact": "52px", + }, + }, + "size-side-navigation-item-collapsed": { + "$description": "The square size of collapsed side navigation items.", + "$value": { + "comfortable": "30px", + "compact": "28px", + }, + }, "size-side-navigation-item-height": { "$description": "The minimum height of side navigation items.", "$value": { @@ -50721,6 +50903,20 @@ exports[`Design tokens artifacts Design tokens JSON for visual-refresh matches t "light": "0px 1px 1px 1px #192534, 0px 6px 36px #00040c", }, }, + "size-side-navigation-collapsed-width": { + "$description": "The default width of the collapsed side navigation rail.", + "$value": { + "comfortable": "52px", + "compact": "52px", + }, + }, + "size-side-navigation-item-collapsed": { + "$description": "The square size of collapsed side navigation items.", + "$value": { + "comfortable": "30px", + "compact": "28px", + }, + }, "size-side-navigation-item-height": { "$description": "The minimum height of side navigation items.", "$value": { @@ -54364,6 +54560,20 @@ exports[`Design tokens artifacts Design tokens JSON for visual-refresh matches t "light": "0px 1px 1px 1px #e9ebed, 0px 6px 36px #0007161a", }, }, + "size-side-navigation-collapsed-width": { + "$description": "The default width of the collapsed side navigation rail.", + "$value": { + "comfortable": "52px", + "compact": "52px", + }, + }, + "size-side-navigation-item-collapsed": { + "$description": "The square size of collapsed side navigation items.", + "$value": { + "comfortable": "30px", + "compact": "28px", + }, + }, "size-side-navigation-item-height": { "$description": "The minimum height of side navigation items.", "$value": { @@ -58007,6 +58217,20 @@ exports[`Design tokens artifacts Design tokens JSON for visual-refresh matches t "light": "0px 1px 1px 1px #e9ebed, 0px 6px 36px #0007161a", }, }, + "size-side-navigation-collapsed-width": { + "$description": "The default width of the collapsed side navigation rail.", + "$value": { + "comfortable": "52px", + "compact": "52px", + }, + }, + "size-side-navigation-item-collapsed": { + "$description": "The square size of collapsed side navigation items.", + "$value": { + "comfortable": "30px", + "compact": "28px", + }, + }, "size-side-navigation-item-height": { "$description": "The minimum height of side navigation items.", "$value": { diff --git a/src/app-layout-toolbar/index.tsx b/src/app-layout-toolbar/index.tsx index a40660a8ae..4d2b0e269a 100644 --- a/src/app-layout-toolbar/index.tsx +++ b/src/app-layout-toolbar/index.tsx @@ -62,6 +62,7 @@ const AppLayoutToolbar = React.forwardRef( disableContentPaddings: rest.disableContentPaddings, navigationWidth, navigationHide: rest.navigationHide, + navigationCloseBehavior: rest.navigationCloseBehavior, toolsHide: rest.toolsHide, toolsWidth, maxContentWidth, diff --git a/src/app-layout/constants.scss b/src/app-layout/constants.scss index 04a4bcc032..2dff5ba050 100644 --- a/src/app-layout/constants.scss +++ b/src/app-layout/constants.scss @@ -35,8 +35,5 @@ $toolbar-z-index: 1000; // Shared toolbar drawer component values $toolbar-vertical-panel-icon-offset: 14px; -// Default collapsed navigation rail width -$navigation-collapsed-width-default: 54px; - $ai-drawer-background: #161d26; $ai-drawer-background: awsui.$color-background-layout-ai-drawer; diff --git a/src/app-layout/visual-refresh-toolbar/navigation/styles.scss b/src/app-layout/visual-refresh-toolbar/navigation/styles.scss index 5830eb28e7..36d9a15f62 100644 --- a/src/app-layout/visual-refresh-toolbar/navigation/styles.scss +++ b/src/app-layout/visual-refresh-toolbar/navigation/styles.scss @@ -8,7 +8,7 @@ @use '../../../internal/generated/custom-css-properties/index.scss' as custom-props; @use '../../constants.scss' as constants; -$collapsed-width: var(#{custom-props.$navigationCollapsedWidth}, constants.$navigation-collapsed-width-default); +$collapsed-width: var(#{custom-props.$navigationCollapsedWidth}, awsui.$size-side-navigation-collapsed-width); .hide-navigation { position: absolute; diff --git a/src/app-layout/visual-refresh-toolbar/skeleton/styles.scss b/src/app-layout/visual-refresh-toolbar/skeleton/styles.scss index 65263ecd5f..4b4d4ac56b 100644 --- a/src/app-layout/visual-refresh-toolbar/skeleton/styles.scss +++ b/src/app-layout/visual-refresh-toolbar/skeleton/styles.scss @@ -155,7 +155,7 @@ &.navigation-collapsed { @include desktop-only { - inline-size: var(#{custom-props.$navigationCollapsedWidth}, constants.$navigation-collapsed-width-default); + inline-size: var(#{custom-props.$navigationCollapsedWidth}, awsui.$size-side-navigation-collapsed-width); } } } diff --git a/src/expandable-section/__tests__/expandable-section.test.tsx b/src/expandable-section/__tests__/expandable-section.test.tsx index 751611d859..3c240ba9bf 100644 --- a/src/expandable-section/__tests__/expandable-section.test.tsx +++ b/src/expandable-section/__tests__/expandable-section.test.tsx @@ -3,7 +3,7 @@ import React from 'react'; import { fireEvent, render } from '@testing-library/react'; -import { warnOnce } from '@cloudscape-design/component-toolkit/internal'; +import { isThemeActive, useReducedMotion, warnOnce } from '@cloudscape-design/component-toolkit/internal'; import '../../__a11y__/to-validate-a11y'; import Button from '../../../lib/components/button'; @@ -17,11 +17,15 @@ import styles from '../../../lib/components/expandable-section/styles.selectors. jest.mock('@cloudscape-design/component-toolkit/internal', () => ({ ...jest.requireActual('@cloudscape-design/component-toolkit/internal'), + isThemeActive: jest.fn().mockReturnValue(false), warnOnce: jest.fn(), + useReducedMotion: jest.fn().mockReturnValue(false), })); afterEach(() => { + (isThemeActive as jest.Mock).mockReturnValue(false); (warnOnce as jest.Mock).mockReset(); + (useReducedMotion as jest.Mock).mockReturnValue(false); }); function renderExpandableSection(props: ExpandableSectionProps = {}): ExpandableSectionWrapper { @@ -230,6 +234,36 @@ describe('Expandable Section', () => { expect(header).not.toHaveAttribute('tabindex', '0'); expect(icon.tagName).toBe('BUTTON'); }); + test('settles content immediately under reduced motion, since grid-template-rows never transitions', () => { + (isThemeActive as jest.Mock).mockReturnValue(true); + (useReducedMotion as jest.Mock).mockReturnValue(true); + const wrapper = renderExpandableSection({ defaultExpanded: false, children: 'Example content' }); + fireEvent.click(wrapper.findHeader().getElement()); + const contentInner = wrapper.findExpandedContent()!.getElement().querySelector(`.${styles['content-inner']}`)!; + expect(contentInner.className).toContain(styles['content-inner-settled']); + }); + test('settles content immediately outside One Theme, where grid-template-rows never transitions', () => { + const wrapper = renderExpandableSection({ defaultExpanded: false, children: 'Example content' }); + fireEvent.click(wrapper.findHeader().getElement()); + const contentInner = wrapper.findExpandedContent()!.getElement().querySelector(`.${styles['content-inner']}`)!; + expect(contentInner.className).toContain(styles['content-inner-settled']); + }); + test('settles after its own transition, ignores nested transitions, and resets immediately on collapse', () => { + (isThemeActive as jest.Mock).mockReturnValue(true); + const wrapper = renderExpandableSection({ defaultExpanded: false, children: 'Example content' }); + fireEvent.click(wrapper.findHeader().getElement()); + const contentOuter = wrapper.findExpandedContent()!.getElement(); + const contentInner = contentOuter.querySelector(`.${styles['content-inner']}`)!; + + expect(contentInner.className).not.toContain(styles['content-inner-settled']); + fireEvent.transitionEnd(contentInner); + expect(contentInner.className).not.toContain(styles['content-inner-settled']); + fireEvent.transitionEnd(contentOuter); + expect(contentInner.className).toContain(styles['content-inner-settled']); + + fireEvent.click(wrapper.findHeader().getElement()); + expect(contentInner.className).not.toContain(styles['content-inner-settled']); + }); }); describe('defaultExpanded', () => { @@ -618,6 +652,27 @@ describe('__expandIconPosition', () => { }); expect(wrapper.findContent().getElement()).not.toHaveClass(styles['disable-content-paddings']); }); + + test('applies disable-content-paddings class for container variant', () => { + const wrapper = renderExpandableSection({ + variant: 'container', + disableContentPaddings: true, + defaultExpanded: true, + headerText: 'Header', + children: 'Content', + }); + expect(wrapper.findContent().getElement()).toHaveClass(styles['disable-content-paddings']); + }); + + test('does not apply disable-content-paddings class for container variant by default', () => { + const wrapper = renderExpandableSection({ + variant: 'container', + defaultExpanded: true, + headerText: 'Header', + children: 'Content', + }); + expect(wrapper.findContent().getElement()).not.toHaveClass(styles['disable-content-paddings']); + }); }); describe('outside icon button (end position with renderIconOutsideHeader)', () => { diff --git a/src/expandable-section/expandable-section-container.tsx b/src/expandable-section/expandable-section-container.tsx index f1d045aa40..c0237133cf 100644 --- a/src/expandable-section/expandable-section-container.tsx +++ b/src/expandable-section/expandable-section-container.tsx @@ -22,7 +22,6 @@ interface ExpandableSectionContainerProps extends InternalBaseComponentProps { children?: React.ReactNode; variant: InternalVariant; expanded: boolean | undefined; - disableContentPaddings: boolean | undefined; __injectAnalyticsComponentMetadata?: boolean; } @@ -32,7 +31,6 @@ export const ExpandableSectionContainer = ({ header, variant, expanded, - disableContentPaddings, __internalRootRef, __injectAnalyticsComponentMetadata, ...rest @@ -59,7 +57,7 @@ export const ExpandableSectionContainer = ({ className={className} header={header} variant={variant === 'stacked' ? 'stacked' : 'default'} - disableContentPaddings={disableContentPaddings || !expanded} + disableContentPaddings={true} disableHeaderPaddings={true} __hiddenContent={!expanded} __internalRootRef={__internalRootRef} diff --git a/src/expandable-section/expandable-section-header.tsx b/src/expandable-section/expandable-section-header.tsx index c14266309c..09245de032 100644 --- a/src/expandable-section/expandable-section-header.tsx +++ b/src/expandable-section/expandable-section-header.tsx @@ -104,6 +104,7 @@ interface ExpandableDefaultHeaderProps { interface ExpandableNavigationHeaderProps extends Omit { ariaLabelledBy?: string; + hideExpandIcon?: boolean; } interface ExpandableHeaderTextWrapperProps extends ExpandableDefaultHeaderProps { @@ -123,6 +124,7 @@ interface ExpandableSectionHeaderProps extends Omit { @@ -186,8 +188,9 @@ const ExpandableNavigationHeader = ({ children, icon, expandIconPosition, + hideExpandIcon, }: ExpandableNavigationHeaderProps) => { - const expandButton = ( + const expandButton = hideExpandIcon ? null : ( { const alwaysShowDivider = variantRequiresActionsDivider(variant) && headerActions; const icon = ( @@ -446,6 +450,7 @@ export const ExpandableSectionHeader = ({ {headerText ?? header} diff --git a/src/expandable-section/internal.tsx b/src/expandable-section/internal.tsx index 92f36921b4..a9c01e9bdb 100644 --- a/src/expandable-section/internal.tsx +++ b/src/expandable-section/internal.tsx @@ -1,16 +1,17 @@ // Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. // SPDX-License-Identifier: Apache-2.0 -import React, { KeyboardEvent, useCallback, useRef } from 'react'; -import { CSSTransition } from 'react-transition-group'; +import React, { KeyboardEvent, useCallback, useEffect, useRef } from 'react'; import clsx from 'clsx'; import { useUniqueId } from '@cloudscape-design/component-toolkit/internal'; import { getBaseProps } from '../internal/base-component'; import { screenReaderTextClass } from '../internal/components/chart-series-details/series-details-text'; +import { Transition } from '../internal/components/transition'; import { fireNonCancelableEvent } from '../internal/events'; import { InternalBaseComponentProps } from '../internal/hooks/use-base-component'; import { useControllable } from '../internal/hooks/use-controllable'; +import { useOneTheme } from '../internal/hooks/use-visual-mode'; import { KeyCode } from '../internal/keycode'; import { ExpandableSectionContainer } from './expandable-section-container'; import { ExpandableSectionHeader } from './expandable-section-header'; @@ -34,10 +35,15 @@ export type InternalExpandableSectionProps = Omit