Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve Clockface Spinners #11697

Merged
merged 8 commits into from
Feb 6, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
## UI Improvements
1. [11683](https://github.com/influxdata/influxdb/pull/11683): Change the wording for the plugin config form button to Done
1. [11689](https://github.com/influxdata/influxdb/pull/11689): Change the wording for the Collectors configure step button to Create and Verify
1. [11697](https://github.com/influxdata/influxdb/pull/11697): Standardize page loading spinner styles

## v2.0.0-alpha.1 [2019-01-23]

Expand Down
15 changes: 5 additions & 10 deletions ui/src/Setup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import {notify as notifyAction} from 'src/shared/actions/notifications'

// Components
import {ErrorHandling} from 'src/shared/decorators/errors'
import {SpinnerContainer, TechnoSpinner} from 'src/clockface'

// Utils
import {isOnboardingURL} from 'src/onboarding/utils'
Expand Down Expand Up @@ -63,18 +64,12 @@ export class Setup extends PureComponent<Props, State> {
}

public render() {
if (this.isLoading) {
return <div className="page-spinner" />
} else {
return this.props.children && React.cloneElement(this.props.children)
}
}

private get isLoading(): boolean {
const {loading} = this.state

return (
loading === RemoteDataState.Loading ||
loading === RemoteDataState.NotStarted
<SpinnerContainer loading={loading} spinnerComponent={<TechnoSpinner />}>
{this.props.children && React.cloneElement(this.props.children)}
</SpinnerContainer>
)
}
}
Expand Down
15 changes: 5 additions & 10 deletions ui/src/Signin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {client} from 'src/utils/api'

// Components
import {ErrorHandling} from 'src/shared/decorators/errors'
import {SpinnerContainer, TechnoSpinner} from 'src/clockface'

// Actions
import {notify as notifyAction} from 'src/shared/actions/notifications'
Expand Down Expand Up @@ -55,18 +56,12 @@ export class Signin extends PureComponent<Props, State> {
}

public render() {
if (this.isLoading) {
return <div className="page-spinner" />
}

return this.props.children && React.cloneElement(this.props.children)
}

private get isLoading(): boolean {
const {loading} = this.state

return (
loading === RemoteDataState.Loading ||
loading === RemoteDataState.NotStarted
<SpinnerContainer loading={loading} spinnerComponent={<TechnoSpinner />}>
{this.props.children && React.cloneElement(this.props.children)}
</SpinnerContainer>
)
}

Expand Down
37 changes: 0 additions & 37 deletions ui/src/clockface/components/spinners/Spinner.tsx

This file was deleted.

9 changes: 9 additions & 0 deletions ui/src/clockface/components/spinners/SpinnerContainer.scss
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;
}
43 changes: 43 additions & 0 deletions ui/src/clockface/components/spinners/SpinnerContainer.tsx
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
29 changes: 29 additions & 0 deletions ui/src/clockface/components/spinners/TechnoSpinner.scss
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;
}
}
59 changes: 59 additions & 0 deletions ui/src/clockface/components/spinners/TechnoSpinner.tsx
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
6 changes: 4 additions & 2 deletions ui/src/clockface/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import WizardProgressHeader from './components/wizard/WizardProgressHeader'
import ProgressBar from './components/wizard/ProgressBar'
import ComponentSpacer from './components/component_spacer/ComponentSpacer'
import EmptyState from './components/empty_state/EmptyState'
import Spinner from './components/spinners/Spinner'
import SparkleSpinner from './components/spinners/SparkleSpinner'
import IndexList from './components/index_views/IndexList'
import Context from './components/context_menu/Context'
Expand All @@ -35,6 +34,8 @@ import GridSizer from 'src/clockface/components/grid_sizer/GridSizer'
import Select from 'src/clockface/components/Select'
import Grid from 'src/clockface/components/grid_layout/Grid'
import QuestionMarkTooltip from 'src/clockface/components/tooltips/QuestionMarkTooltip'
import SpinnerContainer from 'src/clockface/components/spinners/SpinnerContainer'
import TechnoSpinner from 'src/clockface/components/spinners/TechnoSpinner'

// Import Types
import {
Expand Down Expand Up @@ -102,8 +103,9 @@ export {
SlideToggle,
SparkleSpinner,
Sort,
Spinner,
SpinnerContainer,
Stack,
TechnoSpinner,
WizardFullScreen,
WizardProgressHeader,
WizardOverlay,
Expand Down
9 changes: 6 additions & 3 deletions ui/src/configuration/components/ConfigurationPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {withRouter, WithRouterProps} from 'react-router'
// Components
import {Page} from 'src/pageLayout'
import GetLabels from 'src/configuration/components/GetLabels'
import {Spinner} from 'src/clockface'
import {SpinnerContainer, TechnoSpinner} from 'src/clockface'
import TabbedPageSection from 'src/shared/components/tabbed_page/TabbedPageSection'
import TabbedPage from 'src/shared/components/tabbed_page/TabbedPage'
import Labels from 'src/configuration/components/Labels'
Expand Down Expand Up @@ -50,9 +50,12 @@ class ConfigurationPage extends Component<Props> {
>
<GetLabels>
{(labels, loading) => (
<Spinner loading={loading}>
<SpinnerContainer
loading={loading}
spinnerComponent={<TechnoSpinner />}
>
<Labels labels={labels} />
</Spinner>
</SpinnerContainer>
)}
</GetLabels>
</TabbedPageSection>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {connect} from 'react-redux'
import _ from 'lodash'

// Components
import {Spinner} from 'src/clockface'
import {SpinnerContainer, TechnoSpinner} from 'src/clockface'
import {ErrorHandling} from 'src/shared/decorators/errors'

// Actions
Expand Down Expand Up @@ -69,7 +69,12 @@ export class CreateOrUpdateConfig extends PureComponent<Props, State> {

public render() {
return (
<Spinner loading={this.state.loading}>{this.props.children()}</Spinner>
<SpinnerContainer
loading={this.state.loading}
spinnerComponent={<TechnoSpinner />}
>
{this.props.children()}
</SpinnerContainer>
)
}
}
Expand Down
9 changes: 6 additions & 3 deletions ui/src/dataLoaders/components/verifyStep/FetchAuthToken.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, {PureComponent} from 'react'
import _ from 'lodash'

// Components
import {Spinner} from 'src/clockface'
import {SpinnerContainer, TechnoSpinner} from 'src/clockface'
import {ErrorHandling} from 'src/shared/decorators/errors'

// Apis
Expand Down Expand Up @@ -44,9 +44,12 @@ class FetchAuthToken extends PureComponent<Props, State> {

public render() {
return (
<Spinner loading={this.state.loading}>
<SpinnerContainer
loading={this.state.loading}
spinnerComponent={<TechnoSpinner />}
>
{this.props.children(this.state.authToken)}
</Spinner>
</SpinnerContainer>
)
}
}
Expand Down
16 changes: 11 additions & 5 deletions ui/src/me/components/Resources.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import LogoutButton from 'src/me/components/LogoutButton'
import OrgsList from 'src/me/components/OrgsList'
import DashboardsList from 'src/me/components/DashboardsList'
import ResourceFetcher from 'src/shared/components/resource_fetcher'
import {Panel, Spinner} from 'src/clockface'
import {Panel, SpinnerContainer, TechnoSpinner} from 'src/clockface'

// Constants
import {VERSION, GIT_SHA} from 'src/shared/constants'
Expand Down Expand Up @@ -51,9 +51,12 @@ class ResourceLists extends PureComponent<Props> {
<Panel.Body>
<ResourceFetcher<Organization[]> fetcher={getOrganizations}>
{(orgs, loading) => (
<Spinner loading={loading}>
<SpinnerContainer
loading={loading}
spinnerComponent={<TechnoSpinner diameterPixels={50} />}
>
<OrgsList orgs={orgs} />
</Spinner>
</SpinnerContainer>
)}
</ResourceFetcher>
</Panel.Body>
Expand All @@ -63,9 +66,12 @@ class ResourceLists extends PureComponent<Props> {
<Panel.Body>
<ResourceFetcher<Dashboard[]> fetcher={getDashboards}>
{(dashboards, loading) => (
<Spinner loading={loading}>
<SpinnerContainer
loading={loading}
spinnerComponent={<TechnoSpinner diameterPixels={50} />}
>
<DashboardsList dashboards={dashboards} />
</Spinner>
</SpinnerContainer>
)}
</ResourceFetcher>
</Panel.Body>
Expand Down
Loading