• Stars
    star
    194
  • Rank 200,219 (Top 4 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 8 years ago
  • Updated over 3 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Material Design spinner components for React.js.

react-md-spinner

Screenshot

Build Status npm version

Material Design spinner components for React.js.

Live example: https://tsuyoshiwada.github.io/react-md-spinner/

Table of Contents

Installation

You can install the react-md-spinner from npm.

$ npm i -S react-md-spinner
# or
$ yarn add react-md-spinner

Features

  • 🚀 You can start using with zero configuration!
  • 🔧 Support to change of color, size, border and animation speed.
  • 💖 It can also be used in single color.
  • 🌐 Support Server-Side Rendering.

Getting Started

Basic Usage

Because it is made of 100% inline styles, you can start using it right away without setting.

import React from "react";
import MDSpinner from "react-md-spinner";

export const SpinnerExample: React.FC = () => (
  <div>
    <MDSpinner />
  </div>
);

Server-Side Rendering

The following is an example of Server-Side Rendering.
Please checkout examples directory for details.

The point is to use ssrBehavior.

Example

Note: The following is pseudo code.

Client-Side:

import React from "react";
import { render } from "react-dom";
import App from "./App";

render(<App />, document.getElementById("app"));

Server-Side:

import { ssrBehavior } from "react-md-spinner";

// ...

const html = (root: JSX.Element) => `<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    ${ssrBehavior.getStylesheetString()}
  </head>
  <body>
    <div id="app">${renderToString(root)}</div>
    <script defer src="/client.js"></script>
  </body>
</html>`;

app.get("/", (_req, res) => {
  res.status(200).send(`<!doctype html>${renderer(<App />)}`);
});

App:

import React from "react";
import MDSpinner from "react-md-spinner";

export const App: React.FC = () => (
  <div>
    <MDSpinner />
  </div>
);

Props

You can use the following Props. All Props are Optional!

size

type: number
default: 28

Set the size (diameter) of the spinner circle.

borderSize

type: number
default: undefined

Set the spinner border size of. By default, the appropriate size is calculated according to the value of size.

duration

type: number
default: 1333

Set the animation duration (ms) of the spinner.

color1

type: string
default: !rgb(66, 165, 245)

The color of the spinner. Can be set to any valid CSS string (hex, rgb, rgba).

color2

type: string
default: rgb(239, 83, 80)

Same as above.

color3

type: string
default: rgb(253, 216, 53)

Same as above.

color4

type: string
default: rgb(76, 175, 80)

Same as above.

singleColor

type: string
default: undefined

Same as above. Use this if the spinner should be in only one single color. The settings (props) for color1 ~ 4 will be ignored by setting this singleColor property.

API

ssrBehavior

In Server-Side Rendering you need to inject @keyframes inside the <head>.
react-md-spinner provides utilities to handle them.

  • ssrBehavior.getStylesheetString(): string
  • ssrBehavior.getStylesheetComponent(): React.ReactNode

As string output

import { ssrBehavior } from "react-md-spinner";

const html = () => `<!doctype html>
  <head>
    ${ssrBehavior.getStylesheetString()}
  </head>
  <body>
    <div id="app">
      // React stuff here
    </div>
  </body>
</html>`;

As React Components

import React from "react";
import { ssrBehavior } from "react-md-spinner";

const Html: React.FC = () => (
  <html>
    <head>{ssrBehavior.getStylesheetComponent()}</head>
    <body>
      <div id="app">{/* React stuff here */}</div>
    </body>
  </html>
);

ChangeLog

See CHANGELOG.md

Contributing

We are always welcoming your contribution 👏

  1. Fork (https://github.com/tsuyoshiwada/react-md-spinner) 🎉
  2. Create a feature branch
  3. Run test suite with the $ yarn test command and confirm that it passes
  4. Commit your changes 📝
  5. Rebase your local changes against the master branch 💡
  6. Create new Pull Request 💌

Available Scripts

yarn test

Run unit test using Jest.

yarn lint

Run Lint of source code using ESLint.

yarn format

Run formatting using Prettier and ESLint's Fixer.

yarn build

Run build of TypeScript code.

yarn storybook

Run Storybook.

License

MIT © tsuyoshiwada

More Repositories

1

react-stack-grid

Pinterest like layout components for React.js
JavaScript
856
star
2

vim-dogrun

🐶 A dark Neovim / Vim colorscheme for the GUI and 256 / true-color terminals.
Rust
454
star
3

sweet-scroll

🍭 ECMAScript2015+ & TypeScript Friendly, dependency-free smooth scroll library.
TypeScript
384
star
4

rs-monkey-lang

Monkey Programming Language written in Rust.
Rust
256
star
5

react-drip-form

☕ HoC based React forms state manager, Support for validation and normalization.
JavaScript
65
star
6

slack-memo-vim

Simple memo manager with Vim using Slack.
Vim Script
42
star
7

jp-prefecture

Utility library dealing with prefectures and regions in Japan.
JavaScript
33
star
8

github-pr-diff-tree

🌲 This action provide a comment that displays the diff of the pull request in a tree format.
TypeScript
31
star
9

dot-wild

Use powerful dot notation (dot path + wildcard) to manipulate properties of JSON
TypeScript
29
star
10

sequential-number

An Atom package, to inputs sequential numbers across multiple cursors.
CoffeeScript
29
star
11

color-classifier

Classify the color along the reference color. using algorithm the CIEDE2000, RGB, HSV.
JavaScript
27
star
12

nvim-syntax-info

nvim-syntax-info is a plugin that displays syntax information (highlight-groups) with nvim_buf_set_virtual_text.
Vim Script
24
star
13

git-diff-archive

Archive of the diff files using node.js and git.
JavaScript
23
star
14

svg-to-jsx-with-gui

It's a tool to convert SVG to JSX on Web browser.
JavaScript
22
star
15

gin-sandbox

🐕 gin + gorm + jwt authenticate
Go
17
star
16

scs-with-reg-viz

A example repository of visual regression test using storybook-chrome-screenshot and reg-suit.
HTML
13
star
17

toy-tree

WEB+DB PRESS Vol.117「特集1 小さく始めて,大きく改善 実戦投入TypeScript」のサンプルリポジトリ
TypeScript
13
star
18

go-gitlog

Go (golang) package for providing a means to handle git-log.
Go
11
star
19

css-keyframer

Dynamic css animation keyframes Manipulation library.
JavaScript
11
star
20

git-prout

Checkout pull request locally with Golang.
Go
10
star
21

rs-td4

WebAssembly TD4 Emulator with Rust.
Rust
9
star
22

files-sync-action

📦 A customizable action that synchronizes files across multiple repositories.
TypeScript
9
star
23

htmltojsx

⚠️ [DEPRECATED] HTML to JSX converter. Forked from reactjs/react-magic. Support for SVG attributes.
JavaScript
8
star
24

cake-hash

CakePHP in Utility.Hash class like a collection manipulation. In JavaScript.
JavaScript
8
star
25

easy-css-transform-builder

Easily build CSS transform values with JavaScript.
TypeScript
8
star
26

jquery-pwd-measure

jQuery.pwdMeasure.js is jQuery plug-in that measure the strength of the password.
JavaScript
7
star
27

dotfiles

Vim Script
6
star
28

react-drip-form-material-ui

☕ Material-UI component set for react-drip-form.
JavaScript
6
star
29

react-tax-calculator

React.jsを使った消費税計算Webアプリ
JavaScript
6
star
30

lime-grid.css

Powerful Flexbox based Grid System for modern browsers.
CSS
6
star
31

redux-samples

Redux+ES6 samples
JavaScript
5
star
32

go-gitcmd

Go (golang) package providing for tiny git command wrapper.
Go
5
star
33

flamber

💥 WIP 💥 Inspiration scraping tool for Web Designer & Web Engineer.
JavaScript
5
star
34

redux-saga-sandbox

JavaScript
4
star
35

react-drip-form-components

☕ Official UI Components for react-drip-form. styling by styled-components.
JavaScript
4
star
36

blog.wadackel.me

@wadackel's blog.
Astro
4
star
37

drip-form-validator

☕ Simple and Powerful and Customizable validation library for JavaScript.
TypeScript
4
star
38

dot-wild-tiny

Use powerful dot notation (dot path + wildcard) to access properties of JSON
TypeScript
3
star
39

react-samples

JavaScript
3
star
40

sample-d3-pie-chart

JavaScript
2
star
41

jquery-image-changer

Simple jQuery plug-in that the switching of the image with the animation.
JavaScript
2
star
42

dot-finder

dot-finder is using powerful dot notation to get values in JSON object
JavaScript
2
star
43

tslint-ass-wipe-yourself

[EXPERIMENTAL RULE] A TSLint rule. annotation comment are requires assignee name.
TypeScript
2
star
44

gulp-babel-boilerplate

CSS
2
star
45

gha-docgen

📝 Generate documentation based on the Metadata of the GitHub Action.
TypeScript
1
star
46

react-selectable-sandbox

JavaScript
1
star
47

sample-jquery-tooltip

JavaScript
1
star
48

yarn-outdated-notifier-with-circleci

Example repository using yarn-outdated-notifier in CircleCI
1
star
49

react-drip-form-test-utils

Provides useful utilities for testing react-drip-form.
JavaScript
1
star
50

enzyme-sample

JavaScript
1
star
51

sample-webpack-coffee

JavaScript
1
star
52

sample-sort-colors

JavaScript
1
star
53

laravel-sandbox

PHP
1
star
54

react-drip-form-bootstrap

React Bootstrap component set for react-drip-form.
JavaScript
1
star
55

dialog-polyfill-on-ie11

HTML
1
star
56

jquery-sweet-scroll

JavaScript
1
star
57

actions-sandbox

JavaScript
1
star
58

indent2obj

Hierarchy expressed by the indent is converted into the JavaScript object.
JavaScript
1
star
59

sample-react-dnd

react-dndを使ってドラッグ&ドロップを実装するサンプル
JavaScript
1
star
60

directree

Indent text to Tree text.
CSS
1
star
61

react-lime-grid

lime-grid.css for React.js
JavaScript
1
star
62

template-obj

template strings in the javascript object.
JavaScript
1
star