Skip to content

Commit

Permalink
Fixed scrollable sidebar
Browse files Browse the repository at this point in the history
  • Loading branch information
michaldudak committed Feb 4, 2025
1 parent a01c3a6 commit 9d1f4f4
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 40 deletions.
6 changes: 3 additions & 3 deletions docs/src/app/(private)/experiments/[...slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ export default async function Page(props: Props) {
try {
const Experiment = (await import(`../${slug.join('/')}.tsx`)).default;
return (
<React.Fragment>
<Sidebar experimentPath={fullPath} />
<div className={classes.root}>
<Sidebar experimentPath={fullPath} className={classes.sidebar} />
<main className={classes.main}>
<Experiment />
</main>
</React.Fragment>
</div>
);
} catch (error) {
notFound();
Expand Down
4 changes: 1 addition & 3 deletions docs/src/app/(private)/experiments/infra/Sidebar.module.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
.root {
flex: 1 1 300px;
max-width: 400px;
border-right: 1px solid var(--color-gridline);
font-size: var(--text-sm);
overflow: auto;

& h2 {
text-transform: uppercase;
Expand Down
7 changes: 4 additions & 3 deletions docs/src/app/(private)/experiments/infra/Sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import * as React from 'react';
import clsx from 'clsx';
import { ExperimentsList } from './ExperimentsList';
import { EditPanel } from './EditPanel';
import classes from './Sidebar.module.css';

export function Sidebar(props: SidebarProps) {
const { experimentPath } = props;
const { experimentPath, className, ...otherProps } = props;
return (
<div className={classes.root}>
<div {...otherProps} className={clsx(classes.root, className)}>
{experimentPath && (
<React.Fragment>
<div id="experiments-settings" className={classes.panel} />
Expand All @@ -18,6 +19,6 @@ export function Sidebar(props: SidebarProps) {
);
}

interface SidebarProps {
interface SidebarProps extends React.HTMLAttributes<HTMLDivElement> {
experimentPath?: string;
}
20 changes: 0 additions & 20 deletions docs/src/app/(private)/experiments/layout.module.css

This file was deleted.

7 changes: 0 additions & 7 deletions docs/src/app/(private)/experiments/layout.tsx

This file was deleted.

45 changes: 45 additions & 0 deletions docs/src/app/(private)/experiments/page.module.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
.root {
display: flex;
min-height: 100vh;
font-family:
ui-sans-serif,
-apple-system,
BlinkMacSystemFont,
'Segoe UI Variable Display',
'Segoe UI',
Helvetica,
'Apple Color Emoji',
Arial,
sans-serif;

--sidebar-width: 260px;

@media screen and (max-width: 1300px) {
--sidebar-width: 20vw;
}

& h1 {
font-size: 2rem;
margin-bottom: 1rem;
font-weight: 500;
}
}

.main {
flex: 1 1 100%;
display: flex;
Expand All @@ -6,6 +33,24 @@
font-family: var(--ff-sans);
padding: 20px;
background-color: var(--color-background);
margin-left: var(--sidebar-width);

@media screen and (max-width: 650px) {
margin: 0;
}
}

.sidebar {
width: var(--sidebar-width);
font-size: var(--text-sm);
position: fixed;
top: 0;
bottom: 0;
left: 0;

@media screen and (max-width: 650px) {
display: none;
}
}

.landing {
Expand Down
8 changes: 4 additions & 4 deletions docs/src/app/(private)/experiments/page.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import * as React from 'react';
import clsx from 'clsx';
import classes from './page.module.css';
import { Sidebar } from './infra/Sidebar';
import classes from './page.module.css';

export default async function Experiments() {
return (
<React.Fragment>
<Sidebar />
<div className={classes.root}>
<Sidebar className={classes.sidebar} />
<main className={clsx(classes.main, classes.landing)}>
<h1>Base UI experiments</h1>
<p>← Choose an experiment from the list</p>
</main>
</React.Fragment>
</div>
);
}
1 change: 1 addition & 0 deletions docs/src/app/(private)/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as React from 'react';
import 'docs/src/styles.css';
import './layout.css';

export default function Layout({ children }: React.PropsWithChildren) {
Expand Down

0 comments on commit 9d1f4f4

Please sign in to comment.