1
0
Fork 0
mirror of https://github.com/anyproto/anytype-ts.git synced 2025-06-08 05:57:02 +09:00

loader functional + refactoring

This commit is contained in:
Andrew Simachev 2024-11-25 11:09:41 +01:00
parent 02480e90c2
commit a122ae9d41
No known key found for this signature in database
GPG key ID: 1DFE44B21443F0EF
7 changed files with 43 additions and 40 deletions

View file

@ -40,7 +40,7 @@ const Create = observer(class Create extends React.Component<I.PageComponent, St
return (
<div ref={ref => this.node = ref} className="page pageCreate">
{isLoading ? <Loader type="loader" /> : ''}
{isLoading ? <Loader type={I.LoaderType.Loader} /> : ''}
<div className="head">
<div className="side left">

View file

@ -62,7 +62,7 @@ const Create = observer(class Create extends React.Component<I.PageComponent, St
ref={ref => this.node = ref}
className="page pageCreate"
>
{isLoading ? <Loader type="loader" /> : ''}
{isLoading ? <Loader type={I.LoaderType.Loader} /> : ''}
<form onSubmit={this.onSubmit}>
<div className="rows">

View file

@ -910,7 +910,7 @@ const Block = observer(class Block extends React.Component<Props> {
let icon = null;
if (_empty_) {
icon = <Loader type="loader" className={[ 'c' + size, 'inline' ].join(' ')} />;
icon = <Loader type={I.LoaderType.Loader} className={[ 'c' + size, 'inline' ].join(' ')} />;
} else {
icon = (
<IconObject

View file

@ -51,7 +51,7 @@ const BlockLink = observer(class BlockLink extends React.Component<I.BlockCompon
className="loading"
{...U.Common.dataProps({ 'target-block-id': object.id })}
>
<Loader type="loader" />
<Loader type={I.LoaderType.Loader} />
<div className="name">{translate('blockLinkSyncing')}</div>
</div>
);

View file

@ -12,7 +12,7 @@ interface Props {
onMouseLeave?: (e: any) => void;
onMouseDown?: (e: any) => void;
onClick?: (e: any) => void;
}
};
const Label: FC<Props> = ({
id = '',
@ -54,6 +54,7 @@ const Label: FC<Props> = ({
{...U.Common.dataProps({ ...dataset, content: text, 'animation-type': I.AnimType.Text })}
/>
);
};
export default Label;

View file

@ -1,47 +1,44 @@
import * as React from 'react';
import React, { forwardRef } from 'react';
import { I } from 'Lib';
interface Props {
id?: string;
type?: string;
type?: I.LoaderType;
className?: string;
};
class Loader extends React.Component<Props> {
const Loader = forwardRef<HTMLDivElement, Props>(({
id = '',
type = I.LoaderType.Dots,
className = '',
}, ref) => {
public static defaultProps = {
className: '',
type: 'dots',
};
render () {
const { id, type, className } = this.props;
let content = null;
switch (type) {
case 'loader': {
content = <div className="loader" />;
break;
};
case 'dots': {
content = (
<div className="dots">
<div className="dot" />
<div className="dot" />
<div className="dot" />
</div>
);
break;
};
let content = null;
switch (type) {
default:
case I.LoaderType.Dots: {
content = (
<div className="dots">
<div className="dot" />
<div className="dot" />
<div className="dot" />
</div>
);
break;
};
return (
<div id={id} className={[ 'loaderWrapper', className ].join(' ')}>
{content}
</div>
);
case I.LoaderType.Loader: {
content = <div className="loader" />;
break;
};
};
};
return (
<div id={id} className={[ 'loaderWrapper', className ].join(' ')}>
{content}
</div>
);
});
export default Loader;

View file

@ -313,4 +313,9 @@ export enum SortId {
LastUsed = 'lastUsed',
List = 'list',
Compact = 'compact',
};
export enum LoaderType {
Loader = 'loader',
Dots = 'dots',
};