This repository has been archived by the owner on Aug 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 54
/
index.jsx
80 lines (72 loc) · 1.77 KB
/
index.jsx
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
import React from 'react';
import styled, { css } from 'styled-components';
import { string, oneOf, bool, node } from 'prop-types';
import { C_WHITE, C_EBON } from '@bbc/psammead-styles/colours';
import { GEL_SPACING_HLF } from '@bbc/gel-foundations/spacings';
import { getMinion } from '@bbc/gel-foundations/typography';
import { getSansRegular } from '@bbc/psammead-styles/font-styles';
import { mediaIcons } from '@bbc/psammead-assets/svgs';
const MediaIndicatorWrapper = styled.div`
color: ${C_EBON};
background-color: ${C_WHITE};
display: block;
${({ service }) => getSansRegular(service)}
${({ script }) => script && getMinion(script)};
${({ isInline }) =>
isInline &&
css`
display: inline-block;
vertical-align: middle;
`}
`;
const FlexWrapper = styled.div`
display: flex;
align-items: center;
height: 100%;
`;
const TimeDuration = styled.time`
vertical-align: middle;
margin: 0 ${GEL_SPACING_HLF};
`;
const MediaIndicator = ({
datetime,
duration,
type,
topStory,
service,
isInline,
children,
}) => (
<MediaIndicatorWrapper
aria-hidden="true"
topStory={topStory}
service={service}
isInline={isInline}
>
<FlexWrapper>
{mediaIcons[type]}
{duration && datetime && !isInline && (
<TimeDuration dateTime={datetime}>{duration}</TimeDuration>
)}
{children}
</FlexWrapper>
</MediaIndicatorWrapper>
);
MediaIndicator.propTypes = {
datetime: string,
duration: string,
type: oneOf(['video', 'audio', 'photogallery']),
topStory: bool,
service: string.isRequired,
isInline: bool,
children: node,
};
MediaIndicator.defaultProps = {
datetime: null,
duration: null,
type: 'video',
topStory: false,
isInline: false,
children: null,
};
export default MediaIndicator;