Skip to content

Commit

Permalink
refactor(ui): spinner - export react element type
Browse files Browse the repository at this point in the history
  • Loading branch information
Artur Yorsh committed Jul 26, 2019
1 parent c5318b7 commit 7dded0d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
1 change: 1 addition & 0 deletions src/framework/ui/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export {
export {
Spinner,
SpinnerProps,
SpinnerElement,
} from './spinner/spinner.component';
export {
TabView,
Expand Down
13 changes: 7 additions & 6 deletions src/framework/ui/spinner/spinner.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,13 @@ interface ComponentProps extends ViewProps {
}

export type SpinnerProps = StyledComponentProps & ComponentProps;
export type SpinnerElement = React.ReactElement<SpinnerProps>;

/**
* Styled Spinner component. Designed to be used as ActivityIndicator component
*
* @property {boolean} animating - Determines whether component is animating. Default is `true`.
* @property {string} circleSize - Determines the the component.
* @property {string} containerSize - Determines the the component.
* Can be `giant`, `large`, `medium`, `small` or `tiny`.
* Default is `medium`.
* @property status - Determines the status of the component.
Expand Down Expand Up @@ -144,9 +145,9 @@ export class SpinnerComponent extends React.PureComponent<SpinnerProps> {
animating: true,
};

private animation: SpinnerAnimation = new SpinnerAnimation(this.circleSize.height);
private animation: SpinnerAnimation = new SpinnerAnimation(this.containerSize.height);

private get circleSize(): Size {
private get containerSize(): Size {
const { width, height } = StyleSheet.flatten([this.props.themedStyle, this.props.style]);
// @ts-ignore: width and height are restricted to be a number
return new Size(width, height);
Expand Down Expand Up @@ -191,7 +192,7 @@ export class SpinnerComponent extends React.PureComponent<SpinnerProps> {
const end: ArcElementStyle = {
container: source.container,
arc: source.end,
overflow: { top: this.circleSize.height / 2 },
overflow: { top: this.containerSize.height / 2 },
};

return { start, end };
Expand All @@ -214,7 +215,7 @@ export class SpinnerComponent extends React.PureComponent<SpinnerProps> {
};

public render(): React.ReactElement<ViewProps> {
const containerSize: Size = this.circleSize;
const containerSize: Size = this.containerSize;
const { start, end } = this.getComponentStyle(this.animation.toProps());

return (
Expand All @@ -233,4 +234,4 @@ const styles = StyleSheet.create({
},
});

export const Spinner = styled(SpinnerComponent);
export const Spinner = styled<SpinnerProps>(SpinnerComponent);

0 comments on commit 7dded0d

Please sign in to comment.