0.0.53 • Published 1 year ago

mui-status v0.0.53

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

📑 mui-status

run - npm run clean && npm install && npm run dev

Beta2 version (https://materal-ui-panel.herokuapp.com/)

Documentation: https://rand0mc0d3r.github.io/mui-status/

/media/preview.png Hint: Combined panels ✅ , both sides panels ✅ , Splitted sections ✅ , Panel insertion into section ✅

/media/preview.png Hint: Alerts in status-bar ✅ , Alerts in sides panels ✅ , Splitted sections template selector ✅ , Embedded web-views ✅

/media/preview.png 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/mui-status --save
yarn i @kadarka/mui-status

🎛️ Architecture & Structure

📑 - < MuiPanelProvider >

The <MuiPanelProvider> is a HOC Context driven manager suggested to be added close the the root of the document, preferably outside the ±<Router> but inside the <MuiTheme>

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 <ThemeProvider {...{ theme }}>
	{/* ... */}
	<MuiPanelProvider>
	{/* notification?... */}
	{/* login/modals/errors?... */}
	{/* ... */}
	<Router>
	   {/* ... */}
	   <Switch>
	     {routes.map(({ path, exact, component }) => <Route key={path} {...{ exact, path, component }} />)}
	   </Switch>
	</Router>
	{/* ... */}
  </ThemeProvider>
}
Available tweaks's
ArgumentTypeDefaultDescription
allowRightClickbooleanfalseDetermines if the panel allows opening the default browser context menu on right click
positionstringleftA side option to define for a new user the preference of the menu. Options left and right

< MuiPanelManager >

Self organizing manager wrapper that renders all children given

Available API's
ArgumentDefaultDescription
allowRightClickfalseDetermines if the panel allows opening the default browser context menu on right click
Code sample
<MuiPanelManager>
	<MuiDivider tooltip="Default separator" />

	<NotificationPanel />

	<MupPanel title="Lorem Ipsum Panel" icon={<FormatIndentIncreaseIcon />}>
		{`Lorem ipsum dolor sit amet, ...`}
	</MupPanel>

	<MupPanel title="Sample Panel" icon={<FormatAlignLeftIcon />}>
		<Skeleton animation="wave" height={10} style={{ marginBottom: 6 }} />
	</MupPanel>
</MuiPanelManager>

<MuiWrapper> - 🤖 Status + Children Wrapper

Wrapper for instantiating the status wrapper and a pass-thru for the children. It is a HOC that renders the children and the status wrapper.

<MupStatus> - 📟 Status Bar Component

The component creates an object for the status bar that can be clicked. It's self registered and managed by the context provider provided by the library

/media/preview.png

Hint: Direct actions are permitted

/media/preview.png

Hint: As well placed menu actions

/media/preview.png

Hint: Informational sections

/media/preview.png

Hint: Errors are using the secondary color


Internally the wrapper <MupStatusBar> bound to the scene is not being rendered and started if there are no <MupStatus> 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

<MuiPanelProvider /> allows the user to configure the status bar with the following properties:

ArgumentTypeDefaultDescription
allowRightClickboolinheritedDecides if right/long click triggers any action

# Available arguments

ArgumentTypeDefaultDescription
idstring...Give a unique identifier to the status element
elementsarray[]List of objects of type {icon: ReactNode, text: string}
sidestringprimaryDetermines to which side the panel is bound
requestAttentionboolfalseWhen truthy is uses the secondary color
tooltipstring''Provides a tooltip acting as a guide
focusOnClickstringnullToggles visibility of a panel known by <MuiPanelProvider> by it's unique identifier
onClickfunc() => {}Issues callback when status section is clicked
onContextMenufunc() => {}Issues callback when status section is right/long clicked.

Code sample

Simple example - static
// 2 icons with text
<MupStatus
  id="statusA"
  side="left"
  tooltip='33% frames left / Ready for photo'
  elements={[
    { icon: <FormatIndentIncrease color="action" />, text: 'Lorem' },
    { icon: <CameraIcon />, text: 'Ipsum' },
  ]}
/>

// 1 icon triggering a panel
<MupStatus
  id="triggerChromeCastPanel"
  side="left"
  focusOnClick='chromecastPanel'
  tooltip="Toggle visibility for panel"
  elements={[
  { icon: <CastConnectedIcon />, text: 'Toggle Panel' }
]}>
  demo text
</MupStatus>

// 1 icon doing an onClick callback
<MupStatus
  id='statusSimilarDocuments'
  onClick={handleClickOpen}
  tooltip="View Documents ... - (Last checked - 3 min ago)"
  elements={[{ icon: <AllInboxIcon />, text: '4 Related' }]}
/>

// 1 icon requesting attention, no text
<MupStatus
  id='statusSimilarDocuments'
  onClick={handleClickOpen}
  requestAttention
  tooltip="View Documents ... - (Last checked - 3 min ago)"
  elements={[{ icon: <AllInboxIcon /> }]}
/>
Dynamic example - updateable
  ...
  const [open, setOpen] = useState(false);
  const [elements, setElements] = useState();
  const [requestAttention, setRequestAttention] = useState(true);			// Request attention state

  const someFunction = () => {
   setElements([{ icon: <CloudDoneOutlinedIcon />, text: 'Document saved' }])		// Set an element
   setRequestAttention(true)								// Update attention state
  }

  ...

  return <>
    <MupStatus
      id='statusCustomElement'
      requestAttention={requestAttention}						// Reference attention state
      onClick={() => setOpen(true)}
      tooltip="Save Document?"
      elements={elements}								// Initialize empty (won't show)
    />

<MupButton> - 🛎️ Button Component

The component creates an 🏝️ ( + 📄 ) object that can be clicked. It's self registered and managed

/media/preview.png 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 <MuiPanelProvider> is made aware of the <MupButton> instance after the first render which triggers the internal hook to upstream call the provider with a new entity.

# Available arguments

ArgumentReqObservedTypeDefaultDescription
idstring...Give a unique identifier to the status element
icon👀nodePassthru element of Node type. Uses cloneElement internally
tooltip👀stringProvides a tooltip acting as a guide
shortText👀stringProvides a short text of max 4 UTF8 chars
showIcon👀booltrueUsed to determine if the icon should be shown in case provided
disabled👀boolfalseDetermine if the colors turn gray and interactivity is disabled
onClickfuncIssues callback when status section is clicked

Code sample

Simple example - static
<MupButton
  id="appLogo"
  tooltip={`Click here to go ${page.url}`
  shortText="LKDN"                                                  // 4 letters will be displayed in all CAPS
  icon={<BathtubIcon style={{ color: 'orange' }}                    // custom color
  icon={<LinkedInIcon style={{ color: green[500] }} />}             // custom color
  icon={<SvgIcon component={StarIcon} viewBox="0 0 ..." />}         // raw svg icon
  icon={<Icon style={{ color: green[500] }}>add_circle</Icon>}      // font material icon
  icon={<Icon className="fa fa-plus-circle" color="secondary" />}   // 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 <>
  <MupButton
    { ... { tooltip, shortText, icon, showIcon, disabled } }
    id="appLogo"
    ...
  />
</>
Available arguments
ArgumentTypeDefaultDescription
childrenNode...Passthru Node for the current app UI. Expecting the router output or the main <...> of the application. Consider to include all custom wrappers for <Layout ...>, <Notifications ...> and others.

Code sample

Simple example - static
 <MupContent>
  <...>
    <ReactRouter ... />                    // your app page/pages
  </...>
 </MupContent>



TODO

  • todo: make callbacks clean right the GC
0.0.53

1 year ago

0.0.40

2 years ago

0.0.41

2 years ago

0.0.42

2 years ago

0.0.43

1 year ago

0.0.44

1 year ago

0.0.46

1 year ago

0.0.47

1 year ago

0.0.37

2 years ago

0.0.38

2 years ago

0.0.39

2 years ago

0.0.30

2 years ago

0.0.31

2 years ago

0.0.32

2 years ago

0.0.33

2 years ago

0.0.34

2 years ago

0.0.35

2 years ago

0.0.36

2 years ago

0.0.26

2 years ago

0.0.27

2 years ago

0.0.28

2 years ago

0.0.29

2 years ago

0.0.23

2 years ago

0.0.24

2 years ago

0.0.25

2 years ago

0.0.51

1 year ago

0.0.52

1 year ago

0.0.50

1 year ago

0.0.48

1 year ago

0.0.49

1 year ago

0.0.20

2 years ago

0.0.21

2 years ago

0.0.22

2 years ago

0.0.19

2 years ago

0.0.18

2 years ago

0.0.17

2 years ago

0.0.16

2 years ago

0.0.15

2 years ago

0.0.14

2 years ago

0.0.11

2 years ago

0.0.10

2 years ago

0.0.9

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.1

2 years ago