File size: 10,676 Bytes
1e92f2d |
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 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 |
/* eslint no-eval: 0 */
import theme from 'shared/theme';
import styled, { css, keyframes } from 'styled-components';
export const Gradient = (g1, g2) =>
css`radial-gradient(ellipse farthest-corner at top left, ${g1} 0%, ${g2} 100%)`;
export const Truncate = () => css`
text-overflow: ellipsis;
overflow: hidden;
white-space: nowrap;
min-width: 0;
`;
export const tint = (hex: string, amount: number) => {
let R = parseInt(hex.substring(1, 3), 16);
let G = parseInt(hex.substring(3, 5), 16);
let B = parseInt(hex.substring(5, 7), 16);
const getSingle = (number: number) =>
parseInt((number * (100 + amount)) / 100, 10);
R = getSingle(R);
G = getSingle(G);
B = getSingle(B);
R = R < 255 ? R : 255;
G = G < 255 ? G : 255;
B = B < 255 ? B : 255;
const getDouble = (number: number) =>
number.toString(16).length === 1
? `0${number.toString(16)}`
: number.toString(16);
const RR = getDouble(R);
const GG = getDouble(G);
const BB = getDouble(B);
return `#${RR}${GG}${BB}`;
};
export const hexa = (hex, alpha) => {
var r = parseInt(hex.slice(1, 3), 16),
g = parseInt(hex.slice(3, 5), 16),
b = parseInt(hex.slice(5, 7), 16);
if (alpha >= 0) {
return `rgba(${r}, ${g}, ${b}, ${alpha})`;
} else {
return `rgb(${r}, ${g}, ${b})`;
}
};
export const Shadow = {
low: '0 2px 8px',
mid: '0 4px 12px',
high: '0 8px 16px',
};
export const Transition = {
hover: {
on: 'all 0.2s ease-in',
off: 'all 0.2s ease-out',
},
reaction: {
on: 'all 0.15s ease-in',
off: 'all 0.1s ease-out',
},
dropdown: {
off: 'all 0.35s ease-out',
},
};
export const zIndex = new function() {
// Write down a camel-cased element descriptor as the name (e.g. modal or chatInput).
// Define at a component level here, then use math to handle order at a local level.
// (e.g. const ModalInput = styled.input`z-index: zIndex.modal + 1`;)
// This uses constructor syntax because that allows self-referential math
this.base = 1; // z-index: auto content will go here or inherit z-index from a parent
this.background = this.base - 1; // content that should always be behind other things (e.g. textures/illos)
this.hidden = this.base - 2; // this content should be hidden completely (USE ADD'L MEANS OF HIDING)
this.card = this.base + 1; // all cards should default to one layer above the base content
this.loading = this.card + 1; // loading elements should never appear behind cards
this.avatar = this.card + 1; // avatars should never appear behind cards
this.form = this.card + 1; // form elements should never appear behind cards
this.search = this.form; // search is a type of form and should appear at the same level
this.dmInput = this.form;
this.composerToolbar = 2000; // composer toolbar - should sit in between most elements
this.chrome = 3000; // chrome should be visible in modal contexts
this.navBar = this.chrome; // navBar is chrome and should appear at the same level
this.mobileInput = this.chrome + 1; // the chatInput on mobile should appear above the navBar
this.dropDown = this.chrome + 1; // dropDowns shouldn't appear behind the navBar
this.slider = window.innerWidth < 768 ? this.chrome + 1 : this.chrome; // slider should appear significantly above the base to leave room for other elements
this.composer = 4000; // should cover all screen except toasts
this.chatInput = this.slider + 1; // the slider chatInput should always appear above the slider
this.flyout = this.chatInput + 3; // flyout may overlap with chatInput and should take precedence
this.fullscreen = 4000; // fullscreen elements should cover all screen content except toasts
this.modal = 5000; // modals should completely cover base content and slider as well
this.gallery = this.modal + 1; // gallery should never appear behind a modal
this.toast = 6000; // toasts should be visible in every context
this.tooltip = this.toast + 1; // tooltips should always be on top
}();
export const fontStack = css`
font-family: -apple-system, BlinkMacSystemFont, 'Helvetica', 'Segoe',
sans-serif;
`;
export const monoStack = css`
font-family: 'Input Mono', 'Menlo', 'Inconsolata', 'Roboto Mono', monospace;
`;
const spin = keyframes`
to {transform: rotate(360deg);}
`;
export const Spinner = styled.span`
width: ${props => (props.size ? `${props.size}px` : '32px')};
height: ${props => (props.size ? `${props.size}px` : '32px')};
&:before {
content: '';
box-sizing: border-box;
display: inline-block;
position: ${props => (props.inline ? 'relative' : 'absolute')};
top: ${props => (props.inline ? '0' : '50%')};
left: ${props => (props.inline ? '0' : '50%')};
width: ${props => (props.size !== undefined ? `${props.size}px` : '16px')};
height: ${props => (props.size !== undefined ? `${props.size}px` : '16px')};
margin-top: ${props =>
props.size !== undefined ? `-${props.size / 2}px` : '-8px'};
margin-left: ${props =>
props.size !== undefined ? `-${props.size / 2}px` : '-8px'};
border-radius: 50%;
border: 2px solid
${props =>
props.color
? eval(`props.theme.${props.color}`)
: props.theme.brand.alt};
border-top-color: transparent;
border-right-color: ${props =>
props.color ? eval(`props.theme.${props.color}`) : props.theme.brand.alt};
border-bottom-color: transparent;
animation: ${spin} 2s linear infinite;
}
`;
export const Label = styled.label`
display: flex;
flex-direction: column;
width: 100%;
margin-top: 0.5rem;
font-weight: 500;
font-size: 0.875rem;
letter-spacing: -0.4px;
color: ${theme.text.default};
&:not(:first-of-type) {
margin-top: 1.5rem;
}
a {
text-decoration: underline;
}
`;
export const PrefixLabel = styled.label`
display: flex;
width: 100%;
margin-top: 0.25rem;
padding-left: 0.875rem;
font-size: 0.875rem;
font-weight: 500;
color: ${theme.text.placeholder};
> input {
margin-left: 2px;
}
`;
export const Input = styled.input`
flex: 1 0 auto;
background: ${theme.bg.default};
font-weight: 500;
width: 100%;
font-size: 0.875rem;
border: 0.125rem solid ${theme.bg.inactive};
border-radius: 0.25rem;
padding: 0.5rem 0.75rem;
margin-top: 0.125rem;
box-shadow: none;
${props =>
props.type === 'checkbox' &&
css`
flex: initial;
width: initial;
margin-right: 0.5rem;
`} &::placeholder {
color: ${theme.text.placeholder};
}
&::-webkit-input-placeholder {
color: ${theme.text.placeholder};
}
&:-moz-placeholder {
color: ${theme.text.placeholder};
}
&:-ms-input-placeholder {
color: ${theme.text.placeholder};
}
&:focus {
border-color: ${theme.brand.default};
}
`;
export const TextArea = styled.textarea`
flex: 1 0 auto;
width: 100%;
background: ${theme.bg.default};
font-weight: 500;
font-size: 0.875rem;
border: 0.125rem solid ${theme.bg.inactive};
border-radius: 0.25rem;
padding: 0.75rem;
margin-top: 0.125rem;
box-shadow: none;
&::placeholder {
color: ${theme.text.placeholder};
}
&::-webkit-input-placeholder {
color: ${theme.text.placeholder};
}
&:-moz-placeholder {
color: ${theme.text.placeholder};
}
&:-ms-input-placeholder {
color: ${theme.text.placeholder};
}
&:focus {
border-color: ${theme.brand.default};
}
`;
export const UnderlineInput = styled.input`
font-size: inherit;
font-weight: inherit;
color: ${theme.text.default};
border-bottom: 0.125rem solid ${theme.bg.inactive};
&:focus {
border-color: ${theme.brand.default};
}
`;
export const H1 = styled.h1`
${fontStack};
color: ${theme.text.default};
font-weight: 900;
font-size: 1.5rem;
line-height: 1.3;
margin: 0;
padding: 0;
`;
export const H2 = styled.h2`
color: ${theme.text.default};
${fontStack};
font-weight: 700;
font-size: 1.25rem;
line-height: 1.3;
margin: 0;
padding: 0;
`;
export const H3 = styled.h3`
color: ${theme.text.default};
${fontStack};
font-weight: 500;
font-size: 1rem;
line-height: 1.5;
margin: 0;
padding: 0;
`;
export const H4 = styled.h4`
color: ${theme.text.default};
${fontStack};
font-weight: 500;
font-size: 0.875rem;
line-height: 1.4;
margin: 0;
padding: 0;
`;
export const H5 = styled.h5`
color: ${theme.text.default};
${fontStack};
font-weight: 500;
font-size: 0.75rem;
line-height: 1.4;
margin: 0;
padding: 0;
`;
export const H6 = styled.h6`
color: ${theme.text.default};
${fontStack};
font-weight: 600;
text-transform: uppercase;
font-size: 0.675rem;
line-height: 1.5;
margin: 0;
padding: 0;
`;
export const P = styled.p`
color: ${theme.text.default};
${fontStack};
font-weight: 400;
font-size: 0.875rem;
line-height: 1.4;
margin: 0;
padding: 0;
`;
export const Span = styled.span`
color: ${theme.text.default};
${fontStack};
font-weight: 400;
font-size: 0.875rem;
line-height: 1.4;
margin: 0;
padding: 0;
`;
export const FlexRow = styled.div`
display: flex;
flex-direction: row;
justify-content: flex-start;
align-items: center;
`;
export const FlexCol = styled.div`
display: flex;
flex-direction: column;
justify-content: flex-start;
align-items: stretch;
`;
export const Onboarding = props => css`
position: relative;
&:after,
&:before {
line-height: 1;
user-select: none;
pointer-events: none;
position: absolute;
opacity: 0;
display: block;
}
&:before {
content: '';
z-index: ${zIndex.tooltip + 1};
border: 5px solid transparent;
}
&:after {
content: ${props.onboarding ? `'${props.onboarding}'` : "''"};
z-index: ${zIndex.tooltip};
${fontStack};
text-align: left;
line-height: 20px;
font-size: 14px;
font-weight: 500;
width: 300px;
white-space: normal;
overflow: hidden;
padding: 16px;
padding-left: 20px;
border-radius: 12px;
background-color: ${props.theme.bg.default};
background: ${props.theme.bg.default} url(/img/goopy-top.svg) center top
no-repeat;
background-size: 100%;
color: ${props.theme.text.default};
box-shadow: 0 8px 32px rgba(23, 26, 33, 0.35);
}
&:after,
&:before {
opacity: 1;
transition: opacity 0.1s ease-in 0.1s;
}
`;
export const HorizontalRule = styled(FlexRow)`
position: relative;
justify-content: center;
align-items: center;
align-self: stretch;
color: ${theme.bg.border};
hr {
display: inline-block;
flex: 1 0 auto;
border-top: 1px solid ${theme.bg.border};
}
div {
margin: 0 16px;
}
`;
|