-
Notifications
You must be signed in to change notification settings - Fork 4.3k
/
Copy pathalignment-matrix-control-styles.js
92 lines (78 loc) · 1.7 KB
/
alignment-matrix-control-styles.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
/**
* External dependencies
*/
import styled from '@emotion/styled';
import { css } from '@emotion/react';
/**
* Internal dependencies
*/
import { COLORS, reduceMotion } from '../../utils';
export const rootBase = () => {
return css`
border-radius: 2px;
box-sizing: border-box;
display: grid;
grid-template-columns: repeat( 3, 1fr );
outline: none;
`;
};
const rootSize = ( { size = 92 } ) => {
return css`
grid-template-rows: repeat( 3, calc( ${ size }px / 3 ) );
width: ${ size }px;
`;
};
export const Root = styled.div`
${ rootBase };
border: 1px solid transparent;
cursor: pointer;
grid-template-columns: auto;
${ rootSize };
`;
export const Row = styled.div`
box-sizing: border-box;
display: grid;
grid-template-columns: repeat( 3, 1fr );
`;
const pointActive = ( { isActive } ) => {
const boxShadow = isActive ? `0 0 0 2px ${ COLORS.gray[ 900 ] }` : null;
const pointColor = isActive ? COLORS.gray[ 900 ] : COLORS.lightGray[ 800 ];
const pointColorHover = isActive
? COLORS.gray[ 900 ]
: COLORS.blue.medium.focus;
return css`
box-shadow: ${ boxShadow };
color: ${ pointColor };
*:hover > & {
color: ${ pointColorHover };
}
`;
};
export const pointBase = ( props ) => {
return css`
background: currentColor;
box-sizing: border-box;
display: grid;
margin: auto;
transition: all 120ms linear;
${ reduceMotion( 'transition' ) }
${ pointActive( props ) }
`;
};
export const Point = styled.span`
height: 6px;
width: 6px;
${ pointBase }
`;
export const Cell = styled.span`
appearance: none;
border: none;
box-sizing: border-box;
margin: 0;
display: flex;
position: relative;
outline: none;
align-items: center;
justify-content: center;
padding: 0;
`;