Skip to content

Commit f306123

Browse files
committed
Layout adjustments
1 parent 572eac2 commit f306123

File tree

2 files changed

+36
-34
lines changed

2 files changed

+36
-34
lines changed

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

Lines changed: 22 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -47,30 +47,28 @@ function EditableHeader({ onChange, value }: { onChange: (text: string) => void;
4747
}, [editing]);
4848

4949
return (
50-
<Box display="inline-block">
51-
<SpaceBetween direction="horizontal" size="xxs" alignItems="center">
52-
{editing ? (
53-
<>
54-
<Input value={internalValue} onChange={({ detail }) => setInternalValue(detail.value)} ref={inputRef} />
55-
<Button
56-
variant="icon"
57-
iconName="check"
58-
onClick={() => {
59-
onChange(internalValue);
60-
setEditing(false);
61-
}}
62-
/>
63-
<Button variant="icon" iconName="close" onClick={() => setEditing(false)} />
64-
</>
65-
) : (
66-
<>
67-
<Box variant="h3" tagOverride="h2" display="inline" margin={{ vertical: 'n' }} padding={{ vertical: 'n' }}>
68-
{value}
69-
</Box>
70-
<Button variant="inline-icon" iconName="edit" onClick={() => setEditing(true)}></Button>
71-
</>
72-
)}
73-
</SpaceBetween>
50+
<Box display="inline">
51+
{editing ? (
52+
<SpaceBetween direction="horizontal" size="xxs">
53+
<Input value={internalValue} onChange={({ detail }) => setInternalValue(detail.value)} ref={inputRef} />
54+
<Button
55+
variant="icon"
56+
iconName="check"
57+
onClick={() => {
58+
onChange(internalValue);
59+
setEditing(false);
60+
}}
61+
/>
62+
<Button variant="icon" iconName="close" onClick={() => setEditing(false)} />
63+
</SpaceBetween>
64+
) : (
65+
<span style={{ position: 'relative', insetBlockStart: '5px' }}>
66+
<Box variant="h3" tagOverride="span" display="inline" margin={{ vertical: 'n' }} padding={{ vertical: 'n' }}>
67+
{value}
68+
</Box>
69+
<Button variant="inline-icon" iconName="edit" onClick={() => setEditing(true)}></Button>
70+
</span>
71+
)}
7472
</Box>
7573
);
7674
}

src/split-panel/styles.scss

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,8 @@ $app-layout-drawer-width: calc(#{awsui.$space-layout-toggle-diameter} + 2 * #{aw
228228
}
229229

230230
.header {
231+
$vertical-margin: calc(#{awsui.$space-scaled-xxs} + 1px);
232+
231233
inline-size: 100%;
232234
margin-block: awsui.$size-vertical-panel-icon-offset;
233235
margin-inline: 0;
@@ -241,23 +243,24 @@ $app-layout-drawer-width: calc(#{awsui.$space-layout-toggle-diameter} + 2 * #{aw
241243
}
242244

243245
&-main-row {
246+
// Make sure that the panel buttons are always anchored to the block start,
247+
// even if the main content (before-header slot, header text, actions) wraps into multiple lines.
244248
align-items: flex-start;
245249
}
246250

251+
// Area containing the before-header slot, the header text and the actions
247252
&-main-content {
248253
flex: auto;
249254
flex-direction: row;
250255
flex-wrap: wrap;
251256
column-gap: awsui.$space-scaled-xs;
252-
row-gap: awsui.$space-scaled-xxs;
253-
align-items: center;
257+
row-gap: calc(#{awsui.$space-scaled-xxs} + $vertical-margin);
254258
justify-content: space-between;
259+
align-items: center;
255260
}
256261

257262
&-tag-and-info {
258-
$vertical-margin: calc(#{awsui.$space-scaled-xxs} + 1px);
259-
margin-block-start: $vertical-margin;
260-
min-block-size: calc(#{awsui.$font-panel-header-line-height} + #{$vertical-margin});
263+
min-block-size: calc(#{awsui.$font-panel-header-line-height} + 2 * #{$vertical-margin});
261264
// The line height of the header text might not be respected in non-high pixel density screens
262265
// unless it is set to a smaller value in its parent container.
263266
line-height: awsui.$line-height-body-s;
@@ -271,17 +274,18 @@ $app-layout-drawer-width: calc(#{awsui.$space-layout-toggle-diameter} + 2 * #{aw
271274
}
272275

273276
&-tag {
274-
$vertical-margin: calc(#{awsui.$space-scaled-xxs} + 1px);
275277
@include styles.font-panel-header;
276-
padding-block: 0;
277-
padding-inline: 0;
278-
margin-inline: 0;
279-
margin-block: 0;
280278
&.with-info {
281279
margin-inline-end: awsui.$space-scaled-xs;
282280
}
283281
}
284282

283+
&-text,
284+
&-info {
285+
position: relative;
286+
inset-block-start: $vertical-margin;
287+
}
288+
285289
&-before + &-text {
286290
margin-inline-start: awsui.$space-scaled-xs;
287291
}

0 commit comments

Comments
 (0)