mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-04 00:18:01 +01:00
added data table header component with title and actions (#55)
This commit is contained in:
parent
f56118ac0f
commit
1e5949672a
@ -8,6 +8,15 @@
|
|||||||
width: 100%;
|
width: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.horizontalScroll {
|
||||||
|
overflow-x: scroll;
|
||||||
|
-webkit-overflow-scrolling: touch;
|
||||||
|
}
|
||||||
|
|
||||||
|
.horizontalScroll::-webkit-scrollbar {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
|
||||||
.divider {
|
.divider {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
border-color: rgba(0,0,0,.12);
|
border-color: rgba(0,0,0,.12);
|
||||||
@ -22,3 +31,36 @@
|
|||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.dataTableHeader {
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
align-items: center;
|
||||||
|
height: 64px;
|
||||||
|
|
||||||
|
.title {
|
||||||
|
padding: 20px 16px 20px 24px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.titleText {
|
||||||
|
margin: 0;
|
||||||
|
font-size: 20px;
|
||||||
|
line-height: 24px
|
||||||
|
}
|
||||||
|
|
||||||
|
.actions {
|
||||||
|
flex-shrink: 0;
|
||||||
|
padding: 20px 14px 20px 16px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.switchWithLabel {
|
||||||
|
.label {
|
||||||
|
padding-right: 16px;
|
||||||
|
line-height: 24px;
|
||||||
|
}
|
||||||
|
.switch {
|
||||||
|
display: inline-block;
|
||||||
|
padding-right: 8px;
|
||||||
|
}
|
||||||
|
}
|
@ -38,6 +38,19 @@ export const HeaderTitle = ({ title, actions, subtitle }) => (
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
export const DataTableHeader = ({ title, actions }) => (
|
||||||
|
<div className={styles.dataTableHeader}>
|
||||||
|
<div className={styles.title}>
|
||||||
|
<h2 className={styles.titleText}>{title}</h2>
|
||||||
|
</div>
|
||||||
|
{actions &&
|
||||||
|
<div className={styles.actions}>
|
||||||
|
{actions}
|
||||||
|
</div>
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
export const FormButtons = ({ submitText = 'Create', onCancel }) => (
|
export const FormButtons = ({ submitText = 'Create', onCancel }) => (
|
||||||
<div>
|
<div>
|
||||||
<Button type="submit" ripple raised primary icon="add">
|
<Button type="submit" ripple raised primary icon="add">
|
||||||
@ -52,12 +65,12 @@ export const FormButtons = ({ submitText = 'Create', onCancel }) => (
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
||||||
export const SwitchWithLabel = ({ onChange, children, checked }) => (
|
export const SwitchWithLabel = ({ onChange, checked, children, ...switchProps }) => (
|
||||||
<span>
|
<span className={styles.switchWithLabel}>
|
||||||
<span style={{ cursor: 'pointer', display: 'inline-block', width: '52px' }}>
|
<span className={styles.label}>{children}</span>
|
||||||
<Switch onChange={onChange} checked={checked} />
|
<span className={styles.switch}>
|
||||||
|
<Switch checked={checked} onChange={onChange} {...switchProps} />
|
||||||
</span>
|
</span>
|
||||||
<span style={{ fontSize: '16px', lineHeight: '24px' }}>{children}</span>
|
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import React, { PureComponent } from 'react';
|
import React, { PureComponent } from 'react';
|
||||||
import { Grid, Cell } from 'react-mdl';
|
import { Card } from 'react-mdl';
|
||||||
import HistoryList from './history-list-container';
|
import HistoryList from './history-list-container';
|
||||||
|
import { styles as commonStyles } from '../common';
|
||||||
|
|
||||||
class History extends PureComponent {
|
class History extends PureComponent {
|
||||||
|
|
||||||
componentDidMount () {
|
componentDidMount () {
|
||||||
@ -18,11 +20,9 @@ class History extends PureComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Grid className="mdl-color--white">
|
<Card shadow={0} className={commonStyles.fullwidth}>
|
||||||
<Cell col={12}>
|
<HistoryList history={history} title="Recent changes" />
|
||||||
<HistoryList history={history} title="Last 100 changes" />
|
</Card>
|
||||||
</Cell>
|
|
||||||
</Grid>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ import React, { Component } from 'react';
|
|||||||
import HistoryItemDiff from './history-item-diff';
|
import HistoryItemDiff from './history-item-diff';
|
||||||
import HistoryItemJson from './history-item-json';
|
import HistoryItemJson from './history-item-json';
|
||||||
import { Table, TableHeader } from 'react-mdl';
|
import { Table, TableHeader } from 'react-mdl';
|
||||||
import { HeaderTitle, SwitchWithLabel, styles as commonStyles } from '../common';
|
import { DataTableHeader, SwitchWithLabel, styles as commonStyles } from '../common';
|
||||||
import { formatFullDateTime } from '../common/util';
|
import { formatFullDateTime } from '../common/util';
|
||||||
|
|
||||||
import styles from './history.scss';
|
import styles from './history.scss';
|
||||||
@ -44,10 +44,12 @@ class HistoryList extends Component {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={styles.history}>
|
<div className={styles.history}>
|
||||||
<HeaderTitle title={this.props.title} actions={
|
<DataTableHeader title={this.props.title} actions={
|
||||||
<SwitchWithLabel checked={showData} onChange={this.toggleShowDiff.bind(this)}>Show full events</SwitchWithLabel>
|
<SwitchWithLabel checked={showData} onChange={this.toggleShowDiff.bind(this)}>
|
||||||
|
Full events
|
||||||
|
</SwitchWithLabel>
|
||||||
}/>
|
}/>
|
||||||
<div style={{ overflowX: 'scroll' }}>
|
<div className={commonStyles.horizontalScroll}>
|
||||||
{entries}
|
{entries}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import React, { Component, PropTypes } from 'react';
|
import React, { Component, PropTypes } from 'react';
|
||||||
import ListComponent from './history-list-container';
|
import HistoryList from './history-list-container';
|
||||||
import { Link } from 'react-router';
|
|
||||||
|
|
||||||
class HistoryListToggle extends Component {
|
class HistoryListToggle extends Component {
|
||||||
|
|
||||||
@ -18,15 +17,11 @@ class HistoryListToggle extends Component {
|
|||||||
if (!this.props.history || this.props.history.length === 0) {
|
if (!this.props.history || this.props.history.length === 0) {
|
||||||
return <span>fetching..</span>;
|
return <span>fetching..</span>;
|
||||||
}
|
}
|
||||||
const { history, toggleName } = this.props;
|
const { history } = this.props;
|
||||||
return (
|
return (
|
||||||
<ListComponent
|
<HistoryList
|
||||||
history={history}
|
history={history}
|
||||||
title={
|
title="Change log"/>
|
||||||
<span>Showing history for toggle: <Link to={`/features/edit/${toggleName}`}>
|
|
||||||
<strong>{toggleName}</strong>
|
|
||||||
</Link>
|
|
||||||
</span>}/>
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
.history {
|
.history {
|
||||||
width:100%;
|
|
||||||
border-collapse: collapse;
|
|
||||||
|
|
||||||
code {
|
code {
|
||||||
word-wrap: break-word;
|
word-wrap: break-word;
|
||||||
white-space: pre;
|
white-space: pre;
|
||||||
|
Loading…
Reference in New Issue
Block a user