Skip to content

Commit

Permalink
feat(react-components): axis gizmo component (#4287)
Browse files Browse the repository at this point in the history
* feat: Axis Gizmo component
  • Loading branch information
haakonflatval-cognite authored Mar 1, 2024
1 parent 98c37ea commit 940b6fa
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 10 deletions.
4 changes: 2 additions & 2 deletions react-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
},
"peerDependencies": {
"@cognite/cogs.js": ">=9",
"@cognite/reveal": "^4.10.3",
"@cognite/reveal": "^4.10.4",
"react": ">=18",
"react-dom": ">=18",
"styled-components": ">=5"
Expand All @@ -44,7 +44,7 @@
"@cognite/cdf-i18n-utils": "^0.7.5",
"@cognite/cdf-utilities": "^3.5.0",
"@cognite/cogs.js": "^9.17.0",
"@cognite/reveal": "^4.10.3",
"@cognite/reveal": "^4.10.4",
"@cognite/sdk": "^8.2.0",
"@playwright/test": "^1.39.0",
"@storybook/addon-essentials": "7.6.17",
Expand Down
28 changes: 28 additions & 0 deletions react-components/src/components/AxisGizmo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*!
* Copyright 2024 Cognite AS
*/

import { useEffect, type ReactElement } from 'react';

import { AxisGizmoOptions, AxisGizmoTool } from '@cognite/reveal/tools';
import { useReveal } from '..';

export { AxisGizmoOptions };

/**
* A React wrapper around the AxisGizmoTool from Reveal
*/
export const AxisGizmo = ({ options }: { options?: AxisGizmoOptions }): ReactElement => {
const viewer = useReveal();

useEffect(() => {
const axisGizmoTool = new AxisGizmoTool(options);
axisGizmoTool.connect(viewer);

return () => {
axisGizmoTool.dispose();
};
}, [viewer, options]);

return <></>;
};
4 changes: 3 additions & 1 deletion react-components/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,11 @@ export { Image360CollectionContainer } from './components/Image360CollectionCont
export { Image360HistoricalDetails } from './components/Image360HistoricalDetails/Image360HistoricalDetails';
export { Image360Details } from './components/Image360Details/Image360Details';
export { ViewerAnchor } from './components/ViewerAnchor/ViewerAnchor';
export { RevealKeepAlive } from './components/RevealKeepAlive/RevealKeepAlive';

export { RevealToolbar, type RevealToolbarProps } from './components/RevealToolbar/RevealToolbar';
export { RevealTopbar } from './components/RevealTopbar/RevealTopbar';
export { RevealKeepAlive } from './components/RevealKeepAlive/RevealKeepAlive';
export { AxisGizmo, AxisGizmoOptions } from './components/AxisGizmo';

// Hooks
export { useReveal } from './components/RevealCanvas/ViewerContext';
Expand Down
2 changes: 1 addition & 1 deletion react-components/stories/HighlightNode.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
type Image360AssetStylingGroup,
type AssetStylingGroup
} from '../src/components/Reveal3DResources/types';
import { type AnnotationsCogniteAnnotationTypesImagesAssetLink } from '@cognite/sdk/dist/src';
import { type AnnotationsCogniteAnnotationTypesImagesAssetLink } from '@cognite/sdk';

const meta = {
title: 'Example/HighlightNode',
Expand Down
12 changes: 6 additions & 6 deletions react-components/yarn.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 940b6fa

Please sign in to comment.