Skip to content

Commit

Permalink
Merge branch 'main' into zhixzhan/imports-in-projecttree
Browse files Browse the repository at this point in the history
  • Loading branch information
zhixzhan authored Jan 8, 2021
2 parents 04fb9d6 + bb3a8ef commit 4bbfb1b
Show file tree
Hide file tree
Showing 22 changed files with 8,883 additions and 9,177 deletions.
3 changes: 2 additions & 1 deletion Composer/packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,13 @@
"@bfc/ui-plugin-select-skill-dialog": "*",
"@botframework-composer/types": "*",
"@emotion/core": "^10.0.27",
"@geoffcox/react-splitter": "^2.0.3",
"@reach/router": "^1.2.1",
"@uifabric/fluent-theme": "^7.1.107",
"@uifabric/icons": "^7.3.59",
"@uifabric/react-hooks": "^7.4.12",
"@uifabric/styling": "^7.13.7",
"axios": "^0.21.0",
"axios": "^0.21.1",
"babel-plugin-extract-format-message": "^6.2.3",
"format-message": "^6.2.3",
"format-message-generate-id": "^6.2.3",
Expand Down
23 changes: 19 additions & 4 deletions Composer/packages/client/src/components/Page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import { jsx, css, SerializedStyles } from '@emotion/core';
import React from 'react';
import { FontWeights, FontSizes } from 'office-ui-fabric-react/lib/Styling';
import { Toolbar, IToolbarItem } from '@bfc/ui-shared';
import { useRecoilValue } from 'recoil';
import { Split, SplitMeasuredSizes } from '@geoffcox/react-splitter';

import { LeftRightSplit } from '../components/Split/LeftRightSplit';
import { navigateTo, buildURL } from '../utils/navigation';
import { PageMode } from '../recoilModel';
import { dispatcherState, PageMode } from '../recoilModel';

import { NavTree, INavTreeItem } from './NavTree';
import { ProjectTree } from './ProjectTree/ProjectTree';
import { renderThinSplitter } from './Split/ThinSplitter';

// -------------------- Styles -------------------- //

Expand Down Expand Up @@ -124,6 +126,12 @@ const Page: React.FC<IPageProps> = (props) => {
fileId,
} = props;

const { setPageElementState } = useRecoilValue(dispatcherState);

const onMeasuredSizesChanged = (sizes: SplitMeasuredSizes) => {
setPageElementState(pageMode, { leftSplitWidth: sizes.primary });
};

return (
<div css={root} data-testid={props['data-testid']}>
<div css={pageWrapper}>
Expand All @@ -133,7 +141,14 @@ const Page: React.FC<IPageProps> = (props) => {
{onRenderHeaderContent && <div css={headerContent}>{onRenderHeaderContent()}</div>}
</div>
<div css={main} role="main">
<LeftRightSplit initialLeftGridWidth="20%" minLeftPixels={200} minRightPixels={800} pageMode={pageMode}>
<Split
resetOnDoubleClick
initialPrimarySize="20%"
minPrimarySize="200px"
minSecondarySize="800px"
renderSplitter={renderThinSplitter}
onMeasuredSizesChanged={onMeasuredSizesChanged}
>
{useNewTree ? (
<ProjectTree
defaultSelected={{
Expand Down Expand Up @@ -170,7 +185,7 @@ const Page: React.FC<IPageProps> = (props) => {
>
{children}
</div>
</LeftRightSplit>
</Split>
</div>
</div>
</div>
Expand Down
257 changes: 0 additions & 257 deletions Composer/packages/client/src/components/Split/LeftRightSplit.tsx

This file was deleted.

55 changes: 55 additions & 0 deletions Composer/packages/client/src/components/Split/ThinSplitter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

import * as React from 'react';
import styled from '@emotion/styled';
import { RenderSplitterProps } from '@geoffcox/react-splitter';

const splitVisualClassName = 'thin-split-visual';

const HitArea = styled.div(({ horizontal, dragging }: { horizontal: boolean; dragging: boolean }) => ({
boxSizing: 'border-box',
outline: 'none',
overflow: 'hidden',
height: '100%',
width: '100%',
cursor: horizontal ? 'row-resize' : 'col-resize',
background: 'transparent',
[`&:hover .${splitVisualClassName}`]: {
background: dragging ? 'black' : 'gray',
},
userSelect: 'none',
}));

const getCenteredMargin = (size: number) => `${Math.max(0, Math.floor(size / 2) - 1)}px`;

const Splitter = styled.div(
({ horizontal, splitterSize, dragging }: { horizontal: boolean; splitterSize: number; dragging: boolean }) => ({
boxSizing: 'border-box',
outline: 'none',
overflow: 'hidden',
height: horizontal ? '1px' : '100%',
width: horizontal ? '100%' : '1px',
marginLeft: horizontal ? '0' : getCenteredMargin(splitterSize),
marginTop: horizontal ? getCenteredMargin(splitterSize) : '0',
background: dragging ? 'black' : 'silver',
})
);

/**
* The default splitter which provides a thin line within a possibly larger mouse hit area.
* @param props
*/
export const ThinSplitter = (props: RenderSplitterProps) => {
const { horizontal, pixelSize, dragging } = props;

return (
<HitArea dragging={dragging} horizontal={horizontal}>
<Splitter className={splitVisualClassName} dragging={dragging} horizontal={horizontal} splitterSize={pixelSize} />
</HitArea>
);
};

export const renderThinSplitter = (props: RenderSplitterProps) => {
return <ThinSplitter {...props} />;
};
Loading

0 comments on commit 4bbfb1b

Please sign in to comment.