-
Notifications
You must be signed in to change notification settings - Fork 41
/
Copy pathApp.tsx
executable file
·97 lines (89 loc) · 3.27 KB
/
App.tsx
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import { Box, Flex, FlexCenter, H1, H2, Paragraph, Spacer } from '@gilbarbara/components';
import { useUnmount } from '@gilbarbara/hooks';
import disableScroll from 'disable-scroll';
import Block from './components/Block';
import Content from './components/Content';
import GlobalStyles from './components/GlobalStyles';
import Badges from './examples/Badges';
import BeaconMode from './examples/BeaconMode';
import ControlledMode from './examples/ControlledMode';
import Modal from './examples/Modal';
import ProxyMode from './examples/ProxyMode';
import WithAutoOpen from './examples/WithAutoOpen';
import WithCustomStyles from './examples/WithCustomStyles';
import WithHoverAndNoDelay from './examples/WithHoverAndNoDelay';
import WithHoverCustomDelay from './examples/WithHoverCustomDelay';
import WithHoverDefault from './examples/WithHoverDefault';
import WithOverlay from './examples/WithOverlay';
import WithPosition from './examples/WithPosition';
import WithStyledComponents from './examples/WithStyledComponents';
import WithText from './examples/WithText';
import WithTitleAndFooter from './examples/WithTitleAndFooter';
const { NODE_ENV } = process.env;
function callback(action: any, data: any) {
// eslint-disable-next-line no-console
console.log(action, data);
if (data.placement === 'center') {
disableScroll[action === 'open' ? 'on' : 'off']();
}
}
export default function App() {
useUnmount(() => {
disableScroll.off();
});
return (
<Box>
<GlobalStyles />
<FlexCenter minHeight={256} px="xl">
<H1>react-floater</H1>
<Paragraph bold>A component to create awesome tooltips, modals and more!</Paragraph>
{window.innerWidth >= 768 && <WithPosition cb={callback} />}
</FlexCenter>
<Block gray>
<H2 mb="xxl">The classic examples</H2>
<Flex direction="column" gap="xl" width="100%">
<WithAutoOpen cb={callback} />
<Flex justify="space-between" maxWidth={500} mx="auto" width="100%">
<WithTitleAndFooter cb={callback} />
<WithCustomStyles cb={callback} />
</Flex>
<WithStyledComponents cb={callback} />
</Flex>
</Block>
<Block>
<H2>Hover</H2>
<Paragraph color="gray" size="md">
It will switch to click on mobile.
<br />
(can be disabled with <b>disableHoverToClick</b> prop)
</Paragraph>
<Spacer distribution="center" gap="lg" mt="xxxl" orientation="vertical">
<WithHoverDefault cb={callback} />
<WithHoverCustomDelay cb={callback} />
<WithHoverAndNoDelay cb={callback} />
</Spacer>
</Block>
<Block gray>
<H2 mb="xxl">Inside text</H2>
<WithText cb={callback} />
</Block>
<Block>
<H2 mb="xxl">With Overlay</H2>
<WithOverlay cb={callback} />
</Block>
<Block gray>
<H2 mb="xxl">Custom targets</H2>
<Content maxWidth={640} mb="xxl">
<ProxyMode cb={callback} />
<BeaconMode cb={callback} />
</Content>
<Content maxWidth={640}>
<ControlledMode cb={callback} />
<Modal cb={callback} />
</Content>
</Block>
<div id="portalElement" />
{NODE_ENV === 'production' && <Badges />}
</Box>
);
}