-
Notifications
You must be signed in to change notification settings - Fork 10
/
PieMenu.style.js
48 lines (42 loc) · 1.3 KB
/
PieMenu.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
import { css } from 'styled-components';
import { radius, centerRadius, ifObtuse } from './PieMenu.selectors.js';
import { startAngle, endAngle, skew } from './Slice/Slice.selectors.js';
const position = ({ centerX, centerY, ...props }) => css`
position: ${centerX || centerY ? 'absolute' : 'relative'};
${centerX ? `left: calc(${centerX} - ${radius(props)})` : ''};
${centerY ? `top: calc(${centerY} - ${radius(props)})` : ''};
`;
export const container = css`
display: inline-block;
${position}
border-radius: 50%;
overflow: hidden;
`;
export const list = css`
position: relative;
list-style: none;
padding: 0;
margin: 0;
border-radius: 50%;
width: calc(2 * ${radius});
height: calc(2 * ${radius});
`;
export const item = css`
width: ${ifObtuse('100%', '50%')};
height: ${ifObtuse('100%', '50%')};
bottom: ${ifObtuse('50%', 'initial')};
right: ${ifObtuse('50%', 'initial')};
position: absolute;
transform: rotate(${props => startAngle(props) + endAngle(props)}deg) skew(${skew}deg);
transform-origin: bottom right;
overflow: hidden;
`;
export const center = css`
position: absolute;
border-radius: 50%;
background: transparent;
top: calc(50% - ${centerRadius});
left: calc(50% - ${centerRadius});
width: calc(2 * ${centerRadius});
height: calc(2 * ${centerRadius});
`;