Skip to content

Commit

Permalink
feat(react-components): remove all URL-mutations (#4739)
Browse files Browse the repository at this point in the history
* feat(react-components): remove all URL-mutations

* chore: remove additional URL functionality from storybook example

* chore: remove yet another fit-to-url function

* Revert "chore: remove yet another fit-to-url function"

This reverts commit 2ae7014.

* Revert "chore: remove additional URL functionality from storybook example"

This reverts commit 3c22d4e.

* chore: add back useGetCameraStateFromUrlParam to stories

* chore: lint fix

* chore: remove camera url control from Toolbar example

* chore: lint fix

* chore: update screenshot with missing button
  • Loading branch information
haakonflatval-cognite authored Sep 6, 2024
1 parent 5a55694 commit c054f6b
Show file tree
Hide file tree
Showing 11 changed files with 59 additions and 303 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { LayersButton } from './LayersButton';
import { SlicerButton } from './SlicerButton';
import { SettingsButton } from './SettingsButton';
import { withSuppressRevealEvents } from '../../higher-order-components/withSuppressRevealEvents';
import { MeasurementButton } from './MeasurementButton';
import { HelpButton } from './HelpButton';
import { ShareButton } from './ShareButton';
import { ResetCameraButton } from './ResetCameraButton';
Expand Down Expand Up @@ -51,8 +50,7 @@ const DefaultContentWrapper = (props: CustomToolbarContent): ReactElement => {
<RuleBasedOutputsButton />
<Divider weight="2px" length="75%" />

<SlicerButton storeStateInUrl={props.storeStateInUrl} />
<MeasurementButton />
<SlicerButton />

<Divider weight="2px" length="75%" />

Expand Down Expand Up @@ -105,7 +103,6 @@ export const RevealToolbar = withSuppressRevealEvents(
FitModelsButton: typeof FitModelsButton;
SlicerButton: typeof SlicerButton;
LayersButton: typeof LayersButton;
MeasurementButton: typeof MeasurementButton;
ShareButton: typeof ShareButton;
SettingsButton: typeof SettingsButton;
HelpButton: typeof HelpButton;
Expand All @@ -120,7 +117,6 @@ export const RevealToolbar = withSuppressRevealEvents(
RevealToolbar.FitModelsButton = FitModelsButton;
RevealToolbar.SlicerButton = SlicerButton;
RevealToolbar.LayersButton = LayersButton;
RevealToolbar.MeasurementButton = MeasurementButton;
RevealToolbar.ShareButton = ShareButton;
RevealToolbar.SettingsButton = SettingsButton;
RevealToolbar.HelpButton = HelpButton;
Expand Down
20 changes: 2 additions & 18 deletions react-components/src/components/RevealToolbar/SlicerButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { useReveal } from '../RevealCanvas/ViewerContext';
import { Button, Dropdown, Menu, RangeSlider, Tooltip as CogsTooltip } from '@cognite/cogs.js';

import styled from 'styled-components';
import { useSlicerUrlParams } from './hooks/useUrlStateParam';
import { useTranslation } from '../i18n/I18n';
import { use3dModels } from '../../hooks/use3dModels';

Expand All @@ -21,18 +20,11 @@ type SliceState = {
bottomRatio: number;
};

type SlicerButtonProps = {
storeStateInUrl?: boolean;
};

export const SlicerButton = ({ storeStateInUrl = true }: SlicerButtonProps): ReactElement => {
export const SlicerButton = (): ReactElement => {
const viewer = useReveal();
const { t } = useTranslation();
const models = use3dModels();
const [slicerUrlState, setSlicerUrlState] = useSlicerUrlParams();
const { bottom: initialBottomRatio, top: initialTopRatio } = storeStateInUrl
? slicerUrlState
: { bottom: 0, top: 1 };
const { bottom: initialBottomRatio, top: initialTopRatio } = { bottom: 0, top: 1 };
const [sliceActive, setSliceActive] = useState<boolean>(false);

const [sliceState, setSliceState] = useState<SliceState>({
Expand All @@ -58,10 +50,6 @@ export const SlicerButton = ({ storeStateInUrl = true }: SlicerButtonProps): Rea
if (maxHeight !== newMaxY || minHeight !== newMinY) {
// Set clipping plane only if top or bottom has changed & storeStateInUrl is enabled

if (storeStateInUrl && (bottomRatio !== 0 || topRatio !== 1)) {
setGlobalPlanes(bottomRatio, topRatio, newMaxY, newMinY);
}

setSliceState({
maxHeight: newMaxY,
minHeight: newMinY,
Expand All @@ -80,10 +68,6 @@ export const SlicerButton = ({ storeStateInUrl = true }: SlicerButtonProps): Rea
bottomRatio: newValues[0],
topRatio: newValues[1]
});

if (storeStateInUrl) {
setSlicerUrlState(newValues);
}
}

function setGlobalPlanes(
Expand Down

This file was deleted.

This file was deleted.

Loading

0 comments on commit c054f6b

Please sign in to comment.