File size: 1,224 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import React, { useState } from 'react';
import { storiesOf } from '@storybook/react';

import StoryFixture from './StoryFixture';
import Fade from './transitions/CSSFade';

function ToggleFixture({ defaultIn, description, children }) {
  const [show, setShow] = useState(defaultIn || false);

  return (
    <StoryFixture description={description}>
      <div style={{ marginBottom: 10 }}>
        <button
          onClick={() => {
            setShow(!show);
          }}
        >
          Toggle
        </button>
      </div>
      {React.cloneElement(children, { in: show })}
    </StoryFixture>
  );
}

storiesOf('CSSTransition', module)
  .add('Fade', () => (
    <ToggleFixture>
      <Fade>asaghasg asgasg</Fade>
    </ToggleFixture>
  ))
  .add('Fade with appear', () => (
    <ToggleFixture defaultIn>
      <Fade appear>asaghasg asgasg</Fade>
    </ToggleFixture>
  ))
  .add('Fade with mountOnEnter', () => {
    return (
      <ToggleFixture>
        <Fade mountOnEnter>Fade with mountOnEnter</Fade>
      </ToggleFixture>
    );
  })
  .add('Fade with unmountOnExit', () => {
    return (
      <ToggleFixture>
        <Fade unmountOnExit>Fade with unmountOnExit</Fade>
      </ToggleFixture>
    );
  });