Skip to content
This repository was archived by the owner on Nov 25, 2025. It is now read-only.

Commit 86c8864

Browse files
DeividasBakanasGiedriusGrabauskas
authored andcommitted
v2.0.0 source added. (#1)
* v2.0.0 source added. * `npm run server` -> `npm run example` in example. PeerDependencies moved to Dependencies package.json. * .gitignore minified. LoaderId changed to protected in loader-base.ts. Context added to bubble-loader and spinner-loader constructors. Unnecessary parameter `prop` removed from `AppendStyles` in `loader-base.ts`. README.md changed to follow changes in source files. homepage link updated. `package.json` removed from `files` array. classNames added to example as a dependency. imageClass changed to className in logo.tsx of example. * 2.0.0-beta.1 * `AppendStyles` parameters changed in `base-loader`. README.md updated. * cleanup-package-json deleted. CHANGELOG.md updated. README.md updated. example changed to be private package. * ReactDom updated in example. * Update .gitignore * 2.0.0-beta.2 * `shouldReduceSize` changed to `shouldExpand`. CHANGELOG.md and README.md updated. `description` changed in package.json. * 2.0.0-beta.3
1 parent 83c912a commit 86c8864

46 files changed

Lines changed: 2001 additions & 2 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
node_modules
2+
example/dist
3+
example/node_modules
4+
example/@types
5+
builds
6+
src/*/*-loader-style.ts
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
/// <reference types="react" />
2+
import * as React from "react";
3+
/**
4+
* className of a loader when it is reduced.
5+
*
6+
* @export
7+
* @const REDUCED_LOADER_CLASSNAME
8+
*/
9+
export declare const REDUCED_LOADER_CLASSNAME = "reduced";
10+
/**
11+
* className of a loader when it is expanded.
12+
*
13+
* @export
14+
* @const EXPANDED_LOADER_CLASSNAME
15+
*/
16+
export declare const EXPANDED_LOADER_CLASSNAME = "expanded";
17+
/**
18+
* Base props of all loader components in simplr-loaders.
19+
*
20+
* @export
21+
* @interface BaseProps
22+
*/
23+
export interface BaseProps {
24+
/**
25+
* Custom class name of a loader.
26+
*
27+
* @type {string}
28+
* @memberOf BaseProps
29+
*/
30+
className?: string;
31+
/**
32+
* Specifies whether style should be placed in <head>.
33+
* This is a default behavior you can cancel.
34+
*
35+
* @type {boolean}
36+
* @memberOf BaseProps
37+
*/
38+
useDefaultStyle?: boolean;
39+
/**
40+
* Specifies whether the loader should expand to take all possible area.
41+
* Default value `true`.
42+
* Using this prop you can cancel the default behavior.
43+
* In that case the loader will take an area of a strict size.
44+
*
45+
* @type {boolean}
46+
* @memberOf BaseProps
47+
*/
48+
shouldExpand?: boolean;
49+
}
50+
/**
51+
* Base class of all loader components in simplr-loaders.
52+
*
53+
* @export
54+
* @abstract
55+
* @class LoaderBase
56+
* @extends {React.PureComponent<TProps, TState>}
57+
* @template TProps interface of loader component Props.
58+
* @template TState interface of loader component State.
59+
*/
60+
export declare abstract class LoaderBase<TProps extends BaseProps, TState> extends React.PureComponent<TProps, TState> {
61+
/**
62+
* Unique identifier of a loader.
63+
* Used in `protected AppendStyles` to prevent styles duplications.
64+
*/
65+
protected abstract LoaderId: string;
66+
/**
67+
* Puts stringified stylesheet of a loader to the `<head>`.
68+
* @param styles {string} strigified stylesheet of a loader.
69+
* @param props {TProps} props of loader component.
70+
*/
71+
protected AppendStyles(styles: string, props: TProps): void;
72+
/**
73+
* Default className of a loader component.
74+
*
75+
* @protected
76+
* @type {string}
77+
* @memberOf LoaderBase
78+
*/
79+
protected StylesClass: string;
80+
/**
81+
* Aggregates all classNames used inside a loader.
82+
*
83+
* @readonly
84+
* @protected
85+
*
86+
* @memberOf LoaderBase
87+
*/
88+
protected readonly AggregatedClassName: string;
89+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export declare var BubbleLoaderStyle: string;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/// <reference types="react" />
2+
import { LoaderBase, BaseProps } from "../abstractions/loader-base";
3+
/**
4+
* Class of bubble loader component.
5+
*
6+
* @export
7+
* @class BubbleLoader
8+
* @extends {LoaderBase<BaseProps, {}>}
9+
*/
10+
export declare class BubbleLoader extends LoaderBase<BaseProps, {}> {
11+
constructor(props: BaseProps, context: any);
12+
/**
13+
* Id of bubble loader.
14+
*
15+
* @type {string}
16+
* @memberOf BubbleLoader
17+
*/
18+
protected LoaderId: string;
19+
render(): JSX.Element;
20+
}

@types/simplr-loaders.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { BubbleLoader } from "./bubble-loader/bubble-loader";
2+
export { SpinnerLoader } from "./spinner-loader/spinner-loader";
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export declare var SpinnerLoaderStyle: string;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/// <reference types="react" />
2+
import { LoaderBase, BaseProps } from "../abstractions/loader-base";
3+
/**
4+
* Class of spinner loader component.
5+
*
6+
* @export
7+
* @class SpinnerLoader
8+
* @extends {LoaderBase<BaseProps, {}>}
9+
*/
10+
export declare class SpinnerLoader extends LoaderBase<BaseProps, {}> {
11+
constructor(props: BaseProps, context: any);
12+
/**
13+
* Id of spinner loader.
14+
*
15+
* @type {string}
16+
* @memberOf SpinnerLoader
17+
*/
18+
protected LoaderId: string;
19+
render(): JSX.Element;
20+
}

CHANGELOG.md

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
## Changes in 2.0.0 (2017-04-18)
2+
3+
### [Breaking changes]
4+
- Directories structure changed. All production files moved to `dist` folder.
5+
- `blackLoader` prop removed from `SpinnerLoader`.
6+
- `color` prop removed from `BubbleLoader`.
7+
- `shouldReduceSize` props changed to `shouldExpand`. Default value `shouldExpand={true}`.
8+
9+
`color` and `blackLoader` props are removed leaving you a posibility to set them using CSS.
10+
11+
Setting color of `SpinnerLoader`:
12+
```css
13+
.spinner-loader .loader-container .loader {
14+
color: green;
15+
}
16+
```
17+
18+
Setting color of `BubbleLoader`:
19+
```css
20+
.bubble-loader .bounce {
21+
background-color: red;
22+
}
23+
```
24+
25+
### [Fixes]
26+
- Fixed issue that blocked the ability to set color of `SpinnerLoader` and `BubbleLoader` using CSS.
27+
28+
### [Dev]
29+
- `glob-uglifyjs` version updated.
30+
- `pushstate-server` moved to `example`.
31+
- `react` and `@types/react` versions updated.
32+
- `tslint` added.
33+
- `css-to-ts` added to have css in TypeScript files.
34+
- Example build changed (check README.md for more information).
35+
- LoaderBase introduced as a base class for all loaders.
36+
37+
## Changes in 1.0.1 (2017-02-05)
38+
39+
### [Dev]
40+
- `@types/react` version fixed to `15.0.0`.
41+
42+
43+
## Changes in 1.0.0 (2017-02-05)
44+
45+
### [Feature]
46+
- Loaders size is expanded and centered by default.
47+
- Reduced and expanded loaders examples added.
48+
- `shouldReduceSize` prop added.
49+
- `spinner-loader` default class name added to `SpinnerLoader`.
50+
51+
### [Dev]
52+
- `node-sass` version updated.
53+
- `@types/react` updated.
54+
55+
### [Breaking changes]
56+
- `loader-small` class name changed to `bubble-loader` for `BubbleLoader`.
57+
- Additional container added for `SpinnerLoader`.

README.md

Lines changed: 182 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,182 @@
1-
# simplr-loaders
2-
React css loaders with no prerequisite style loading.
1+
# simplr-loaders
2+
React CSS loaders with no prerequisites for required styles loading.
3+
4+
# Get started
5+
6+
```sh
7+
$ npm install simplr-loaders --save
8+
```
9+
10+
# Usage
11+
12+
```ts
13+
import * as React from "react";
14+
import { BubbleLoader } from "simplr-loaders";
15+
16+
export class MyComponent extends React.Component<{}, {}> {
17+
render() {
18+
return <BubbleLoader />;
19+
}
20+
}
21+
```
22+
23+
## Loaders
24+
25+
This package currently contains two loaders:
26+
- `SpinnerLoader`
27+
- `BubbleLoader`
28+
29+
If you'd like to see more loaders here feel free to contribute.
30+
31+
## Style
32+
33+
### Stylesheets
34+
35+
You don't need to import loaders stylesheets. By default they are loaded after first use of a loader component.
36+
37+
If you still want to load css yourself, you can cancel default behavior by setting `useDefaultStyle={false}`.
38+
and load it from stylesheets that are included in this package.
39+
40+
### Use of space
41+
42+
We found it useful for loaders to center itself and expand to take all possible area around.
43+
44+
If you want to position loader yourself you can set prop `shouldExpand={false}`.
45+
46+
# Example
47+
1. Clone this repository
48+
2. Install packages in simplr-loaders root directory:
49+
```sh
50+
$ npm install
51+
```
52+
3. Go to 'example' folder and run:
53+
```sh
54+
$ npm run example && npm run start
55+
```
56+
57+
# API
58+
59+
## LoaderBase
60+
61+
```ts
62+
export abstract class LoaderBase<TProps extends BaseProps, TState> extends React.PureComponent<TProps, TState>
63+
```
64+
`LoaderBase` is a base class of all loader components in `simplr-loaders`.
65+
66+
### `protected abstract LoaderId: string;`
67+
Unique identifier of a loader.
68+
69+
### `protected StylesClass: string;`
70+
Default className of a loader component. If not declared, `LoaderId` will be taken as default className.
71+
72+
### `protected AppendStyles(styles: string, props: TProps)`
73+
Puts stringified stylesheet of a loader into the `<head>`.
74+
75+
`styles: string` - stringified stylesheet.
76+
77+
`props: TProps` - component props.
78+
79+
### `protected get AggregatedClassName()`
80+
Aggregates all classNames of a loader:
81+
- default className defined in `StylesClass`
82+
- `props.className`
83+
- className that defines how loader use the space (whether it's size should be expanded or reduced).
84+
85+
## BaseProps
86+
Base props of all loader components in simplr-loaders.
87+
88+
```ts
89+
export interface BaseProps {
90+
/**
91+
* Custom class name of a loader.
92+
*
93+
* @type {string}
94+
* @memberOf BaseProps
95+
*/
96+
className?: string;
97+
/**
98+
* Specifies whether style should be placed in <head>.
99+
* This is a default behavior you can cancel.
100+
*
101+
* @type {boolean}
102+
* @memberOf BaseProps
103+
*/
104+
useDefaultStyle?: boolean;
105+
/**
106+
* Specifies whether the loader should expand to take all possible area.
107+
* Default value `true`.
108+
* Using this prop you can cancel the default behavior.
109+
* In that case the loader will take an area of a strict size.
110+
*
111+
* @type {boolean}
112+
* @memberOf BaseProps
113+
*/
114+
shouldExpand?: boolean;
115+
}
116+
```
117+
118+
# Contribution
119+
120+
If you want to add loader to this package you'll need to know basic concepts of:
121+
- [`TypeScript`](https://www.typescriptlang.org/docs/tutorial.html)
122+
- [`SCSS`](http://sass-lang.com/guide)
123+
- [`React`](https://facebook.github.io/react/tutorial/tutorial.html)
124+
125+
In `src/your-loader-folder` should be placed three files:
126+
- Stylesheet written in SCSS;
127+
- React component of a loader written in TypeScript;
128+
- TypeScript file with exported stringified stylesheet of your loader (automatically generated with [`css-to-ts`](https://www.npmjs.com/package/css-to-ts) when building).
129+
130+
## Component
131+
132+
Use TypeScript to create component class:
133+
134+
```ts
135+
import * as React from "react";
136+
137+
// `MyLoaderStyle` TypeScript file with stringified css will be generated from your stylesheet when build is started.
138+
// But you still have to import it.
139+
import { MyLoaderStyle } from "./spinner-loader-style";
140+
141+
import { LoaderBase, BaseProps } from "../abstractions/loader-base";
142+
143+
// Loader MUST extend LoaderBase class.
144+
// Every loader MUST have props that are defined in BaseProps.
145+
// If you need more props, you can create your own interface with BaseProps extended.
146+
export class MyLoader extends LoaderBase<BaseProps, {}> {
147+
148+
// Load style using `AppendStyles` from LoaderBase.
149+
constructor(props: BaseProps, context: any) {
150+
super(props, context);
151+
this.AppendStyles(MyLoaderStyle, props);
152+
}
153+
154+
// Define loader id.
155+
// Id is used to identify style in `<head>`.
156+
protected LoaderId: string = "my-loader";
157+
158+
// This property is optional.
159+
// If you don't define `StylesClass`, `LoaderId` will be taken as 'StylesClass'.
160+
protected StylesClass: string = "class-name-of-my-loader";
161+
162+
// Define containers structure that your loader requires.
163+
render() {
164+
// Use `AggregatedClassName` from `LoaderBase` to define all classNames of your loader.
165+
return <div className={this.AggregatedClassName}>
166+
<div></div>
167+
<div></div>
168+
</div>;
169+
}
170+
}
171+
```
172+
173+
## StyleSheet
174+
Use SCSS to write a loader's stylesheet.
175+
176+
Next to all styles of your loader you should implement two additional classNames:
177+
178+
- `.expanded` when loader takes all area of parrent container (default).
179+
- `.reduced` when loader takes strict area. Basically it should contain specified height and width.
180+
181+
# License
182+
Released under the [MIT license](LICENSE).

dist/abstractions/loader-base.js

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)