-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBalloonToolbar.styles.ts
151 lines (135 loc) · 3.82 KB
/
BalloonToolbar.styles.ts
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import { BalloonToolbarProps, getToolbarStyles, ToolbarBase } from '@udecode/plate'
import { createStyles } from '@udecode/plate-styled-components'
import { transparentize } from 'polished'
import styled, { css, CSSProp } from 'styled-components'
// import tw from 'twin.macro'
// import { getToolbarStyles } from '../Toolbar/Toolbar.styles';
import { BalloonToolbarStyleProps } from './BalloonToolbar.types'
export const getBalloonToolbarStyles = (props: BalloonToolbarStyleProps) => {
let color = 'rgb(157, 170, 182)'
let colorActive = 'white'
let background = 'rgb(36, 42, 49)'
let borderColor = 'transparent'
if (props.theme === 'light') {
color = 'rgba(0, 0, 0, 0.50)'
colorActive = 'black'
background = 'rgb(250, 250, 250)'
borderColor = 'rgb(196, 196, 196)'
}
const { placement = 'top' } = props
const arrowStyle: CSSProp = [
props.arrow &&
css`
::after {
left: 50%;
content: ' ';
position: absolute;
margin-top: -1px;
transform: translateX(-50%);
border-color: ${background} transparent;
border-style: solid;
}
`,
props.arrow &&
placement.includes('top') &&
css`
::after {
top: 100%;
bottom: auto;
border-width: 8px 8px 0;
}
`,
props.arrow &&
!placement.includes('top') &&
css`
::after {
top: auto;
bottom: 100%;
border-width: 0 8px 8px;
}
`
]
const arrowBorderStyle: CSSProp = [
props.arrow &&
placement.includes('top') &&
props.theme === 'light' &&
css`
::before {
margin-top: 0;
border-width: 9px 9px 0;
border-color: ${borderColor} transparent;
}
`,
props.arrow &&
!placement.includes('top') &&
props.theme === 'light' &&
css`
::before {
margin-top: 0;
border-width: 0 9px 9px;
border-color: ${borderColor} transparent;
}
`
]
return createStyles(
{ prefixClassNames: 'BalloonToolbar', ...props },
{
root: [
...getToolbarStyles(props).root.css,
css`
position: absolute;
white-space: nowrap;
opacity: 100;
transition: opacity 0.2s ease-in-out;
color: ${color};
background: ${background};
z-index: 500;
border: 1px solid ${borderColor};
border-radius: 4px;
.slate-ToolbarButton-active,
.slate-ToolbarButton:hover {
color: ${colorActive};
}
::before {
${arrowBorderStyle}
}
`,
...arrowStyle,
...arrowBorderStyle
]
}
)
}
export const BalloonToolbarBase = styled(ToolbarBase)<BalloonToolbarProps>`
display: flex;
user-select: none;
box-sizing: content-box;
align-items: center;
position: absolute;
white-space: nowrap;
opacity: 100;
transition: opacity 0.2s ease-in-out;
color: ${({ theme }) => theme.colors.text.default};
background: ${({ theme }) => theme.colors.gray[8]};
z-index: 500;
border: 1px solid transparent;
border-radius: ${({ theme }) => theme.borderRadius.tiny};
padding: 0 ${({ theme }) => theme.spacing.tiny};
.slate-ToolbarButton-active,
.slate-ToolbarButton:hover {
/* padding: ${({ theme: { spacing } }) => `${spacing.tiny}`}; */
color: ${({ theme }) => theme.colors.primary};
background-color: ${({ theme }) => transparentize(0.5, theme.colors.gray[9])};
border-radius: ${({ theme }) => theme.borderRadius.tiny};
}
`
export const BalloonToolbarInputWrapper = styled.div`
display: flex;
align-items: center;
gap: ${({ theme }) => theme.spacing.small};
padding: ${({ theme }) => theme.spacing.tiny};
svg {
width: 1.2rem;
height: 1.2rem;
}
`