-
Notifications
You must be signed in to change notification settings - Fork 2
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
dd3d86b
commit 5e581d3
Showing
32 changed files
with
1,539 additions
and
18 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,4 +1,5 @@ | ||
{ | ||
"semi": false, | ||
"singleQuote": true, | ||
"trailingComma": "all" | ||
} | ||
} |
Binary file not shown.
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 @@ | ||
<!DOCTYPE html><html><head><meta charset="utf-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><title>daylight</title><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="description" content="Natural clock for visualizing daylight hours"><link href="https://fonts.googleapis.com/css?family=Roboto" rel="stylesheet"><link rel="icon" href="favicon.76ea7194.ico"><link rel="stylesheet" href="style.0be0e570.css"></head><body> <div id="root"></div> <script src="main.6b73d6db.js"></script> </body></html> |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 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 @@ | ||
daylight.website |
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,35 @@ | ||
import React from 'react' | ||
import { connect } from 'react-redux' | ||
|
||
import Countdown from '~components/Countdown' | ||
import Disc from '~components/Disc' | ||
import Links from '~components/Links' | ||
import TimeTable from '~components/TimeTable' | ||
import Waiting from '~components/Waiting' | ||
import { WIDTH } from '~singletons/constants' | ||
import { Space, State } from '~singletons/interfaces' | ||
|
||
interface Props { | ||
space?: Space | ||
} | ||
|
||
const App = ({ space }: Props): JSX.Element => { | ||
if (!space) return <Waiting /> | ||
return ( | ||
<div | ||
style={{ | ||
minWidth: `${WIDTH + 32}px`, | ||
padding: '6px 16px', | ||
}} | ||
> | ||
<Countdown /> | ||
<Disc /> | ||
<TimeTable /> | ||
<Links /> | ||
</div> | ||
) | ||
} | ||
|
||
const mapStateToProps = ({ space }: State): Props => ({ space }) | ||
|
||
export default connect(mapStateToProps)(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,67 @@ | ||
import moment from 'moment' | ||
import React from 'react' | ||
import { connect } from 'react-redux' | ||
|
||
import { MS_HOUR } from '~singletons/constants' | ||
import { State, Suns, Time } from '~singletons/interfaces' | ||
|
||
interface Props { | ||
now?: Time | ||
suns?: Suns | ||
} | ||
|
||
const checkSunrise = (now: Time, suns: Suns) => | ||
now.ms > suns.sunrise.ms && now.ms <= suns.sunriseEnd.ms | ||
|
||
const checkSunset = (now: Time, suns: Suns) => | ||
now.ms > suns.sunsetStart.ms && now.ms <= suns.sunset.ms | ||
|
||
const checkDay = (now: Time, suns: Suns) => | ||
now.ms > suns.sunriseEnd.ms && now.ms <= suns.sunsetStart.ms | ||
|
||
const Countdown = ({ now, suns }: Props): JSX.Element => { | ||
if (!suns || !now) return <div /> | ||
let untilText = '' | ||
const isSunrise = checkSunrise(now, suns) | ||
const isSunset = checkSunset(now, suns) | ||
const isDay = checkDay(now, suns) | ||
if (isSunrise || isSunset) { | ||
untilText += 'the sun is ' + (isSunrise ? 'rising' : 'setting') | ||
} else { | ||
const duration = isDay | ||
? moment.duration(suns.sunsetStart.ms - now.ms) | ||
: moment.duration(suns.sunrise.ms + 24 * MS_HOUR - now.ms) // near enough | ||
const hours = duration.hours() | ||
const minutes = duration.minutes() | ||
const seconds = hours === 0 && minutes === 0 && duration.seconds() | ||
if (hours) untilText += `${hours}h ` | ||
if (minutes) untilText += `${minutes}m ` | ||
if (seconds) untilText += `${seconds}s ` | ||
untilText += 'until ' + (isDay ? 'sunset' : 'sunrise') | ||
} | ||
return ( | ||
<div | ||
className="countdown" | ||
style={{ | ||
color: '#555', | ||
height: 'auto', | ||
padding: '8px', | ||
textAlign: 'center', | ||
}} | ||
> | ||
<div | ||
style={{ | ||
fontSize: '28px', | ||
fontWeight: 'bold', | ||
margin: '8px 8px -2px', | ||
}} | ||
> | ||
{untilText} | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
const mapStateToProps = ({ suns, now }: State): Props => ({ suns, now }) | ||
|
||
export default connect(mapStateToProps)(Countdown) |
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,42 @@ | ||
import React from 'react' | ||
import { connect } from 'react-redux' | ||
|
||
import Colors from '~components/Disc/Colors' | ||
import Hours from '~components/Disc/Hours' | ||
import Now from '~components/Disc/Now' | ||
import { CX, CY, HEIGHT, WIDTH } from '~singletons/constants' | ||
import { State, Suns, Time } from '~singletons/interfaces' | ||
|
||
interface Props { | ||
suns?: Suns | ||
hours?: Time[] | ||
} | ||
|
||
const Disc = ({ suns, hours }: Props): JSX.Element => { | ||
if (!suns || !hours) return <div /> | ||
const transform = | ||
window.location.hash !== '#alt' | ||
? `rotate(${90 - hours[12].angle + 180} ${CX} ${CY})` | ||
: '' | ||
return ( | ||
<svg | ||
xmlns="http://www.w3.org/2000/svg" | ||
width={WIDTH} | ||
height={HEIGHT} | ||
style={{ | ||
display: 'block', | ||
margin: 'auto', | ||
}} | ||
> | ||
<g transform={transform}> | ||
<Colors /> | ||
<Hours /> | ||
<Now /> | ||
</g> | ||
</svg> | ||
) | ||
} | ||
|
||
const mapStateToProps = ({ suns, hours }: State): Props => ({ suns, hours }) | ||
|
||
export default connect(mapStateToProps)(Disc) |
Oops, something went wrong.