Skip to content

Commit 126dbf6

Browse files
authored
feat(components): Add condensed styles to Table (#458)
* Add condensed styles * Replace [PRIVATE] with @Private attribute in Table * Add tests
1 parent 56fd262 commit 126dbf6

File tree

13 files changed

+562
-30
lines changed

13 files changed

+562
-30
lines changed

src/components/Table/Table.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -154,9 +154,10 @@ class Table extends Component {
154154
const {
155155
rowHeaders,
156156
headers,
157-
onRowClick,
158157
noShadow,
159-
borderCollapsed
158+
borderCollapsed,
159+
condensed,
160+
onRowClick
160161
} = this.props;
161162
const { sortDirection, sortHover, sortedRow } = this.state;
162163

@@ -177,6 +178,7 @@ class Table extends Component {
177178
borderCollapsed={borderCollapsed}
178179
>
179180
<TableHead
181+
condensed={condensed}
180182
sortDirection={sortDirection}
181183
sortedRow={sortedRow}
182184
onSortBy={this.onSortBy}
@@ -186,6 +188,7 @@ class Table extends Component {
186188
rowHeaders={rowHeaders}
187189
/>
188190
<TableBody
191+
condensed={condensed}
189192
rows={this.getSortedRows()}
190193
rowHeaders={rowHeaders}
191194
sortHover={sortHover}
@@ -223,6 +226,10 @@ Table.propTypes = {
223226
* Removes the default box-shadow from the table.
224227
*/
225228
noShadow: PropTypes.bool,
229+
/**
230+
* Toggles condensed styles on the Table.
231+
*/
232+
condensed: PropTypes.bool,
226233
/**
227234
* Custom onSortBy function for the onSort handler.
228235
* The signature is (index, nextDirection, currentRows) and it should return

src/components/Table/Table.spec.js

+5
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ describe('Table', () => {
4949
);
5050
expect(actual).toMatchSnapshot();
5151
});
52+
53+
it('should render a condensed table', () => {
54+
const actual = create(<Table headers={headers} rows={items} condensed />);
55+
expect(actual).toMatchSnapshot();
56+
});
5257
});
5358

5459
describe('Accessibility tests', () => {

src/components/Table/Table.story.js

+1
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ storiesOf(`${GROUPS.COMPONENTS}|Table`, module)
7070
headers={headers}
7171
rows={rows}
7272
rowHeaders={boolean('Mobile rows', false)}
73+
condensed={boolean('Condensed', false)}
7374
noShadow={boolean('Without Shadow', false)}
7475
onRowClick={action('onRowClick')}
7576
borderCollapsed={boolean('Border collapsed', false)}

0 commit comments

Comments
 (0)