-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Introduce spinner container and techno spinner Co-Authored-By: Delmer <[email protected]> * Replace unstyled "Spinner" component with spinner container / techno spinner combo Co-Authored-By: Delmer <[email protected]> * Replace instances of Spinner with SpinnerContainer * Replace instances of PageSpinner with SpinnerContainer * Cleanup * Updoot * Improve changelog message
- Loading branch information
alexpaxton
authored
Feb 6, 2019
1 parent
c1a6aeb
commit cd6fb3c
Showing
26 changed files
with
341 additions
and
180 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,9 @@ | ||
.spinner-container { | ||
width: 100%; | ||
height: 100%; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
align-content: center; | ||
flex-direction: column; | ||
} |
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,43 @@ | ||
// Libraries | ||
import React, {Component} from 'react' | ||
import classnames from 'classnames' | ||
|
||
// Types | ||
import {RemoteDataState} from 'src/types' | ||
|
||
// Styles | ||
import 'src/clockface/components/spinners/SpinnerContainer.scss' | ||
|
||
// Decorators | ||
import {ErrorHandling} from 'src/shared/decorators/errors' | ||
|
||
interface Props { | ||
children: JSX.Element[] | JSX.Element | ||
className?: string | ||
loading: RemoteDataState | ||
spinnerComponent: JSX.Element | ||
} | ||
|
||
@ErrorHandling | ||
class SpinnerContainer extends Component<Props> { | ||
public render() { | ||
const {loading, children, spinnerComponent} = this.props | ||
|
||
if ( | ||
loading === RemoteDataState.Loading || | ||
loading === RemoteDataState.NotStarted | ||
) { | ||
return <div className={this.className}>{spinnerComponent}</div> | ||
} | ||
|
||
return children | ||
} | ||
|
||
private get className(): string { | ||
const {className} = this.props | ||
|
||
return classnames('spinner-container', {[`${className}`]: className}) | ||
} | ||
} | ||
|
||
export default SpinnerContainer |
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 'src/style/modules'; | ||
|
||
.techno-spinner { | ||
border-style: solid; | ||
border-color: rgba($g5-pepper, 0.4); | ||
border-left-color: $c-pool; | ||
border-radius: 50%; | ||
animation: technoSpinnerAnimation 0.8s infinite linear; | ||
} | ||
|
||
@keyframes technoSpinnerAnimation { | ||
0% { | ||
transform: rotate(0deg); | ||
border-left-color: $c-pool; | ||
} | ||
25% { | ||
border-left-color: $c-comet; | ||
} | ||
50% { | ||
border-left-color: $c-pool; | ||
} | ||
75% { | ||
border-left-color: $c-rainforest; | ||
} | ||
100% { | ||
transform: rotate(360deg); | ||
border-left-color: $c-pool; | ||
} | ||
} |
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,59 @@ | ||
// Libraries | ||
import React, {Component, CSSProperties} from 'react' | ||
|
||
// Types | ||
import {ComponentSize} from 'src/clockface/types' | ||
|
||
// Styles | ||
import 'src/clockface/components/spinners/TechnoSpinner.scss' | ||
|
||
interface Props { | ||
diameterPixels?: number | ||
strokeWidth?: ComponentSize | ||
} | ||
|
||
class TechnoSpinner extends Component<Props> { | ||
public static defaultProps: Props = { | ||
diameterPixels: 100, | ||
strokeWidth: ComponentSize.Small, | ||
} | ||
|
||
public render() { | ||
return <div className="techno-spinner" style={this.style} /> | ||
} | ||
|
||
private get style(): CSSProperties { | ||
const {diameterPixels} = this.props | ||
|
||
const borderWidth = `${this.strokeWidth}px` | ||
const width = `${diameterPixels}px` | ||
const height = `${diameterPixels}px` | ||
|
||
return {width, height, borderWidth} | ||
} | ||
|
||
private get strokeWidth(): number { | ||
const {strokeWidth} = this.props | ||
|
||
let width | ||
|
||
switch (strokeWidth) { | ||
case ComponentSize.ExtraSmall: | ||
width = 1 | ||
break | ||
case ComponentSize.Small: | ||
width = 2 | ||
break | ||
case ComponentSize.Medium: | ||
width = 4 | ||
break | ||
case ComponentSize.Large: | ||
default: | ||
width = 8 | ||
} | ||
|
||
return width | ||
} | ||
} | ||
|
||
export default TechnoSpinner |
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
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
Oops, something went wrong.