Skip to content

Feature/reactui sidenav #402

New issue

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

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

Already on GitHub? # to your account

Merged
merged 12 commits into from
Apr 11, 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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ pnpm build

### Develop

**Note:** Run `pnpm build` before `pnpm dev` to ensure that all packages have required files built and ready.

To develop all apps and packages, run the following command:

```bash
Expand Down
47 changes: 47 additions & 0 deletions apps/docs/components/ExampleSideNav.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
'use client';

import { SideNav, SideNavItem, SideNavItemGroup } from '@enterwell/react-ui';
import { Button } from '@mui/material';
import { Stack } from '@mui/system';
import Image from 'next/image';
import { useSearchParams } from 'next/navigation';

export function ExampleSideNav() {
const params = useSearchParams();
const selectedItem = params.get('item');
const show = params.get('show') === 'true';
function setShow(show: boolean) {
const url = new URL(window.location.href);
url.searchParams.set('show', show.toString());
window.history.pushState({}, '', url.toString());
}
Comment on lines +10 to +17
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you choose native browser APIs over "Next.js's way" for any specific reason? I see that you're using Next's useSearchParams, so I think maybe you could integrate Next.js's routing all the way for consistency and reactivity

For example:

const router = useRouter();
const pathname = usePathname();
const params = useSearchParams();
const selectedItem = params.get('item');
const show = params.get('show') === 'true';

function setShow(show: boolean) {
    const params = new URLSearchParams(searchParams);
    params.set('show', show.toString());
    
    router.push(`${pathname}?${params.toString()}`);
    // router.push(`${pathname}?${params.toString()}`, { shallow: true }); If you don't want to run data fetching methods again
}


return (
<>
{show && (
// @highlight-start
<SideNav header={(
<Stack direction='row' alignItems='center' spacing={2}>
<div className="flex flex-row gap-1 items-center whitespace-nowrap">
<Image
alt="Enterwell"
width={32}
height={32}
src="https://enterwell.net/wp-content/uploads/2023/05/ew-logomark-monochrome-negative-64.x71089.svg" />
<span className="text-xs sm:text-sm md:text-lg">Enterwell {'<'}UI{' \\>'}</span>
</div>
</Stack>
)}>
<SideNavItem href="?item=1&show=true" selected={selectedItem === '1'}>Item 1</SideNavItem>
<SideNavItem href="?item=2&show=true" selected={selectedItem === '2'}>Item 2</SideNavItem>
<SideNavItemGroup label="Group 1" defaultExpanded={selectedItem === '3' || selectedItem === '4'}>
<SideNavItem href="?item=3&show=true" selected={selectedItem === '3'}>Item 3</SideNavItem>
<SideNavItem href="?item=4&show=true" selected={selectedItem === '4'}>Item 4</SideNavItem>
</SideNavItemGroup>
</SideNav>
// @highlight-end
)}
<Button variant='contained' onClick={() => setShow(!show)}>Toggle SideNav</Button>
</>
)
}
33 changes: 33 additions & 0 deletions apps/docs/content/react-ui/components/side-nav.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
---
title: SideNav
---

import { SideNav } from '@enterwell/react-ui';
import { ComponentWithSource } from '../../../components/docs/ComponentWithSource.tsx';
import { ExampleSideNav } from '../../../components/ExampleSideNav.tsx';
import { ComponentDescription, ComponentParameters, ComponentSource } from '../../../components/docs/ComponentDocs';

# SideNav

## Description

<ComponentDescription name="SideNav" />

### Parameters

<ComponentParameters name="SideNav" />

## Example

<ComponentWithSource component={ ExampleSideNav } centered />

## Inspect

<details>
<summary>Source code</summary>
<ComponentSource
package="@enterwell/react-ui"
directory="SideNav"
name="SideNav"
/>
</details>
7 changes: 7 additions & 0 deletions packages/react-hooks/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

_NOTE: This is an automatically generated file. Do not modify contents of this file manually._

## [0.7.0] - 2025-04-02
### Changed
- Updated React to v19

### Fixed
- useResizeObserver not returns correct ref type

## [0.6.0] - 2025-04-01
### Changed
- Updated packages
Expand Down
2 changes: 1 addition & 1 deletion packages/react-hooks/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@enterwell/react-hooks",
"version": "0.6.0",
"version": "0.7.0",
"type": "module",
"main": "dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
4 changes: 4 additions & 0 deletions packages/react-mui-hooks/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

_NOTE: This is an automatically generated file. Do not modify contents of this file manually._

## [0.10.0] - 2025-04-02
### Changed
- Migrated to MUI 7

## [0.9.0] - 2025-04-01
### Changed
- Migrated to MUI 6
Expand Down
Empty file.
2 changes: 1 addition & 1 deletion packages/react-mui-hooks/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@enterwell/react-mui-hooks",
"version": "0.9.0",
"version": "0.10.0",
"type": "module",
"main": "dist/index.js",
"types": "./dist/index.d.ts",
Expand Down
3 changes: 2 additions & 1 deletion packages/react-ui/.changelog.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"Select",
"SplitButton",
"TimeInput",
"ItemAccordion"
"ItemAccordion",
"SideNav"
]
}
7 changes: 7 additions & 0 deletions packages/react-ui/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

_NOTE: This is an automatically generated file. Do not modify contents of this file manually._

## [0.16.0] - 2025-04-02
### Added
- [PageDrawer] `bgColor` and `slots` optional props

### Changed
- Updated MUI to v7

## [0.15.0] - 2025-04-01
### Changed
- Updated MUI to v6
Expand Down
Loading
Loading