Skip to content

Commit

Permalink
Feat: refactor moderation auth pages (#903)
Browse files Browse the repository at this point in the history
* feat(ui): create and export moderation error card
- update interfaces

* feat(apps): refactor moderation auth pages
- remove redundant files
  • Loading branch information
josenriagu committed Mar 3, 2021
1 parent e651a4f commit 75bc116
Show file tree
Hide file tree
Showing 9 changed files with 127 additions and 91 deletions.
4 changes: 0 additions & 4 deletions apps/moderation/src/assets/illustration-blocked.ts

This file was deleted.

4 changes: 0 additions & 4 deletions apps/moderation/src/assets/illustration-intro.ts

This file was deleted.

46 changes: 11 additions & 35 deletions apps/moderation/src/components/prompt-authentication.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@ import DS from '@akashaproject/design-system';

import { IPromptAuthorizationProps } from './prompt-authorization';

import illustration from '../assets/illustration-intro';

import { ContentWrapper, PageWrapper } from './styled';

const { Box, Text, Image, Button } = DS;
const { ModerationAppErrorCard } = DS;

export interface IPromptAuthenticationProps extends IPromptAuthorizationProps {
buttonLabel?: string;
Expand All @@ -26,36 +22,16 @@ const PromptAuthentication: React.FC<IPromptAuthenticationProps> = props => {
}, [ethAddress]);

return (
<PageWrapper style={{ background: 'white' }}>
<ContentWrapper
pad={{ top: '0rem', horizontal: '1.2rem', bottom: '1.2rem' }}
margin={{ top: '-2rem' }}
>
<Box height="18.75rem" width="18.75rem" alignSelf="center">
<Image fit="contain" src={illustration} />
</Box>
<Text
weight={600}
margin={{ bottom: 'medium', horizontal: 'auto' }}
size="large"
textAlign="center"
>
{titleLabel}
</Text>
<Text
weight="normal"
margin={{ bottom: 'medium' }}
color="secondaryText"
size="medium"
textAlign="center"
>
{subtitleLabel}
</Text>
<Box width="fit-content" alignSelf="center">
<Button primary={true} label={buttonLabel} onClick={showLoginModal} />
</Box>
</ContentWrapper>
</PageWrapper>
<ModerationAppErrorCard
size={'18.75rem'}
errorType={'no-authentication'}
titleLabel={titleLabel}
subtitleLabel={subtitleLabel}
buttonLabel={buttonLabel}
textMarginBottom={true}
hasButton={true}
showLoginModal={showLoginModal}
/>
);
};

Expand Down
38 changes: 9 additions & 29 deletions apps/moderation/src/components/prompt-authorization.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import React from 'react';
import DS from '@akashaproject/design-system';

import illustration from '../assets/illustration-blocked';

import { ContentWrapper, PageWrapper } from './styled';

const { Box, Text, Image } = DS;
const { ModerationAppErrorCard } = DS;

export interface IPromptAuthorizationProps {
titleLabel: string;
Expand All @@ -15,30 +11,14 @@ export interface IPromptAuthorizationProps {
const PromptAuthorization: React.FC<IPromptAuthorizationProps> = props => {
const { titleLabel, subtitleLabel } = props;
return (
<PageWrapper style={{ background: 'white' }}>
<ContentWrapper pad={{ top: '0rem', horizontal: '1.4rem', bottom: '1.4rem' }}>
<Box height="14rem" width="14rem" margin={{ bottom: 'small' }} alignSelf="center">
<Image fit="contain" src={illustration} />
</Box>
<Text
weight={600}
margin={{ bottom: 'large', horizontal: 'auto' }}
size="large"
textAlign="center"
>
{titleLabel}
</Text>
<Text
weight="normal"
margin={{ top: 'xsmall' }}
color="secondaryText"
size="medium"
textAlign="center"
>
{subtitleLabel}
</Text>
</ContentWrapper>
</PageWrapper>
<ModerationAppErrorCard
size={'14rem'}
errorType={'no-access-granted'}
titleLabel={titleLabel}
subtitleLabel={subtitleLabel}
textMarginTop={true}
imageBoxHasMargin={true}
/>
);
};

Expand Down
19 changes: 1 addition & 18 deletions apps/moderation/src/components/styled/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,4 @@ const StyledBox: any = styled(Box)`
background-color: ${props => props.theme.colors.accentLight};
`;

const PageWrapper: any = styled(Box)`
background: ${props => props.theme.colors.modalBackgroundAlt};
`;

const ContentWrapper: any = styled(Box)`
top: 0;
left: 0;
bottom: 0;
right: 0;
margin: auto;
background: white;
border-radius: 0.5rem;
span {
letter-spacing: 0.03em;
}
`;

export { StyledBox, PageWrapper, ContentWrapper };
export { StyledBox };
15 changes: 15 additions & 0 deletions ui/design/src/components/Errors/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,18 @@ export interface ErrorLoaderProps {
devDetails?: string | React.ReactNode;
style?: React.CSSProperties;
}

export interface IModerationAppErrorCardProps {
size: string;
errorType: string;
titleLabel: string;
subtitleLabel: string;
buttonLabel?: string;
textMarginTop?: boolean;
textMarginBottom?: boolean;
hasButton?: boolean;
imageBoxHasMargin?: boolean;
/* Path to public folder */
publicImgPath?: string;
showLoginModal?: () => void;
}
71 changes: 71 additions & 0 deletions ui/design/src/components/Errors/moderation-app-error-card.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import React from 'react';
import { Box, Text, Image } from 'grommet';

import { Button } from '../Buttons';

import type { IModerationAppErrorCardProps } from './interfaces';
import { PageWrapper, ContentWrapper } from './styled-elements';

const ModerationAppErrorCard: React.FC<IModerationAppErrorCardProps> = props => {
const {
size,
errorType,
titleLabel,
subtitleLabel,
buttonLabel,
textMarginTop,
textMarginBottom,
hasButton,
imageBoxHasMargin,
publicImgPath = '/images',
showLoginModal,
} = props;

const handleClick = () => {
if (showLoginModal) {
showLoginModal();
}
};

return (
<PageWrapper>
<ContentWrapper pad={{ top: '0rem', horizontal: '5rem', bottom: '1.2rem' }}>
<Box
height={size}
width={size}
margin={{ ...(imageBoxHasMargin && { bottom: 'small' }) }}
alignSelf="center"
>
<Image fit="contain" src={`${publicImgPath}/${errorType}.png`} />
</Box>
<Text
weight={600}
margin={{ bottom: 'medium', horizontal: 'auto' }}
size="xlarge"
textAlign="center"
>
{titleLabel}
</Text>
<Text
weight="normal"
margin={{
...(textMarginTop && { top: 'xsmall' }),
...(textMarginBottom && { bottom: 'medium' }),
}}
color="secondaryText"
size="large"
textAlign="center"
>
{subtitleLabel}
</Text>
{hasButton && (
<Box width="fit-content" alignSelf="center">
<Button primary={true} label={buttonLabel} onClick={handleClick} />
</Box>
)}
</ContentWrapper>
</PageWrapper>
);
};

export default ModerationAppErrorCard;
19 changes: 18 additions & 1 deletion ui/design/src/components/Errors/styled-elements.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import styled from 'styled-components';
import { Box } from 'grommet';

import { BasicCardBox } from '../Cards';

const StyledErrorCard = styled(BasicCardBox)`
Expand All @@ -14,4 +16,19 @@ const StyledImage = styled.img`
height: auto;
padding: 2em 0;
`;
export { StyledErrorCard, StyledImage };

const PageWrapper: any = styled(Box)`
background: white;
`;

const ContentWrapper: any = styled(Box)`
margin: auto;
position: absolute;
top: 40%;
transform: translate(0, -50%);
border-radius: 0.5rem;
span {
letter-spacing: 0.03em;
}
`;
export { StyledErrorCard, StyledImage, PageWrapper, ContentWrapper };
2 changes: 2 additions & 0 deletions ui/design/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ import TextInputField from './components/Forms/text-input-field';
import { AppIcon, Icon, iconTypes } from './components/Icon';
import ErrorInfoCard from './components/Errors/error-info-card';
import ErrorLoader from './components/Errors/error-loader';
import ModerationAppErrorCard from './components/Errors/moderation-app-error-card';

import { CommentInput, SearchInput, DropSearchInput } from './components/Input';
import {
Expand Down Expand Up @@ -124,6 +125,7 @@ const exported = {
EditableAvatar,
ErrorInfoCard,
ErrorLoader,
ModerationAppErrorCard,
AppInfoWidgetCard,
AppsWidgetCard,
BasicCardBox,
Expand Down

0 comments on commit 75bc116

Please sign in to comment.