Skip to content

Commit

Permalink
refactor: toolbar implementation changed
Browse files Browse the repository at this point in the history
  • Loading branch information
Lukeybooi committed Jul 6, 2023
1 parent 285863a commit 81f439a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import FormDesignerToolbar from './formDesignerToolbar';
import ComponentPropertiesPanel from './componentPropertiesPanel';
import ComponentPropertiesTitle from './componentPropertiesTitle';
import { useForm } from '../../providers/form';
import { MetadataProvider, useSidebarMenu } from '../../providers';
import { MetadataProvider, useSheshaApplication } from '../../providers';
import ConditionalWrap from '../conditionalWrapper';
import { useFormPersister } from '../../providers/formPersisterProvider';
import { useFormDesigner } from '../../providers/formDesigner';
Expand All @@ -15,14 +15,18 @@ import { FORM_STATUS_MAPPING } from '../../utils/configurationFramework/models';
import { getFormFullName } from '../../utils/form';
import HelpTextPopover from '../helpTextPopover';
import classNames from 'classnames';
import { getInitIsExpanded } from './util';

const { Title } = Typography;

export const FormDesignerRenderer: FC = ({}) => {
const [widgetsOpen, setWidgetOpen] = useState(true);
const [fieldPropertiesOpen, setFieldPropertiesOpen] = useState(true);
const { formProps } = useFormPersister();
const { isExpanded } = useSidebarMenu(true);

const { globalVariables: { isSideBarExpanded } = {} } = useSheshaApplication();

const isExpanded = typeof isSideBarExpanded == 'boolean' ? isSideBarExpanded : getInitIsExpanded();

const toggleWidgetSidebar = () => setWidgetOpen((widget) => !widget);

Expand Down
12 changes: 5 additions & 7 deletions shesha-reactjs/src/components/mainLayout/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import NodeOrFuncRenderer, { ReactNodeOrFunc } from '../nodeOrFuncRenderer';
import { IHtmlHeadProps } from '../htmlHead';
import LayoutHeading from '../layoutHeading';
import { withAuth } from '../../hocs';
import { useSidebarMenuDefaults, useSidebarMenu } from '../../providers/sidebarMenu';
import { useSidebarMenuDefaults } from '../../providers/sidebarMenu';
import ConfigurableSidebarMenu from '../configurableSidebarMenu';
import { useLocalStorage, useTheme } from '../..';
import { useLocalStorage, useSheshaApplication, useTheme } from '../..';
import { SIDEBAR_MENU_NAME } from '../../shesha-constants';
import { SIDEBAR_COLLAPSE } from './constant';
import './styles/styles.less';
Expand Down Expand Up @@ -81,7 +81,8 @@ const DefaultLayout: FC<PropsWithChildren<IMainLayoutProps>> = (props) => {
} = props;
const { theme: themeFromStorage } = useTheme();
const sidebarDefaults = useSidebarMenuDefaults();
const { collapse, expand } = useSidebarMenu(true);

const { setGlobalVariables } = useSheshaApplication();

const sideMenuTheme = themeFromStorage?.sidebar;

Expand All @@ -100,10 +101,7 @@ const DefaultLayout: FC<PropsWithChildren<IMainLayoutProps>> = (props) => {
}, [heading, title, heading, showHeading]);

const onCollapse = (value: boolean) => {
const execute = value ? collapse : expand;

execute();

setGlobalVariables({ isSideBarExpanded: !value });
setCollapsed(value);
};

Expand Down

0 comments on commit 81f439a

Please sign in to comment.