Skip to content

Commit b0ff19f

Browse files
committed
POC restrict clickable area
1 parent 7ddbe32 commit b0ff19f

File tree

6 files changed

+13
-35
lines changed

6 files changed

+13
-35
lines changed

pages/app-layout/split-panel-with-custom-header.page.tsx

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -19,15 +19,13 @@ import { splitPaneli18nStrings } from './utils/strings';
1919
import * as toolsContent from './utils/tools-content';
2020

2121
type SplitPanelHeaderContentType = 'text' | 'react-node';
22-
type SplitPanelHeaderLength = 'short' | 'long' | 'very-long';
2322

2423
type SplitPanelDemoContext = React.Context<
2524
AppContextType<{
2625
renderBadge: boolean;
2726
renderActions: boolean;
2827
splitPanelPosition: AppLayoutProps.SplitPanelPreferences['position'];
2928
splitPanelHeaderContentType: SplitPanelHeaderContentType;
30-
splitPanelHeaderLength: SplitPanelHeaderLength;
3129
}>
3230
>;
3331

@@ -84,28 +82,20 @@ const DEMO_CONTENT = (
8482
</div>
8583
);
8684

87-
const baseHeaderText = 'Split panel header';
88-
const headerTextWithLongWord = baseHeaderText + ' withlongwordthatshouldbesplitinsteadofmakingthepanelscroll';
89-
9085
export default function () {
9186
const { urlParams, setUrlParams } = useContext(AppContext as SplitPanelDemoContext);
9287

93-
const headerText =
94-
urlParams.splitPanelHeaderLength === 'short'
95-
? baseHeaderText
96-
: urlParams.splitPanelHeaderLength === 'long'
97-
? headerTextWithLongWord
98-
: new Array(20).fill(baseHeaderText);
99-
10088
const header =
10189
urlParams.splitPanelHeaderContentType === 'text' ? (
102-
headerText
90+
'This split panel can be opened by clicking anywhere on it'
10391
) : (
10492
<div style={{ display: 'flex', justifyContent: 'space-between', inlineSize: '100%' }}>
10593
<SpaceBetween direction="horizontal" size="xs" alignItems="center">
10694
{urlParams.renderBadge && <Badge>Badge</Badge>}
10795
<Box variant="h3" tagOverride="h2" margin={{ vertical: 'n' }} padding={{ vertical: 'n' }}>
108-
<span style={{ letterSpacing: 'normal' }}>{headerText}</span>
96+
<span style={{ letterSpacing: 'normal' }}>
97+
This split panel can be opened only by clicking on the caret icon
98+
</span>
10999
</Box>
110100
</SpaceBetween>
111101
{urlParams.renderActions && (
@@ -144,22 +134,6 @@ export default function () {
144134
</Header>
145135
</div>
146136
<SpaceBetween size="l">
147-
<FormField label="Split panel header text length">
148-
<Tiles
149-
value={urlParams.splitPanelHeaderLength}
150-
items={[
151-
{ label: 'Short', value: 'short' },
152-
{ label: 'Long', value: 'long' },
153-
{ label: 'Very long', value: 'very-long' },
154-
]}
155-
onChange={({ detail }) =>
156-
setUrlParams({
157-
...urlParams,
158-
splitPanelHeaderLength: detail.value as SplitPanelHeaderLength,
159-
})
160-
}
161-
/>
162-
</FormField>
163137
<FormField label="Split panel header content type">
164138
<Tiles
165139
value={urlParams.splitPanelHeaderContentType}

src/split-panel/bottom.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,9 @@ export function SplitPanelContentBottom({
7979
[styles.refresh]: isRefresh,
8080
[styles['with-toolbar']]: isToolbar,
8181
[styles.hidden]: closeBehavior === 'hide' && !isOpen,
82+
[styles.clickable]: !!onToggle,
8283
})}
83-
onClick={() => !isOpen && onToggle()}
84+
onClick={() => !isOpen && onToggle && onToggle()}
8485
style={{
8586
insetBlockEnd: bottomOffset,
8687
insetInlineStart: leftOffset,

src/split-panel/implementation.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,8 @@ export function SplitPanelImplementation({
9595
id: panelHeaderId,
9696
};
9797

98+
const restrictClickableArea = typeof header !== 'string' && position === 'bottom';
99+
98100
const wrappedHeader = (
99101
<div className={clsx(styles.header, isToolbar && styles['with-toolbar'])} style={appLayoutMaxWidth}>
100102
{typeof header === 'string' ? (
@@ -139,6 +141,7 @@ export function SplitPanelImplementation({
139141
ariaLabel={i18nStrings.openButtonAriaLabel}
140142
ref={refs.toggle}
141143
ariaExpanded={isOpen}
144+
onClick={restrictClickableArea ? onToggle : undefined}
142145
/>
143146
)}
144147
</div>
@@ -232,7 +235,7 @@ export function SplitPanelImplementation({
232235
isOpen={isOpen}
233236
splitPanelRef={mergedRef}
234237
cappedSize={size}
235-
onToggle={onToggle}
238+
onToggle={!restrictClickableArea ? onToggle : undefined}
236239
header={wrappedHeader}
237240
panelHeaderId={panelHeaderId}
238241
appLayoutMaxWidth={appLayoutMaxWidth}

src/split-panel/interfaces.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,5 +62,5 @@ export interface SplitPanelContentProps {
6262
resizeHandle: React.ReactNode;
6363
header: React.ReactNode;
6464
children: React.ReactNode;
65-
onToggle: () => void;
65+
onToggle?: () => void;
6666
}

src/split-panel/side.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export function SplitPanelContentSide({
6262
top: topOffset,
6363
bottom: bottomOffset,
6464
}}
65-
onClick={() => !isOpen && onToggle()}
65+
onClick={() => !isOpen && onToggle && onToggle()}
6666
aria-labelledby={panelHeaderId}
6767
role="region"
6868
>

src/split-panel/styles.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ $app-layout-drawer-width: calc(#{awsui.$space-layout-toggle-diameter} + 2 * #{aw
7171
&.drawer-closed {
7272
overflow: hidden;
7373
}
74-
&.drawer-closed:hover {
74+
&.drawer-closed.clickable:hover {
7575
background: awsui.$color-background-layout-panel-hover;
7676
}
7777
& > .drawer-content-bottom > [aria-hidden='true'] {

0 commit comments

Comments
 (0)