-
Notifications
You must be signed in to change notification settings - Fork 903
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(core/details): Creating generic component for entity details (…
- Loading branch information
1 parent
71a4d9e
commit 608b83a
Showing
2 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
app/scripts/modules/core/src/presentation/details/Details.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters