Skip to content

upgrade docusaurus #127

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@
"@testing-library/dom": "^10.4.0",
"@testing-library/react": "^16.2.0",
"@testing-library/user-event": "^14.6.1",
"@types/react": "^19.0.8",
"@types/react-dom": "^19.0.3",
"@types/react": "^19.1.8",
"@types/react-dom": "^19.1.6",
"@types/react-transition-group": "^4.4.12",
"@typescript-eslint/eslint-plugin": "^8.23.0",
"@typescript-eslint/parser": "^8.23.0",
Expand Down
2 changes: 1 addition & 1 deletion src/Waypoint.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import useCallbackRef from '@restart/hooks/useCallbackRef';
import * as React from 'react';

import useWaypoint, {
Position,
type WaypointOptions,
type WaypointEvent,
type Position,
} from './useWaypoint.js';

export { Position };
Expand Down
87 changes: 43 additions & 44 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,46 +1,45 @@
import Dropdown from './Dropdown.js';
import { useDropdownMenu } from './DropdownMenu.js';
import { useDropdownToggle } from './DropdownToggle.js';
import { useDropdownItem } from './DropdownItem.js';
import Modal from './Modal.js';
import Overlay from './Overlay.js';
import Portal from './Portal.js';
import useRootClose from './useRootClose.js';
import Nav from './Nav.js';
import NavItem, { useNavItem } from './NavItem.js';
import Button from './Button.js';
import Tabs from './Tabs.js';
import TabPanel from './TabPanel.js';

export {
Button,
Dropdown,
useDropdownMenu,
useDropdownToggle,
useDropdownItem,
Nav,
NavItem,
useNavItem,
Modal,
Overlay,
Portal,
useRootClose,
Tabs,
TabPanel,
};

export type { ButtonProps } from './Button.js';
export type {
DropdownProps,
DropdownMenuProps,
UseDropdownMenuMetadata,
UseDropdownMenuOptions,
DropdownToggleProps,
UseDropdownToggleMetadata,
DropdownItemProps,
default as Dropdown,
type DropdownProps,
type DropdownMenuProps,
type UseDropdownMenuMetadata,
type UseDropdownMenuOptions,
type DropdownToggleProps,
type UseDropdownToggleMetadata,
type DropdownItemProps,
} from './Dropdown.js';
export type { NavItemProps, UseNavItemOptions, NavProps } from './Nav.js';
export type { ModalProps } from './Modal.js';
export type { OverlayProps } from './Overlay.js';
export type { PortalProps } from './Portal.js';
export type { TabsProps, TabPanelProps } from './Tabs.js';
export { useDropdownMenu } from './DropdownMenu.js';
export { useDropdownToggle } from './DropdownToggle.js';
export { useDropdownItem } from './DropdownItem.js';
export { default as Modal, type ModalProps } from './Modal.js';
export { default as Overlay, type OverlayProps } from './Overlay.js';
export { default as Portal, type PortalProps } from './Portal.js';
export {
default as useRootClose,
type RootCloseOptions,
} from './useRootClose.js';
export {
default as Nav,
type NavItemProps,
type UseNavItemOptions,
type NavProps,
} from './Nav.js';
export { default as NavItem, useNavItem } from './NavItem.js';
export { default as Button, type ButtonProps } from './Button.js';
export { default as Tabs, type TabsProps, type TabPanelProps } from './Tabs.js';
export { default as TabPanel } from './TabPanel.js';

export {
default as Waypoint,
type WaypointProps,
type WaypointEvent,
} from './Waypoint.js';
export {
default as useWaypoint,
Position,
type WaypointOptions,
} from './useWaypoint.js';
export {
default as useClickOutside,
type ClickOutsideOptions,
} from './useClickOutside.js';
7 changes: 0 additions & 7 deletions www/babel.config.js

This file was deleted.

12 changes: 7 additions & 5 deletions www/docs/Button.mdx
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
An abstract button component for creating accessible buttons regardless of the HTML
element used to render it.

```jsx live className=button-example
```jsx live
import { Button } from "@restart/ui";

<Button>I'm a Button</Button>;
<div className="button-example">
<Button>I'm a Button</Button>
</div>;
```

Not very impressive on its own, but `Button` does come with a few conveniences
Expand All @@ -14,10 +16,10 @@ over the plain HTML element.
- Ensures that non `button` `as` options remain accessible
- contextually renders an `<a>` if href or other anchor props are added.

```jsx live className=button-example
```jsx live
import { Button } from "@restart/ui";

<div className="space-x-4">
<div className="space-x-4 button-example">
<Button>I'm a Button</Button>
<Button href="/home">I'm a link</Button>
<Button as="span">I'm a span but also a button</Button>
Expand Down Expand Up @@ -73,7 +75,7 @@ function StyledButton(props) {
!props.disabled &&
"cursor-pointer hover:bg-primary hover:text-white",
"active:bg-primary-600 active:text-white",
props.disabled && "cursor-not-allowed opacity-60"
props.disabled && "cursor-not-allowed opacity-60",
)}
/>
);
Expand Down
9 changes: 5 additions & 4 deletions www/docs/Dropdown.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const DropdownMenu = ({ role }) => {
{
flip: true,
offset: [0, 8],
}
},
);

useLayoutEffect(() => {
Expand All @@ -38,7 +38,7 @@ const DropdownMenu = ({ role }) => {
role={role}
className={clsx(
show ? "flex" : "hidden",
"w-48 py-2 flex-col shadow-lg border-gray-200 border bg-white z-10 rounded"
"w-48 py-2 flex-col shadow-lg border-gray-200 border bg-white z-10 rounded",
)}
>
<Dropdown.Item className="text-left hover:bg-primary-100 px-6 py-2 focus:ring-2 focus:outline-none">
Expand Down Expand Up @@ -307,6 +307,7 @@ your app's needs.
The example here positions the `Menu` to the `document` body via a `Portal`.

```jsx live
import { createPortal } from "react-dom";
import { Dropdown } from "@restart/ui";
import Button from "../src/Button";

Expand All @@ -320,7 +321,7 @@ import Button from "../src/Button";
</Dropdown.Toggle>
<Dropdown.Menu offset={[0, 12]}>
{(props, { show }) =>
ReactDOM.createPortal(
createPortal(
<div
{...props}
className={`${
Expand All @@ -329,7 +330,7 @@ import Button from "../src/Button";
>
<p>I am rendered into the document body</p>
</div>,
document.body
document.body,
)
}
</Dropdown.Menu>
Expand Down
11 changes: 4 additions & 7 deletions www/docs/Waypoint.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,8 @@ to the `root` prop.

```tsx
function ScrollArea({ items, onPositionChange }) {
const [element, setElement] = useState<HTMLDivElement>(
null
);
const [element, setElement] =
useState<HTMLDivElement>(null);

return (
<div ref={setElement} style={{ overflow: "auto" }}>
Expand Down Expand Up @@ -91,9 +90,7 @@ when you want an individual component to respond

```tsx live
import getScrollParent from "dom-helpers/scrollParent";
import useWaypoint, {
Position,
} from "@restart/ui/useWaypoint";
import { useWaypoint, Position } from "@restart/ui";

function LazyImage({ src }) {
const [element, attachRef] = useState(null);
Expand All @@ -112,7 +109,7 @@ function LazyImage({ src }) {
root: "scrollParent",
scrollDirection: "horizontal",
rootMargin: { right: -80 },
}
},
);

return (
Expand Down
44 changes: 23 additions & 21 deletions www/docs/useRootClose.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,30 @@
import { useRootClose } from "@restart/ui";
import Button from "../src/Button";

const ref = useRef();
const [show, setShow] = useState(false);
const handleRootClose = () => setShow(false);
function RootCloseWrapper() {
const ref = useRef();
const [show, setShow] = useState(false);
const handleRootClose = () => setShow(false);

useRootClose(ref, handleRootClose, {
disabled: !show,
});
useRootClose(ref, handleRootClose, {
disabled: !show,
});

return (
<div className="flex flex-col items-center space-y-4">
<Button type="button" onClick={() => setShow(true)}>
Render RootCloseWrapper
</Button>
return (
<div className="flex flex-col items-center space-y-4">
<Button type="button" onClick={() => setShow(true)}>
Render RootCloseWrapper
</Button>

{show && (
<div
ref={ref}
className="rounded shadow bg-white p-6"
>
<span>Click anywhere to dismiss me!</span>
</div>
)}
</div>
);
{show && (
<div
ref={ref}
className="rounded shadow bg-white p-6"
>
<span>Click anywhere to dismiss me!</span>
</div>
)}
</div>
);
}
```
14 changes: 4 additions & 10 deletions www/docusaurus.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,15 @@ module.exports = {
plugins: [require.resolve('./plugins/webpack')],
presets: [
[
'@4c/docusaurus-preset',
'@docusaurus/preset-classic',
{
theme: [
'@docusaurus/theme-classic',
{
customCss: [require.resolve('./src/css/tailwind.css')],
},
],
theme: {
customCss: [require.resolve('./src/css/tailwind.css')],
},
docs: {
routeBasePath: '/',
sidebarPath: require.resolve('./sidebars.js'),
},
reactMetadata: {
src: '../src/**/*.{js,tsx,ts}',
},
},
],
],
Expand Down
23 changes: 14 additions & 9 deletions www/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,27 @@
"write-heading-ids": "docusaurus write-heading-ids"
},
"dependencies": {
"@4c/docusaurus-preset": "^1.0.0",
"@docusaurus/core": "2.2.0",
"@docusaurus/preset-classic": "2.2.0",
"@docusaurus/core": "^3.8.1",
"@docusaurus/preset-classic": "^3.8.1",
"@docusaurus/theme-common": "^3.8.1",
"@emotion/react": "^11.10.5",
"@emotion/styled": "^11.10.5",
"@mdx-js/react": "^1.6.21",
"@restart/hooks": "^0.4.7",
"@restart/hooks": "^0.6.2",
"clsx": "^1.2.1",
"docusaurus-theme-tailwind": "^1.0.1-rc.0",
"emotion": "^11.0.0",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"jarle": "^3.2.1",
"react": "^19.0.0",
"react-dom": "^19.0.0",
"tailwindcss": "^2.2.4"
},
"devDependencies": {
"@docusaurus/module-type-aliases": "^3.8.1",
"@docusaurus/tsconfig": "^3.8.1",
"@docusaurus/types": "^3.8.1",
"@types/react": "^19.1.8",
"@types/react-dom": "^19.1.6",
"autoprefixer": "^10.4.13",
"postcss": "^8.4.21"
"postcss": "^8.4.21",
"typescript": "^5.8.3"
}
}
14 changes: 0 additions & 14 deletions www/plugins/webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,6 @@ module.exports = () => ({
return {
devtool: 'inline-cheap-module-source-map',

module: {
rules: [
{
test: /\.(j|t)sx?$/,
include: [path.resolve(__dirname, '../../src')],
use: [
getJSLoader(
isServer,
path.resolve(__dirname, '../babel.config.js'),
),
],
},
],
},
resolve: {
alias: {
'@restart/ui': path.resolve(__dirname, '../../src'),
Expand Down
Loading
Loading