-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathBasicFilm.js
75 lines (67 loc) · 2.33 KB
/
BasicFilm.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
import classNames from 'classnames';
import PropTypes from 'prop-types';
import React, { useMemo } from 'react';
import Dots from './Dots';
import Filmstrip from './Filmstrip';
import Flipper from './Flipper';
import ScrollBar from './ScrollBar';
import useDir from './hooks/useDir';
import useHeight from './hooks/useHeight';
import useNumItems from './hooks/useNumItems';
import useScrollBarWidth from './hooks/useScrollBarWidth';
import useScrolling from './hooks/useScrolling';
import useStyleOptions from './hooks/useStyleOptions';
import useStyleSetClassNames from './hooks/useStyleSetClassNames';
const BasicFilm = ({ children, className }) => {
const [dir] = useDir();
const [height] = useHeight();
const [numItems] = useNumItems();
const [scrollBarWidth] = useScrollBarWidth();
const [scrolling] = useScrolling();
const [{ root: rootClassName }] = useStyleSetClassNames();
const [
{
flipperBlurFocusOnClick,
leftFlipperAriaLabel,
leftFlipperText,
rightFlipperAriaLabel,
rightFlipperText,
showDots,
showFlipper,
showScrollBar
}
] = useStyleOptions();
const contentStyle = useMemo(() => ({ height }), [height]);
return (
<div className={classNames(rootClassName, (className || '') + '')} dir={dir}>
<div
className={classNames('react-film__main', { 'react-film__main--scrolling': scrolling })}
style={contentStyle}
>
{!!numItems && scrollBarWidth !== '100%' && !!showFlipper && (
<Flipper aria-label={leftFlipperAriaLabel} blurFocusOnClick={flipperBlurFocusOnClick} mode="left">
{leftFlipperText}
</Flipper>
)}
<Filmstrip>{children}</Filmstrip>
{!!numItems && scrollBarWidth !== '100%' && !!showFlipper && (
<Flipper aria-label={rightFlipperAriaLabel} blurFocusOnClick={flipperBlurFocusOnClick} mode="right">
{rightFlipperText}
</Flipper>
)}
{!!numItems && scrollBarWidth !== '100%' && !!showScrollBar && <ScrollBar />}
</div>
{!!numItems && scrollBarWidth !== '100%' && !!showDots && <Dots />}
</div>
);
};
// TODO: Move from styleSet to styleSheet.
BasicFilm.defaultProps = {
children: undefined,
className: undefined
};
BasicFilm.propTypes = {
children: PropTypes.any,
className: PropTypes.string
};
export default BasicFilm;