Skip to content

Commit 15a5473

Browse files
committed
Move the styles inline to the file
1 parent c6984f9 commit 15a5473

File tree

3 files changed

+38
-31
lines changed

3 files changed

+38
-31
lines changed

src/app/(main)/layout.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export default function MainLayout({
2626
toc={[]}
2727
docsDirectories={docsDirectories}
2828
fullDirectories={directories}
29+
asPopover
2930
/>
3031
<div className="isolate bg-neu-0 text-neu-900 antialiased">
3132
{children}

src/components/sidebar/index.tsx

Lines changed: 30 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -52,22 +52,22 @@ const Folder = memo(function FolderInner(props: FolderProps) {
5252

5353
const classes = {
5454
link: cn(
55-
"_flex _px-2 _py-1.5 _text-sm _transition-colors [word-break:break-word]",
56-
"_cursor-pointer contrast-more:border contrast-more:hover:underline gql-focus-visible focus-visible:outline-offset-1",
55+
"flex px-2 py-1.5 text-sm transition-colors [word-break:break-word]",
56+
"cursor-pointer contrast-more:border contrast-more:hover:underline gql-focus-visible focus-visible:outline-offset-1",
5757
),
5858
inactive: cn(
5959
"text-neu-800 hover:bg-neu-100 hover:text-neu-900 hover:bg-neu-100 dark:hover:bg-neu-50/50",
6060
"contrast-more:border-transparent",
6161
),
6262
active: cn(
6363
"bg-pri-lighter/25 text-pri-dark dark:bg-pri-light/10 dark:text-pri-light",
64-
"contrast-more:_border-primary-500 contrast-more:dark:_border-primary-500",
64+
"contrast-more:border-primary-500 contrast-more:dark:border-primary-500",
6565
),
66-
list: cn("_flex _flex-col _gap-1"),
66+
list: cn("flex flex-col gap-1"),
6767
border: cn(
68-
"_relative before:_absolute before:_inset-y-1",
69-
'before:_w-px before:bg-neu-100 before:_content-[""] dark:before:bg-neu-50',
70-
"ltr:_pl-3 ltr:before:_left-0 rtl:_pr-3 rtl:before:_right-0",
68+
"relative before:absolute before:inset-y-1",
69+
'before:w-px before:bg-neu-100 before:content-[""] dark:before:bg-neu-50',
70+
"pl-3 before:left-0",
7171
),
7272
}
7373

@@ -164,8 +164,8 @@ function FolderImpl({ item, anchors, onFocus }: FolderProps): ReactElement {
164164
}
165165
data-href={isLink ? undefined : item.route}
166166
className={cn(
167-
"_items-center _justify-between _gap-2",
168-
!isLink && "_text-left _w-full",
167+
"items-center justify-between gap-2",
168+
!isLink && "w-full text-left",
169169
classes.link,
170170
active ? classes.active : classes.inactive,
171171
)}
@@ -197,17 +197,16 @@ function FolderImpl({ item, anchors, onFocus }: FolderProps): ReactElement {
197197
<ArrowRightIcon
198198
height="18"
199199
className={cn(
200-
"_shrink-0",
201-
"_p-0.5 hover:bg-neu-100/5",
202-
"motion-reduce:*:_transition-none *:_origin-center *:_transition-transform *:rtl:_-rotate-180",
203-
open && "*:ltr:_rotate-90 *:rtl:_rotate-[-270deg]",
200+
"shrink-0 p-0.5 hover:bg-neu-100/5",
201+
"origin-center transition-transform motion-reduce:*:transition-none",
202+
open && "rotate-90",
204203
)}
205204
/>
206205
</ComponentToUse>
207206
{Array.isArray(item.children) && (
208207
<Collapse isOpen={open}>
209208
<Menu
210-
className={cn(classes.border, "_pt-1 ltr:_ml-3 rtl:_mr-3")}
209+
className={cn(classes.border, "ml-3 pt-1")}
211210
directories={item.children}
212211
base={item.route}
213212
anchors={anchors}
@@ -270,14 +269,14 @@ function File({
270269
{item.title}
271270
</Anchor>
272271
{active && anchors.length > 0 && (
273-
<ul className={cn(classes.list, classes.border, "ltr:_ml-3 rtl:_mr-3")}>
272+
<ul className={cn(classes.list, classes.border, "ml-3")}>
274273
{anchors.map(({ id, value }) => (
275274
<li key={id}>
276275
<a
277276
href={`#${id}`}
278277
className={cn(
279278
classes.link,
280-
'_flex _gap-2 before:_opacity-25 before:_content-["#"]',
279+
'flex gap-2 before:opacity-25 before:content-["#"]',
281280
activeAnchor[id]?.isActive
282281
? classes.active
283282
: classes.inactive,
@@ -400,26 +399,26 @@ export function Sidebar({
400399
return (
401400
<>
402401
{includePlaceholder && asPopover && (
403-
<div className="max-xl:_hidden _h-0 _w-64 _shrink-0" />
402+
<div className="h-0 w-64 shrink-0 max-xl:hidden" />
404403
)}
405404
<div
406405
className={cn(
407406
"[transition:background-color_1.5s_ease]",
408407
menu
409-
? "max-md:_bg-black/80 max-md:dark:_bg-black/60 _fixed _inset-0 _z-10"
410-
: "_bg-transparent",
408+
? "fixed inset-0 z-10 max-md:bg-black/80 max-md:dark:bg-black/60"
409+
: "bg-transparent",
411410
)}
412411
onClick={() => setMenu(false)}
413412
/>
414413
<aside
415414
className={cn(
416-
"nextra-sidebar-container _flex _flex-col",
417-
"md:_top-16 md:_shrink-0 motion-reduce:_transform-none motion-reduce:_transition-none",
418-
"[.resizing_&]:_transition-none",
419-
"_transform-gpu _transition-all _ease-in-out",
420-
"print:_hidden",
421-
showSidebar ? "md:_w-64" : "md:_w-20",
422-
asPopover ? "md:_hidden" : "md:_sticky md:_self-start",
415+
"nextra-sidebar-container flex flex-col",
416+
"motion-reduce:transform-none motion-reduce:transition-none md:top-16 md:shrink-0",
417+
"[.resizing_&]:transition-none",
418+
"transform-gpu transition-all ease-in-out",
419+
"print:hidden",
420+
showSidebar ? "md:w-64" : "md:w-20",
421+
asPopover ? "md:hidden" : "md:sticky md:self-start",
423422
menu
424423
? "max-md:[transform:translate3d(0,0,0)]"
425424
: "max-md:[transform:translate3d(0,-100%,0)]",
@@ -436,8 +435,8 @@ export function Sidebar({
436435
<OnFocusItemContext.Provider value={setFocused}>
437436
<div
438437
className={cn(
439-
"_overflow-y-auto",
440-
"_p-4 _grow md:_h-[calc(100vh-var(--nextra-navbar-height)-var(--nextra-menu-height))]",
438+
"overflow-y-auto",
439+
"grow p-4 md:h-[calc(100vh-var(--nextra-navbar-height)-var(--nextra-menu-height))]",
441440
showSidebar ? "nextra-scrollbar" : "no-scrollbar",
442441
)}
443442
ref={sidebarRef}
@@ -447,7 +446,7 @@ export function Sidebar({
447446
<Collapse isOpen={showSidebar} horizontal>
448447
<Menu
449448
// eslint-disable-next-line tailwindcss/no-custom-classname
450-
className="nextra-menu-desktop max-md:_hidden"
449+
className="nextra-menu-desktop max-md:hidden"
451450
// The sidebar menu, shows only the docs directories.
452451
directories={docsDirectories}
453452
// When the viewport size is larger than `md`, hide the anchors in
@@ -459,7 +458,7 @@ export function Sidebar({
459458
)}
460459
{mounted && window.innerWidth < 768 && (
461460
<Menu
462-
className="nextra-menu-mobile md:_hidden"
461+
className="nextra-menu-mobile md:hidden"
463462
// The mobile dropdown menu, shows all the directories.
464463
directories={fullDirectories}
465464
// Always show the anchor links on mobile (`md`).
@@ -509,7 +508,7 @@ export function SidebarFooter({
509508
className,
510509
)}
511510
>
512-
<div className={showSidebar && !hasI18n ? "_grow _flex _flex-col" : ""}>
511+
<div className={showSidebar && !hasI18n ? "flex grow flex-col" : ""}>
513512
<ThemeSwitch lite={!showSidebar} />
514513
</div>
515514
{themeConfig.sidebar.toggleButton && (

tailwind.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ const config: Config = {
220220
})
221221
}),
222222
tailwindMediaHover(),
223+
prefersContrastPlugin(),
223224
scrollStartPlugin(),
224225
scrollviewFadePlugin(),
225226
browserPlugin,
@@ -236,6 +237,12 @@ function tailwindMediaHover() {
236237
})
237238
}
238239

240+
function prefersContrastPlugin() {
241+
return plugin(({ addVariant }) => {
242+
addVariant("contrast-more", "@media (prefers-contrast: more)")
243+
})
244+
}
245+
239246
function scrollStartPlugin() {
240247
return plugin(({ addBase, matchUtilities, theme }) => {
241248
addBase({

0 commit comments

Comments
 (0)