Skip to content

Commit

Permalink
feat: 🐛 hide sidebar when sidesheet is open (#497)
Browse files Browse the repository at this point in the history
* feat: 🐛 hide sidebar when sidesheet is open

* fix: 🐛 localstorage edit

* fix: 🧪 updated test filter
  • Loading branch information
espenkalle authored Oct 12, 2023
1 parent 30a69bf commit 660fec8
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 22 deletions.
2 changes: 1 addition & 1 deletion packages/garden/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@equinor/workspace-garden",
"version": "5.1.4",
"version": "5.1.5",
"type": "module",
"sideEffects": false,
"license": "MIT",
Expand Down
26 changes: 16 additions & 10 deletions packages/garden/src/lib/components/Garden.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,22 @@ export function Garden<TData extends Record<PropertyKey, unknown>, TContext = un
>
<VirtualContainer context={context as TContext} dataSource={dataSource} />
</GardenConfigProvider>
<ViewSettings
dataSource={dataSource}
dateVariant={dateVariant}
groupingKeys={groupingKeys}
timeInterval={timeInterval}
context={context}
onChangeDateVariant={onChangeDateVariant}
onChangeTimeInterval={onChangetimeInterval}
setGroupingKeys={setGroupingKeys}
/>

{
// Hides ViewSettings sidebar when sidesheet is open
selected ? null : (
<ViewSettings
dataSource={dataSource}
dateVariant={dateVariant}
groupingKeys={groupingKeys}
timeInterval={timeInterval}
context={context}
onChangeDateVariant={onChangeDateVariant}
onChangeTimeInterval={onChangetimeInterval}
setGroupingKeys={setGroupingKeys}
/>
)
}
</GardenContextProvider>
</Suspense>
</ErrorBoundary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { GardenDataSource } from '../Garden';
import { GroupingSelector } from '../GroupingSelector/GroupingSelector';
import { StyledViewSettings } from './viewSettings.styles';

const LOCAL_STORAGE_KEY = 'toggleState';
const LOCAL_STORAGE_KEY = 'WorkspaceSidebarToggleState';

interface ViewSettingsProps<TData extends Record<PropertyKey, unknown>, TContext = undefined> {
dataSource: GardenDataSource<TContext>;
Expand All @@ -32,7 +32,7 @@ export function ViewSettings<TData extends Record<PropertyKey, unknown>, TContex
}: ViewSettingsProps<TData, TContext>): JSX.Element | null {
const [toggle, setToggle] = useState<boolean>(() => {
const savedState = localStorage.getItem(LOCAL_STORAGE_KEY);
return savedState !== null ? JSON.parse(savedState) : true;
return savedState !== null ? !!JSON.parse(savedState) : true;
});

const onChangeToggle = (state: boolean) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import styled from 'styled-components';
import { tokens } from '@equinor/eds-tokens';

type StyledViewSettingsProps = {
expanded: boolean;
Expand All @@ -11,4 +12,5 @@ export const StyledViewSettings = styled.div<StyledViewSettingsProps>`
padding: 10px;
transition: width 0.1s ease;
overflow: hidden;
background-color: ${tokens.colors.ui.background__light.rgba};
`;
16 changes: 8 additions & 8 deletions packages/workspace-fusion-integration-test/tests/Filter.test.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { Workspace } from '@equinor/workspace-fusion';
import { act, render } from '@testing-library/react';
import { act, render, waitFor } from '@testing-library/react';
import { workspaceOptions } from '../config/workspaceOptions';
import { fakeTimeout } from '../utils/fakeTimeout';
import { getMockGardenConfig } from '../config/mockGardenConfig';
Expand Down Expand Up @@ -38,13 +38,13 @@ describe('Testing filter integration', () => {
);
});

//Have to make an artificial timeout to ensure suspense has settled.
await fakeTimeout();
const el = getSearchInputEl();
//ensure search element is present
expect(el).toBeTruthy();
triggerSearchInput('abc');
await waitFor(() => {
const el = getSearchInputEl();
//ensure search element is present
expect(el).toBeTruthy();
triggerSearchInput('abc');

expect(mockFilterMeta).toBeCalledTimes(2);
expect(mockFilterMeta).toBeCalledTimes(2);
});
});
});
2 changes: 1 addition & 1 deletion packages/workspace-fusion/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@equinor/workspace-fusion",
"version": "5.3.6",
"version": "5.3.7",
"type": "module",
"sideEffects": false,
"license": "MIT",
Expand Down

0 comments on commit 660fec8

Please sign in to comment.