Skip to content

Commit

Permalink
refactor(core/details): Creating generic component for entity details (
Browse files Browse the repository at this point in the history
  • Loading branch information
alanmquach authored Jul 25, 2019
1 parent 71a4d9e commit 608b83a
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
54 changes: 54 additions & 0 deletions app/scripts/modules/core/src/presentation/details/Details.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import * as React from 'react';
import { UISref } from '@uirouter/react';

import { Spinner } from 'core/widgets/spinners/Spinner';

interface IDetailsProps {
loading: boolean;
}

interface IDetailsHeaderProps {
icon: React.ReactNode;
name: string;
}

interface IDetailsSFCWithExtras extends React.SFC<IDetailsProps> {
Header: React.SFC<IDetailsHeaderProps>;
}

const CloseButton = (
<div className="close-button">
<UISref to="^">
<a className="btn btn-link">
<span className="glyphicon glyphicon-remove" />
</a>
</UISref>
</div>
);

const DetailsHeader: React.SFC<IDetailsHeaderProps> = props => (
<div className="header">
{CloseButton}
<div className="header-text horizontal middle">
{props.icon}
<h3 className="horizontal middle space-between flex-1">{props.name}</h3>
</div>
<div>{props.children}</div>
</div>
);

const loading = (
<div className="header">
<div className="horizontal center middle spinner-container">
<Spinner />
</div>
</div>
);

const Details: IDetailsSFCWithExtras = props => (
<div className="details-panel">{props.loading ? loading : props.children}</div>
);

Details.Header = DetailsHeader;

export { Details };
1 change: 1 addition & 0 deletions app/scripts/modules/core/src/presentation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export * from './TetheredCreatable';
export * from './Tooltip';
export * from './WatchValue';
export * from './collapsibleSection/CollapsibleSection';
export * from './details/Details';
export * from './forms';
export * from './robotToHumanFilter/robotToHuman.filter';
export * from './sortToggle';
Expand Down

0 comments on commit 608b83a

Please sign in to comment.