Skip to content

Commit

Permalink
squash commits
Browse files Browse the repository at this point in the history
  • Loading branch information
OlegMoshkovich committed Oct 12, 2023
1 parent bbcf9f8 commit 4ddb6a3
Show file tree
Hide file tree
Showing 18 changed files with 500 additions and 320 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bldrs",
"version": "1.0.0-r730",
"version": "1.0.0-r702",
"main": "src/index.jsx",
"license": "MIT",
"homepage": "https://github.com/bldrs-ai/Share",
Expand Down
55 changes: 17 additions & 38 deletions src/Components/ControlsGroup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,64 +3,43 @@ import ButtonGroup from '@mui/material/ButtonGroup'
import OpenModelControl from './OpenModelControl'
import useStore from '../store/useStore'
import {TooltipIconButton} from './Buttons'
import HistoryIcon from '@mui/icons-material/History'
import SearchOutlinedIcon from '@mui/icons-material/SearchOutlined'
import SearchIcon from '@mui/icons-material/Search'
import TreeIcon from '../assets/icons/Tree.svg'


/**
* OperationsGroup contains tools for sharing, notes, properties, cut
* plane, deselect, theme change and about.
* Controls gropup contains visibility toggle for serach, spatial navigation and search
*
* @property {Function} deselectItems deselects currently selected element
* @property {Function} fileOpen function that is passed to to the openControl for open localfiles
* @return {React.Component}
*/
export default function OperationsGroup({fileOpen}) {
const cutPlanes = useStore((state) => state.cutPlanes)
const levelInstance = useStore((state) => state.levelInstance)
const selectedElement = useStore((state) => state.selectedElement)

const isSelected = () => {
const ifSelected = (
selectedElement !== null ||
cutPlanes.length !== 0 ||
levelInstance !== null
)
return ifSelected
}
export default function ControlsGroup({fileOpen}) {
const toggleIsNavigationVisible = useStore((state) => state.toggleIsNavigationVisible)
const isNavigationVisible = useStore((state) => state.isNavigationVisible)
const toggleIsSearchVisible = useStore((state) => state.toggleIsSearchVisible)
const isSearchVisible = useStore((state) => state.isSearchVisible)

return (
<ButtonGroup orientation='horizontal' >
{/* <TooltipIconButton
title='Open Project'
icon={<CreateNewFolderIcon color='secondary'/>}
placement='bottom'
selected={true}
onClick={() => (isSelected)}
/> */}
<ButtonGroup
orientation='horizontal'
variant='contained'
>
<OpenModelControl fileOpen={fileOpen}/>
<TooltipIconButton
title='Search'
icon={<SearchOutlinedIcon/>}
icon={<SearchIcon className='icon-share' color='secondary'/>}
placement='bottom'
aboutInfo={false}
selected={true}
onClick={() => (isSelected)}
selected={isSearchVisible}
onClick={toggleIsSearchVisible}
/>
<TooltipIconButton
title='Navigation'
icon={<TreeIcon className='icon-share' color='secondary' style={{width: '17px', height: '17px'}}/>}
placement='bottom'
aboutInfo={false}
selected={true}
onClick={() => (isSelected)}
/>
<TooltipIconButton
title='Project History'
icon={<HistoryIcon className='icon-share' color='secondary'/>}
placement='bottom'
selected={true}
onClick={() => (isSelected)}
selected={isNavigationVisible}
onClick={toggleIsNavigationVisible}
/>
</ButtonGroup>
)
Expand Down
29 changes: 29 additions & 0 deletions src/Components/ControlsGroup.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react'
import {render, screen} from '@testing-library/react'
import ControlsGroup from './ControlsGroup'


jest.mock('./Buttons', () => ({
TooltipIconButton: (props) => <button>{props.title}</button>,
}))


describe('ControlsGroup', () => {
it('renders the search toggle', () => {
render(<ControlsGroup fileOpen={jest.fn()}/>)
const searchToggle = screen.getByText('Search')
expect(searchToggle).toBeInTheDocument()
})

it('renders the navigation toggle', () => {
render(<ControlsGroup fileOpen={jest.fn()}/>)
const navigationToggle = screen.getByText('Navigation')
expect(navigationToggle).toBeInTheDocument()
})

it('renders open model control button', () => {
render(<ControlsGroup fileOpen={jest.fn()}/>)
const navigationToggle = screen.getByText('Open IFC')
expect(navigationToggle).toBeInTheDocument()
})
})
119 changes: 94 additions & 25 deletions src/Components/InputAutocomplete.jsx
Original file line number Diff line number Diff line change
@@ -1,38 +1,107 @@
import React from 'react'
import Paper from '@mui/material/Paper'
import Autocomplete from '@mui/material/Autocomplete'
import InputAdornment from '@mui/material/InputAdornment'
import IconButton from '@mui/material/IconButton'
import TextField from '@mui/material/TextField'
import Stack from '@mui/material/Stack'
import {assertDefined} from '../utils/assert'
import HighlightOffIcon from '@mui/icons-material/HighlightOff'
import useTheme from '@mui/styles/useTheme'


/**
* Input with autocomplete feature.
* InputAutocomplete Component.
*
* @property {Array<object>} elements suggested elements used to autocomple input,the object is in a shape of {title:'suggestion'}
* @property {string} placeholder Input placeholder
* @property {string} size MUI size of the input component
* @param {string} inputText - The input text value.
* @param {Function} setInputText - Function to set the input text.
* @param {string} error - The error message.
* @param {Function} onClear - Function to be executed when the clear button is clicked.
* @param {Array<string>} options - Array of options for the autocomplete.
* @param {React.ReactNode} startAdornment - Start adornment for the input.
* @param {string} placeholder - Placeholder text for the input.
* @return {React.Component}
*/
export default function InputAutocomplete({elements, placeholder, size = 'small'}) {
assertDefined(elements, placeholder)
function InputAutocomplete({
inputText,
setInputText,
error = '', // Set default value
onClear,
options = [],
startAdornment = null,
placeholder = '',
}) {
const theme = useTheme()

return (
<Stack spacing={3} sx={{minWidth: '280px'}}>
<Paper elevation={1} variant='control'>
<Autocomplete
multiple
options={elements}
getOptionLabel={(option) => option.title}
filterSelectedOptions
size={size}
renderInput={(params) => {
return (
<TextField
{...params}
placeholder={placeholder}
size={size}
/>
)
}
}
fullWidth
freeSolo
options={options}
value={inputText}
onChange={(_, newValue) => setInputText(newValue || '')}
onInputChange={(_, newInputValue) => setInputText(newInputValue || '')}
inputValue={inputText}
PaperComponent={({children}) => (
<Paper
sx={{
'backgroundColor': theme.palette.scene.background,
'.MuiAutocomplete-option': {
backgroundColor: theme.palette.scene.background,
},
}}
>
{children}
</Paper>
)}
renderInput={(params) => (
<TextField
{...params}
size="small"
error={!!error.length}
placeholder={placeholder}
variant="outlined"
sx={{
'width': '100%',
'border': 'none',
'& fieldset': {
border: 'none',
},
'&:hover fieldset': {
border: 'none',
},
'&.Mui-focused fieldset': {
border: 'none',
},
'& .MuiOutlinedInput-root': {
border: 'none',
height: '46px',
},
}}
InputProps={{
...params.InputProps,
startAdornment: startAdornment,
endAdornment: inputText.length > 0 ? (
<InputAdornment position="end">
<IconButton
size="small"
onClick={onClear}
style={{padding: 0, opacity: 0.8}}
>
<HighlightOffIcon
className="icon-share"
sx={{opacity: 0.8}}
size="inherit"
color="secondary"
/>
</IconButton>
</InputAdornment>
) : null,
}}
/>
)}
/>
</Stack>
</Paper>
)
}

export default InputAutocomplete
Loading

0 comments on commit 4ddb6a3

Please sign in to comment.