summaryrefslogtreecommitdiffstats
path: root/comm/mail/components/storybook/stories/pane-splitter.stories.mjs
blob: 6cc0418e062594f55bb5b5c0642be5da62eb2d82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

import { html } from "lit";
import "mail/base/content/widgets/pane-splitter.js"; //eslint-disable-line import/no-unassigned-import

export default {
  title: "Widgets/Pane Splitter",
  argTypes: {
    resizeDirection: {
      options: ["", "vertical", "horizontal"],
      control: { type: "radio" },
    },
  },
};

const Template = ({ resizeDirection, collapseWidth, collapseHeight }) => html`
  <style>
    hr[is="pane-splitter"] {
      border: none;
      z-index: 1;
      margin: ${resizeDirection === "horizontal" ? "0 -3px" : "-3px 0"};
      opacity: .4;
      background-color: red;
    }

    .wrapper {
      display: inline-grid;
      grid-template-${
        resizeDirection === "horizontal" ? "columns" : "rows"
      }: minmax(auto, var(--splitter-${
  resizeDirection === "horizontal" ? "width" : "height"
})) 0 auto;
      width: 500px;
      height: 500px;
      margin: 1em;
      --splitter-width: 200px;
      --splitter-height: 200px;
    }
  </style>
  <div class="wrapper">
    <div id="resizeme" style="background: lightblue"></div>
    <hr is="pane-splitter"
      resize-direction="${resizeDirection}"
      resize-id="resizeme"
      collapse-width="${collapseWidth}"
      collapse-height="${collapseHeight}"
      id="splitter"
    ></hr>
    <div id="fill" style="background: lightslategrey"></div>
  </div>
`;

export const PaneSplitter = Template.bind({});
PaneSplitter.args = {
  resizeDirection: "",
  collapseWidth: 0,
  collapseHeight: 0,
};