Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactored section list items + test
- Loading branch information
Showing
3 changed files
with
94 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,84 +1,41 @@ | ||
import Link from "next/link"; | ||
import React from "react"; | ||
import styled from "styled-components"; | ||
|
||
import { Container } from "../Container"; | ||
import { H1 } from "../H1/H1"; | ||
import { H2 } from "../H2/H2"; | ||
import { LoginsIcon } from "../LoginsIcon/LoginsIcon"; | ||
import { NeutralLink } from "../NeutralLink/NeutralLink"; | ||
import RightChevron from "../RightChevron/RightChevron"; | ||
import { SectionListItem } from "../SectionListItem/SectionListItem"; | ||
import { SecurityIcon } from "../SecurityIcon/SecurityIcon"; | ||
import { ShadowBox } from "../ShadowBox/ShadowBox"; | ||
|
||
export const SECTION_LIST_CONTENT = { | ||
LOGINS: { | ||
text: | ||
"Manage your logins options, including emails, phone numbers and social logins", | ||
icon: <LoginsIcon />, | ||
}, | ||
SECURITY: { | ||
text: | ||
"Set or change your password. You can check your connections history here", | ||
icon: <SecurityIcon />, | ||
}, | ||
}; | ||
|
||
const Account: React.FC = () => { | ||
return ( | ||
<Container> | ||
<H1>Welcome to your account</H1> | ||
<H2>First name last name</H2> | ||
<ShadowBox> | ||
<Content> | ||
<Link href="/account/logins"> | ||
<NeutralLink> | ||
<Flex> | ||
<LoginsIcon /> | ||
<TextBox> | ||
<Span>LOGINS</Span> | ||
<div> | ||
Manage your logins options, including emails, phone numbers | ||
and social logins | ||
</div> | ||
</TextBox> | ||
<RightChevron /> | ||
</Flex> | ||
</NeutralLink> | ||
</Link> | ||
</Content> | ||
</ShadowBox> | ||
<ShadowBox> | ||
<Content> | ||
<Link href="/account/security"> | ||
<NeutralLink> | ||
<Flex> | ||
<SecurityIcon /> | ||
<TextBox> | ||
<Span>SECURITY</Span> | ||
<div> | ||
Set or change your password. You can check your connections | ||
history here, | ||
</div> | ||
</TextBox> | ||
<RightChevron /> | ||
</Flex> | ||
</NeutralLink> | ||
</Link> | ||
</Content> | ||
</ShadowBox> | ||
{Object.entries(SECTION_LIST_CONTENT).map(([sectionName, content]) => { | ||
return ( | ||
<SectionListItem | ||
key={sectionName} | ||
sectionName={sectionName} | ||
content={content} | ||
/> | ||
); | ||
})} | ||
</Container> | ||
); | ||
}; | ||
|
||
export default Account; | ||
|
||
const Content = styled.div` | ||
cursor: pointer; | ||
`; | ||
|
||
const Flex = styled.div` | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
padding: ${({ theme }) => theme.spaces.xs}; | ||
`; | ||
|
||
export const TextBox = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
max-width: 50%; | ||
font-size: ${({ theme }) => theme.fontSizes.xxs}; | ||
line-height: ${({ theme }) => theme.lineHeights.title}; | ||
`; | ||
|
||
export const Span = styled.p` | ||
font-size: ${({ theme }) => theme.fontSizes.s}; | ||
`; |
61 changes: 61 additions & 0 deletions
61
src/components/display/fewlines/SectionListItem/SectionListItem.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import Link from "next/link"; | ||
import React from "react"; | ||
import styled from "styled-components"; | ||
|
||
import { NeutralLink } from "../NeutralLink/NeutralLink"; | ||
import { RightChevron } from "../RightChevron/RightChevron"; | ||
import { ShadowBox } from "../ShadowBox/ShadowBox"; | ||
|
||
type SectionListItemProps = { | ||
sectionName: string; | ||
content: { text: string; icon: JSX.Element }; | ||
}; | ||
|
||
export const SectionListItem: React.FC<SectionListItemProps> = ({ | ||
sectionName, | ||
content, | ||
}) => { | ||
const { text, icon } = content; | ||
|
||
return ( | ||
<> | ||
<ShadowBox> | ||
<Content> | ||
<Link href={`/account/${sectionName.toLocaleLowerCase()}`}> | ||
<NeutralLink> | ||
<Flex> | ||
{icon} | ||
<TextBox> | ||
<SectionName>{sectionName}</SectionName> | ||
{text} | ||
</TextBox> | ||
<RightChevron /> | ||
</Flex> | ||
</NeutralLink> | ||
</Link> | ||
</Content> | ||
</ShadowBox> | ||
</> | ||
); | ||
}; | ||
|
||
const Content = styled.div` | ||
cursor: pointer; | ||
`; | ||
|
||
const Flex = styled.div` | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
padding: ${({ theme }) => theme.spaces.xs}; | ||
`; | ||
|
||
export const TextBox = styled.div` | ||
max-width: 50%; | ||
font-size: ${({ theme }) => theme.fontSizes.xs}; | ||
line-height: ${({ theme }) => theme.lineHeights.title}; | ||
`; | ||
|
||
export const SectionName = styled.p` | ||
font-size: ${({ theme }) => theme.fontSizes.s}; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters