Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cb 4429 change divider behavior #2335

Merged
merged 19 commits into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion webapp/packages/core-app/src/AppScreen/Main.m.css
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.space {
composes: theme-typography--body2 theme-background-primary from global;
composes: theme-background-surface theme-text-on-surface from global;
display: flex;
flex-direction: row;
flex: 1;
Expand Down
7 changes: 1 addition & 6 deletions webapp/packages/core-app/src/AppScreen/Main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,7 @@ export const Main = observer(function Main() {
return (
<Loader className={s(styles, { loader: true })} suspense>
<main className={s(styles, { space: true })}>
<Split
{...splitMainState}
sticky={30}
mode={leftBarDisabled ? 'minimize' : splitMainState.mode}
disable={leftBarDisabled}
>
<Split {...splitMainState} sticky={30} mode={leftBarDisabled ? 'minimize' : splitMainState.mode} disable={leftBarDisabled}>
<Pane className={s(styles, { pane: true })} basis="250px" main>
<Loader suspense>
<SideBarPanel container={leftBarPanelService.tabsContainer} />
Expand Down
5 changes: 5 additions & 0 deletions webapp/packages/core-blocks/src/Split/Pane.m.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,8 @@
overflow: auto;
z-index: 0;
}

.hiddenContent {
Wroud marked this conversation as resolved.
Show resolved Hide resolved
opacity: 0;
pointer-events: none;
}
5 changes: 4 additions & 1 deletion webapp/packages/core-blocks/src/Split/Pane.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,12 @@ import { observer } from 'mobx-react-lite';
import { s } from '../s';
import { useS } from '../useS';
import style from './Pane.m.css';
import { useSplit } from './useSplit';

export const Pane = observer<PaneProps>(function Pane({ className, ...rest }) {
const styles = useS(style);
const split = useSplit();
const hiddenContent = rest.main && split.state.mode === 'minimize';

Wroud marked this conversation as resolved.
Show resolved Hide resolved
return <BasePane className={s(styles, { pane: true }, className)} {...rest} />;
return <BasePane className={s(styles, { pane: true, hiddenContent }, className)} {...rest} />;
});
17 changes: 14 additions & 3 deletions webapp/packages/core-blocks/src/Split/Split.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,24 @@ import { s } from '../s';
import { useS } from '../useS';
import style from './Split.m.css';

export type ISplitProps = SplitProps;
export type ISplitProps = SplitProps & {
disableAutoMargin?: boolean;
};

export const Split = observer<ISplitProps>(function Split({ className, split, ...rest }) {
const AUTO_MARGIN = 22;

export const Split = observer<ISplitProps>(function Split({ className, minSize, maxSize, split, disableAutoMargin = false, ...rest }) {
const styles = useS(style);

const vertical = split === 'vertical' || split === undefined;
const horizontal = split === 'horizontal';

return <BaseSplit className={s(styles, { split: true, vertical, horizontal }, className)} split={split} {...rest} />;
if (!disableAutoMargin) {
minSize = AUTO_MARGIN;
maxSize = -AUTO_MARGIN;
}

return (
<BaseSplit minSize={minSize} maxSize={maxSize} className={s(styles, { split: true, vertical, horizontal }, className)} split={split} {...rest} />
);
});
8 changes: 6 additions & 2 deletions webapp/packages/core-blocks/src/Split/SplitControls.m.css
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

.button {
composes: theme-button theme-button_unelevated theme-button_background theme-elevation-z3 from global;
opacity: 0;
opacity: 1;
transition-property: opacity, box-shadow !important;
transition: opacity 0.3s ease-in-out;
}
Expand All @@ -24,10 +24,14 @@
composes: theme-button_ripple from global;
}

.container:hover .button {
.container:hover .resizeButton {
opacity: 1;
}

.resizeButton {
opacity: 0;
}

.container[data-s-split='vertical'] {
flex-direction: column;
cursor: ew-resize;
Expand Down
9 changes: 7 additions & 2 deletions webapp/packages/core-blocks/src/Split/SplitControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { useSplit } from './useSplit';
export const SplitControls: React.FC = function SplitControls() {
const split = useSplit();
const styles = useS(SplitControlsStyles);
const isResizeMode = split.state.mode === 'resize';

const inverse = split.state.isMainSecond();

Expand Down Expand Up @@ -64,12 +65,16 @@ export const SplitControls: React.FC = function SplitControls() {
onDoubleClick={split.state.onDoubleClick}
>
{split.state.mode !== 'minimize' && (
<button className={s(styles, { button: true, primary: !inverse })} type="button" onClick={handlers.handleCollapse}>
<button
className={s(styles, { button: true, primary: !inverse, resizeButton: isResizeMode })}
type="button"
onClick={handlers.handleCollapse}
>
<div className={s(styles, { ripple: true })} />
</button>
)}
{split.state.mode !== 'maximize' && (
<button className={s(styles, { button: true, primary: inverse })} type="button" onClick={handlers.handleExpand}>
<button className={s(styles, { button: true, primary: inverse, resizeButton: isResizeMode })} type="button" onClick={handlers.handleExpand}>
<div className={s(styles, { ripple: true })} />
</button>
)}
Expand Down
Loading