-
Notifications
You must be signed in to change notification settings - Fork 342
/
NotifBanner.tsx
168 lines (155 loc) · 4.71 KB
/
NotifBanner.tsx
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
import React from 'react'
import styled, { ThemeProvider, css } from 'styled-components'
import * as icons from 'src/common-ui/components/design-library/icons'
import Icon from '@worldbrain/memex-common/lib/common-ui/components/icon'
import { theme } from './design-library/theme'
import browser from 'webextension-polyfill'
import { PrimaryAction } from '@worldbrain/memex-common/lib/common-ui/components/PrimaryAction'
import { MemexThemeVariant } from '@worldbrain/memex-common/lib/common-ui/styles/types'
const MemexLogo = browser.runtime.getURL('img/memexLogo.svg')
export interface ThemeProps {
variant: MemexThemeVariant
width?: string
position?: string
iconSize?: string
}
export interface Props {
mainText: string
mainBtnText: string
theme?: ThemeProps
onMainBtnClick: React.MouseEventHandler
onCloseBtnClick: React.MouseEventHandler
location: string
}
export class NotifBanner extends React.PureComponent<Props> {
render() {
const { theme: themeProps } = this.props
themeProps.width = themeProps.width ?? '100%'
themeProps.iconSize = '24px'
return (
<ThemeProvider
theme={{
...theme({ variant: this.props.theme.variant }),
...themeProps,
}}
>
<Banner location={this.props.location}>
<MainContent location={this.props.location}>
<Icon
filePath={MemexLogo}
heightAndWidth="30px"
hoverOff
color="prime1"
/>
<MainText>{this.props.mainText}</MainText>
<ButtonBox location={this.props.location}>
<PrimaryAction
icon="longArrowRight"
onClick={this.props.onMainBtnClick}
label={'See changes'}
type={'forth'}
size={'medium'}
/>
<Icon
icon="removeX"
heightAndWidth="22px"
onClick={this.props.onCloseBtnClick}
/>
</ButtonBox>
</MainContent>
</Banner>
</ThemeProvider>
)
}
}
const ButtonBox = styled.div<{
location: string
}>`
display: flex;
align-items: center;
grid-gap: 10px;
${(props) => props.location === 'sidebar' && css``}
`
const Banner = styled.div<{
location: string
}>`
display: flex;
flex-direction: row;
background: ${(props) => props.theme.colors.black}70;
height: 60px;
width: fit-content;
position: ${({ theme }) => theme.position};
padding: 0 20px;
bottom: 0px;
right: 0px;
z-index: 2147483647;
justify-content: center;
align-items: center;
border: 1px solid ${(props) => props.theme.colors.prime1};
margin: 0 10px 10px 10px;
border-radius: 8px;
backdrop-filter: blur(4px);
box-shadow: 0px 4px 16px rgba(0, 0, 0, 0.6);
animation: slide-up ease-out;
animation-duration: 0.2s;
${(props) =>
props.theme.variant === 'light' &&
css`
border-color: ${(props) =>
props.theme.borderStyles.borderHoverElements};
box-shadow: ${(props) =>
props.theme.borderStyles.boxShadowHoverElements};
`};
${(props) =>
props.location === 'sidebar' &&
css`
grid-gap: 10px;
margin: 0 6px 10px -10px;
`}
${(props) =>
props.location === 'search' &&
css`
animation: slide-down ease-out;
animation-duration: 0.1s;
grid-gap: 10px;
margin: 10px 10px 10px 10px;
width: fill-available;
`}
@keyframes slide-up {
0% {
bottom: -100px;
opacity: 0%;
}
100% {
bottom: 0px;
opacity: 100%;
}
}
@keyframes slide-down {
0% {
margin-top: -60px;
opacity: 0%;
}
100% {
margin-top: 0px;
opacity: 100%;
}
}
`
const MainContent = styled.div<{
location: string
}>`
max-width: 770px;
width: 100%;
display: flex;
align-items: center;
justify-content: center;
grid-gap: 15px;
`
const MainText = styled.span`
font-size: 16px;
font-weight: bold;
margin-right: 20px;
color: ${(props) => props.theme.colors.white};
white-space: nowrap;
`