Skip to content

Commit

Permalink
add team + guide (#656)
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegMoshkovich committed Mar 17, 2023
1 parent 1395e32 commit c421572
Show file tree
Hide file tree
Showing 20 changed files with 188 additions and 40 deletions.
29 changes: 22 additions & 7 deletions src/Components/About/AboutControl.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,15 @@ import React, {useState} from 'react'
import Box from '@mui/material/Box'
import Typography from '@mui/material/Typography'
import {getCookieBoolean, setCookieBoolean} from '../../privacy/Privacy'
import useStore from '../../store/useStore'
import Dialog from '../Dialog'
import {ControlButton} from '../Buttons'
import AboutGuide from './AboutGuide'
import {useIsMobile} from '../Hooks'
import AboutDescription from './AboutDescription'
import PrivacyControl from './PrivacyControl'
import AboutIcon from '../../assets/icons/Information.svg'
import LogoB from '../../assets/LogoB.svg'
import {Helmet} from 'react-helmet-async'
import useStore from '../../store/useStore'


/**
Expand All @@ -25,12 +26,25 @@ export default function AboutControl() {
name: 'isFirstTime',
defaultValue: true,
}))
const isMobile = useIsMobile()
const displayTooltip = () => isMobile ? turnOffIsTooltipsOpen() : toggleIsTooltipsOpen()
const toggleIsTooltipsOpen = useStore((state) => state.toggleIsTooltipsOpen)
const turnOffIsTooltipsOpen = useStore((state) => state.turnOffIsTooltipsOpen)
const setIsDialogDisplayedLocal = (value) => {
setIsDialogDisplayed(value)
displayTooltip()
}
const setIsDialogDisplayedForDialog = () => {
setIsDialogDisplayed(false)
setCookieBoolean({component: 'about', name: 'isFirstTime', value: false})
displayTooltip()
}

return (
<ControlButton
title='About bldrs'
title='About'
isDialogDisplayed={isDialogDisplayed}
setIsDialogDisplayed={setIsDialogDisplayed}
setIsDialogDisplayed={setIsDialogDisplayedLocal}
icon={
<AboutIcon
style={{
Expand All @@ -45,6 +59,7 @@ export default function AboutControl() {
setIsDialogDisplayed={() => {
setIsDialogDisplayed(false)
setCookieBoolean({component: 'about', name: 'isFirstTime', value: false})
toggleIsTooltipsOpen()
}}
/>
}
Expand Down Expand Up @@ -72,7 +87,7 @@ function AboutDialog({isDialogDisplayed, setIsDialogDisplayed}) {
headerText={''}
isDialogDisplayed={isDialogDisplayed}
setIsDialogDisplayed={setIsDialogDisplayed}
content={<AboutContent/>}
content={<AboutContent setIsDialogDisplayed={setIsDialogDisplayed}/>}
actionTitle='OK'
actionCb={() => setIsDialogDisplayed(false)}
/>
Expand All @@ -85,7 +100,7 @@ function AboutDialog({isDialogDisplayed, setIsDialogDisplayed}) {
*
* @return {React.ReactElement} React component
*/
function AboutContent() {
function AboutContent({setIsDialogDisplayed}) {
return (
<Box sx={{'& a': {textDecoration: 'none'}}}>
<Helmet>
Expand All @@ -95,7 +110,7 @@ function AboutContent() {
<a href='https://github.com/bldrs-ai/Share' target='_new'>
github.com/bldrs-ai/Share
</a>
<AboutGuide/>
<AboutDescription setIsDialogDisplayed={setIsDialogDisplayed}/>
<PrivacyControl/>
</Box>)
}
6 changes: 3 additions & 3 deletions src/Components/About/AboutControl.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import AboutControl from './AboutControl'
describe('About control tests', () => {
test('renders the AboutControl button', () => {
const {getByTitle} = render(<MockComponent><AboutControl/></MockComponent>)
const aboutControl = getByTitle('About bldrs')
const aboutControl = getByTitle('About')
expect(aboutControl).toBeInTheDocument()
})

test('renders AbotDialog when control is pressed', () => {
test('renders AboutDialog when control is pressed', () => {
const {getByTitle, getByText} = render(<MockComponent><AboutControl/></MockComponent>)
const aboutControl = getByTitle('About bldrs')
const aboutControl = getByTitle('About')
fireEvent.click(aboutControl)
const dialogTitle = getByText('build every thing together')
expect(dialogTitle).toBeInTheDocument()
Expand Down
76 changes: 76 additions & 0 deletions src/Components/About/AboutDescription.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
import React from 'react'
import Box from '@mui/material/Box'
import Typography from '@mui/material/Typography'
import useTheme from '@mui/styles/useTheme'


/**
* A miniature view of the App to show as a guide in the About dialog.
*
* @return {React.ReactComponent}
*/
export default function AboutDescription({setIsDialogDisplayed}) {
const theme = useTheme()


/**
* Close About dialog when a link is clicked
*/
function onClickLink() {
setIsDialogDisplayed(false)
}
return (
<Box
sx={{
width: '260px',
height: '160px',
fontSize: '.9em',
fontWeight: 'bold',
borderRadius: '3px',
margin: '2em 0',
padding: '.3em 1em .5em .5em',
color: theme.palette.primary.contrastText,
border: `1px solid ${theme.palette.primary.main}`,
textAlign: 'left',
}}
>
<Box
sx={{
padding: '10px 10px',
}}
>
<Typography variant={'h5'}>
Cross-functional online collaboration unlocks team flow,
productivity and creativity.
Open workspaces, open standards and open source code is the most powerful way to work.
Cooperation is the unfair advantage.
</Typography>
<Box
sx={{
marginRight: '-6px',
display: 'flex',
flexDirection: 'row',
justifyContent: 'flex-end',
position: 'relative',
top: '1.4em',
}}
>
<a
href='https://bldrs.ai/share/v/p/index.ifc#c:-113.444,0.464,81.43,-23.595,24.522,10.88::i:1493510953'
onClick={onClickLink}
>
<Typography sx={{textDecoration: 'underline', marginLeft: '10px'}}>Guide</Typography>
</a>
<a
// eslint-disable-next-line max-len
href='https://bldrs.ai/share/v/gh/OlegMoshkovich/Logo/main/IFC_STUDY.ifc#c:40.821,-10.247,39.647,5.918,-13.326,-13.866::i:1605443723'
onClick={onClickLink}
>
<Typography sx={{textDecoration: 'underline', marginLeft: '10px'}}>Team</Typography>
</a>
</Box>
</Box>
</Box>
)
}

2 changes: 1 addition & 1 deletion src/Components/BranchesControl.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export default function Branches() {
}}
onChange={(e) => handleSelect(e)}
variant='outlined'
label='Git Branches / Project Versions'
label='Project Iterations'
value={selected}
select
role="button"
Expand Down
38 changes: 26 additions & 12 deletions src/Components/Buttons.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Button from '@mui/material/Button'
import ToggleButton from '@mui/material/ToggleButton'
import Tooltip from '@mui/material/Tooltip'
import {assertDefined} from '../utils/assert'
import {useIsMobile} from './Hooks'
import useStore from '../store/useStore'
import CloseIcon from '../assets/icons/Close.svg'


Expand All @@ -25,21 +25,34 @@ export function TooltipIconButton({
selected = false,
size = 'medium',
dataTestId = '',
aboutInfo = true,
}) {
assertDefined(title, onClick, icon)
const isMobile = useIsMobile()
const [openLocal, setOpenLocal] = React.useState(false)
const isTooltipsOpen = useStore((state) => state.isTooltipsOpen)
const open = aboutInfo ? isTooltipsOpen : false
const handleClose = () => {
setOpenLocal(false)
}
const handleOpen = () => {
setOpenLocal(true)
}
return (
<>
{isMobile ?
<ToggleButton selected={selected} onClick={onClick} value={''} size={size}>
{icon}
</ToggleButton> :
<Tooltip title={title} describeChild placement={placement} data-testid={dataTestId}>
<ToggleButton selected={selected} onClick={onClick} value={''} size={size}>
{icon}
</ToggleButton>
</Tooltip>
}
<Tooltip
open={openLocal || open}
onClose={handleClose}
onOpen={handleOpen}
title={title}
describeChild
placement={placement}
data-testid={dataTestId}
PopperProps={{style: {zIndex: 0}}}
>
<ToggleButton selected={selected} onClick={onClick} value={''} size={size}>
{icon}
</ToggleButton>
</Tooltip>
</>
)
}
Expand Down Expand Up @@ -89,6 +102,7 @@ export function CloseButton({onClick}) {
placement='bottom'
icon={<CloseIcon style={{width: '15px', height: '15px'}}/>}
size='medium'
aboutInfo={false}
/>
)
}
Expand Down
19 changes: 18 additions & 1 deletion src/Components/Buttons.test.jsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React from 'react'
import {fireEvent, render} from '@testing-library/react'
import {fireEvent, render, renderHook, act} from '@testing-library/react'
import {MockComponent} from '../__mocks__/MockComponent'
import {TooltipIconButton} from './Buttons'
import useStore from '../store/useStore'
import QuestionIcon from '../assets/icons/Question.svg'


Expand All @@ -25,4 +26,20 @@ describe('<TooltipIconButton />', () => {
const tooltip = await rendered.findByRole('tooltip')
expect(tooltip).toBeInTheDocument()
})
test('show tooltip when the help is activated', async () => {
const {result} = renderHook(() => useStore((state) => state))
await act(() => {
result.current.toggleIsTooltipsOpen()
})
const {getByText} = render(
<MockComponent>
<TooltipIconButton
title={'TestTooltip'}
// eslint-disable-next-line no-empty-function
onClick={() => {}}
icon={<QuestionIcon/>}
/>
</MockComponent>)
expect(await getByText('TestTooltip')).toBeVisible()
})
})
1 change: 1 addition & 0 deletions src/Components/Dialog.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export default function Dialog({
onClose={close}
sx={{
textAlign: 'center',
zIndex: 1000,
}}
PaperProps={{variant: 'control'}}
>
Expand Down
1 change: 1 addition & 0 deletions src/Components/Logo.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export default function Logo({onClick}) {
placement="right"
icon={<LogoIcon/>}
onClick={onClick}
aboutInfo={false}
/>
</Box>
)
Expand Down
1 change: 1 addition & 0 deletions src/Components/Notes/NoteCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ const CardFooter = ({
placement='bottom'
onClick={onClickCamera}
icon={<CameraIcon/>}
aboutInfo={false}
/>}
{selected &&
<TooltipIconButton
Expand Down
2 changes: 1 addition & 1 deletion src/Components/Notes/Notes.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default function Notes() {
const fetchedNotes = []
const issuesData = await getIssues(repository, accessToken)
let issueIndex = 0
issuesData.data.slice(0).map((issue, index) => {
issuesData.data.slice(0).reverse().map((issue, index) => {
if (issue.body === null) {
debug().warn(`issue ${index} has no body: `, issue)
return null
Expand Down
4 changes: 2 additions & 2 deletions src/Components/OpenModelControl.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ export default function OpenModelControl({fileOpen}) {
title={'Open IFC'}
onClick={() => setIsDialogDisplayed(true)}
icon={<OpenIcon/>}
placement={'top'}
placement={'right'}
selected={isDialogDisplayed}
dataTestId='open-ifc'
dataTestId='open-ifc'ß
/>
</Paper>
{isDialogDisplayed &&
Expand Down
27 changes: 25 additions & 2 deletions src/Components/OperationsGroup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import useTheme from '@mui/styles/useTheme'
import useStore from '../store/useStore'
import {assertDefined} from '../utils/assert'
import {hexToRgba} from '../utils/color'
import {useIsMobile} from './Hooks'
import AboutControl from './About/AboutControl'
import CameraControl from './CameraControl'
import CutPlaneMenu from './CutPlaneMenu'
Expand All @@ -16,6 +17,7 @@ import ListIcon from '../assets/icons/List.svg'
import MoonIcon from '../assets/icons/Moon.svg'
import NotesIcon from '../assets/icons/Notes.svg'
import SunIcon from '../assets/icons/Sun.svg'
import QuestionIcon from '../assets/icons/Question.svg'


/**
Expand All @@ -38,6 +40,13 @@ export default function OperationsGroup({deselectItems}) {
const isCollaborationGroupVisible = useStore((state) => state.isCollaborationGroupVisible)
const isModelInteractionGroupVisible = useStore((state) => state.isModelInteractionGroupVisible)
const isSettingsVisible = useStore((state) => state.isSettingsVisible)
const toggleIsTooltipsOpen = useStore((state) => state.toggleIsTooltipsOpen)
const isTooltipsOpen = useStore((state) => state.isTooltipsOpen)
const turnOffIsTooltipsOpen = useStore((state) => state.turnOffIsTooltipsOpen)
const isMobile = useIsMobile()
const turnOffTooltips = () => {
return isMobile ? turnOffIsTooltipsOpen() : null
}

const isSelected = () => {
const ifSelected = (
Expand Down Expand Up @@ -104,11 +113,18 @@ export default function OperationsGroup({deselectItems}) {
title='Notes'
icon={<NotesIcon/>}
selected={isNotesOn}
onClick={() => toggle('Notes')}
onClick={() => {
turnOffTooltips()
toggle('Notes')
}
}
/>
<TooltipIconButton
title='Properties'
onClick={() => toggle('Properties')}
onClick={() => {
turnOffTooltips()
toggle('Properties')
}}
selected={isPropertiesOn}
icon={<ListIcon/>}
/>
Expand All @@ -120,6 +136,7 @@ export default function OperationsGroup({deselectItems}) {
selected={isSelected()}
icon={<ClearIcon/>}
/>

</ButtonGroup>
}

Expand All @@ -130,6 +147,12 @@ export default function OperationsGroup({deselectItems}) {
onClick={() => theme.toggleColorMode()}
icon={theme.palette.mode === 'light' ? <MoonIcon/> : <SunIcon/>}
/>
<TooltipIconButton
title='Help'
onClick={() => toggleIsTooltipsOpen()}
selected={isTooltipsOpen}
icon={<QuestionIcon/>}
/>
<AboutControl/>
</ButtonGroup>
}
Expand Down

0 comments on commit c421572

Please sign in to comment.