Skip to content
This repository was archived by the owner on Apr 14, 2020. It is now read-only.

Commit c3c41d5

Browse files
committed
chore: adds search overlay example
1 parent 46424c6 commit c3c41d5

2 files changed

Lines changed: 172 additions & 0 deletions

File tree

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
import * as React from 'react';
2+
import { storiesOf } from '@storybook/react';
3+
import Baba, { FLIPMove as Move } from 'yubaba';
4+
import { Toggler } from 'yubaba-common';
5+
import * as Styled from './styled';
6+
7+
storiesOf('yubaba-examples/Transformation/Search', module).add('Default', () => (
8+
<Styled.Banner>
9+
<Styled.Container>
10+
<Styled.Header>Find help and support</Styled.Header>
11+
<Toggler>
12+
{({ shown, toggle }) => (
13+
<React.Fragment>
14+
{shown && (
15+
<React.Fragment>
16+
<Styled.Blanket onClick={() => toggle()} />
17+
18+
<Styled.StickyContainer>
19+
<Styled.Container>
20+
<Baba name="search-bar">
21+
<Move zIndex={802}>
22+
{baba => (
23+
<Styled.StickyInput
24+
autoFocus
25+
style={baba.style}
26+
innerRef={baba.ref}
27+
placeholder="Search for anything..."
28+
/>
29+
)}
30+
</Move>
31+
</Baba>
32+
</Styled.Container>
33+
34+
<Baba name="search-bar-bg">
35+
<Move zIndex={801}>
36+
{baba => <Styled.InputBackground style={baba.style} innerRef={baba.ref} />}
37+
</Move>
38+
</Baba>
39+
</Styled.StickyContainer>
40+
</React.Fragment>
41+
)}
42+
43+
<Styled.RelativeContainer>
44+
<Baba name="search-bar" in={!shown}>
45+
<Move zIndex={802}>
46+
{baba => (
47+
<Styled.Input
48+
onClick={() => toggle()}
49+
style={{
50+
...baba.style,
51+
opacity: shown ? 0 : 1,
52+
}}
53+
innerRef={baba.ref}
54+
placeholder="Search for anything..."
55+
/>
56+
)}
57+
</Move>
58+
</Baba>
59+
60+
<Baba name="search-bar-bg" in={!shown}>
61+
<Move zIndex={801}>
62+
{baba => (
63+
<Styled.InputStaticBackground
64+
style={{
65+
...baba.style,
66+
opacity: shown ? 0 : 1,
67+
}}
68+
innerRef={baba.ref}
69+
/>
70+
)}
71+
</Move>
72+
</Baba>
73+
</Styled.RelativeContainer>
74+
</React.Fragment>
75+
)}
76+
</Toggler>
77+
</Styled.Container>
78+
</Styled.Banner>
79+
));
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
import styled from 'styled-components';
2+
3+
export const Blanket = styled.div`
4+
position: fixed;
5+
top: 0;
6+
left: 0;
7+
right: 0;
8+
bottom: 0;
9+
background-color: rgba(0, 0, 0, 0.8);
10+
z-index: 800;
11+
`;
12+
13+
export const Input = styled.input`
14+
display: block;
15+
width: 100%;
16+
font-size: 20px;
17+
padding: 20px;
18+
border-radius: 3px;
19+
border: 0;
20+
background-color: white;
21+
z-index: 2;
22+
position: relative;
23+
24+
:focus {
25+
outline: 0;
26+
}
27+
`;
28+
29+
export const StickyInput = styled(Input)`
30+
margin-top: 20px;
31+
`;
32+
33+
export const InputBackground = styled.div`
34+
background-color: white;
35+
height: 100px;
36+
position: absolute;
37+
left: 0;
38+
right: 0;
39+
top: 0;
40+
z-index: -1;
41+
`;
42+
43+
export const Banner = styled.div`
44+
height: 60vh;
45+
min-height: 400px;
46+
background-color: #2eb886;
47+
padding: 50px;
48+
box-sizing: border-box;
49+
display: flex;
50+
align-items: center;
51+
margin-bottom: 70vh;
52+
53+
* {
54+
box-sizing: border-box;
55+
}
56+
`;
57+
58+
export const Header = styled.h1`
59+
font-size: 30px;
60+
color: white;
61+
font-family: Roboto, HelveticaNeue, Arial, sans-serif;
62+
font-weight: 400;
63+
`;
64+
65+
export const Container = styled.div`
66+
width: 100%;
67+
max-width: 800px;
68+
margin: 0 auto;
69+
`;
70+
71+
export const StickyContainer = styled.div`
72+
position: fixed;
73+
top: 0;
74+
left: 0;
75+
right: 0;
76+
z-index: 900;
77+
`;
78+
79+
export const InputStaticBackground = styled.div`
80+
background-color: white;
81+
position: absolute;
82+
top: 0;
83+
left: 0;
84+
right: 0;
85+
bottom: 0;
86+
z-index: 1;
87+
border-radius: 3px;
88+
`;
89+
90+
export const RelativeContainer = styled.div`
91+
position: relative;
92+
border-radius: 3px;
93+
`;

0 commit comments

Comments
 (0)