-
-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add ifc slice to the store add ifc slice state properties to cadview add select IFC element test add viewer test add viewer test new build
- Loading branch information
1 parent
0671471
commit 7d227e5
Showing
8 changed files
with
336 additions
and
254 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import create from 'zustand' | ||
|
||
|
||
const useStore = create((set) => ({ | ||
const createUISlice = (set, get) => ({ | ||
isDrawerOpen: false, | ||
isCommentsOn: false, | ||
snackMessage: null, | ||
isPropertiesOn: false, | ||
setSnackMessage: (message) => set(() => ({snackMessage: message})), | ||
openDrawer: () => set(() => ({isDrawerOpen: true})), | ||
closeDrawer: () => set(() => ({isDrawerOpen: false})), | ||
})) | ||
export default useStore | ||
toggleIsPropertiesOn: () => set((state) => ({isPropertiesOn: !state.isPropertiesOn})), | ||
}) | ||
|
||
export default createUISlice |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
const craeateIFCSlice = (set, get) => ({ | ||
viewerStore: {}, | ||
modelStore: null, | ||
selectedElement: {}, | ||
setViewerStore: (viewer) => set(() => ({viewerStore: viewer})), | ||
setModelStore: (model) => set(() => ({modelStore: model})), | ||
setSelectedElement: (element) => set(() => ({selectedElement: element})), | ||
}) | ||
|
||
export default craeateIFCSlice |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import create from 'zustand' | ||
import createUISlice from './UISlice' | ||
import craeateIFCSlice from './IFCSlice' | ||
|
||
|
||
const useStore = create((set, get) => ({ | ||
...createUISlice(set, get), | ||
...craeateIFCSlice(set, get), | ||
})) | ||
|
||
export default useStore | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import {act, renderHook} from '@testing-library/react-hooks' | ||
import useStore from './useStore' | ||
|
||
|
||
describe('UI slice', () => { | ||
it('Set snack message', () => { | ||
const {result} = renderHook(() => useStore((state) => state)) | ||
act(() => { | ||
result.current.setSnackMessage(['loading']) | ||
}) | ||
expect(result.current.snackMessage).toEqual(['loading']) | ||
}) | ||
}) | ||
|
||
describe('UI slice', () => { | ||
it('Set Drawer State', () => { | ||
const {result} = renderHook(() => useStore((state) => state)) | ||
act(() => { | ||
result.current.openDrawer() | ||
}) | ||
expect(result.current.isDrawerOpen).toEqual(true) | ||
}) | ||
}) | ||
|
||
describe('IFC slice', () => { | ||
it('select an IFC element', () => { | ||
const {result} = renderHook(() => useStore((state) => state)) | ||
act(() => { | ||
result.current.setSelectedElement( | ||
{Name: { | ||
type: 1, | ||
value: 'Together', | ||
}, | ||
}) | ||
}) | ||
expect(result.current.selectedElement).toEqual({Name: { | ||
type: 1, | ||
value: 'Together', | ||
}, | ||
}) | ||
}) | ||
}) | ||
|
||
describe('IFC slice', () => { | ||
it('set IFC model', () => { | ||
const {result} = renderHook(() => useStore((state) => state)) | ||
act(() => { | ||
result.current.setModelStore({castShadow: false}) | ||
}) | ||
expect(result.current.modelStore).toEqual( | ||
{castShadow: false}, | ||
) | ||
}) | ||
}) | ||
|
||
describe('IFC slice', () => { | ||
it('set IFC viewer', () => { | ||
const {result} = renderHook(() => useStore((state) => state)) | ||
act(() => { | ||
result.current.setViewerStore({GLTF: {GLTFModels: {}}}) | ||
}) | ||
expect(result.current.viewerStore).toEqual( | ||
{GLTF: {GLTFModels: {}}}, | ||
) | ||
}) | ||
}) |
This file was deleted.
Oops, something went wrong.