-
-
Notifications
You must be signed in to change notification settings - Fork 114
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement enumerate rows to table component (#1582)
* feat: implement enumerate rows to table component * fix: improved extra columns append to columnsData * fix: improved getColumns setup * fix: updated to align with spec results * fix: counter updates and markup fix * css counter used for enumerable * markup aligned with standards * feat: specs added for enumerable column integration for Table component * fix: counter * fix: firt data column Co-authored-by: LeandroTorresSicilia <jtorressicilia@gmail.com>
- Loading branch information
1 parent
7ee18cf
commit 189bc64
Showing
17 changed files
with
571 additions
and
39 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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
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
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
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,14 @@ | ||
import React from 'react'; | ||
import StyledCellContainer from './styled/cellContainer'; | ||
import StyledCellContent from './styled/cellContent'; | ||
import StyledEnumerable from './styled/enumerable'; | ||
|
||
export default function EnumerableCell() { | ||
return ( | ||
<StyledCellContainer role="gridcell" tabIndex={-1}> | ||
<StyledCellContent> | ||
<StyledEnumerable /> | ||
</StyledCellContent> | ||
</StyledCellContainer> | ||
); | ||
} |
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
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,14 @@ | ||
import styled from 'styled-components'; | ||
import attachThemeAttrs from '../../../../styles/helpers/attachThemeAttrs'; | ||
|
||
const StyledEnumerable = attachThemeAttrs(styled.span)` | ||
display: block; | ||
text-align: center; | ||
color: ${props => props.palette.text.header}; | ||
&::after { | ||
content: counter(rowCounter); | ||
} | ||
`; | ||
|
||
export default StyledEnumerable; |
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
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
13 changes: 13 additions & 0 deletions
13
src/components/Table/helpers/columns/__test__/getEnumerableWidth.spec.js
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,13 @@ | ||
import getEnumerableWidth from '../getEnumerableWidth'; | ||
|
||
describe('getEnumerableWidth', () => { | ||
it('should return the default width when value is not sent', () => { | ||
expect(getEnumerableWidth()).toBe(48); | ||
}); | ||
it('should return the default calculated width when value is default', () => { | ||
expect(getEnumerableWidth(0)).toBe(48); | ||
}); | ||
it('should return the right width when value length is 3 (999)', () => { | ||
expect(getEnumerableWidth(999)).toBe(72); | ||
}); | ||
}); |
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
11 changes: 11 additions & 0 deletions
11
src/components/Table/helpers/columns/getEnumerableWidth.js
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,11 @@ | ||
const enumerableColumnOffset = 40; | ||
const singleNumberWidth = 8; | ||
|
||
export default function getEnumerableWidth(numberValue) { | ||
if (numberValue) { | ||
const valuePlusOne = Number(numberValue) + 1; | ||
const enumerableStringWidth = singleNumberWidth * valuePlusOne.toString().length; | ||
return enumerableStringWidth + enumerableColumnOffset; | ||
} | ||
return 48; | ||
} |
Oops, something went wrong.