Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
rand0mC0d3r committed Aug 27, 2023
1 parent 773d109 commit 6430907
Show file tree
Hide file tree
Showing 7 changed files with 159 additions and 50 deletions.
14 changes: 9 additions & 5 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ import Preopen from './components/Preopen'
import Samples from './components/Samples'
import Search from './components/Search'
import SpeedMonitor from './components/SpeedMonitor'
// import Sidebars from './components/Sidebars'

import './App.css'
// import Sidebars from './components/Sidebars'
import StatusCoreGenerator from './components/StatusCoreGenerator'

function App() {
const [width, setWidth] = useState('100%')
Expand All @@ -33,7 +34,7 @@ function App() {

return <>
<IndustrialProvider
debug
// debug
fullWidth={fullWidth}
hasLock={true}
hasBorder={hasBorder}
Expand All @@ -42,8 +43,9 @@ function App() {
size="medium"
variant={variant}
>
<StatusCoreGenerator />
{/* <Sidebars /> */}
<Samples />
{/* <Samples />
<Search />
<GithubPage />
<NotificationsGenerator />
Expand All @@ -53,9 +55,11 @@ function App() {
<ChatClient />
<KeyboardShortcuts />
{!loggedIn && <Preopen />}
<SpeedMonitor /> */}
{/* {!loggedIn && <Preopen />} */}
{/* <Commands {...{ wikiFrame, setWikiFrame }} /> */}
<SpeedMonitor />
<Commands {...{ wikiFrame, setWikiFrame }} />

<KeyboardShortcuts />
<ControlPanel {...{
wikiFrame, setWikiFrame,
variant, setVariant,
Expand Down
6 changes: 3 additions & 3 deletions src/components/ChatClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -99,9 +99,9 @@ export default function () {
childrenOrder = {5}
text="Chats" >
<Fragment>
<Status.Template mask image={'https://avatars.githubusercontent.com/u/79695292?v=4'}/>
<Status.Template mask image={'https://avatars.githubusercontent.com/u/11871180?v=4'}/>
<Status.Template mask image={'https://avatars.githubusercontent.com/u/11874180?v=4'}/>
<Status.Template icon={<Avatar src='https://avatars.githubusercontent.com/u/79695292?v=4' />}/>
<Status.Template icon={<Avatar src='https://avatars.githubusercontent.com/u/11871180?v=4'/>}/>
<Status.Template icon={<Avatar src='https://avatars.githubusercontent.com/u/11874180?v=4'/>}/>
</Fragment>
</Status.Template>
</Status>
Expand Down
66 changes: 34 additions & 32 deletions src/components/ControlPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,38 +172,40 @@ export default function ({
<Accordion expanded={expanded} onChange={handleChange}>
<AccordionSummary>Control Panel</AccordionSummary>
<AccordionDetails>
<div style={{
alignItems: 'stretch',
flexDirection: 'column',
display: 'flex',
border: '1px solid #888',
borderRadius: '8px',
padding: '16px',
gap: '16px'
}}>
{toggleBlock('Simulate logged in', loggedIn, setLoggedIn)}
{toggleBlock('Border', hasBorder, setHasBorder)}
{toggleBlock('FullWidth', fullWidth, setFullWidth)}
{toggleOptions('Variant', ['default', 'outlined'], setVariant, variant)}
{toggleOptions('Position', ['top', 'bottom'], setPosition, position)}
{toggleOptions('Width', ['75vw', '100%', '60%', '1400px'], setWidth, width)}
{toggleOptions('Margin', ['0px', '4px', '16px'], setMargin, margin)}
</div>
<div style={{ alignItems: 'center', flexDirection: 'column', display: 'flex', gap: '16px' }}>
<Button onClick={() => window.location.reload()} variant='contained' color="primary"
fullWidth>
<ReplayIcon /> Reload
</Button>
<textarea onMouseUp={() => {
let textVal = selectionRef.current
let cursorStart = textVal.selectionStart
let cursorEnd = textVal.selectionEnd
let selectedText = text.substring(cursorStart,cursorEnd)
setSelectionIndexes({ start: cursorStart, end: cursorEnd })
setSelectedText(selectedText)
}} ref={selectionRef} style={{ width: '100%', height: '400px' }}
defaultValue={text.trim()} />
</div>
{expanded && <>
<div style={{
alignItems: 'stretch',
flexDirection: 'column',
display: 'flex',
border: '1px solid #888',
borderRadius: '8px',
padding: '16px',
gap: '16px'
}}>
{toggleBlock('Simulate logged in', loggedIn, setLoggedIn)}
{toggleBlock('Border', hasBorder, setHasBorder)}
{toggleBlock('FullWidth', fullWidth, setFullWidth)}
{toggleOptions('Variant', ['default', 'outlined'], setVariant, variant)}
{toggleOptions('Position', ['top', 'bottom'], setPosition, position)}
{toggleOptions('Width', ['75vw', '100%', '60%', '1400px'], setWidth, width)}
{toggleOptions('Margin', ['0px', '4px', '16px'], setMargin, margin)}
</div>
<div style={{ alignItems: 'center', flexDirection: 'column', display: 'flex', gap: '16px' }}>
<Button onClick={() => window.location.reload()} variant='contained' color="primary"
fullWidth>
<ReplayIcon /> Reload
</Button>
<textarea onMouseUp={() => {
let textVal = selectionRef.current
let cursorStart = textVal.selectionStart
let cursorEnd = textVal.selectionEnd
let selectedText = text.substring(cursorStart,cursorEnd)
setSelectionIndexes({ start: cursorStart, end: cursorEnd })
setSelectedText(selectedText)
}} ref={selectionRef} style={{ width: '100%', height: '400px' }}
defaultValue={text.trim()} />
</div>
</>}
</AccordionDetails>
</Accordion>
</>}
Expand Down
6 changes: 3 additions & 3 deletions src/components/KeyboardShortcuts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Crop32OutlinedIcon from '@mui/icons-material/Crop32Outlined'
import EditAttributesIcon from '@mui/icons-material/EditAttributes'
import KeyboardIcon from '@mui/icons-material/Keyboard'
import { ListItemText, MenuItem, MenuList } from '@mui/material'
import { KeyboardHelper, PopperWidth, Status, StatusType, useConfig, useRegisterShortcut, useShortcuts } from 'mui-industrial'
import { KeyboardHelper, PopperWidth, ShortcutObject, Status, StatusType, useConfig, useRegisterShortcut, useShortcuts } from 'mui-industrial'
import { useEffect, useState } from 'react'

const kbdId = 'bkdShortcut'
Expand All @@ -16,7 +16,7 @@ const i18n = {

export default function () {
const shortcuts = useShortcuts()
const [open, setOpen] = useState<boolean>(false)
const [open, setOpen] = useState<boolean>(true)
const [edit, setEdit] = useState<boolean>(false)
const [asChip, setAsChip] = useState<boolean>(true)
const { handleKeyboardGetLabel } = useRegisterShortcut()
Expand All @@ -31,7 +31,7 @@ export default function () {

const keyboards = [
{ id: kbdId, ctrlKey: true, char: 'K', onTrigger: () => setOpen((prev) => !prev), label: 'Toggle Shortcuts' }
]
] as ShortcutObject[]

useEffect(() => {
config({ keyboards })
Expand Down
33 changes: 27 additions & 6 deletions src/components/Preopen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,19 @@ import FacebookIcon from '@mui/icons-material/Facebook'
import GitHubIcon from '@mui/icons-material/GitHub'
import GoogleIcon from '@mui/icons-material/Google'
import PasswordIcon from '@mui/icons-material/Password'
import { Box, Typography } from '@mui/material'
import { Avatar, Box, Typography } from '@mui/material'
import { useTheme } from '@mui/material/styles'
import { Highlight, KeyboardHelper, PopperWidth, Status, StatusType, useConfig } from 'mui-industrial'
import { useEffect, useState } from 'react'

const id = 'preOpen'
const kbdId = 'preLogin'

export default function () {
const theme = useTheme()
const { config, configUnmount } = useConfig()
const [open, setOpen] = useState<boolean>(true)
const [isLogged, setIsLogged] = useState<boolean>(false)

const keyboards = [
{ id: kbdId, ctrlKey: true, char: 'L', onTrigger: () => setOpen((prev: any) => !prev), label: 'Toggle Login' },
Expand All @@ -24,14 +27,21 @@ export default function () {
{ id: 'googleLogin',
icon : <GoogleIcon />,
shortcutId: 'googleLogin',
onTrigger: () => console.log('Google command', id),
onTrigger: () => {
console.log('Google command', id)
setIsLogged(true)
},
label: 'Google Login' },
{ id: 'facebookLogin', icon : <FacebookIcon />, onTrigger: () => console.log('Facebook', id), label: 'Facebook Login' },
{ id: 'githubLogin', icon : <GitHubIcon />, onTrigger: () => console.log('Github', id), label: 'Github Login' },
]

const content = <Box style={{ padding: '32px', textAlign: 'center' }}>
<Typography variant='subtitle2' color="textSecondary">Login buttons...</Typography>
const content = <Box display="flex" style={{ padding: '32px 16px', gap: '16px', textAlign: 'center' }} flexDirection="column">
{/* {isLogged ? 'yes' : 'no'} */}
{!isLogged && <Avatar sx={{ width: '64px', backgroundColor: theme.palette.primary.light, height: '64px', margin: 'auto' }} >AU</Avatar>}
{isLogged && <Avatar src='https://avatars.githubusercontent.com/u/79695292?v=4'
sx={{ width: '64px', backgroundColor: theme.palette.primary.light, height: '64px', margin: 'auto' }} />}
<Typography variant='h6'>{isLogged ? 'Anonymous User' : 'Login...'}</Typography>
</Box>

useEffect(() => {
Expand All @@ -51,7 +61,10 @@ export default function () {
onClose: () => setOpen(false)
},
actions: [
{ icon: <GoogleIcon />, tooltip: 'Login with Google', onClick: () => console.log('Google button') },
{ icon: <GoogleIcon />, tooltip: 'Login with Google', onClick: () => {
console.log('Google button')
setIsLogged(true)
} },
{ icon: <FacebookIcon />, tooltip: 'Login with Facebook', onClick: () => console.log('Facebook') },
{ icon: <GitHubIcon />, tooltip: 'Login with GitHub', onClick: () => console.log('GitHub') }
],
Expand All @@ -64,6 +77,14 @@ export default function () {
content
}}
>
<Status.Template icon={<PasswordIcon />} text="Login" />
<Status.Template
childrenOrder={10}
text={isLogged ? 'Random Guy' : 'Login now'}
>
<>
{!isLogged && <Status.Template icon={<PasswordIcon />}/>}
{isLogged && <Status.Template icon={<Avatar src='https://avatars.githubusercontent.com/u/79695292?v=4'/>}/>}
</>
</Status.Template>
</Status>
}
2 changes: 1 addition & 1 deletion src/components/Samples.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export default () => <>
<Status.Template badge="badge" />
</Status>

<Status id="onlyIcon" onClick={() => {}}>
<Status id="onlyIcon" onClick={() => {}}>
<Status.Template icon={<ListAltIcon />} />
</Status>
</>
82 changes: 82 additions & 0 deletions src/components/StatusCoreGenerator.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/* eslint-disable no-console */
/* eslint-disable no-unused-vars */
import FacebookIcon from '@mui/icons-material/Facebook'
import GitHubIcon from '@mui/icons-material/GitHub'
import GoogleIcon from '@mui/icons-material/Google'
import PasswordIcon from '@mui/icons-material/Password'
import { Avatar, Box, Checkbox, MenuItem, Select, TextField, Typography } from '@mui/material'
import { useTheme } from '@mui/material/styles'
import { Highlight, KeyboardHelper, PopperWidth, Status, StatusType, useConfig } from 'mui-industrial'
import { useEffect, useState } from 'react'

const id = 'statusCoreGenerator'

export default function () {
const theme = useTheme()
const [open, setOpen] = useState<boolean>(false)

const [primaryText, setPrimaryText] = useState<string>('Sample')
const [badgeText, setBadgeText] = useState<string>('')
const [tooltip, setTooltip] = useState<string>('Tooltip')
const [popperText, setPopperText] = useState<string>('Status Generator Popper')
const [highlight, setHighlight] = useState<string>(Highlight.DEFAULT)

const [order, setOrder] = useState<number>(0)

const [reverse, setReverse] = useState<boolean>(false)
const [secondary, setSecondary] = useState<boolean>(false)
const [showIcon, setShowIcon] = useState<boolean>(false)

const content = <Box display="flex" style={{ padding: '32px 16px', gap: '16px', textAlign: 'center' }} flexDirection="column">
<TextField value={primaryText} onChange={(e) => setPrimaryText(e.target.value)} label="Primary Text" />
<TextField value={popperText} onChange={(e) => setPopperText(e.target.value)} label="Popper Text" />
<TextField value={badgeText} onChange={(e) => setBadgeText(e.target.value)} label="Badge Text" />
<TextField value={tooltip} onChange={(e) => setTooltip(e.target.value)} label="Tooltip Text" />
<TextField value={order} onChange={(e) => setOrder(Number(e.target.value))} label="Order"
type={'number'} />
<Select value={highlight} onChange={(e) => {
setHighlight(e.target.value)
} } label="Highlight">
<MenuItem value={Highlight.PRIMARY}>Primary</MenuItem>
<MenuItem value={Highlight.SECONDARY}>Secondary</MenuItem>
<MenuItem value={Highlight.DEFAULT}>None</MenuItem>
</Select>
<Box display="flex" sx={{ gap: '4px' }} alignItems="center">
<Checkbox checked={reverse} onChange={(e) => setReverse(e.target.checked)} />
<Typography>Reverse</Typography>
</Box>

<Box display="flex" sx={{ gap: '4px' }} alignItems="center">
<Checkbox checked={secondary} onChange={(e) => setSecondary(e.target.checked)} />
<Typography>Secondary</Typography>
</Box>

<Box display="flex" sx={{ gap: '4px' }} alignItems="center">
<Checkbox checked={showIcon} onChange={(e) => setShowIcon(e.target.checked)} />
<Typography>Show Icon</Typography>
</Box>

</Box>

return <Status {...{ id, order, secondary, tooltip }}
highlight={highlight as Highlight}
onClick={() => setOpen((p: any) => !p)}
options = {{
as: StatusType.POPPER,
popper: {
width: PopperWidth.SM,
onClose: () => setOpen(false),
},
title: `${open ? 'open' : 'closed'} - ${popperText}`,
content,
open
}}
>
<Status.Template
icon={showIcon ? <Avatar src="https://mui.com/static/images/avatar/1.jpg" /> : undefined}
badge={badgeText}
reverse={reverse}
text={primaryText}
/>
</Status>
}

0 comments on commit 6430907

Please sign in to comment.