-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathSlice.style.js
60 lines (49 loc) · 1.65 KB
/
Slice.style.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
import { css } from 'styled-components';
import { system } from '@styled-system/core';
import { color } from '@styled-system/color';
import { themeGet } from '@styled-system/theme-get';
import { skew, endAngle } from './Slice.selectors.js';
import { radius, centerRadius, centralAngle, polar, ifObtuse } from '../PieMenu.selectors.js';
const getColor = value => themeGet(`colors.${value}`, value);
export const getBackground = background => (background ? css`
background: radial-gradient(transparent ${centerRadius}, ${getColor(background)} ${centerRadius});
` : '');
const background = props => getBackground(props.bg || props.backgroundColor);
const textHighlight = system({
textHighlight: {
property: 'color',
scale: 'colors',
},
});
const highlight = props => getBackground(props.highlight);
export const container = css`
display: block;
width: 200%;
height: 200%;
transform-origin: 50% 50%;
border-radius: 50%;
transform: skew(${props => -skew(props)}deg) rotate(${props => ((polar(props) ? 90 : centralAngle(props)) / 2) - 90}deg);
color: black;
${color}
${getBackground('rgba(109, 109, 109, 0.925)')}; /* css fallback */
${background};
outline: none;
&[_highlight="true"] {
color: white;
${textHighlight}
${getBackground('#424242')};
${highlight};
}
`;
const contentHeight = props => props.contentHeight;
export const contentContainer = css`
position: absolute;
width: 100%;
text-align: center;
top: calc((${ifObtuse('50%', '0px')} + ${radius} - ${centerRadius}) / 2 - ${contentHeight} / 2);
`;
export const content = css`
display: inline-block;
transform: rotate(-${endAngle}deg);
user-select: none;
`;