Skip to content

Commit

Permalink
feat(core): ✨ inherit float classes to table wrapper
Browse files Browse the repository at this point in the history
So that table would have the correct float style
  • Loading branch information
alistair3149 committed May 1, 2023
1 parent ee90992 commit d1d49e6
Showing 1 changed file with 24 additions and 6 deletions.
30 changes: 24 additions & 6 deletions resources/skins.citizen.scripts/tables.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,31 @@ function setupOverflowState( element ) {
* @return {void}
*/
function wrapTable( table ) {
// Don't do anything if there is a nowrap class
if ( table.classList.contains( 'citizen-table-nowrap' ) ) {
return;
}
// Don't do anything if there is a nowrap class
if ( table.classList.contains( 'citizen-table-nowrap' ) ) {
return;
}

const wrapper = document.createElement( 'div' );

// Some classes should be inherited from the table
// For example, float helper classes like floatleft and floatright
const inheritTableClass = () => {
const tableClasses = [
'floatleft',
'floatright'
];

tableClasses.forEach( ( tableClass ) => {
if ( table.classList.contains( tableClass ) ) {
wrapper.classList.add( tableClass );
table.classList.remove( tableClass );
}
} );
};

const wrapper = document.createElement( 'div' );
wrapper.classList.add( 'citizen-table-wrapper' );
wrapper.classList.add( 'citizen-table-wrapper' );
inheritTableClass();
table.parentNode.insertBefore( wrapper, table );
wrapper.appendChild( table );

Expand Down

0 comments on commit d1d49e6

Please sign in to comment.