Skip to content

Commit

Permalink
docs: add new basic story Visible With Animation
Browse files Browse the repository at this point in the history
  • Loading branch information
percy507 committed Jan 29, 2023
1 parent f75e0bd commit dd2ab68
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 0 deletions.
12 changes: 12 additions & 0 deletions stories/basic.stories.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,15 @@
color: rgb(30, 30, 30);
overflow: visible;
}

/* Styles for VisibleWithAnimation demo */
.leftPane,
.rightPane {
transition: all 0.15s ease-in-out;
will-change: width;
}
.splitViewContainer:global(.split-view-sash-dragging) .leftPane,
.splitViewContainer:global(.split-view-sash-dragging) .rightPane {
/* disable animation while sash dragging */
transition: none;
}
36 changes: 36 additions & 0 deletions stories/basic.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,42 @@ export const Visible: Story<AllotmentProps> = (args) => {
};
Visible.args = {};

export const VisibleWithAnimation: Story<AllotmentProps> = (args) => {
const [visible, setVisible] = useState(true);

return (
<div>
<button
className={styles.button}
type="button"
onClick={() => {
setVisible((visible) => !visible);
}}
>
{visible ? "Hide" : "Show"}
</button>
<div className={styles.container}>
<Allotment
{...args}
className={styles.splitViewContainer}
snap
onVisibleChange={(_index, value) => {
setVisible(value);
}}
>
<Allotment.Pane visible={visible} className={styles.leftPane}>
<Content />
</Allotment.Pane>
<Allotment.Pane className={styles.rightPane}>
<Content />
</Allotment.Pane>
</Allotment>
</div>
</div>
);
};
VisibleWithAnimation.args = {};

export const OnReset: Story = (args) => {
const ref = useRef<AllotmentHandle>(null!);

Expand Down

0 comments on commit dd2ab68

Please sign in to comment.