Skip to content

Commit f5df15a

Browse files
heiskrCopilot
andauthored
Replace sx and inline style declarations with CSS modules (#57848)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent b15df11 commit f5df15a

36 files changed

+246
-134
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
.eventItem {
2+
margin-bottom: 3rem;
3+
}
4+
5+
.eventAction {
6+
font-style: normal;
7+
}
8+
9+
.eventDetail {
10+
margin-left: 1rem;
11+
font-style: normal;
12+
}
13+
14+
.eventDescription {
15+
margin-left: 1rem;
16+
}

src/audit-logs/components/GroupedEvents.tsx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ import { HeadingLink } from '@/frame/components/article/HeadingLink'
44
import { useTranslation } from '@/languages/components/useTranslation'
55
import type { AuditLogEventT } from '../types'
66

7+
import styles from './GroupedEvents.module.scss'
8+
79
type Props = {
810
auditLogEvents: AuditLogEventT[]
911
category: string
@@ -47,15 +49,15 @@ export default function GroupedEvents({ auditLogEvents, category, categoryNote }
4749
)}
4850
<div>
4951
{auditLogEvents.map((event) => (
50-
<div key={event.action} style={{ marginBottom: '3rem' }}>
52+
<div key={event.action} className={styles.eventItem}>
5153
<dl>
52-
<dt style={{ fontStyle: 'normal' }}>
54+
<dt className={styles.eventAction}>
5355
<code>{event.action}</code>
5456
</dt>
5557
<dd>{event.description}</dd>
5658

57-
<dt style={{ marginLeft: '1rem', fontStyle: 'normal' }}>{t('fields')}</dt>
58-
<dd style={{ marginLeft: '1rem' }}>
59+
<dt className={styles.eventDetail}>{t('fields')}</dt>
60+
<dd className={styles.eventDescription}>
5961
{event.fields
6062
? event.fields.map((field, index) => (
6163
<span key={field}>
@@ -68,8 +70,8 @@ export default function GroupedEvents({ auditLogEvents, category, categoryNote }
6870

6971
{event.docs_reference_links && event.docs_reference_links !== 'N/A' && (
7072
<>
71-
<dt style={{ marginLeft: '1rem', fontStyle: 'normal' }}>{t('reference')}</dt>
72-
<dd style={{ marginLeft: '1rem' }}>{renderReferenceLinks(event)}</dd>
73+
<dt className={styles.eventDetail}>{t('reference')}</dt>
74+
<dd className={styles.eventDescription}>{renderReferenceLinks(event)}</dd>
7375
</>
7476
)}
7577
</dl>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.mainContent {
2+
scroll-margin-top: 5rem;
3+
}

src/frame/components/DefaultLayout.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ import { useLanguages } from '@/languages/components/LanguagesContext'
1515
import { ClientSideLanguageRedirect } from './ClientSideLanguageRedirect'
1616
import { SearchOverlayContextProvider } from '@/search/components/context/SearchOverlayContext'
1717

18+
import styles from './DefaultLayout.module.scss'
19+
1820
const MINIMAL_RENDER = Boolean(JSON.parse(process.env.MINIMAL_RENDER || 'false'))
1921

2022
type Props = { children?: React.ReactNode }
@@ -51,7 +53,7 @@ export const DefaultLayout = (props: Props) => {
5153
<Breadcrumbs />
5254
</div>
5355

54-
<main id="main-content" style={{ scrollMarginTop: '5rem' }}>
56+
<main id="main-content" className={styles.mainContent}>
5557
{props.children}
5658
</main>
5759
</div>
@@ -150,7 +152,7 @@ export const DefaultLayout = (props: Props) => {
150152
{/* Need to set an explicit height for sticky elements since we also
151153
set overflow to auto */}
152154
<div className="flex-column flex-1 min-width-0">
153-
<main id="main-content" style={{ scrollMarginTop: '5rem' }}>
155+
<main id="main-content" className={styles.mainContent}>
154156
<DeprecationBanner />
155157
<RestBanner />
156158

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.logoContainer {
2+
z-index: 3;
3+
}

src/frame/components/GenericError.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import { useRouter } from 'next/router'
55
import { MarkGithubIcon, CommentDiscussionIcon } from '@primer/octicons-react'
66
import { Lead } from '@/frame/components/ui/Lead'
77

8+
import styles from './GenericError.module.scss'
9+
810
export function GenericError() {
911
return (
1012
<div className="min-h-screen d-flex flex-column">
@@ -44,7 +46,7 @@ export const SimpleHeader = () => {
4446
role="banner"
4547
aria-label="Main"
4648
>
47-
<div className="d-flex flex-items-center" style={{ zIndex: 3 }} id="github-logo-mobile">
49+
<div className={`d-flex flex-items-center ${styles.logoContainer}`} id="github-logo-mobile">
4850
<Link href={`/${router.locale}`} aria-hidden="true" tabIndex={-1}>
4951
<MarkGithubIcon size={32} className="color-fg-default" />
5052
</Link>

src/frame/components/page-header/Header.module.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,7 @@
5757
padding: 0 !important;
5858
}
5959
}
60+
61+
.headerContainer {
62+
row-gap: 1rem;
63+
}

src/frame/components/page-header/Header.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,10 @@ export const Header = () => {
156156
aria-label="Main"
157157
>
158158
<div
159-
className="d-flex flex-justify-between p-2 flex-items-center flex-wrap"
160-
style={{
161-
// In the rare case of header overflow, create a pleasant gap between the rows
162-
rowGap: '1rem',
163-
}}
159+
className={cx(
160+
'd-flex flex-justify-between p-2 flex-items-center flex-wrap',
161+
styles.headerContainer,
162+
)}
164163
data-testid="desktop-header"
165164
>
166165
<div

src/frame/components/page-header/HeaderSearchAndWidgets.module.scss

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,29 @@
1010
visibility: hidden !important;
1111
}
1212
}
13+
14+
// The ... menu button when the smaller width search UI is open. Since the search
15+
// UI is open, we don't show the button at smaller widths but we do show it as
16+
// the browser width increases to md, and then at lg and above widths we hide
17+
// the button again since the pickers and sign-up button are shown in the header.
18+
.menuButtonSearchOpen {
19+
margin-left: 0.5rem;
20+
display: none;
21+
22+
@include breakpoint(md) {
23+
display: inline-block;
24+
margin-left: 0.25rem;
25+
}
26+
}
27+
28+
// The ... menu button when the smaller width search UI is closed, the button is
29+
// shown up to lg. At lg and above we don't show the button since the pickers
30+
// and sign-up button are shown in the header.
31+
.menuButtonSearchClosed {
32+
margin-left: 1rem;
33+
34+
@include breakpoint(lg) {
35+
margin-left: 0;
36+
display: none;
37+
}
38+
}

src/frame/components/page-header/HeaderSearchAndWidgets.tsx

Lines changed: 2 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -55,36 +55,8 @@ export function HeaderSearchAndWidgets({ width, isSearchOpen, SearchButton }: Pr
5555
data-testid="mobile-menu"
5656
icon={KebabHorizontalIcon}
5757
aria-label={t('header.open_menu_label')}
58-
sx={
59-
isSearchOpen
60-
? // The ... menu button when the smaller width search UI is open. Since the search
61-
// UI is open, we don't show the button at smaller widths but we do show it as
62-
// the browser width increases to md, and then at lg and above widths we hide
63-
// the button again since the pickers and sign-up button are shown in the header.
64-
{
65-
marginLeft: '8px',
66-
display: 'none',
67-
// breakpoint(md)
68-
'@media (min-width: 768px)': {
69-
display: 'inline-block',
70-
marginLeft: '4px',
71-
},
72-
// breakpoint(lg)
73-
'@media (min-width: 1012px)': {
74-
display: 'inline-block',
75-
marginLeft: '4px',
76-
},
77-
}
78-
: // The ... menu button when the smaller width search UI is closed, the button is
79-
// shown up to md. At lg and above we don't show the button since the pickers
80-
// and sign-up button are shown in the header.
81-
{
82-
marginLeft: '16px',
83-
'@media (min-width: 1012px)': {
84-
marginLeft: '0',
85-
display: 'none',
86-
},
87-
}
58+
className={
59+
isSearchOpen ? styles.menuButtonSearchOpen : styles.menuButtonSearchClosed
8860
}
8961
/>
9062
</ActionMenu.Anchor>

0 commit comments

Comments
 (0)