Skip to content
This repository was archived by the owner on Dec 17, 2024. It is now read-only.

Commit f138532

Browse files
committed
fixes
1 parent 96a7ebe commit f138532

File tree

6 files changed

+38
-29
lines changed

6 files changed

+38
-29
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "vim-webgl-component",
3-
"version": "0.3.5",
3+
"version": "0.3.7",
44
"description": "A demonstration app built on top of the vim-webgl-viewer",
55
"files": [
66
"dist"

src/bim/bimPanel.tsx

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,13 @@ import { Grouping, toTreeData } from './bimTreeData'
1313
import { ViewerState } from '../viewerState'
1414
import { AugmentedElement } from '../helpers/element'
1515
import { ComponentSettings, isFalse } from '../settings/settings'
16-
import { whenAllTrue, whenTrue } from '../helpers/utils'
16+
import { whenAllTrue, whenSomeTrue, whenTrue } from '../helpers/utils'
1717
import { BimInfoPanel } from './bimInfoPanel'
1818
import { BimInfoPanelRef } from './bimInfoData'
1919

20+
// Not sure why I need this,
21+
// when I inline this method in component.tsx it causes an error.
22+
// The error appears only in JSFiddle when the module is directly imported in a script tag.
2023
export function OptionalBimPanel (props: {
2124
viewer: VIM.Viewer
2225
camera: ComponentCamera
@@ -27,13 +30,10 @@ export function OptionalBimPanel (props: {
2730
treeRef: React.MutableRefObject<TreeActionRef>
2831
bimInfoRef: BimInfoPanelRef
2932
}) {
30-
if (
31-
(isFalse(props.settings.ui.bimTreePanel) &&
32-
isFalse(props.settings.ui.bimInfoPanel))
33-
) {
34-
return null
35-
}
36-
return React.createElement(BimPanel, props)
33+
return whenSomeTrue([
34+
props.settings.ui.bimTreePanel,
35+
props.settings.ui.bimInfoPanel],
36+
React.createElement(BimPanel, props))
3737
}
3838

3939
/**
@@ -105,13 +105,15 @@ export function BimPanel (props: {
105105

106106
const last =
107107
props.viewerState.selection[props.viewerState.selection.length - 1]
108-
const full = isFalse(props.settings.ui.bimInfoPanel)
108+
const fullTree = isFalse(props.settings.ui.bimInfoPanel)
109+
const fullInfo = isFalse(props.settings.ui.bimTreePanel)
110+
109111
return (
110-
<div className={`vim-bim-panel vc-inset-0 vc-absolute vc-h-full vc-w-full ${full ? 'full-tree' : ''} ${props.visible ? '' : 'vc-hidden'}`}>
112+
<div className={`vim-bim-panel vc-inset-0 vc-absolute vc-h-full vc-w-full ${fullTree ? 'full-tree' : ''} ${props.visible ? '' : 'vc-hidden'}`}>
111113
{isFalse(props.settings.ui.bimTreePanel)
112114
? null
113115
: (
114-
<div className={`vim-bim-upper vc-flex vc-flex-col vc-absolute vc-w-full ${full ? 'vc-h-full' : 'vc-h-[49%]'} ${props.viewerState.elements.length > 0 ? '' : 'vc-hidden'}`}>
116+
<div className={`vim-bim-upper vc-flex vc-flex-col vc-absolute vc-w-full ${fullTree ? 'vc-h-full' : 'vc-h-[49%]'} ${props.viewerState.elements.length > 0 ? '' : 'vc-hidden'}`}>
115117
<h2
116118
className="vim-bim-upper-title vc-title vc-text-xs vc-font-bold vc-uppercase">
117119
Project Inspector
@@ -141,17 +143,16 @@ export function BimPanel (props: {
141143
],
142144
divider())
143145
}
144-
145146
{whenTrue(props.settings.ui.bimInfoPanel,
146-
<div className='vim-bim-lower-container vc-absolute vc-top-[50%] vc-bottom-0 vc-bottom vc-left-0 vc-right-0'>
147-
<BimInfoPanel
148-
object={last}
149-
vim={props.viewerState.vim}
150-
elements={filteredElements}
151-
full={isFalse(props.settings.ui.bimTreePanel)}
152-
bimInfoRef={props.bimInfoRef}
153-
/>
154-
</div>)}
147+
<div className={`vim-bim-lower-container vc-absolute ${fullInfo ? 'vc-top-0' : 'vc-top-[50%]'} vc-bottom-0 vc-bottom vc-left-0 vc-right-0`}>
148+
<BimInfoPanel
149+
object={last}
150+
vim={props.viewerState.vim}
151+
elements={filteredElements}
152+
full={isFalse(props.settings.ui.bimTreePanel)}
153+
bimInfoRef={props.bimInfoRef}
154+
/>
155+
</div>)}
155156
</div>
156157
)
157158
}

src/bim/bimTree.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export function BimTree (props: {
8989

9090
// Scroll view so that element is visible, if needed.
9191
useEffect(() => {
92-
if (props.treeData && objects.length === 1) {
92+
if (props.treeData && objects.length === 1 && div.current) {
9393
scrollToSelection(div.current)
9494
const [first] = props.viewer.selection.objects
9595
focus.current = props.treeData.getNodeFromElement(first.element)
@@ -143,7 +143,7 @@ export function BimTree (props: {
143143
onBlur={() => (props.viewer.inputs.keyboard.arrowsEnabled = true)}
144144
>
145145
<ControlledTreeEnvironment
146-
renderDepthOffset={Math.min(div.current.clientWidth * 0.04, 10)}
146+
renderDepthOffset={div.current ? Math.min(div.current.clientWidth * 0.04, 10) : 10 }
147147
items={props.treeData.nodes}
148148

149149
getItemTitle={(item) => (item as VimTreeNode).title}

src/component.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ export function VimComponent (props: {
160160

161161
const sidePanel = () => (
162162
<>
163-
<OptionalBimPanel
163+
{<OptionalBimPanel
164164
viewer={props.viewer}
165165
camera={camera}
166166
viewerState={viewerState}
@@ -169,7 +169,7 @@ export function VimComponent (props: {
169169
treeRef={treeRef}
170170
settings={settings.value}
171171
bimInfoRef={bimInfoRef}
172-
/>
172+
/>}
173173
<MenuSettings
174174
visible={side.getContent() === 'settings'}
175175
viewer={props.viewer}

src/helpers/utils.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,13 @@ export function whenAllTrue (value: (UserBoolean| boolean)[], element: JSX.Eleme
1313
}
1414

1515
export function whenAllFalse (value: (UserBoolean| boolean)[], element: JSX.Element) {
16-
return value.every(isTrue) ? element : null
16+
return value.every(isFalse) ? element : null
17+
}
18+
19+
export function whenSomeTrue (value: (UserBoolean| boolean)[], element: JSX.Element) {
20+
return value.some(isTrue) ? element : null
21+
}
22+
23+
export function whenSomeFalse (value: (UserBoolean| boolean)[], element: JSX.Element) {
24+
return value.some(isFalse) ? element : null
1725
}

src/panels/icons.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ export type IconOptions = {
2020
}
2121

2222
// Common
23-
export function settings ({ height, width, fill }: IconOptions) {
23+
export function settings ({ height, width, fill, className }: IconOptions) {
2424
return (
25-
<svg height={height} width={width} viewBox="0 0 256 256">
25+
<svg className={className} height={height} width={width} viewBox="0 0 256 256">
2626
<path
2727
fill={fill}
2828
d="M110.325,241.773c-2.567,7.495-10.811,11.566-18.271,9.145l-7.218-2.346c-7.522-2.44-11.739-10.548-9.41-18.133l.849-2.764c1.939-6.314-.798-14.567-6.152-18.465l-1.461-1.066c-5.339-3.882-14.046-3.953-19.452-.162l-2.369,1.662c-6.48,4.553-15.542,3.001-20.158-3.341l-4.466-6.136c-4.652-6.397-3.246-15.472,3.037-20.195l2.314-1.741c5.28-3.965,7.913-12.249,5.864-18.552l-.557-1.722c-2.038-6.279-9.043-11.455-15.646-11.563l-2.894-.047c-7.913-.13-14.334-6.709-14.334-14.552v-7.593c0-7.909,6.476-14.425,14.334-14.552l2.894-.047c6.602-.107,13.6-5.264,15.646-11.566l.557-1.718c2.041-6.279-.584-14.587-5.864-18.555l-2.314-1.738c-6.33-4.758-7.649-13.852-3.037-20.195l4.466-6.14c4.656-6.393,13.73-7.854,20.158-3.341l2.369,1.662c5.406,3.795,14.093,3.736,19.452-.162l1.461-1.062c5.335-3.882,8.091-12.151,6.152-18.465l-.849-2.768c-2.326-7.57,1.951-15.708,9.41-18.129l7.218-2.346c7.522-2.444,15.7,1.639,18.271,9.142l.94,2.74c2.144,6.247,9.209,11.313,15.835,11.313h1.805c6.602,0,13.69-5.066,15.831-11.313l.94-2.74c2.571-7.491,10.816-11.563,18.275-9.141l7.218,2.346c7.522,2.44,11.739,10.544,9.41,18.129l-.849,2.768c-1.939,6.314,.798,14.567,6.152,18.465l1.461,1.062c5.339,3.886,14.046,3.957,19.448,.162l2.369-1.662c6.48-4.549,15.546-2.997,20.158,3.341l4.47,6.14c4.652,6.397,3.246,15.472-3.037,20.195l-2.314,1.738c-5.28,3.969-7.913,12.253-5.868,18.555l.561,1.718c2.038,6.282,9.043,11.459,15.646,11.566l2.891,.047c7.917,.126,14.334,6.709,14.334,14.552v7.593c0,7.905-6.476,14.425-14.334,14.552l-2.891,.047c-6.602,.107-13.6,5.26-15.646,11.563l-.561,1.722c-2.038,6.279,.588,14.587,5.868,18.552l2.314,1.741c6.33,4.758,7.649,13.852,3.037,20.195l-4.47,6.136c-4.652,6.397-13.726,7.858-20.158,3.341l-2.369-1.662c-5.402-3.791-14.09-3.736-19.448,.162l-1.461,1.066c-5.335,3.882-8.091,12.151-6.152,18.465l.849,2.764c2.326,7.574-1.951,15.712-9.41,18.133l-7.218,2.346c-7.522,2.44-15.7-1.639-18.275-9.145l-.94-2.736c-2.14-6.247-9.205-11.313-15.831-11.313h-1.805c-6.602,0-13.69,5.066-15.835,11.313l-.94,2.736Zm17.674-45.77c37.559,0,68.002-30.443,68.002-68.002s-30.443-67.998-68.002-67.998-67.998,30.443-67.998,67.998,30.443,68.002,67.998,68.002Z"

0 commit comments

Comments
 (0)