mirror of
https://github.com/a2nt/webpack-bootstrap-ui-kit.git
synced 2024-10-22 11:05:45 +02:00
IMPR: Mobile friendly tables
This commit is contained in:
parent
d0e1b6080a
commit
a5f1509440
@ -1,19 +1,18 @@
|
|||||||
import Events from '../_events'
|
import Events from '../_events'
|
||||||
|
|
||||||
const LayoutUI = ((W) => {
|
const LayoutUI = ((window) => {
|
||||||
const NAME = '_layout'
|
const NAME = '_layout'
|
||||||
const D = document
|
|
||||||
|
|
||||||
const initFonts = () => {
|
const initFonts = () => {
|
||||||
console.log(`${NAME}: initFonts`)
|
console.log(`${NAME}: initFonts`)
|
||||||
|
|
||||||
const css = D.createElement('link')
|
const css = document.createElement('link')
|
||||||
css.rel = 'stylesheet'
|
css.rel = 'stylesheet'
|
||||||
css.type = 'text/css'
|
css.type = 'text/css'
|
||||||
css.media = 'all'
|
css.media = 'all'
|
||||||
css.href =
|
css.href =
|
||||||
'https://fonts.googleapis.com/css?family=Roboto:ital,wght@0,400;0,700;1,400&display=swap'
|
'https://fonts.googleapis.com/css?family=Roboto:ital,wght@0,400;0,700;1,400&display=swap'
|
||||||
D.getElementsByTagName('head')[0].appendChild(css)
|
document.getElementsByTagName('head')[0].appendChild(css)
|
||||||
}
|
}
|
||||||
|
|
||||||
const initAnalytics = () => {
|
const initAnalytics = () => {
|
||||||
@ -42,9 +41,30 @@ const LayoutUI = ((W) => {
|
|||||||
ga('send', 'pageview'); */
|
ga('send', 'pageview'); */
|
||||||
}
|
}
|
||||||
|
|
||||||
W.addEventListener(`${Events.LOADED}`, () => {
|
// set attributes for mobile friendly tables
|
||||||
|
const initMobileTables = () => {
|
||||||
|
document.querySelectorAll('.typography table').forEach((el) => {
|
||||||
|
const header = el.querySelector('thead tr:first-child')
|
||||||
|
if (!header) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
header.classList.add('d-typography-breakpoint-none')
|
||||||
|
|
||||||
|
header.querySelectorAll('td').forEach((h) => {
|
||||||
|
el.querySelectorAll(`td:eq(${i})`)
|
||||||
|
.forEach((el) => {
|
||||||
|
if (!el.dataset.label) {
|
||||||
|
el.dataset.label = h.innerText
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener(`${Events.LOADED}`, () => {
|
||||||
initFonts()
|
initFonts()
|
||||||
initAnalytics()
|
initAnalytics()
|
||||||
|
initMobileTables()
|
||||||
})
|
})
|
||||||
})(window)
|
})(window)
|
||||||
export default LayoutUI
|
export default LayoutUI
|
||||||
|
@ -249,7 +249,7 @@ img {
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
|
|
||||||
&:before {
|
&[data-label]:before {
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
display: block;
|
display: block;
|
||||||
width: 50%;
|
width: 50%;
|
||||||
@ -276,3 +276,11 @@ img {
|
|||||||
left: 0;
|
left: 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
img:last-child {
|
||||||
|
margin-bottom: 0!important;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-none tr:last-child > td {
|
||||||
|
padding-bottom: 0;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user