forked from badges/shields
-
Notifications
You must be signed in to change notification settings - Fork 1
/
common.js
109 lines (90 loc) · 1.91 KB
/
common.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
import React from 'react'
import PropTypes from 'prop-types'
import styled, { css, createGlobalStyle } from 'styled-components'
export const noAutocorrect = Object.freeze({
autoComplete: 'off',
autoCorrect: 'off',
autoCapitalize: 'off',
spellCheck: 'false',
})
export const nonBreakingSpace = '\u00a0'
export const GlobalStyle = createGlobalStyle`
* {
box-sizing: border-box;
}
`
export const BaseFont = styled.div`
font-family: Lekton, sans-serif;
color: #534;
`
export const H2 = styled.h2`
font-style: italic;
margin-top: 12mm;
font-variant: small-caps;
::before {
content: '☙ ';
}
::after {
content: ' ❧';
}
`
export const H3 = styled.h3`
font-style: italic;
`
const BadgeWrapper = styled.span`
padding: 2px;
height: ${({ height }) => height};
vertical-align: middle;
display: ${({ display }) => display};
${({ clickable }) =>
clickable &&
css`
cursor: pointer;
`};
`
export function Badge({
src,
alt = '',
display = 'inline',
height = '20px',
clickable = false,
...rest
}) {
return (
<BadgeWrapper clickable={clickable} display={display} height={height}>
{src ? <img alt={alt} src={src} {...rest} /> : nonBreakingSpace}
</BadgeWrapper>
)
}
Badge.propTypes = {
src: PropTypes.string.isRequired,
alt: PropTypes.string,
display: PropTypes.oneOf(['inline', 'block', 'inline-block']),
height: PropTypes.string,
clickable: PropTypes.bool,
}
export const StyledInput = styled.input`
height: 15px;
border: solid #b9a;
border-width: 0 0 1px 0;
padding: 0;
text-align: center;
color: #534;
:focus {
outline: 0;
}
`
export const InlineInput = styled(StyledInput)`
width: 70px;
margin-left: 5px;
margin-right: 5px;
`
export const BlockInput = styled(StyledInput)`
width: 40%;
background-color: transparent;
`
export const VerticalSpace = styled.hr`
border: 0;
display: block;
height: 3mm;
`