Skip to content

Commit 5cbb414

Browse files
[Brand Refactor] Fixes SectionIntro layout (#1360)
1 parent 21c954b commit 5cbb414

26 files changed

Lines changed: 66 additions & 25 deletions

File tree

.changeset/soft-clouds-shift.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@primer/react-brand': patch
3+
---
4+
5+
Updated `SectionIntroStacked` layout spacing for improved visual alignment.

packages/react/src/SectionIntroStacked/SectionIntroStacked.features.stories.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,3 +117,11 @@ export const Gridline: Story = {
117117
)
118118
},
119119
}
120+
121+
export const GridlineTablet: Story = {
122+
name: 'Gridline (tablet)',
123+
globals: {
124+
viewport: {value: 'ipad10p'},
125+
},
126+
render: Gridline.render,
127+
}

packages/react/src/SectionIntroStacked/SectionIntroStacked.module.css

Lines changed: 30 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,20 @@
11
.SectionIntroStacked {
2-
--brand-Grid-spacing-row: var(--base-size-48);
2+
--brand-Grid-spacing-row: var(--base-size-64);
3+
}
4+
5+
@media screen and (min-width: 48rem) and (max-width: 63.24rem) {
6+
.SectionIntroStacked {
7+
max-width: 618px;
8+
margin-inline: auto;
9+
}
10+
11+
.SectionIntroStacked.SectionIntroStacked--variant-gridline {
12+
padding-inline: var(--base-size-32);
13+
padding-block: calc(var(--base-size-64) - var(--base-size-4));
14+
15+
--SectionIntroStacked-item-divider-overflow-start: var(--base-size-32);
16+
--SectionIntroStacked-item-divider-overflow-end: var(--base-size-32);
17+
}
318
}
419

520
.SectionIntroStacked--variant-gridline {
@@ -21,15 +36,6 @@
2136
}
2237
}
2338

24-
@media screen and (min-width: 63.25rem) {
25-
.SectionIntroStacked--variant-gridline {
26-
padding-inline: var(--base-size-64);
27-
padding-block: var(--base-size-64);
28-
--SectionIntroStacked-item-divider-overflow-start: 0px;
29-
--SectionIntroStacked-item-divider-overflow-end: calc(var(--brand-Grid-spacing-margin) + var(--base-size-64));
30-
}
31-
}
32-
3339
@media screen and (min-width: 80rem) {
3440
.SectionIntroStacked--variant-gridline {
3541
border-inline: var(--brand-borderWidth-thin) solid var(--brand-color-border-muted);
@@ -71,10 +77,13 @@
7177
flex-direction: column;
7278
}
7379

74-
@media screen and (max-width: 63.25rem) {
80+
@media screen and (max-width: 63.24rem) {
7581
.SectionIntroStacked-heading {
7682
font-size: var(--brand-text-size-600);
7783
}
84+
.SectionIntroStacked-items {
85+
overflow: hidden;
86+
}
7887
}
7988

8089
@media screen and (min-width: 63.25rem) {
@@ -86,15 +95,18 @@
8695
.SectionIntroStacked--variant-gridline .SectionIntroStacked-items {
8796
border-inline-start: var(--brand-borderWidth-thin) solid var(--brand-color-border-muted);
8897
margin-block: calc(-1 * var(--base-size-64));
89-
padding-block: 0;
98+
padding-block: calc(var(--base-size-64) - var(--base-size-32));
9099
position: static;
91100
top: auto;
92101
}
93102

103+
.SectionIntroStacked-content {
104+
padding-inline-end: var(--base-size-80);
105+
}
106+
94107
.SectionIntroStacked--variant-gridline .SectionIntroStackedItem-item {
95108
/* Inset item content from the vertical gridline */
96-
padding-inline-start: var(--base-size-32);
97-
padding-inline-end: var(--base-size-32);
109+
padding-inline-start: var(--base-size-64);
98110
}
99111
}
100112

@@ -137,21 +149,22 @@
137149

138150
.SectionIntroStackedItem-item--with-icon {
139151
display: flex;
140-
flex-direction: row;
141152
align-items: flex-start;
142153
gap: var(--base-size-24);
154+
flex-direction: column;
143155
}
144156

145-
@media screen and (min-width: 63.25rem) {
157+
@media screen and (min-width: 48rem) {
146158
.SectionIntroStackedItem-item--with-icon {
147159
gap: var(--base-size-48);
160+
flex-direction: row;
148161
}
149162
}
150163

151164
.SectionIntroStackedItem__content {
152165
display: flex;
153166
flex-direction: column;
154-
gap: var(--base-size-8);
167+
gap: var(--base-size-12);
155168
flex: 1;
156169
min-width: 0;
157170
}

packages/react/src/SectionIntroStacked/SectionIntroStacked.module.css.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ declare const styles: {
22
readonly "SectionIntroStacked": string;
33
readonly "SectionIntroStacked--full-width": string;
44
readonly "SectionIntroStacked--variant-gridline": string;
5+
readonly "SectionIntroStacked-content": string;
56
readonly "SectionIntroStacked-description": string;
67
readonly "SectionIntroStacked-heading": string;
78
readonly "SectionIntroStacked-heading--muted": string;

packages/react/src/SectionIntroStacked/SectionIntroStacked.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,11 @@ const Root = forwardRef<HTMLElement, PropsWithChildren<SectionIntroStackedProps>
4545
{...props}
4646
style={{...animationInlineStyles, ...style}}
4747
>
48-
<Grid fullWidth enableGutters={variant !== 'gridline'}>
49-
<Grid.Column span={{large: 6}}>{otherChildren}</Grid.Column>
50-
<Grid.Column
51-
span={variant === 'gridline' ? {large: 6} : {large: 5}}
52-
start={variant === 'gridline' ? {large: 7} : {large: 8}}
53-
>
48+
<Grid fullWidth enableGutters={variant !== 'gridline'} columnGap="none">
49+
<Grid.Column span={{large: 6}} className={styles['SectionIntroStacked-content']}>
50+
{otherChildren}
51+
</Grid.Column>
52+
<Grid.Column span={{large: 6}} start={{large: 7}}>
5453
{items}
5554
</Grid.Column>
5655
</Grid>
@@ -167,7 +166,7 @@ const ItemIcon = ({className, color = 'green', ...props}: SectionIntroStackedIte
167166
<Icon
168167
className={clsx(styles['SectionIntroStackedItem__icon'], className)}
169168
hasBackground
170-
size="medium"
169+
size="small"
171170
color={color}
172171
{...props}
173172
/>

packages/react/src/SectionIntroStacked/SectionIntroStacked.visual.spec.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,19 @@ test.describe('Visual Comparison: SectionIntroStacked', () => {
7575
await page.waitForTimeout(500)
7676
await expect(page).toHaveScreenshot({fullPage: true})
7777
})
78+
79+
// eslint-disable-next-line i18n-text/no-en
80+
test.describe('Tablet viewport test for Gridline (tablet)', () => {
81+
test.use({viewport: {width: 834, height: 1112}})
82+
test('SectionIntroStacked / Gridline (tablet)', async ({page}) => {
83+
await page.goto(
84+
'http://localhost:6006/iframe.html?args=&id=components-sectionintrostacked-features--gridline-tablet&viewMode=story',
85+
{waitUntil: 'networkidle'},
86+
)
87+
await page.locator('body.sb-show-main').waitFor({state: 'visible'})
88+
89+
await page.waitForTimeout(500)
90+
await expect(page).toHaveScreenshot({fullPage: true})
91+
})
92+
})
7893
})
Loading
Loading
Loading

0 commit comments

Comments
 (0)