-
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.
Merge pull request #154 from hypothesis/update-spinner-design
Make spinner visual treatment work better in various sizes
- Loading branch information
Showing
9 changed files
with
119 additions
and
55 deletions.
There are no files selected for viewing
File renamed without changes
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
43 changes: 23 additions & 20 deletions
43
src/pattern-library/components/patterns/SpinnerComponents.js
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,28 +1,31 @@ | ||
import { Spinner } from '../../..'; | ||
import Library from '../Library'; | ||
|
||
import { | ||
PatternPage, | ||
Pattern, | ||
PatternExamples, | ||
PatternExample, | ||
} from '../PatternPage'; | ||
import { Spinner } from '../../..'; | ||
|
||
export default function SpinnerComponents() { | ||
return ( | ||
<PatternPage title="Spinner"> | ||
<Pattern title="Spinner"> | ||
<PatternExamples> | ||
<PatternExample details="basic loading spinner"> | ||
<Library.Page title="Spinner"> | ||
<p> | ||
The <code>Spinner</code> component is based on the <code>spinner</code>{' '} | ||
pattern and renders an animated SVG. | ||
</p> | ||
<Library.Pattern title="Spinner"> | ||
<Library.Example title="Basic usage"> | ||
<Library.Demo withSource> | ||
<Spinner /> | ||
</PatternExample> | ||
<PatternExample details="loading spinner, large"> | ||
<Spinner size="large" /> | ||
</PatternExample> | ||
<PatternExample details="loading spinner, small"> | ||
</Library.Demo> | ||
</Library.Example> | ||
<Library.Example title="Small size"> | ||
<Library.Demo withSource> | ||
<Spinner size="small" /> | ||
</PatternExample> | ||
</PatternExamples> | ||
</Pattern> | ||
</PatternPage> | ||
</Library.Demo> | ||
</Library.Example> | ||
<Library.Example title="Large size"> | ||
<Library.Demo withSource> | ||
<Spinner size="large" /> | ||
</Library.Demo> | ||
</Library.Example> | ||
</Library.Pattern> | ||
</Library.Page> | ||
); | ||
} |
66 changes: 44 additions & 22 deletions
66
src/pattern-library/components/patterns/SpinnerPatterns.js
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,37 +1,59 @@ | ||
import { | ||
PatternExample, | ||
PatternExamples, | ||
PatternPage, | ||
Pattern, | ||
} from '../PatternPage'; | ||
import Library from '../Library'; | ||
|
||
import { SvgIcon } from '../../..'; | ||
|
||
export default function SpinnerPatterns() { | ||
return ( | ||
<PatternPage title="Spinners"> | ||
<Library.Page title="Spinners"> | ||
<p> | ||
The <code>spinner</code> pattern can be used to show loading states. It | ||
is an animated SVG. | ||
</p> | ||
<Pattern title="Spinner"> | ||
<Library.Pattern title="Spinner"> | ||
<p> | ||
The spinner is <code>em-sized</code>; it renders at <code>1em</code>{' '} | ||
square, by default. Other relative sizes are available as follows. For | ||
square, by default. Other relative sizes are available as shown. For | ||
manual sizing control, adjust the font-size of a parent element. | ||
Spinners have a default foreground color, which may be overridden with | ||
utility classes. | ||
</p> | ||
<PatternExamples> | ||
<PatternExample details="basic spinner"> | ||
<SvgIcon name="spinner" className="hyp-spinner" /> | ||
</PatternExample> | ||
<PatternExample details="spinner, large size"> | ||
<SvgIcon name="spinner" className="hyp-spinner--large" /> | ||
</PatternExample> | ||
<PatternExample details="spinner, small size"> | ||
<SvgIcon name="spinner" className="hyp-spinner--small" /> | ||
</PatternExample> | ||
</PatternExamples> | ||
</Pattern> | ||
</PatternPage> | ||
<Library.Example title="Default size"> | ||
<p> | ||
At its default size, the spinner is <code>2em</code> square. | ||
</p> | ||
<Library.Demo withSource> | ||
<SvgIcon name="hyp-spinner" className="hyp-spinner" /> | ||
</Library.Demo> | ||
</Library.Example> | ||
<Library.Example title="Small size"> | ||
<p> | ||
Small spinners are <code>1em</code> square and can be used inline. | ||
</p> | ||
<Library.Demo withSource> | ||
<SvgIcon name="hyp-spinner" className="hyp-spinner--small" /> | ||
</Library.Demo> | ||
</Library.Example> | ||
<Library.Example title="Large size"> | ||
<p> | ||
Large spinners are <code>4em</code> square. | ||
</p> | ||
<Library.Demo withSource> | ||
<SvgIcon name="hyp-spinner" className="hyp-spinner--large" /> | ||
</Library.Demo> | ||
</Library.Example> | ||
|
||
<Library.Example title="Changing color"> | ||
<p> | ||
The color of the spinner may be changed by use of utility classes. | ||
</p> | ||
<Library.Demo withSource> | ||
<SvgIcon | ||
name="hyp-spinner" | ||
className="hyp-spinner hyp-u-color--brand" | ||
/> | ||
</Library.Demo> | ||
</Library.Example> | ||
</Library.Pattern> | ||
</Library.Page> | ||
); | ||
} |
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,14 +1,14 @@ | ||
@use '../mixins/patterns/spinners'; | ||
|
||
.Hyp-Spinner--small { | ||
@include spinners.spinner($size: 1em); | ||
@include spinners.spinner($size: 'small'); | ||
} | ||
|
||
.Hyp-Spinner, | ||
.Hyp-Spinner--medium { | ||
@include spinners.spinner($size: 2em); | ||
@include spinners.spinner; | ||
} | ||
|
||
.Hyp-Spinner--large { | ||
@include spinners.spinner($size: 3em); | ||
@include spinners.spinner($size: 'large'); | ||
} |
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,9 +1,20 @@ | ||
@use '../../variables' as var; | ||
|
||
// Style an SVG as a loading spinner | ||
@mixin spinner($size: 2em) { | ||
color: var.$color-grey-5; | ||
/** | ||
* Style an SVG as a loading spinner | ||
* | ||
* @param {'small'|'medium'|'large'} [$size='medium'] - Relative size of | ||
* spinner image | ||
*/ | ||
@mixin spinner($size: 'medium') { | ||
$-size: 2em; | ||
@if ($size == 'large') { | ||
$-size: 4em; | ||
} @else if ($size == 'small') { | ||
$-size: 1em; | ||
} | ||
color: var.$color-grey-6; | ||
// Assure that the spinner SVG is sized proportinally to local font-size | ||
width: $size; | ||
height: $size; | ||
width: $-size; | ||
height: $-size; | ||
} |
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,14 +1,14 @@ | ||
@use '../mixins/patterns/spinners'; | ||
|
||
.hyp-spinner--small { | ||
@include spinners.spinner($size: 1em); | ||
@include spinners.spinner($size: 'small'); | ||
} | ||
|
||
.hyp-spinner, | ||
.hyp-spinner--medium { | ||
@include spinners.spinner($size: 2em); | ||
@include spinners.spinner; | ||
} | ||
|
||
.hyp-spinner--large { | ||
@include spinners.spinner($size: 3em); | ||
@include spinners.spinner($size: 'large'); | ||
} |