-
Notifications
You must be signed in to change notification settings - Fork 167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Public layout component #3208
Open
georgylobko
wants to merge
62
commits into
main
Choose a base branch
from
feat/public-layout-component
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 3 commits
Commits
Show all changes
62 commits
Select commit
Hold shift + click to select a range
b08c0c2
feat: PageLayout component
georgylobko 7db9b3d
chore: U tests for trigerless navigation and drawers
georgylobko 610983d
chore: Update snapshots
georgylobko 060df7f
chore: Clean up a testing page for page-layout
georgylobko 3646600
chore: App layout internal props refactoring
georgylobko 457fe76
Merge remote-tracking branch 'origin/main' into feat/public-layout-co…
georgylobko 1074be4
chore: Document optional trigger scenario for PageLayout
georgylobko ce4393f
chore: Document optional trigger scenario for PageLayout
georgylobko b6fd838
chore: Don't display the toolbar if neither navigation trigger is pro…
georgylobko e164d82
Merge branch 'main' into feat/public-layout-component
georgylobko a77bf17
chore: Omit disableBodyScroll prop
georgylobko f61d5c0
feat: Set useAppLayoutToolbarEnabled to true for the public layout co…
georgylobko 63e9618
Merge branch 'main' into feat/public-layout-component
georgylobko 0cf8021
feat: focusNavigation API
georgylobko 05bdf0d
chore: focusNavigation on without-toolbar.page.tsx
georgylobko 604a5bc
chore: toolbarHide API
georgylobko b5e432b
chore: Cleanup
georgylobko 3a5ba52
Merge branch 'main' into feat/public-layout-component
georgylobko dffa826
chore: Update snapshots
georgylobko ff8c5d0
chore: Add u tests
georgylobko e6c0aef
Merge branch 'main' into feat/public-layout-component
georgylobko 2ca92dd
feat: navigationTriggerHide prop
georgylobko f1e10f0
fix: U tests
georgylobko 1d319ab
Merge branch 'main' into feat/public-layout-component
georgylobko fef9d66
chore: Introduce BaseLayoutProps
georgylobko 1bb2102
chore: Add a dedup condition to check if split panel's trigger is hid…
georgylobko 77be6f5
Merge branch 'main' into feat/public-layout-component
georgylobko 1851665
chore: Introduce a warning when PageLayout is used in classic theme
georgylobko 56fe031
Merge branch 'main' into feat/public-layout-component
georgylobko 56575f3
chore: U test for toolbarless scenario
georgylobko 2cd3a3b
chore: Rename page-layout to app-layout-toolbar
georgylobko d60372e
Merge branch 'main' into feat/public-layout-component
georgylobko 8833c38
chore: Rename integ test
georgylobko 6e533af
chore: Don't pass split panel props into the toolbar if splitPanelTog…
georgylobko 6cef166
chore: Throw an error when app layout toolbar is rendered in classic …
georgylobko bc4f76b
chore: Functional tests for vr/classic components
georgylobko 5c456be
chore: Skip vr only components in classic for a11y tests
georgylobko 4bb7a31
chore: Skip vr only components in classic for a11y tests
georgylobko 34bf270
Merge branch 'main' into feat/public-layout-component
georgylobko 0db8c86
chore: Small fixes
georgylobko 400fae4
chore: Adjust drawers api description
georgylobko 9eef6a1
chore: Update doc snapshot
georgylobko 85106ff
chore: Replace useVisualRefresh by symbols in functional tests
georgylobko fe5898e
feat: Make dedup logic for app layout toolbar component apply only un…
georgylobko e026042
chore: Small eslint fix
georgylobko 369ed49
Merge branch 'main' into feat/public-layout-component
georgylobko 9b7fd81
chore: Integ test for nested app layout toolbars
georgylobko 8760dd5
Merge remote-tracking branch 'origin/main' into feat/public-layout-co…
georgylobko 61b009c
fix: Remove redundant navigationTriggerHide
georgylobko 867f79f
Merge branch 'main' into feat/public-layout-component
georgylobko 5a2c9eb
chore: Small refactoring
georgylobko 785c664
chore: Small refactoring
georgylobko cf3ef8e
chore: Reuse pages/utils in pages/app-layout-toolbar from pages/app-l…
georgylobko c9ace4e
chore: Remove styles.scss from pages/app-layout-toolbar
georgylobko 6178811
Merge branch 'main' into feat/public-layout-component
georgylobko 8d306d9
Merge branch 'main' into feat/public-layout-component
georgylobko 273633b
chore: Switch globalWithFlags[Symbol.for('awsui-visual-refresh-flag')…
georgylobko c21e321
chore: Refactoring. Introduce useAppLayoutToolbarPublicEnabled hook
georgylobko 5b0b82f
Merge branch 'main' into feat/public-layout-component
georgylobko 2b0606c
Revert "chore: Switch globalWithFlags[Symbol.for('awsui-visual-refres…
georgylobko 5e19c40
chore: Refactoring. Rename feature flags
georgylobko 587732c
Merge branch 'main' into feat/public-layout-component
georgylobko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,188 @@ | ||
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
import React, { useContext, useRef, useState } from 'react'; | ||
|
||
import { | ||
Button, | ||
ContentLayout, | ||
Header, | ||
HelpPanel, | ||
Link, | ||
PageLayout, | ||
SpaceBetween, | ||
SplitPanel, | ||
Toggle, | ||
} from '~components'; | ||
import awsuiPlugins from '~components/internal/plugins'; | ||
import { PageLayoutProps } from '~components/page-layout'; | ||
|
||
import AppContext, { AppContextType } from '../app/app-context'; | ||
import { Breadcrumbs, Containers, CustomDrawerContent } from './utils/content-blocks'; | ||
import { drawerLabels } from './utils/drawers'; | ||
import appLayoutLabels from './utils/labels'; | ||
|
||
type DemoContext = React.Context< | ||
AppContextType<{ | ||
hasTools: boolean | undefined; | ||
hasDrawers: boolean | undefined; | ||
splitPanelPosition: PageLayoutProps.SplitPanelPreferences['position']; | ||
}> | ||
>; | ||
|
||
export default function WithDrawers() { | ||
const [activeDrawerId, setActiveDrawerId] = useState<string | null>(null); | ||
const [helpPathSlug, setHelpPathSlug] = useState<string>('default'); | ||
const { urlParams, setUrlParams } = useContext(AppContext as DemoContext); | ||
const hasTools = urlParams.hasTools ?? false; | ||
const hasDrawers = urlParams.hasDrawers ?? true; | ||
const [isToolsOpen, setIsToolsOpen] = useState(false); | ||
const [isNavigationOpen, setIsNavigationOpen] = useState(true); | ||
const appLayoutRef = useRef<PageLayoutProps.Ref>(null); | ||
|
||
const drawersProps: Pick<PageLayoutProps, 'activeDrawerId' | 'onDrawerChange' | 'drawers'> | null = !hasDrawers | ||
? null | ||
: { | ||
activeDrawerId: activeDrawerId, | ||
drawers: [ | ||
{ | ||
ariaLabels: { | ||
closeButton: 'ProHelp close button', | ||
drawerName: 'ProHelp drawer content', | ||
triggerButton: 'ProHelp trigger button', | ||
resizeHandle: 'ProHelp resize handle', | ||
}, | ||
content: <CustomDrawerContent />, | ||
id: 'pro-help', | ||
}, | ||
], | ||
onDrawerChange: event => { | ||
setActiveDrawerId(event.detail.activeDrawerId); | ||
}, | ||
}; | ||
|
||
return ( | ||
<PageLayout | ||
ariaLabels={{ ...appLayoutLabels, ...drawerLabels }} | ||
breadcrumbs={<Breadcrumbs />} | ||
ref={appLayoutRef} | ||
content={ | ||
<ContentLayout | ||
disableOverlap={true} | ||
header={ | ||
<SpaceBetween size="m"> | ||
<Header | ||
variant="h1" | ||
description="Sometimes you need custom drawers to get the job done." | ||
info={ | ||
<Link | ||
data-testid="info-link-header" | ||
variant="info" | ||
onFollow={() => { | ||
setHelpPathSlug('header'); | ||
setIsToolsOpen(true); | ||
appLayoutRef.current?.focusToolsClose(); | ||
}} | ||
> | ||
Info | ||
</Link> | ||
} | ||
> | ||
Testing Custom Drawers! | ||
</Header> | ||
|
||
<SpaceBetween size="xs"> | ||
<Toggle checked={hasTools} onChange={({ detail }) => setUrlParams({ hasTools: detail.checked })}> | ||
Use Tools | ||
</Toggle> | ||
|
||
<Toggle checked={hasDrawers} onChange={({ detail }) => setUrlParams({ hasDrawers: detail.checked })}> | ||
Use Drawers | ||
</Toggle> | ||
|
||
<Button onClick={() => setIsNavigationOpen(current => !current)}>Toggle navigation</Button> | ||
|
||
<Button | ||
onClick={() => { | ||
setActiveDrawerId('pro-help'); | ||
appLayoutRef.current?.focusActiveDrawer(); | ||
}} | ||
> | ||
Open a local drawer without a trigger | ||
</Button> | ||
<Button onClick={() => setActiveDrawerId(null)}>Close a local drawer without a trigger</Button> | ||
|
||
<Button | ||
onClick={() => awsuiPlugins.appLayout.openDrawer('circle4-global')} | ||
data-testid="open-drawer-button" | ||
> | ||
Open a drawer without a trigger | ||
</Button> | ||
<Button onClick={() => awsuiPlugins.appLayout.closeDrawer('circle4-global')}> | ||
Close a drawer without a trigger | ||
</Button> | ||
</SpaceBetween> | ||
</SpaceBetween> | ||
} | ||
> | ||
<Header | ||
info={ | ||
<Link | ||
data-testid="info-link-content" | ||
variant="info" | ||
onFollow={() => { | ||
setHelpPathSlug('content'); | ||
setIsToolsOpen(true); | ||
}} | ||
> | ||
Info | ||
</Link> | ||
} | ||
> | ||
Content | ||
</Header> | ||
<Containers /> | ||
</ContentLayout> | ||
} | ||
splitPanel={ | ||
<SplitPanel | ||
header="Split panel header" | ||
i18nStrings={{ | ||
preferencesTitle: 'Preferences', | ||
preferencesPositionLabel: 'Split panel position', | ||
preferencesPositionDescription: 'Choose the default split panel position for the service.', | ||
preferencesPositionSide: 'Side', | ||
preferencesPositionBottom: 'Bottom', | ||
preferencesConfirm: 'Confirm', | ||
preferencesCancel: 'Cancel', | ||
closeButtonAriaLabel: 'Close panel', | ||
openButtonAriaLabel: 'Open panel', | ||
resizeHandleAriaLabel: 'Slider', | ||
}} | ||
> | ||
This is the Split Panel! | ||
</SplitPanel> | ||
} | ||
splitPanelPreferences={{ | ||
position: urlParams.splitPanelPosition, | ||
}} | ||
onSplitPanelPreferencesChange={event => { | ||
const { position } = event.detail; | ||
setUrlParams({ splitPanelPosition: position === 'side' ? position : undefined }); | ||
}} | ||
onToolsChange={event => { | ||
setIsToolsOpen(event.detail.open); | ||
}} | ||
tools={<Info helpPathSlug={helpPathSlug} />} | ||
toolsOpen={isToolsOpen} | ||
toolsHide={!hasTools} | ||
navigationTriggerHide={true} | ||
navigationOpen={isNavigationOpen} | ||
onNavigationChange={event => setIsNavigationOpen(event.detail.open)} | ||
{...drawersProps} | ||
/> | ||
); | ||
} | ||
|
||
function Info({ helpPathSlug }: { helpPathSlug: string }) { | ||
return <HelpPanel header={<h2>Info</h2>}>Here is some info for you: {helpPathSlug}</HelpPanel>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
/* | ||
Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
@use '~design-tokens' as awsui; | ||
|
||
.contentPlaceholder::before { | ||
content: 'X'; | ||
display: block; | ||
background-color: awsui.$color-background-input-disabled; | ||
color: awsui.$color-background-container-content; | ||
text-align: center; | ||
font-size: 400px; | ||
line-height: 400px; | ||
} | ||
|
||
.footer { | ||
inset-block-end: 0; | ||
inline-size: 100%; | ||
color: #eee; | ||
background: #232f3e; | ||
box-sizing: border-box; | ||
padding-block: 0; | ||
padding-inline: 1rem; | ||
line-height: 30px; | ||
z-index: 1000; | ||
&:not(.legacyNav) { | ||
position: sticky; | ||
} | ||
} | ||
|
||
.highlightBorder { | ||
border-block: 1px solid red; | ||
border-inline: 1px solid red; | ||
} | ||
|
||
.longContent { | ||
block-size: 200vh; | ||
} | ||
|
||
.floatingBlock { | ||
position: relative; | ||
z-index: 1; | ||
background: awsui.$color-background-container-content; | ||
} | ||
|
||
.wizard { | ||
display: flex; | ||
align-items: flex-start; | ||
justify-content: flex-start; | ||
} | ||
|
||
.wizard-steps { | ||
inline-size: 16rem; | ||
block-size: 40rem; | ||
margin-inline-end: 4rem; | ||
} | ||
|
||
.wizard-form { | ||
min-inline-size: 30rem; | ||
max-inline-size: 80rem; | ||
block-size: 150rem; | ||
} | ||
|
||
@media (max-width: 703px) { | ||
.wizard { | ||
display: block; | ||
} | ||
|
||
.wizard-steps { | ||
margin-inline-end: 0; | ||
} | ||
|
||
.wizard-form { | ||
margin-block-start: 4rem; | ||
} | ||
} | ||
|
||
.custom-drawer-wrapper { | ||
display: flex; | ||
flex-direction: column; | ||
block-size: 100%; | ||
overflow-y: hidden; | ||
} | ||
|
||
.drawer-sticky-header, | ||
.drawer-scrollable-content, | ||
.drawer-sticky-footer { | ||
padding-inline: 24px; | ||
} | ||
|
||
.drawer-sticky-header { | ||
background-color: peachpuff; | ||
border-block-end: 2px solid grey; | ||
padding-block: awsui.$space-scaled-l; | ||
} | ||
.drawer-scrollable-content { | ||
flex: 1; | ||
overflow-y: auto; | ||
padding-block: awsui.$space-scaled-s; | ||
} | ||
.drawer-sticky-footer { | ||
background-color: lightpink; | ||
border-block-start: 2px solid grey; | ||
padding-block: awsui.$space-scaled-s; | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These styles were copied from
pages/app-layout