fix(table): adjust border size depending on devicePixelRatio [which depends on page zoom level] so we do not lose table cell borders
This commit is contained in:
parent
0c6dbc86f0
commit
16ee0ca934
2 changed files with 21 additions and 1 deletions
20
app/javascript/controllers/fix_table_border_controller.ts
Normal file
20
app/javascript/controllers/fix_table_border_controller.ts
Normal file
|
@ -0,0 +1,20 @@
|
|||
import { ApplicationController } from './application_controller';
|
||||
|
||||
export class FixTableBorderController extends ApplicationController {
|
||||
connect() {
|
||||
const pixelSize = Math.round((1 / window.devicePixelRatio) * 100) / 100;
|
||||
|
||||
// Safari does not support devicePixelRatio
|
||||
if (navigator.userAgent.indexOf('Safari') > -1) {
|
||||
return;
|
||||
}
|
||||
|
||||
const fix = document.createElement('style');
|
||||
fix.innerText = `
|
||||
.fr-table.fr-table--bordered .fr-table__content th,
|
||||
.fr-table.fr-table--bordered .fr-table__content td {
|
||||
background-size: 100% ${pixelSize}px, ${pixelSize}px 100%}
|
||||
}`;
|
||||
document.body.appendChild(fix);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue