-
Notifications
You must be signed in to change notification settings - Fork 33
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
1 parent
7c49bd2
commit 470f427
Showing
15 changed files
with
544 additions
and
75 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,2 +1,2 @@ | ||
REACT_APP_PACKAGE_NAME=$npm_package_name | ||
REACT_APP_PACKAGE_NAME=@cahil/snowfall | ||
REACT_APP_GITHUB_URL=$npm_package_homepage |
Large diffs are not rendered by default.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,38 @@ | ||
import React, { Component } from 'react' | ||
import React, { useContext } from 'react' | ||
import Snowfall from '@cahil/snowfall' | ||
import GithubLink from './GithubLink' | ||
import GithubLink from './components/GithubLink/GithubLink' | ||
import Settings from './components/Settings' | ||
import { SettingsContext, StateProvider } from './context/settings' | ||
import './App.css' | ||
|
||
const githubURL = process.env.REACT_APP_GITHUB_URL as string | ||
const packageName = process.env.REACT_APP_PACKAGE_NAME as string | ||
|
||
class App extends Component { | ||
render() { | ||
return ( | ||
<div className="app"> | ||
<GithubLink url={githubURL} /> | ||
<Snowfall snowflakeCount={200} /> | ||
<h1>snowfall</h1> | ||
<a href={githubURL}>{packageName}</a> | ||
</div> | ||
) | ||
} | ||
const Demo = () => { | ||
const settings = useContext(SettingsContext) | ||
|
||
return <Snowfall color={settings.color} snowflakeCount={settings.snowflakeCount} /> | ||
} | ||
|
||
const Title = () => { | ||
const settings = useContext(SettingsContext) | ||
|
||
return ( | ||
<a href={githubURL} style={{ color: settings.color }}> | ||
<h1>{packageName}</h1> | ||
</a> | ||
) | ||
} | ||
|
||
const App = () => ( | ||
<StateProvider> | ||
<div className="app"> | ||
<GithubLink url={githubURL} /> | ||
<Title /> | ||
<Demo /> | ||
<Settings /> | ||
</div> | ||
</StateProvider> | ||
) | ||
|
||
export default App |
File renamed without changes
File renamed without changes.
File renamed without changes.
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 @@ | ||
.settings-container { | ||
background-color: rgba(66, 66, 66, 0.7) !important; | ||
width: 100%; | ||
max-width: 400px; | ||
padding: 32px; | ||
} |
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 React, { useContext } from 'react' | ||
import { CirclePicker } from 'react-color' | ||
import Box from '@material-ui/core/Box' | ||
import Paper from '@material-ui/core/Paper' | ||
import Typography from '@material-ui/core/Typography' | ||
import Slider from '@material-ui/lab/Slider' | ||
import { SettingsContext, SnowfallSettings } from 'context/settings' | ||
import { ThemeProvider } from './theme' | ||
|
||
import './Settings.css' | ||
|
||
const colors = [ | ||
'#dee4fd', | ||
'#e91e63', | ||
'#9c27b0', | ||
'#673ab7', | ||
'#3f51b5', | ||
'#2196f3', | ||
'#03a9f4', | ||
'#00bcd4', | ||
'#009688', | ||
'#4caf50', | ||
'#8bc34a', | ||
'#cddc39', | ||
'#ffeb3b', | ||
'#ffc107', | ||
'#ff9800', | ||
'#ff5722', | ||
'#795548', | ||
'#607d8b', | ||
] | ||
|
||
const Settings = () => { | ||
const settings = useContext(SettingsContext) as SnowfallSettings | ||
|
||
return ( | ||
<ThemeProvider> | ||
<Paper className="settings-container"> | ||
<Typography gutterBottom>Snowflake Count - {settings.snowflakeCount}</Typography> | ||
<Slider | ||
value={settings.snowflakeCount} | ||
min={0} | ||
max={750} | ||
step={1} | ||
onChange={(_, value) => settings.setSnowflakeCount(value)} | ||
/> | ||
<Box my={2}> | ||
<Typography gutterBottom>Color - {settings.color}</Typography> | ||
<CirclePicker | ||
colors={colors} | ||
width="100%" | ||
color={settings.color} | ||
onChangeComplete={value => settings.setColor(value.hex)} | ||
/> | ||
</Box> | ||
</Paper> | ||
</ThemeProvider> | ||
) | ||
} | ||
|
||
export default Settings |
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 { default } from './Settings' |
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,15 @@ | ||
import * as React from 'react' | ||
import { createMuiTheme, MuiThemeProvider } from '@material-ui/core/styles' | ||
|
||
export const theme = createMuiTheme({ | ||
palette: { | ||
type: 'dark', | ||
primary: { | ||
main: 'rgba(33, 150, 243, 0.87)', | ||
}, | ||
}, | ||
}) | ||
|
||
export const ThemeProvider: React.FC = ({ children }) => { | ||
return <MuiThemeProvider theme={theme}>{children}</MuiThemeProvider> | ||
} |
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,20 @@ | ||
import React, { createContext, useState, FC } from 'react' | ||
import { SnowfallProps } from '@cahil/snowfall' | ||
|
||
export interface SnowfallSettings extends SnowfallProps { | ||
setColor: (color: string) => void | ||
setSnowflakeCount: (count: number) => void | ||
} | ||
|
||
export const SettingsContext = createContext<Partial<SnowfallSettings>>({}) | ||
|
||
export const StateProvider: FC = ({ children }) => { | ||
const [color, setColor] = useState('#dee4fd') | ||
const [snowflakeCount, setSnowflakeCount] = useState(200) | ||
|
||
return ( | ||
<SettingsContext.Provider value={{ color, setColor, snowflakeCount, setSnowflakeCount }}> | ||
{children} | ||
</SettingsContext.Provider> | ||
) | ||
} |
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