Skip to content

Commit efc4c52

Browse files
committed
v0.8.7 - Change line feature
v0.8.7 * Added feature for line change, if you send text with the escape char \n, it will be rendered in different lines in the UI, and also escaped in the CSV download. E.g: let text = '"Gianluigi\nBuffon"'; Check the Example in GitHub.
1 parent 4cd61b9 commit efc4c52

File tree

4 files changed

+23
-8
lines changed

4 files changed

+23
-8
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,12 @@ Changes the background to white and the text to blue
169169
| warningColor | string |N | Hex value for text (default: #ba8722)|
170170

171171
# What's new
172+
v0.8.7
172173

173-
v0.8.3
174+
* Added feature for line change, if you send text with the escape char \n, it will be rendered in different lines in the UI, and also escaped in the CSV download.
175+
E.g: let text = '"Gianluigi\nBuffon"'; Check the Example in GitHub.
176+
177+
v0.8.6
174178
* If there is a tie between an error and a warning, the error will have priority and show the error color
175179

176180
v0.8.3

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-js-table-with-csv-dl",
3-
"version": "0.8.4",
3+
"version": "0.8.7",
44
"description": "React JS tables and log viewer with stats if needed. Has the functionality to dowload table contents in CSV file with data stored in class prop.",
55
"main": "build/index.js",
66
"peerDependencies": {

react-table-example/src/App.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ class App extends Component {
1818
"array2":[],
1919
"Object":[{"id":1000,"values":"K-1"}]};
2020

21+
let text = '"Gianluigi\nBuffon"';
22+
2123
let table = [
22-
{number: 12, name:"Buffon", success: true},
24+
{number: 12, name:text, success: true},
2325
{number: 21, name: "Pirlo", metadata: JSON.stringify(json), success: false},
2426
{number: 10, name: "Ruiz", position: "MDI"},
2527
{number: 7, name: "Nesta", position: "RB"},

src/index.js

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -299,14 +299,15 @@ class TableViewer extends Component {
299299
let isWarning = row.warning || false;
300300
let isSucccess = row.success;
301301
let fontColor = "#000000";
302-
if (isSucccess === true){
303-
fontColor = (this.props.successColor ) ? this.props.successColor : '#0b7012';
302+
303+
if (isSucccess=== false){ // because can be undefined
304+
fontColor = (this.props.errorColor ) ? this.props.errorColor : '#b30009';
304305
}
305306
else if(isWarning){
306307
fontColor = (this.props.warningColor ) ? this.props.warningColor : '#ba8722';
307308
}
308-
else if (isSucccess=== false){ // because can be undefined
309-
fontColor = (this.props.errorColor ) ? this.props.errorColor : '#b30009';
309+
else if (isSucccess === true){
310+
fontColor = (this.props.successColor ) ? this.props.successColor : '#0b7012';
310311
}
311312

312313
return(
@@ -360,13 +361,21 @@ class TableViewer extends Component {
360361
let rowContent = headers.map((header, element) => {
361362
let content = row[header];
362363
let isJson = false;
364+
console.log("Cont: "+ content);
363365
try {
364366
if (isNaN(content)){
365367
content = JSON.parse(content);
366368
isJson = true;
367-
}
369+
}
368370
} catch (e) {
369371
content = row[header];
372+
if(content){
373+
content = content.split("\n").map((item, i) => {
374+
return (<p key={`part-${i}`}>{item}</p>)
375+
});
376+
}
377+
378+
console.log("catch: "+ content);
370379
isJson = false;
371380
}
372381
if (isJson){

0 commit comments

Comments
 (0)