Skip to content

Commit 13fe984

Browse files
committed
rename Loader to Loading
1 parent b586294 commit 13fe984

10 files changed

Lines changed: 48 additions & 50 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ MML React components could be divided in four categories:
6868
- [`Input`](/components/input): an input field
6969
- [`MD`](/components/md): renders markdown
7070
- [`Icon`](/components/icon): simply displays an icon from material design icons
71-
- [`Loader`](/components/loader): signals a _loading_ temporary state with a circular spinner
71+
- [`Loading`](/components/loading): signals a _loading_ temporary state with a circular spinner
7272
- [`Error`](/components/error): display an _error_ message
7373
- [`Success`](/components/success): display a _success_ message
7474

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,41 +1,41 @@
11
---
2-
route: /components/loader
2+
route: /components/loading
33
menu: Utility Components
44
---
55

66
import { Playground, Props } from 'docz';
7-
import { Loader } from './Loader.tsx';
7+
import { Loading } from './Loading.tsx';
88

9-
# Loader
9+
# Loading
1010

11-
Loader simply indicates a loading/pending state, you can use it to manage users expectations during async behaviours or waiting times. Internally it uses the `<Progress />` component to show a circular progress indicator.
11+
Loading simply indicates a loading/pending state, you can use it to manage users expectations during async behaviours or waiting times. Internally it uses the `<Progress />` component to show a circular progress indicator.
1212

1313
> This component is not exposed as `mml` string, it is used internally in other mml components and it can be imported to create your custom ones.
1414
1515
## Properties
1616

17-
<Props of={Loader} />
17+
<Props of={Loading} />
1818

1919
## Basic usage
2020

2121
<Playground>
22-
<Loader loading={true} />
22+
<Loading loading={true} />
2323
</Playground>
2424

2525
## With text
2626

2727
<Playground>
28-
<Loader loading={true} text="Please wait..." />
28+
<Loading loading={true} text="Please wait..." />
2929
</Playground>
3030

3131
## Style customization
3232

3333
If your projects include a `sass` compilation step you might customize the overall look and feel of the component through `scss` variables, here are all the available ones with their default values:
3434

3535
```scss
36-
// Loader:
37-
$mml-loader-spacer: $mml-spacer;
38-
$mml-loader-font-size: 88%;
36+
// Loading:
37+
$mml-loading-spacer: $mml-spacer;
38+
$mml-loading-font-size: 88%;
3939

4040
// Progress:
4141
$mml-progress-width: 1em;
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { FC } from 'react';
22
import { Progress, ProgressProps } from './Progress';
33

4-
export type LoaderProps = {
4+
export type LoadingProps = {
55
/**
66
* Flag that indicates whether the component should show
77
* @default false
@@ -19,15 +19,15 @@ export type LoaderProps = {
1919
} & ProgressProps;
2020

2121
/**
22-
* Loader indicator
22+
* Loading indicator
2323
*/
24-
export const Loader: FC<LoaderProps> = ({ className = '', loading = false, text, size, thickness, color }) => {
24+
export const Loading: FC<LoadingProps> = ({ className = '', loading = false, text, size, thickness, color }) => {
2525
if (!loading) return null;
2626

2727
return (
28-
<div className={`mml-loader ${className}`}>
28+
<div className={`mml-loading ${className}`}>
2929
<Progress {...{ size, thickness, color }} />
30-
{text && <div className="mml-loader__text">{text}</div>}
30+
{text && <div className="mml-loading__text">{text}</div>}
3131
</div>
3232
);
3333
};

src/components/Scheduler.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { Card } from './Card';
88
import { CardHeader } from './CardHeader';
99
import { CardBody } from './CardBody';
1010
import { Error as ErrorComponent } from './Error';
11-
import { Loader as LoaderComponent } from './Loader';
11+
import { Loading as LoadingComponent } from './Loading';
1212

1313
export type SchedulerProps = {
1414
/**
@@ -104,7 +104,7 @@ export const Scheduler: FC<SchedulerProps> = ({
104104
<CardHeader icon="date_range" text="Scheduler" />
105105
<CardBody>
106106
{error && !loading && <ErrorComponent error={`Failed, error: ${error}`} />}
107-
{!error && loading && <LoaderComponent loading={true} text="Loading availability" />}
107+
{!error && loading && <LoadingComponent loading={true} text="Loading availability" />}
108108
{!error && !loading && (
109109
<DatePicker
110110
name={name}

src/components/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export * from './Error';
1111
export * from './Icon';
1212
export * from './Image';
1313
export * from './Input';
14-
export * from './Loader';
14+
export * from './Loading';
1515
export * from './MD';
1616
export * from './Number';
1717
export * from './Row';

src/mml/MML.tsx

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useState, useMemo, useCallback, FC, ComponentType, FormEvent } from 'react';
22

33
import { Parse, ConvertorType } from '../parser';
4-
import { Loader as LoaderComponent, LoaderProps } from '../components/Loader';
4+
import { Loading as LoadingComponent, LoadingProps } from '../components/Loading';
55
import { Error as ErrorComponent, ErrorProps } from '../components/Error';
66
import { Success as SuccessComponent, SuccessProps } from '../components/Success';
77

@@ -26,12 +26,12 @@ export type MMLProps = {
2626
| string;
2727
/** Custom classname, appended to wrapper classname */
2828
className?: string;
29-
/** The Loader component */
30-
Loader?: ComponentType<LoaderProps>;
31-
/** The error component */
32-
Error?: ComponentType<ErrorProps>;
33-
/** The success message component */
34-
Success?: ComponentType<SuccessProps>;
29+
/** The Loading component, accepts null to render nothing */
30+
Loading?: ComponentType<LoadingProps> | null;
31+
/** The error component, accepts null to render nothing */
32+
Error?: ComponentType<ErrorProps> | null;
33+
/** The success message component, accepts null to render nothing */
34+
Success?: ComponentType<SuccessProps> | null;
3535
};
3636

3737
/**
@@ -43,7 +43,7 @@ export const MML: FC<MMLProps> = ({
4343
converters,
4444
theme = '',
4545
className = '',
46-
Loader = LoaderComponent,
46+
Loading = LoadingComponent,
4747
Error = ErrorComponent,
4848
Success = SuccessComponent,
4949
}) => {
@@ -85,15 +85,13 @@ export const MML: FC<MMLProps> = ({
8585
return (
8686
<div className={`mml-container ${theme} ${className}`} data-testid="mml-container">
8787
{error ? (
88-
<div className="mml-wrap">
89-
<Error error={error} />
90-
</div>
88+
<div className="mml-wrap">{Error && <Error error={error} />}</div>
9189
) : (
9290
<form onSubmit={handleSubmit} className="mml-wrap" data-testid="mml-form">
9391
{tree?.type ? <div className="mml-card">{tree?.reactElements}</div> : tree?.reactElements}
94-
{submitState.loading && <Loader loading={submitState.loading} />}
95-
{submitState.success && <Success success={submitState.success} />}
96-
{submitState.error && <Error error={submitState.error} />}
92+
{submitState.loading && Loading && <Loading loading={submitState.loading} />}
93+
{submitState.success && Success && <Success success={submitState.success} />}
94+
{submitState.error && Error && <Error error={submitState.error} />}
9795
</form>
9896
)}
9997
</div>

src/styles/common/_variables.scss

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,10 +134,10 @@ $mml-input-color: mml-theme-val(text-mid-emphasis) !default;
134134
$mml-input-focus-color: mml-theme-val(text-high-emphasis) !default;
135135
$mml-input-focus-outline: $mml-btn-focus-outline !default;
136136

137-
// Loader:
137+
// Loading:
138138
// -----------------------------------------------------------------------------
139-
$mml-loader-spacer: $mml-spacer !default;
140-
$mml-loader-font-size: 88% !default;
139+
$mml-loading-spacer: $mml-spacer !default;
140+
$mml-loading-font-size: 88% !default;
141141

142142
// Progress:
143143
// -----------------------------------------------------------------------------

src/styles/components/Loader/_base.scss

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
@import '../Progress/base';
2+
3+
@include mml-component('loading') {
4+
display: flex;
5+
align-items: center;
6+
justify-content: center;
7+
padding: $mml-loading-spacer;
8+
font-size: $mml-loading-font-size;
9+
10+
&__text {
11+
padding-left: $mml-loading-spacer;
12+
}
13+
}

src/styles/components/index.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
@import 'Icon/base';
99
@import 'Image/base';
1010
@import 'Input/base';
11-
@import 'Loader/base';
11+
@import 'Loading/base';
1212
@import 'MD/base';
1313
@import 'Number/base';
1414
@import 'Row/base';

0 commit comments

Comments
 (0)