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);
|
||||
}
|
||||
}
|
|
@ -31,7 +31,7 @@
|
|||
= yield(:invisible_captcha_styles)
|
||||
= render partial: 'layouts/setup_theme'
|
||||
|
||||
%body{ { id: content_for(:page_id), class: browser.platform.ios? ? 'ios' : nil, data: { controller: 'turbo number-input' } }.compact }
|
||||
%body{ { id: content_for(:page_id), class: browser.platform.ios? ? 'ios' : nil, data: { controller: 'turbo number-input fix-table-border' } }.compact }
|
||||
= render partial: 'layouts/skiplinks'
|
||||
= render partial: 'layouts/display_theme_modal'
|
||||
|
||||
|
|
Loading…
Reference in a new issue