Skip to content

Commit 6e2cacf

Browse files
authored
Fixing row height on browser scaling (#615)
Fixing row height on browser scaling
2 parents 26b69ec + d22d604 commit 6e2cacf

File tree

5 files changed

+89
-5
lines changed

5 files changed

+89
-5
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import React from 'react'
2+
import { mount } from 'enzyme'
3+
import { noop } from 'test-utility'
4+
import GroupRows from 'lib/row/GroupRows'
5+
6+
const defaultProps = {
7+
groups: [
8+
{
9+
bgColor: '#e8ccff',
10+
id: '2998',
11+
label: 'Label Dustin"',
12+
rightTitle: 'Wolff',
13+
title: 'Carlotta',
14+
},
15+
{
16+
bgColor: '#e8ccff',
17+
id: '2999',
18+
label: 'Label Myrtle"',
19+
rightTitle: '"Sauer"',
20+
title: 'Elmer',
21+
}
22+
],
23+
canvasWidth: 10,
24+
lineCount: 2,
25+
groupHeights: [30, 27],
26+
onRowClick: noop,
27+
onRowDoubleClick: noop,
28+
clickTolerance: 0,
29+
onRowContextClick: noop,
30+
}
31+
32+
describe('GroupRows', () => {
33+
it('passes props and get right height for first group', () => {
34+
const wrapper = mount(<GroupRows {...defaultProps} />);
35+
36+
const component = wrapper.find('GroupRow').first();
37+
expect(component.prop('style').height).toBe('30px');
38+
})
39+
})
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import React from 'react'
2+
import { mount } from 'enzyme'
3+
import Sidebar from 'lib/layout/Sidebar'
4+
5+
const defaultProps = {
6+
groups: [
7+
{
8+
bgColor: '#e8ccff',
9+
id: '2998',
10+
label: 'Label Dustin"',
11+
rightTitle: 'Wolff',
12+
title: 'Carlotta',
13+
},
14+
{
15+
bgColor: '#e8ccff',
16+
id: '2999',
17+
label: 'Label Myrtle"',
18+
rightTitle: '"Sauer"',
19+
title: 'Elmer',
20+
}
21+
],
22+
width: 10,
23+
height: 10,
24+
groupHeights: [30, 27],
25+
keys: {
26+
groupIdKey: 'id',
27+
groupRightTitleKey: 'rightTitle',
28+
groupTitleKey: 'title',
29+
itemDivTitleKey: 'title',
30+
itemGroupKey: 'group',
31+
itemIdKey: 'id',
32+
itemTimeEndKey: 'end',
33+
itemTimeStartKey: 'start',
34+
itemTitleKey: 'title'
35+
}
36+
}
37+
38+
describe('GroupRows', () => {
39+
it('passes props and get right height for first group', () => {
40+
const wrapper = mount(<Sidebar {...defaultProps} />);
41+
42+
const component = wrapper.find('div.rct-sidebar-row').first();
43+
expect(component.prop('style').height).toBe('30px');
44+
})
45+
})

src/lib/Timeline.scss

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ $weekend: rgba(250, 246, 225, 0.5);
7575
overflow: hidden;
7676
white-space: nowrap;
7777
text-overflow: ellipsis;
78-
box-sizing: content-box;
78+
box-sizing: border-box;
7979
margin: 0;
8080
border-bottom: $border-width solid $border-color;
8181

@@ -114,7 +114,7 @@ $weekend: rgba(250, 246, 225, 0.5);
114114
.rct-hl-even,
115115
.rct-hl-odd {
116116
border-bottom: $border-width solid $border-color;
117-
box-sizing: content-box;
117+
box-sizing: border-box;
118118
z-index: 40;
119119
}
120120
.rct-hl-odd {

src/lib/layout/Sidebar.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ export default class Sidebar extends Component {
5151

5252
let groupLines = this.props.groups.map((group, index) => {
5353
const elementStyle = {
54-
height: `${groupHeights[index] - 1}px`,
55-
lineHeight: `${groupHeights[index] - 1}px`
54+
height: `${groupHeights[index]}px`,
55+
lineHeight: `${groupHeights[index]}px`
5656
}
5757

5858
return (

src/lib/row/GroupRows.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ export default class GroupRows extends Component {
5151
horizontalLineClassNamesForGroup={horizontalLineClassNamesForGroup}
5252
style={{
5353
width: `${canvasWidth}px`,
54-
height: `${groupHeights[i] - 1}px`
54+
height: `${groupHeights[i]}px`
5555
}}
5656
/>
5757
)

0 commit comments

Comments
 (0)