More small css adjustments (#353)

This commit is contained in:
Jaco Greeff 2020-06-01 14:57:32 +02:00 committed by GitHub
parent e154bb89d2
commit 5bdc3aec3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 102 additions and 103 deletions

View File

@ -70,7 +70,7 @@ const HiddenOptions = styled.div<{ visible: boolean }>`
} }
`; `;
export default styled(AddressDropdown)` export default styled(AddressDropdown)(({ theme }: ThemeProps) => `
margin-bottom: 16px; margin-bottom: 16px;
cursor: pointer; cursor: pointer;
@ -83,13 +83,13 @@ export default styled(AddressDropdown)`
width: 30px; width: 30px;
height: 30px; height: 30px;
background: url(${arrow}) center no-repeat; background: url(${arrow}) center no-repeat;
background-color: ${({ theme }: ThemeProps): string => theme.inputBackground}; background-color: ${theme.inputBackground};
pointer-events: none; pointer-events: none;
border-radius: 4px; border-radius: 4px;
border: 1px solid ${({ theme }: ThemeProps): string => theme.boxBorderColor}; border: 1px solid ${theme.boxBorderColor};
} }
${Address} ${Svg} { ${Address} ${Svg} {
visibility: hidden; visibility: hidden;
} }
`; `);

View File

@ -5,7 +5,7 @@
import { MetadataDef } from '@polkadot/extension-inject/types'; import { MetadataDef } from '@polkadot/extension-inject/types';
import { ThemeProps } from '../../types'; import { ThemeProps } from '../../types';
import React, { useContext } from 'react'; import React, { useCallback, useContext } from 'react';
import styled from 'styled-components'; import styled from 'styled-components';
import { ActionBar, ActionContext, Button, Link, Table, Warning } from '../../components'; import { ActionBar, ActionContext, Button, Link, Table, Warning } from '../../components';
@ -22,14 +22,24 @@ interface Props {
function Request ({ className, metaId, request, url }: Props): React.ReactElement<Props> { function Request ({ className, metaId, request, url }: Props): React.ReactElement<Props> {
const chain = useMetadata(request.genesisHash); const chain = useMetadata(request.genesisHash);
const onAction = useContext(ActionContext); const onAction = useContext(ActionContext);
const _onApprove = (): Promise<void> =>
approveMetaRequest(metaId) const _onApprove = useCallback(
.then((): void => onAction()) (): void => {
.catch((error: Error) => console.error(error)); approveMetaRequest(metaId)
const _onReject = (): Promise<void> => .then(() => onAction())
rejectMetaRequest(metaId) .catch(console.error);
.then((): void => onAction()) },
.catch((error: Error) => console.error(error)); [metaId, onAction]
);
const _onReject = useCallback(
(): void => {
rejectMetaRequest(metaId)
.then(() => onAction())
.catch(console.error);
},
[metaId, onAction]
);
return ( return (
<div className={className}> <div className={className}>
@ -59,49 +69,40 @@ function Request ({ className, metaId, request, url }: Props): React.ReactElemen
<td className='data'>{chain ? chain.specVersion : 'unknown'} -&gt; {request.specVersion}</td> <td className='data'>{chain ? chain.specVersion : 'unknown'} -&gt; {request.specVersion}</td>
</tr> </tr>
</Table> </Table>
<RequestInfo> <div className='requestInfo'>
<RequestWarning>This approval will add the metadata to your extension instance, allowing future requests to be decoded using this metadata.</RequestWarning> <Warning className='requestWarning'>This approval will add the metadata to your extension instance, allowing future requests to be decoded using this metadata.</Warning>
<AcceptButton onClick={_onApprove}>Yes, do this metadata update</AcceptButton> <Button
<RejectButton> className='btnAccept'
onClick={_onApprove}
>
Yes, do this metadata update
</Button>
<ActionBar className='btnReject'>
<Link <Link
isDanger isDanger
onClick={_onReject} onClick={_onReject}
> >
Reject Reject
</Link> </Link>
</RejectButton> </ActionBar>
</RequestInfo> </div>
</div> </div>
); );
} }
const RequestInfo = styled.div` export default styled(Request)(({ theme }: ThemeProps) => `
display: flex; .btnAccept {
flex-direction: column; margin: 25px auto 0;
align-items: center; width: 90%;
margin-bottom: 8px; }
background: ${({ theme }: ThemeProps): string => theme.highlightedAreaBackground};
`;
const AcceptButton = styled(Button)` .btnReject {
width: 90%; margin: 8px 0 15px 0;
margin: 25px auto 0; text-decoration: underline;
`; }
const RequestWarning = styled(Warning)`
margin: 24px 24px 0 1.45rem;
`;
AcceptButton.displayName = 'AcceptButton';
const RejectButton = styled(ActionBar)`
margin: 8px 0 15px 0;
text-decoration: underline;
`;
export default styled(Request)`
.icon { .icon {
background: ${({ theme }: ThemeProps): string => theme.buttonBackgroundDanger}; background: ${theme.buttonBackgroundDanger};
color: white; color: white;
min-width: 18px; min-width: 18px;
width: 14px; width: 14px;
@ -113,20 +114,15 @@ export default styled(Request)`
padding-left: 0.5px; padding-left: 0.5px;
} }
.tab-info { .requestInfo {
overflow: hidden; align-items: center;
margin: 0.75rem 20px 0 0; background: ${theme.highlightedAreaBackground};
display: flex;
flex-direction: column;
margin-bottom: 8px;
} }
.tab-name, .requestWarning {
.tab-url { margin: 24px 24px 0 1.45rem;
color: ${({ theme }: ThemeProps): string => theme.textColor};
display: inline-block;
max-width: 20rem;
overflow: hidden;
text-overflow: ellipsis;
vertical-align: top;
cursor: pointer;
text-decoration: underline;
} }
`; `);

View File

@ -31,7 +31,7 @@ function Qr ({ className, onSignature, payload, request }: Props): React.ReactEl
return ( return (
<div className={className}> <div className={className}>
<QrArea> <div className='qrContainer'>
{isScanning {isScanning
? <QrScanSignature onScan={onSignature} /> ? <QrScanSignature onScan={onSignature} />
: ( : (
@ -43,27 +43,32 @@ function Qr ({ className, onSignature, payload, request }: Props): React.ReactEl
/> />
) )
} }
</QrArea> </div>
{!isScanning && ( {!isScanning && (
<ScanButton onClick={_onShowQr}>Scan signature via camera</ScanButton> <Button
className='scanButton'
onClick={_onShowQr}
>
Scan signature via camera
</Button>
)} )}
</div> </div>
); );
} }
const ScanButton = styled(Button)`
margin-bottom: 8px;
`;
const QrArea = styled.div`
width: 65%;
margin: 5px auto 10px auto;
img {
border: white solid 1px;
}
`;
export default styled(Qr)` export default styled(Qr)`
height: 100%; height: 100%;
.qrContainer {
margin: 5px auto 10px auto;
width: 65%;
img {
border: white solid 1px;
}
}
.scanButton {
margin-bottom: 8px;
}
`; `;

View File

@ -11,26 +11,26 @@ import { Svg } from '../../components';
import ArrowLeftImage from '../../assets/arrowLeft.svg'; import ArrowLeftImage from '../../assets/arrowLeft.svg';
interface Props { interface Props {
className?: string;
index: number; index: number;
totalItems: number; totalItems: number;
onNextClick: () => void; onNextClick: () => void;
onPreviousClick: () => void; onPreviousClick: () => void;
className?: string;
} }
interface ArrowProps extends ThemeProps { interface ArrowProps extends ThemeProps {
isActive: boolean; isActive: boolean;
} }
function TransactionIndex ({ index, onNextClick, onPreviousClick, totalItems }: Props): React.ReactElement<Props> { function TransactionIndex ({ className, index, onNextClick, onPreviousClick, totalItems }: Props): React.ReactElement<Props> {
const previousClickActive = index !== 0; const previousClickActive = index !== 0;
const nextClickActive = index < totalItems - 1; const nextClickActive = index < totalItems - 1;
return ( return (
<CreationSteps> <div className={className}>
<div> <div>
<CurrentStep>{index + 1}</CurrentStep> <span className='currentStep'>{index + 1}</span>
<TotalSteps>/{totalItems}</TotalSteps> <span className='totalSteps'>/{totalItems}</span>
</div> </div>
<div> <div>
<ArrowLeft <ArrowLeft
@ -42,33 +42,10 @@ function TransactionIndex ({ index, onNextClick, onPreviousClick, totalItems }:
onClick={(): unknown => nextClickActive && onNextClick()} onClick={(): unknown => nextClickActive && onNextClick()}
/> />
</div> </div>
</CreationSteps> </div>
); );
} }
const CreationSteps = styled.div`
align-items: center;
display: flex;
justify-content: space-between;
flex-grow: 1;
padding-right: 24px;
`;
const CurrentStep = styled.span`
font-size: ${({ theme }: ThemeProps): string => theme.labelFontSize};
line-height: ${({ theme }: ThemeProps): string => theme.labelLineHeight};
color: ${({ theme }: ThemeProps): string => theme.primaryColor};
font-weight: 600;
margin-left: 10px;
`;
const TotalSteps = styled.span`
font-size: ${({ theme }: ThemeProps): string => theme.labelFontSize};
line-height: ${({ theme }: ThemeProps): string => theme.labelLineHeight};
color: ${({ theme }: ThemeProps): string => theme.textColor};
font-weight: 600;
`;
const ArrowLeft = styled(Svg).attrs(() => ({ src: ArrowLeftImage }))<ArrowProps>` const ArrowLeft = styled(Svg).attrs(() => ({ src: ArrowLeftImage }))<ArrowProps>`
display: inline-block; display: inline-block;
background: ${({ isActive, theme }: ArrowProps): string => isActive ? theme.primaryColor : theme.iconNeutralColor}; background: ${({ isActive, theme }: ArrowProps): string => isActive ? theme.primaryColor : theme.iconNeutralColor};
@ -86,4 +63,25 @@ const ArrowRight = styled(ArrowLeft)`
ArrowRight.displayName = 'ArrowRight'; ArrowRight.displayName = 'ArrowRight';
export default TransactionIndex; export default styled(TransactionIndex)(({ theme }: ThemeProps) => `
align-items: center;
display: flex;
justify-content: space-between;
flex-grow: 1;
padding-right: 24px;
.currentStep {
color: ${theme.primaryColor};
font-size: ${theme.labelFontSize};
line-height: ${theme.labelLineHeight};
font-weight: 600;
margin-left: 10px;
}
.totalSteps {
font-size: ${theme.labelFontSize};
line-height: ${theme.labelLineHeight};
color: ${theme.textColor};
font-weight: 600;
}
`);