Add width between table headers in Custom Table Form - reactjs

Using Example from SO Table Form
I successfully implemented the form in my component as per my need. The only thing bugging me is there is no gap between the headers and I can't seem to figure out on how to do that as it looks very odd.
As you can see in the highlighted it looks very weird with no gap between headers.
Working codebox
Please do let me know if anyone figures out on how to do that.
I tried:
formtable.css:
table {
border-collapse: separate;
border-spacing: 30px;
}
and it does provides space between header but it looks more ugly as header shifts to left and when clicking on add address inside form looks weird.

Well, you have not applied any styles. That says it all.
I have added some basic styling for your reference, you can style per your need.
Check the working example here
.App {
font-family: sans-serif;
text-align: center;
padding: 1rem;
}
table {
border-spacing: 0;
border: 1px solid black;
}
tr:last-child td {
border-bottom: 0;
}
th,
td {
margin: 0;
padding: 0.5rem;
border-bottom: 1px solid black;
border-right: 1px solid black;
}
th:last-child {
border-right: 0;
}
td:last-child {
border-right: 0;
}

Related

React Module.css property syntax

I am new to React and working on improving my skills. My question is the following:
What is the difference bettwen
<button className={classes["button--alt"]}>Close</button>
and
<button className={classes.button}>Order</button>
for accessing the properties from the css file.
.actions button {
font: inherit;
cursor: pointer;
background-color: transparent;
border: 1px solid #8a2b06;
padding: 0.5rem 2rem;
border-radius: 25px;
margin-left: 1rem;
}
.actions button:hover,
.actions button:active {
background-color: #5a1a01;
border-color: #5a1a01;
color: white;
}
.actions .button--alt {
color: #8a2b06;
}
.actions .button {
background-color: #8a2b06;
color: white;
}
I am stuck and don't seem to figure this out if anybody can give me a hint or a page or something I would highly appreciate thank you!
Basically, the dash - doesn't allows the class object to access the property directly using the dot operator such as using classes.button--alt so we access it using the alternate object key syntax which is using classes["class-key"]

react-table show input in editable cell only when the cell is clicked

I am working on react-table library and trying to make editable cells and only when I click on a cell it should show the input box for editing. But, it shows the input box always.
Here is what I have done https://codesandbox.io/s/strange-wildflower-g9cqif?file=/src/App.js
Any idea what am I missing?
You can refer to the react-table documentation: https://react-table.tanstack.com/docs/examples/editable-data
We can update the style of input so that only on click one will know it is an input box, as done in the documentation.
input {
font-size: 1rem;
padding: 0;
margin: 0;
border: 0;
}
Whole code:
th,
td {
margin: 0;
padding: 0.5rem;
border-bottom: 1px solid black;
border-right: 1px solid black;
:last-child {
border-right: 0;
}
input {
font-size: 1rem;
padding: 0;
margin: 0;
border: 0;
}
}

React-CodeMirror2 Editor not responding to CSS float value

I am fairly new to CSS and I can't seem to figure out why my editors are responding the way they are to float: left. I am trying to get the below editors next to each other horizontally:
With the following CSS:
.form-container {
margin: 0 auto;
max-width: 95%;
background: white;
border-radius: 10px;
display: flex;
height: 50hv;
flex-direction: column;
border: 1px solid #ddd;
}
.left-editor, .right-editor {
margin: 10px;
}
Once I add float: left to .left-editor, .right-editor the editor disappears and looks like this:
Any idea as to why?

can't show caret icon for sorting beside the column name

I can't show caret icon for sorting beside the column name using react-bootstrap-table2 even i set the attribut sort to true in columns.
Thank you
Hopefully this link will solve your problem https://github.com/react-bootstrap-table/react-bootstrap-table2/issues/215
If, by default, the caret is missing, you may add the following styles to your global stylesheet.
.caret {
display: inline-block;
width: 0;
height: 0;
margin-left: 2px;
vertical-align: middle;
border-top: 4px dashed;
border-top: 4px solid \9;
border-right: 4px solid transparent;
border-left: 4px solid transparent;
}

React component size changes in print window

So this is my problem, I am trying to print some components in React using window.print, my components have defined sizes say 5cm x 5cm, I have hidden all other components in the print page (note that the styling of the whole page is somehow complex to post here), the problem is that my components get resized when on the print page. I have looked a lot but nothing has worked for me.
Note that when I tested the same print in a different page (with no complex styling) it worked fine. So is there any way to pass the styles to the print window or "Override" the styling so that my components get rendered correctly?
Thanks.
EDIT: Here is my CSS. This is working fine in a fresh app so there must be something I used messing things up, I removed all #media print from Bootstrap CSS files but no luck.
I tried to put the code inside as well as outside the #media print but no luck as well.
As far as I know media should render real physical lengths and units, any help would be appreciated.
Thanks again
.print-only {
display: none;
}
#media print {
#page {
margin: 0;
size: a4 !important;
}
body {
margin: 0.5cm !important;
padding: 0;
}
.print-only {
margin-top: 20px;
display: block;
}
.no-print {
width: 100%;
margin: 0px;
display: none;
}
.Container {
position: relative;
display: block;
border: 3px solid black;
width: 6in !important;
height: 2in !important;
margin: 0;
padding: 0;
text-align: start;
}
.labels {
font-family: Arial, "Helvetica Neue", Helvetica, sans-serif;
font-size: 6pt;
font-style: normal;
font-variant: normal;
height: 13px;
}
.container2 {
height: 39px;
font-size: 8px;
font-weight: 550;
position: absolute;
top: 20px;
right: 1in;
line-height: 13px;
text-align: center;
}
}
Recently, I've encountered with the same issue while designing a print template in React. I was totally wrong in my understanding that whatever styles I write in my CSS files will apply. Then I found there is certain semantics while are required to be followed while designing an HTML print template.
Take a look at this link. This will be very helpful for your design.

Resources