Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TableCell] Better handle long text #8685

Merged
merged 2 commits into from
Oct 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions docs/src/pages/demos/tables/BasicTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,14 @@ import Table, { TableBody, TableCell, TableHead, TableRow } from 'material-ui/Ta
import Paper from 'material-ui/Paper';

const styles = theme => ({
paper: {
root: {
width: '100%',
marginTop: theme.spacing.unit * 3,
overflowX: 'auto',
},
table: {
width: 700,
},
});

let id = 0;
Expand All @@ -32,8 +35,8 @@ function BasicTable(props) {
const { classes } = props;

return (
<Paper className={classes.paper}>
<Table>
<Paper className={classes.root}>
<Table className={classes.table}>
<TableHead>
<TableRow>
<TableCell>Dessert (100g serving)</TableCell>
Expand Down
11 changes: 9 additions & 2 deletions docs/src/pages/demos/tables/EnhancedTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,11 @@ class EnhancedTableHead extends React.Component {
numeric={column.numeric}
padding={column.disablePadding ? 'none' : 'default'}
>
<Tooltip title="Sort" placement="bottom-end" enterDelay={300}>
<Tooltip
title="Sort"
placement={column.numeric ? 'bottom-end' : 'bottom-start'}
enterDelay={300}
>
<TableSortLabel
active={orderBy === column.id}
direction={order}
Expand Down Expand Up @@ -163,6 +167,9 @@ const styles = theme => ({
width: '100%',
marginTop: theme.spacing.unit * 3,
},
table: {
width: 800,
},
tableWrapper: {
overflowX: 'auto',
},
Expand Down Expand Up @@ -264,7 +271,7 @@ class EnhancedTable extends React.Component {
<Paper className={classes.root}>
<EnhancedTableToolbar numSelected={selected.length} />
<div className={classes.tableWrapper}>
<Table>
<Table className={classes.table}>
<EnhancedTableHead
numSelected={selected.length}
order={order}
Expand Down
9 changes: 3 additions & 6 deletions src/Table/TableCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,21 +50,19 @@ export type Props = {
export const styles = (theme: Object) => ({
root: {
borderBottom: `1px solid ${theme.palette.text.lightDivider}`,
whiteSpace: 'nowrap',
textOverflow: 'ellipsis',
textAlign: 'left',
},
numeric: {
textAlign: 'right',
flexDirection: 'row-reverse', // can be dynamically inherited at runtime by contents
},
head: {
whiteSpace: 'pre',
fontWeight: theme.typography.fontWeightMedium,
position: 'relative', // Workaround for Tooltip positioning issue.
},
paddingDefault: {
padding: `0 ${theme.spacing.unit * 7}px 0 ${theme.spacing.unit * 3}px`,
padding: `${theme.spacing.unit / 2}px ${theme.spacing.unit * 7}px ${theme.spacing.unit /
2}px ${theme.spacing.unit * 3}px`,
'&:last-child': {
paddingRight: theme.spacing.unit * 3,
},
Expand All @@ -73,8 +71,7 @@ export const styles = (theme: Object) => ({
paddingRight: theme.spacing.unit * 3,
},
paddingCheckbox: {
paddingLeft: 12,
paddingRight: 12,
padding: '0 12px',
},
footer: {
borderBottom: 0,
Expand Down
32 changes: 15 additions & 17 deletions src/Table/TablePagination.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ export const styles = (theme: Object) => ({
caption: {
flexShrink: 0,
},
selectRoot: {
marginRight: theme.spacing.unit * 4,
},
select: {
marginLeft: theme.spacing.unit,
width: 34,
Expand All @@ -41,9 +44,6 @@ export const styles = (theme: Object) => ({
height: 32,
lineHeight: '32px',
},
selectRoot: {
marginRight: theme.spacing.unit * 4,
},
actions: {
flexShrink: 0,
color: theme.palette.text.secondary,
Expand Down Expand Up @@ -178,20 +178,18 @@ class TablePagination extends React.Component<ProvidedProps & Props> {
<Typography type="caption" className={classes.caption}>
{labelRowsPerPage}
</Typography>
<Typography component="div" type="caption">
<Select
classes={{ root: classes.selectRoot, select: classes.select }}
input={<Input disableUnderline />}
value={rowsPerPage}
onChange={onChangeRowsPerPage}
>
{rowsPerPageOptions.map(rowsPerPageOption => (
<MenuItem key={rowsPerPageOption} value={rowsPerPageOption}>
{rowsPerPageOption}
</MenuItem>
))}
</Select>
</Typography>
<Select
classes={{ root: classes.selectRoot, select: classes.select }}
input={<Input disableUnderline />}
value={rowsPerPage}
onChange={onChangeRowsPerPage}
>
{rowsPerPageOptions.map(rowsPerPageOption => (
<MenuItem key={rowsPerPageOption} value={rowsPerPageOption}>
{rowsPerPageOption}
</MenuItem>
))}
</Select>
<Typography type="caption" className={classes.caption}>
{labelDisplayedRows({
from: count === 0 ? 0 : page * rowsPerPage + 1,
Expand Down
2 changes: 1 addition & 1 deletion src/Table/TablePagination.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ describe('<TablePagination />', () => {
assert.strictEqual(
wrapper
.find('withStyles(Typography)')
.at(2)
.at(1)
.text(),
'0-0 of 0',
);
Expand Down