-
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.
- Loading branch information
Showing
12 changed files
with
139 additions
and
31 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
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 was deleted.
Oops, something went wrong.
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,81 @@ | ||
import { styled } from 'linaria/react'; | ||
import { ChangeEvent, useState } from 'react'; | ||
import { RgbColorPicker } from 'react-colorful'; | ||
import { Wallet } from './components'; | ||
import { getKeys } from './utils'; | ||
|
||
export const App = () => { | ||
const [selectedColor, setSelectedColor] = useState<RgbColor>(initialColor); | ||
|
||
const getOnInputChange = | ||
(part: keyof RgbColor) => (event: ChangeEvent<HTMLInputElement>) => { | ||
const newPartValue = event.target.value; | ||
setSelectedColor((value) => ({ ...value, [part]: newPartValue })); | ||
}; | ||
|
||
return ( | ||
<Page selectedColor={selectedColor}> | ||
<Wallet /> | ||
|
||
<ColorRoot> | ||
<RgbColorPicker color={selectedColor} onChange={setSelectedColor} /> | ||
<Inputs> | ||
{getKeys(selectedColor).map((key) => ( | ||
<Input | ||
key={key} | ||
value={selectedColor[key]} | ||
onChange={getOnInputChange(key)} | ||
/> | ||
))} | ||
</Inputs> | ||
</ColorRoot> | ||
</Page> | ||
); | ||
}; | ||
|
||
const Page = styled.div<{ selectedColor: RgbColor }>` | ||
width: 100%; | ||
height: 100vh; | ||
display: flex; | ||
align-items: center; | ||
background-color: ${({ selectedColor: { b, g, r } }) => | ||
`rgb(${r},${g},${b})`}; | ||
`; | ||
|
||
const Input = styled.input` | ||
border-radius: 5px; | ||
height: 50px; | ||
width: 50px; | ||
text-align: center; | ||
font-size: 30px; | ||
border-color: #eee; | ||
`; | ||
|
||
const initialColor: RgbColor = { | ||
r: 255, | ||
g: 255, | ||
b: 255 | ||
}; | ||
|
||
const Inputs = styled.div` | ||
display: flex; | ||
justify-content: space-between; | ||
margin-top: 10px; | ||
`; | ||
|
||
const ColorRoot = styled.div` | ||
margin: 0 auto; | ||
display: inline-block; | ||
padding: 20px; | ||
background-color: #fff; | ||
border-radius: 10px; | ||
border: 5px solid #444; | ||
box-shadow: 0 0 69px -16px #fff; | ||
`; | ||
|
||
type RgbColor = { | ||
r: number; | ||
g: number; | ||
b: number; | ||
}; |
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,5 @@ | ||
|
||
body { | ||
margin: 0; | ||
padding: 0; | ||
} |
This file was deleted.
Oops, something went wrong.
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,18 @@ | ||
import type { AppProps } from 'next/app'; | ||
import Head from 'next/head'; | ||
import '../global.css'; | ||
|
||
const App = ({ Component, pageProps }: AppProps) => { | ||
return ( | ||
<> | ||
<Head> | ||
<title>Near frontend app</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
</Head> | ||
|
||
<Component {...pageProps} /> | ||
</> | ||
); | ||
}; | ||
|
||
export default App; |
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 { App as default } from '../App'; |
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,6 @@ | ||
/** returns literal string instead of «string» for the concrete objects */ | ||
export function getKeys<T extends Record<string | number, unknown>>( | ||
object: T | ||
): (keyof T)[] { | ||
return Object.keys(object) as (keyof T)[]; | ||
} |
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 +1,2 @@ | ||
export { getKeys } from './getKeys'; | ||
export { isClientSide } from './isClientSide'; |
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