Issues with borders
See original GitHub issueHi,
I noticed some strange issues with borders. Sometimes they are not visible at all, sometimes are of different width even if I set the same width to all borders, sometimes they stretch after the end of the View (See image below)
This is the table component that I made to render tables:
import React from 'react';
import PropTypes from 'prop-types';
import { View, StyleSheet, Text } from '@react-pdf/renderer';
const tableBorderWidth = '1px';
const tableBorderColor = 'grey';
const styles = StyleSheet.create({
rowsContainer: {
flex: 0,
flexDirection: 'column',
borderTop: `${tableBorderWidth} solid ${tableBorderColor}`
},
row: {
flex: 0,
flexDirection: 'row',
borderLeft: `${tableBorderWidth} solid ${tableBorderColor}`,
borderBottom: `${tableBorderWidth} solid ${tableBorderColor}`
},
defaultText: {
padding: 0,
fontSize: 7
// marginTop: 2 // hack to center text vertically,
},
defaultCell: {
paddingVertical: 1,
paddingHorizontal: 3,
borderRight: `${tableBorderWidth} solid ${tableBorderColor}`
}
});
export default class PDFTable extends React.PureComponent {
renderSingleCell = ({ cellStyle, textStyle, value }, columnIndex) => (
<View
key={columnIndex}
style={[styles.defaultCell, cellStyle, { width: this.props.columnWidths[columnIndex] }]}
>
<Text style={[styles.defaultText, textStyle]}>{value}</Text>
</View>
);
renderSingleRow = (row, rowIndex) => {
return (
<View key={rowIndex} style={styles.row}>
{row.map(this.renderSingleCell)}
</View>
);
}
render = () => {
return (
<View style={styles.rowsContainer}>
{this.props.rows.map(this.renderSingleRow)}
</View>
);
}
}
const CellShape = PropTypes.shape({
cellStyle: PropTypes.objectOf(PropTypes.any),
textStyle: PropTypes.objectOf(PropTypes.any),
value: PropTypes.oneOfType([PropTypes.number, PropTypes.string])
});
PDFTable.propTypes = {
columnWidths: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.number, PropTypes.string])),
rows: PropTypes.arrayOf(PropTypes.arrayOf(CellShape)).isRequired
};
Btw, I was only able to set border in pixels, is there any other unit I can use to define border? Thanks.
Issue Analytics
- State:
- Created 5 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Everyone can now agree -- the US has a border crisis - CNN
Amid growing concerns that large groups of migrants waiting in Mexico could cross over the border next week, Biden's team said Thursday it ......
Read more >What's happening at the U.S.-Mexico border in 7 charts
In Ecuador, widespread economic problems and the COVID-19 pandemic have led many migrants to make the journey north.
Read more >Border Issues | Wilson Center
Key law enforcement efforts to counter transnational crime occur in the border region, and the nature of border ecosystems, which ignore national boundaries, ......
Read more >Taking Migration Seriously: Real Solutions to Complex ...
Taking Migration Seriously: Real Solutions to Complex Challenges at the Border · New drivers of migration in the Western Hemisphere require ...
Read more >Immigration Border Crisis - NBC News
The decision comes as border towns' resources are overwhelmed and local migrant shelters are at capacity.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@diegomura I also confirm it. see table example here: https://codesandbox.io/s/6xzq3rw8rk
increase table height