Skip to content

Commit 51e2bd7

Browse files
authored
Merge pull request #559 from puppetlabs/tasks/add-fixed-last-column-dg
Add fixed last column option to data-grid Table
2 parents b609dce + 89b04d5 commit 51e2bd7

File tree

5 files changed

+39
-12
lines changed

5 files changed

+39
-12
lines changed

packages/data-grid/package-lock.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/data-grid/package.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@puppet/data-grid",
3-
"version": "0.6.4",
3+
"version": "0.6.5",
44
"author": "Puppet, Inc.",
55
"license": "Apache-2.0",
66
"main": "dist/index.js",
@@ -12,6 +12,7 @@
1212
"test": "jest",
1313
"test:coverage": "jest --collectCoverage",
1414
"test:watch": "jest --watch",
15+
"test:update": "jest --updateSnapshot",
1516
"format": "eslint --fix src/**/*.{js,jsx} && prettier --write {src}/**/*.{graphql,json,css,md} .babelrc .prettierrc package.json README.md CONTRIBUTING.md",
1617
"lint": "eslint src/**/*.{js,jsx} postcss.config.js",
1718
"prepare": "npm run build"

packages/data-grid/src/__test__/__snapshots__/Table.test.jsx.snap

+2
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ exports[`Snapshot test Check component matches previous HTML snapshot 1`] = `
7777
emptyStateMessage="Prompt to action or solution"
7878
fixed={false}
7979
fixedColumn={false}
80+
fixedLastColumn={false}
8081
headerCheckState={false}
8182
headerIndeterminateState={false}
8283
horizontalScroll={false}
@@ -442,6 +443,7 @@ exports[`Snapshot test Check component matches previous HTML snapshot 2`] = `
442443
emptyStateMessage="Prompt to action or solution"
443444
fixed={false}
444445
fixedColumn={false}
446+
fixedLastColumn={false}
445447
headerCheckState={false}
446448
headerIndeterminateState={false}
447449
horizontalScroll={false}

packages/data-grid/src/table/Table.jsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,10 @@ const propTypes = {
6969
onSort: func,
7070
/** Optional boolean to cause horizontal scrolling when table extends past the container */
7171
horizontalScroll: bool,
72-
/** Optional boolean to cause the first column to be fixed when horizontalScrool is true */
72+
/** Optional boolean to cause the first column to be fixed when horizontalScroll is true */
7373
fixedColumn: bool,
74+
/** Optional boolean to cause the last column to be fixed when horizontalScroll is true */
75+
fixedLastColumn: bool,
7476
/** Optional string to provider header which is visable when no data is available */
7577
emptyStateHeader: string,
7678
/** Optional string to provider descriptive message explaining the empty state of the table */
@@ -96,6 +98,7 @@ const defaultProps = {
9698
sortedColumn: { direction: '', sortDataKey: '' },
9799
horizontalScroll: false,
98100
fixedColumn: false,
101+
fixedLastColumn: false,
99102
emptyStateHeader: 'No data available',
100103
emptyStateMessage: 'Prompt to action or solution',
101104
loading: false,
@@ -158,6 +161,7 @@ class Table extends Component {
158161
loading,
159162
loadingMessage,
160163
fixedColumn,
164+
fixedLastColumn,
161165
horizontalScroll,
162166
emptyStateHeader,
163167
emptyStateMessage,
@@ -181,6 +185,7 @@ class Table extends Component {
181185
className={classnames({
182186
'dg-table-horizontal-scroll': horizontalScroll,
183187
'dg-table-fixed-column': fixedColumn,
188+
'dg-table-fixed-last-column': fixedLastColumn,
184189
})}
185190
>
186191
<table

packages/data-grid/src/table/Table.scss

+28-9
Original file line numberDiff line numberDiff line change
@@ -93,22 +93,41 @@
9393
border-collapse: separate;
9494
border-spacing: 0;
9595

96-
th:first-child {
97-
position: -webkit-sticky;
98-
position: sticky;
99-
left: 0;
100-
z-index: 2;
96+
th,
97+
td {
98+
&:first-child {
99+
position: -webkit-sticky;
100+
position: sticky;
101+
left: 0;
102+
z-index: 2;
103+
}
101104
}
102105

103106
td:first-child {
104-
position: -webkit-sticky;
105-
position: sticky;
106-
left: 0;
107-
z-index: 2;
108107
background-color: $puppet-n200;
109108
}
110109
}
111110

111+
.dg-table-fixed-last-column {
112+
width: 100%;
113+
border-collapse: separate;
114+
border-spacing: 0;
115+
116+
th,
117+
td {
118+
&:last-child {
119+
position: -webkit-sticky;
120+
position: sticky;
121+
right: 0;
122+
z-index: 2;
123+
}
124+
}
125+
126+
td:last-child {
127+
background-color: $puppet-white;
128+
}
129+
}
130+
112131
/** Loading State **/
113132

114133
.dg-table-loading-container {

0 commit comments

Comments
 (0)