https://github.com/rand0mc0d3r/material-ui-panel
Self managed PanelManager build in React.js with MaterialUI inspired from VSCode window system
https://github.com/rand0mc0d3r/material-ui-panel
material-ui panel-management panels react react-panel vscode-clone window-management
Last synced: 2 months ago
JSON representation
Self managed PanelManager build in React.js with MaterialUI inspired from VSCode window system
- Host: GitHub
- URL: https://github.com/rand0mc0d3r/material-ui-panel
- Owner: rand0mC0d3r
- License: gpl-3.0
- Created: 2021-07-03T09:47:41.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2023-10-27T23:48:35.000Z (over 2 years ago)
- Last Synced: 2025-02-27T03:20:47.257Z (over 1 year ago)
- Topics: material-ui, panel-management, panels, react, react-panel, vscode-clone, window-management
- Language: JavaScript
- Homepage: https://materal-ui-panel.herokuapp.com/
- Size: 12.3 MB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 24
-
Metadata Files:
- Readme: README.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# 📑 material-ui-panel
### Alpha version (https://materal-ui-panel.herokuapp.com/)
##### Documentation: https://rand0mc0d3r.github.io/material-ui-panel/

**Hint**: Combined panels ✅ , both sides panels ✅ , Splitted sections ✅ , Panel insertion into section ✅

**Hint**: Alerts in status-bar ✅ , Alerts in sides panels ✅ , Splitted sections template selector ✅ , Embedded web-views ✅

**Hint**: Dark-Mode ✅ , Upper bar ✅ , Menu capabilities ✅
A zero-maintenance/batteries-included panel manager inspired by VSCode style/aspect that adds via Material-UI elements a self populating/managed and state keeping organization of generated children panels.
#### Current limitations
- **StatusBar**
- Cannot display 2 status bars, 1 up and 1 down
- Status items cannot be ordered
- Status items are not draggable
- Status items don't have a pre-defined size
- Status items require a unique id
**NOTE:** comes bundled with ```prop-types```. No **Typescript** support. Help me by creating a *PR* 💌 .
---
## 🪄 Installation
**Minimal version** for mandatory dependencies. Up to the user to provide **React 16.0+** and **Material UI 4.0**
Install the latest version with your favorite package manager.
```
npm install @kadarka/material-ui-panel --save
```
```
yarn i @kadarka/material-ui-panel
```
---
## 🎛️ Architecture & Structure
#### DOM & CSS Grid wise
The base structure it's a grid with 5 columns, at most 5, at least 3 all the time visible, with 1 or 2 always potentially ```width: 0px```
Grid-columns are ```[ ( 'leftMenu' '{leftPanel?}' ) 'main' ( '{rightPanel?}' 'rightMenu' ) ]```.
Side note: ```leftPanel``` and ```rightPanel``` are only visible if needed. Internally they are a ```grid-area``` sub-populated as a ```flex``` with direction ```column```
##### Visually
| leftMenu | leftPanel | main | rightPanel | rightMenu |
|----------|-----------|------|------------|-----------|
| announced panels for side: ```left``` | panels[ ] qualifying for side and visibility properties | *user main app* | panels[ ] qualifying for side and visibility properties | announced panels for side: ```right``` |
### 📑 - < MuiPanelProvider >
The `````` is a HOC Context driven manager suggested to be added close the the root of the document, preferably outside the ±`````` but inside the ``````
The **MuiPanelProvider** constitutes of a wrapper around the **Context API** that acts as a store, with a few methods exposed to the user for managing the states, along with some internal methods that allow the panels to announce themselves, broadcast state changes and react to events. Communication is duplex and the panels themselves are in a dual-binding open chat with the **Provider**.
```
import { createTheme, ThemeOptions, ThemeProvider } from '@material-ui/core/styles'
// import { useMemo } from 'react'
// import { BrowserRouter as Router, Route, Switch } from 'react-router-dom'
// import routes from './routes'
export default (): JSX.Element => {
const theme = useMemo(() => createTheme({ palette: { type: 'dark' } } as ThemeOptions), [])
return
{/* ... */}
{/* notification?... */}
{/* login/modals/errors?... */}
{/* ... */}
{/* ... */}
{routes.map(({ path, exact, component }) => )}
{/* ... */}
}
```
##### Available tweaks's
| Argument | Type |Default | Description |
|-----|----|----|--------|
| *allowRightClick* | boolean | ```false``` | Determines if the panel allows opening the default browser context menu on right click |
| *initialSide* | string | ```left``` | A side option to define for a new user the preference of the menu. Options ```left``` and ```right``` |
| *inverseMarkers* | boolean | ```false``` | Determines is the highlight markers are oriented towards the outer borders of the screen, or towards the main content of the screen |
| *markerColor* | string | ```textPrimary``` | Sets on of the material-UI ```Typography``` range of available colors. Options ```textPrimary```, ```textSecondary```, ```primary```, ```secondary``` |
---
## < MuiPanelManager >
Self organizing manager wrapper that renders all children given
##### Available API's
| Argument | Default | Description |
|-----|----|--------|
| allowRightClick | false | Determines if the panel allows opening the default browser context menu on right click |
##### Code sample
```
}>
{`Lorem ipsum dolor sit amet, ...`}
}>
```
---
## < MuiPanelManager >
Self organizing manager wrapper that renders all children given
---
## `````` - 🕵️ (Internal) - Debug component
A utility modal to display the current state of the panels, layout, settings and the rest of the store. It's constantly updated via the **Provider** hooks.
```
...
...
...
```
---
## < Mui Splitter >
Self organizing manager wrapper that renders all children given
---
## `````` - 🪟 Panel Component
##### The component creates a panel object to host the contents given. It's self registered and managed

**Hint**: Panels can issue notifications

**Hint**: Panels can feature automatic padding
---
## `````` - 📟 Status Bar Component
The component creates an object for the status bar that can be clicked. It's self registered and managed

**Hint**: Direct actions are permitted

**Hint**: As well placed menu actions

**Hint**: Informational sections

**Hint**: Errors are using the secondary color
---
Internally the wrapper `````` bound to the scene is not being rendered and started if there are no `````` announced across the application at any point in time. Later instantiation is fully encouraged to de-clutter the DOM.
Add a section to either ```primary``` or ```secondary``` side of the status bar. An omission will result in a default section.
Each ```MupStatus``` entity must contain an ```id``` in form of an unique identifier across the session.
#### # Inherited configuration
`````` allows the user to configure the status bar with the following properties:
| Argument | Type | Default | Description |
|-----|--|--|---|
| allowRightClick | ```bool``` | _inherited_ | Decides if right/long click triggers any action |
#### # Available arguments
| Argument | | Type | Default | Description |
|-----|--|--|--|---|
| id |⭐ | ```string``` | ... | Give a unique identifier to the status element |
| elements | ⭐ | ```array``` | ```[]``` | List of objects of type ```{icon: ReactNode, text: string}``` |
| side | | ```string``` | ```primary``` | Determines to which side the panel is bound |
| requestAttention | | ```bool``` | ```false``` | When truthy is uses the ```secondary``` color |
| tooltip | | ```string``` | ```''``` | Provides a tooltip acting as a guide |
| focusOnClick | | ```string``` | _null_ | Toggles visibility of a panel known by `````` by it's unique identifier |
| onClick | | ```func``` | ```() => {}``` | Issues callback when status section is clicked |
| onContextMenu | | ```func``` | ```() => {}``` | Issues callback when status section is right/long clicked. |
#### Code sample
##### Simple example - static
```
// 2 icons with text
, text: 'Lorem' },
{ icon: , text: 'Ipsum' },
]}
/>
// 1 icon triggering a panel
, text: 'Toggle Panel' }
]}>
demo text
// 1 icon doing an onClick callback
, text: '4 Related' }]}
/>
// 1 icon requesting attention, no text
}]}
/>
```
##### Dynamic example - updateable
```
...
const [open, setOpen] = useState(false);
const [elements, setElements] = useState();
const [requestAttention, setRequestAttention] = useState(true); // Request attention state
const someFunction = () => {
setElements([{ icon: , text: 'Document saved' }]) // Set an element
setRequestAttention(true) // Update attention state
}
...
return <>
setOpen(true)}
tooltip="Save Document?"
elements={elements} // Initialize empty (won't show)
/>
```
---
## `````` - 🛎️ Button Component
##### The component creates an 🏝️ ( + 📄 ) object that can be clicked. It's self registered and managed

**HINT**: Works great to display a logo or a button with a custom icon ( + text )
Allows the developer to add to the sidebars a logo, a logo with a custom short text, or a button triggering a custom action.
Internally the `````` is made aware of the `````` instance after the **first render** which triggers the internal hook to upstream call the provider with a new entity.
#### # Available arguments
| Argument | Req | Observed | Type | Default | Description |
|-----|--|--|--|--|---|
| id |⭐ | |```string``` | ... | Give a unique identifier to the status element |
| icon |⭐ | 👀 | ```node``` | | Passthru element of Node type. Uses ```cloneElement``` internally |
| tooltip | | 👀 | ```string``` | | Provides a tooltip acting as a guide |
| shortText | | 👀 | ```string``` | | Provides a short text of max 4 UTF8 chars |
| showIcon | | 👀 |```bool``` | ```true``` | Used to determine if the icon should be shown in case provided |
| disabled | | 👀 |```bool``` | ```false``` | Determine if the colors turn gray and interactivity is disabled |
| onClick | | | ```func``` | | Issues callback when status section is clicked |
#### Code sample
##### Simple example - static
```
} // custom color
icon={} // raw svg icon
icon={add_circle} // font material icon
icon={} // font awesome icon
showIcon={false} // hide icon
disabled={true} // disable interaction
onClick={() => console.log('clicked')} // callback
/>
```
##### Dynamic example - updateable
```
export default ({ tooltip, shortText, icon, showIcon, disabled, ... }) => {
return <>
>
```
---
## `````` - ⚠️ Your Content Component -
This is the observable wrapper of your entire application. This should be included as close to root as possible where content represents your view or a representation of your current application UI.
##### Available arguments
| | Argument | Type | Default | Description |
|--|-----|--|--|---|
| ⭐ | children | ```Node``` | ... | Passthru ```Node``` for the current app UI. Expecting the router output or the **main <...>** of the application.
Consider to include all custom wrappers for ****, **** and others. |
#### Code sample
##### Simple example - static
```
<...>
// your app page/pages
```
---
---
---
### TODO
- todo: make callbacks clean right the GC