Skip to content

Commit

Permalink
Merge pull request #1439 from oasisprotocol/lw/alertbox-colors
Browse files Browse the repository at this point in the history
Update AlertBox colors
  • Loading branch information
lukaw3d authored May 9, 2023
2 parents 578a49f + a31fc60 commit 93c1920
Show file tree
Hide file tree
Showing 27 changed files with 782 additions and 571 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`<AddEscrowForm /> should match snapshot 1`] = `
.c0 {
.c1 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
Expand All @@ -16,7 +16,7 @@ exports[`<AddEscrowForm /> should match snapshot 1`] = `
padding-top: 12px;
}
.c1 {
.c2 {
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
Expand All @@ -32,7 +32,7 @@ exports[`<AddEscrowForm /> should match snapshot 1`] = `
flex-direction: column;
}
.c4 {
.c5 {
-webkit-flex: 0 0 auto;
-ms-flex: 0 0 auto;
flex: 0 0 auto;
Expand All @@ -42,7 +42,7 @@ exports[`<AddEscrowForm /> should match snapshot 1`] = `
width: 12px;
}
.c5 {
.c6 {
display: inline-block;
box-sizing: border-box;
cursor: pointer;
Expand All @@ -53,65 +53,66 @@ exports[`<AddEscrowForm /> should match snapshot 1`] = `
background: transparent;
overflow: visible;
text-transform: none;
border: 2px solid #7D4CDB;
border-radius: 18px;
border: 2px solid #0092f6;
border-radius: 4px;
color: #444444;
padding: 4px 22px;
font-size: 18px;
line-height: 24px;
background-color: #7D4CDB;
background-color: #0092f6;
color: #f8f8f8;
border-radius: 18px;
border-radius: 4px;
-webkit-transition-property: color,background-color,border-color,box-shadow;
transition-property: color,background-color,border-color,box-shadow;
-webkit-transition-duration: 0.1s;
transition-duration: 0.1s;
-webkit-transition-timing-function: ease-in-out;
transition-timing-function: ease-in-out;
font-weight: bold;
}
.c5:hover {
box-shadow: 0px 0px 0px 2px #7D4CDB;
.c6:hover {
box-shadow: 0px 0px 0px 2px #0092f6;
}
.c5:focus {
.c6:focus {
outline: none;
box-shadow: 0 0 2px 2px #6FFFB0;
}
.c5:focus > circle,
.c5:focus > ellipse,
.c5:focus > line,
.c5:focus > path,
.c5:focus > polygon,
.c5:focus > polyline,
.c5:focus > rect {
.c6:focus > circle,
.c6:focus > ellipse,
.c6:focus > line,
.c6:focus > path,
.c6:focus > polygon,
.c6:focus > polyline,
.c6:focus > rect {
outline: none;
box-shadow: 0 0 2px 2px #6FFFB0;
}
.c5:focus::-moz-focus-inner {
.c6:focus::-moz-focus-inner {
border: 0;
}
.c5:focus:not(:focus-visible) {
.c6:focus:not(:focus-visible) {
outline: none;
box-shadow: none;
}
.c5:focus:not(:focus-visible) > circle,.c5:focus:not(:focus-visible) > ellipse,
.c5:focus:not(:focus-visible) > line,.c5:focus:not(:focus-visible) > path,
.c5:focus:not(:focus-visible) > polygon,.c5:focus:not(:focus-visible) > polyline,
.c5:focus:not(:focus-visible) > rect {
.c6:focus:not(:focus-visible) > circle,.c6:focus:not(:focus-visible) > ellipse,
.c6:focus:not(:focus-visible) > line,.c6:focus:not(:focus-visible) > path,
.c6:focus:not(:focus-visible) > polygon,.c6:focus:not(:focus-visible) > polyline,
.c6:focus:not(:focus-visible) > rect {
outline: none;
box-shadow: none;
}
.c5:focus:not(:focus-visible)::-moz-focus-inner {
.c6:focus:not(:focus-visible)::-moz-focus-inner {
border: 0;
}
.c3 {
.c4 {
box-sizing: border-box;
font-size: inherit;
font-family: inherit;
Expand All @@ -127,103 +128,121 @@ exports[`<AddEscrowForm /> should match snapshot 1`] = `
border-radius: 4px;
}
.c3:focus {
.c4:focus {
outline: none;
box-shadow: 0 0 2px 2px #6FFFB0;
}
.c3:focus > circle,
.c3:focus > ellipse,
.c3:focus > line,
.c3:focus > path,
.c3:focus > polygon,
.c3:focus > polyline,
.c3:focus > rect {
.c4:focus > circle,
.c4:focus > ellipse,
.c4:focus > line,
.c4:focus > path,
.c4:focus > polygon,
.c4:focus > polyline,
.c4:focus > rect {
outline: none;
box-shadow: 0 0 2px 2px #6FFFB0;
}
.c3:focus::-moz-focus-inner {
.c4:focus::-moz-focus-inner {
border: 0;
}
.c3::-webkit-input-placeholder {
.c4::-webkit-input-placeholder {
color: #AAAAAA;
}
.c3::-moz-placeholder {
.c4::-moz-placeholder {
color: #AAAAAA;
}
.c3:-ms-input-placeholder {
.c4:-ms-input-placeholder {
color: #AAAAAA;
}
.c3::-webkit-search-decoration {
.c4::-webkit-search-decoration {
-webkit-appearance: none;
}
.c3::-moz-focus-inner {
.c4::-moz-focus-inner {
border: none;
outline: none;
}
.c3:-moz-placeholder,
.c3::-moz-placeholder {
.c4:-moz-placeholder,
.c4::-moz-placeholder {
opacity: 1;
}
.c2 {
.c3 {
position: relative;
width: 100%;
}
.c0 {
font-family: Rubik;
font-size: 18px;
line-height: 24px;
background-color: #ffffff;
color: #444444;
box-sizing: border-box;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
-moz-osx-font-smoothing: grayscale;
-webkit-font-smoothing: antialiased;
}
@media only screen and (max-width:768px) {
.c0 {
.c1 {
padding-top: 6px;
}
}
@media only screen and (max-width:768px) {
.c4 {
.c5 {
width: 6px;
}
}
<form>
<div
class="c0"
>
<div
class="c0"
style="min-height: 100vh;"
>
<form>
<div
class="c1"
>
<div
class="c2"
>
<input
autocomplete="off"
<div
class="c3"
data-testid="amount"
id="amount-id"
min="0"
name="amount"
placeholder="common.amount"
required=""
step="any"
type="number"
value=""
/>
>
<input
autocomplete="off"
class="c4"
data-testid="amount"
id="amount-id"
min="0"
name="amount"
placeholder="common.amount"
required=""
step="any"
type="number"
value=""
/>
</div>
</div>
<div
class="c5"
/>
<button
class="c6"
type="submit"
>
account.addEscrow.delegate
</button>
</div>
<div
class="c4"
/>
<button
class="c5"
type="submit"
>
account.addEscrow.delegate
</button>
</div>
</form>
</form>
</div>
`;
9 changes: 6 additions & 3 deletions src/app/components/AddEscrowForm/__tests__/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,16 @@ import { configureAppStore } from 'store/configureStore'
import { transactionActions } from 'app/state/transaction'
import { WalletErrors } from 'types/errors'
import { AddEscrowForm } from '..'
import { ThemeProvider } from '../../../../styles/theme/ThemeProvider'

const renderComponent = (store: any, address: string, validatorStatus: Validator['status']) =>
render(
<Provider store={store}>
<ModalProvider>
<AddEscrowForm validatorAddress={address} validatorStatus={validatorStatus} validatorRank={21} />
</ModalProvider>
<ThemeProvider>
<ModalProvider>
<AddEscrowForm validatorAddress={address} validatorStatus={validatorStatus} validatorRank={21} />
</ModalProvider>
</ThemeProvider>
</Provider>,
)

Expand Down
55 changes: 33 additions & 22 deletions src/app/components/AlertBox/index.tsx
Original file line number Diff line number Diff line change
@@ -1,49 +1,60 @@
import { Box } from 'grommet/es6/components/Box'
import { Text } from 'grommet/es6/components/Text'
import { normalizeColor } from 'grommet/es6/utils'
import * as React from 'react'
import { useContext } from 'react'
import { ThemeContext } from 'styled-components'

export type AlertBoxColor = 'status-error' | 'status-warning' | 'status-ok' | 'status-ok-weak'
export type AlertBoxStatus = 'error' | 'warning' | 'ok' | 'ok-weak'

interface Props {
color: AlertBoxColor
status: AlertBoxStatus
center?: boolean
/** Example `icon={<Info size="20px" color="currentColor" />}` */
icon?: React.ReactNode
children: React.ReactNode
}

const mapColor = {
'status-error': {
color: 'status-error',
background: 'status-error-background',
const mapStatus = {
error: {
color: 'alert-box-error',
background: 'alert-box-error-background',
},
'status-warning': {
color: 'status-warning',
background: 'status-warning-background',
warning: {
color: 'alert-box-warning',
background: 'alert-box-warning-background',
},
'status-ok': {
color: 'status-ok',
background: 'status-ok-background',
ok: {
color: 'alert-box-ok',
background: 'alert-box-ok-background',
},
'status-ok-weak': {
color: 'status-ok-weak',
background: 'status-ok-weak-background',
'ok-weak': {
color: 'alert-box-ok-weak',
background: 'alert-box-ok-weak-background',
},
}

export function AlertBox(props: Props) {
const theme = useContext(ThemeContext)
// If we don't normalize upfront then grommet auto-detects darkness of background, and decides to use ['alert-box-warning'].dark with ['alert-box-warning-background'].dark
const color = normalizeColor(mapStatus[props.status].color, theme)

return (
<Box
border={{
color: mapColor[props.color].color,
color: color,
side: 'left',
size: '3px',
}}
background={{
color: mapColor[props.color].background,
}}
background={{ color: mapStatus[props.status].background }}
pad={{ horizontal: 'small' }}
>
<Text weight="bold" size="12px" style={{ lineHeight: '34px' }}>
{props.children}
</Text>
<Box direction="row" gap="small" align="center" justify={props.center ? 'center' : 'start'}>
{props.icon && <Text color={color}>{props.icon}</Text>}
<Text weight="bold" size="12px" style={{ marginTop: 10, marginBottom: 10 }}>
{props.children}
</Text>
</Box>
</Box>
)
}
Loading

0 comments on commit 93c1920

Please sign in to comment.