-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor BestBuyPage and chart style
- Loading branch information
Showing
10 changed files
with
183 additions
and
108 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
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,29 @@ | ||
import React, { ChangeEventHandler } from 'react'; | ||
import { useSymbols } from '../hooks/useSymbols'; | ||
|
||
type Props = { | ||
selectedValue: string; | ||
onChange: ChangeEventHandler<HTMLInputElement>; | ||
}; | ||
|
||
export const TokensSelector = ({ selectedValue, onChange }: Props) => { | ||
const { symbols } = useSymbols(); | ||
|
||
return ( | ||
<> | ||
<input | ||
data-testid="input-symbol" | ||
id="symbol" | ||
list="symbols" | ||
value={selectedValue} | ||
onChange={onChange} | ||
required | ||
/> | ||
<datalist id="symbols"> | ||
{symbols.map((symbol, index) => ( | ||
<option key={index} value={symbol} /> | ||
))} | ||
</datalist> | ||
</> | ||
); | ||
}; |
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,45 @@ | ||
import styled from 'styled-components'; | ||
|
||
export const Row = styled.div<{ best?: boolean; dca?: boolean }>` | ||
border-radius: 5px; | ||
margin-bottom: 10px; | ||
background: ${(props) => { | ||
if (props.dca && props.best) { | ||
return '#A0F0A0'; | ||
} else if (props.dca && !props.best) { | ||
return '#FFF3AD'; | ||
} | ||
return '#FFD1DC'; | ||
}}; | ||
padding: 10px; | ||
border-width: 1px; | ||
border-style: solid; | ||
border-color: ${(props) => { | ||
if (props.dca && props.best) { | ||
return '#90EE90'; | ||
} else if (props.dca && !props.best) { | ||
return '#FFEB9C'; | ||
} | ||
return '#FFC0CB'; | ||
}}; | ||
`; | ||
|
||
export const DCAInfoContainer = styled.div` | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: space-between; | ||
@media (max-width: 690px) { | ||
flex-direction: column; | ||
} | ||
`; | ||
|
||
export const Column = styled.div` | ||
width: 50%; | ||
@media (max-width: 690px) { | ||
width: 100%; | ||
} | ||
`; |
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
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,33 @@ | ||
import styled, { keyframes } from 'styled-components'; | ||
import { Row } from './BestBuyPage.styles'; | ||
|
||
export const SkeletonRow = styled(Row)` | ||
background: #efefef; | ||
border-color: #e0e0e0; | ||
`; | ||
|
||
export const skeletonLoading = keyframes` | ||
0% { | ||
background-color: hsl(200, 20%, 80%); | ||
} | ||
100% { | ||
background-color: hsl(200, 20%, 95%); | ||
} | ||
`; | ||
|
||
export const Bar = styled.div` | ||
height: 18px; | ||
animation: ${skeletonLoading} 1s linear infinite alternate; | ||
margin-bottom: 8px; | ||
width: 50%; | ||
`; | ||
|
||
export const ThickBar = styled(Bar)` | ||
height: 37px; | ||
`; | ||
|
||
export const AspectRatioBox = styled.div<{ aspectRatio: number }>` | ||
width: 100%; | ||
padding-top: ${(props) => props.aspectRatio}%; | ||
animation: ${skeletonLoading} 1s linear infinite alternate; | ||
`; |
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,29 @@ | ||
import { Column, DCAInfoContainer } from './BestBuyPage.styles'; | ||
import { AspectRatioBox, Bar, SkeletonRow, ThickBar } from './Skeleton.styles'; | ||
|
||
type Props = { | ||
rows?: number; | ||
}; | ||
|
||
export const Skeleton = ({ rows = 5 }: Props) => { | ||
return ( | ||
<div> | ||
{new Array(rows).fill(0).map((dataItem, index) => ( | ||
<SkeletonRow key={index}> | ||
<ThickBar /> | ||
<DCAInfoContainer> | ||
<Column> | ||
<Bar /> | ||
<Bar /> | ||
<Bar /> | ||
<Bar /> | ||
</Column> | ||
<Column> | ||
<AspectRatioBox aspectRatio={50} /> | ||
</Column> | ||
</DCAInfoContainer> | ||
</SkeletonRow> | ||
))} | ||
</div> | ||
); | ||
}; |
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 @@ | ||
export { BestBuyPage } from './BestBuyPage'; |
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
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
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