forked from jossmac/react-images
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFooter.js
121 lines (104 loc) · 3.16 KB
/
Footer.js
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
// @flow
// @jsx glam
import glam from 'glam';
import React from 'react';
import { smallDevice } from './css-helpers';
import { Div, Span } from '../primitives';
import type { PropsWithStyles, ViewType } from '../types';
import { className } from '../utils';
type State = { isModal: boolean, interactionIsIdle: boolean };
type Props = State &
PropsWithStyles & {
components: Object,
currentView: ViewType,
innerProps: any,
isFullscreen: boolean,
isModal: boolean,
modalProps: any,
interactionIsIdle: any,
};
export const footerCSS = ({ isModal, interactionIsIdle }: State) => ({
alignItems: 'top',
bottom: isModal ? 0 : null,
color: isModal ? 'rgba(255, 255, 255, 0.9)' : '#666',
display: 'flex ',
flex: '0 0 auto',
fontSize: 13,
justifyContent: 'space-between',
left: isModal ? 0 : null,
opacity: interactionIsIdle && isModal ? 0 : 1,
padding: isModal ? '30px 20px 20px' : '10px 0',
position: isModal ? 'absolute' : null,
right: isModal ? 0 : null,
transform: isModal ? `translateY(${interactionIsIdle ? 10 : 0}px)` : null,
transition: 'opacity 300ms, transform 300ms',
zIndex: isModal ? 1 : null,
[smallDevice]: {
padding: isModal ? '20px 15px 15px' : '5px 0',
},
});
const Footer = (props: Props) => {
const { components, getStyles, innerProps, isFullscreen, isModal } = props;
const style = isModal
? { background: 'linear-gradient(rgba(0,0,0,0), rgba(0,0,0,0.33))' }
: null;
const state = { isFullscreen, isModal };
const cn = {
container: className('footer', state),
caption: className('footer__caption', state),
count: className('footer__count', state),
};
const css = {
container: getStyles('footer', props),
caption: getStyles('footerCaption', props),
count: getStyles('footerCount', props),
};
const { Caption, Count } = components;
return (
<Div
css={css.container}
className={cn.container}
// TODO glam prefixer fails on gradients
// https://github.com/threepointone/glam/issues/35
style={style}
{...innerProps}
>
<Caption {...props} />
<Count {...props} />
</Div>
);
};
// ==============================
// Inner Elements
// ==============================
export const footerCaptionCSS = () => ({});
export const FooterCaption = (props: ViewType) => {
const { currentView, getStyles, isFullscreen, isModal } = props;
const { caption } = currentView;
const state = { isFullscreen, isModal };
return (
<Span
css={getStyles('footerCaption', props)}
className={className('footer__caption', state)}
>
{caption}
</Span>
);
};
export const footerCountCSS = () => ({ flexShrink: 0, marginLeft: '1em' });
export const FooterCount = (props: ViewType) => {
const { currentIndex, getStyles, isFullscreen, isModal, views } = props;
const state = { isFullscreen, isModal };
const activeView = currentIndex + 1;
const totalViews = views.length;
if (!activeView || !totalViews) return null;
return (
<Span
css={getStyles('footerCount', props)}
className={className('footer__count', state)}
>
{activeView} of {totalViews}
</Span>
);
};
export default Footer;