mirror of
https://github.com/janishutz/fundamentals-of-webengineering.git
synced 2025-11-25 05:44:24 +00:00
Some CSS work
This commit is contained in:
@@ -37,8 +37,8 @@ const headerList = listRef<string>(
|
||||
[],
|
||||
'table-header',
|
||||
{
|
||||
'type': 'td',
|
||||
'cssClasses': [],
|
||||
'type': 'th',
|
||||
'cssClasses': [ 'sortable' ],
|
||||
'children': []
|
||||
}
|
||||
);
|
||||
@@ -75,6 +75,10 @@ columnDatatype.addConditionalElementBind( document.getElementById( 'title-column
|
||||
columnDatatype.addConditionalElementBind( columnEntriesElement, stringOrNumberCheckPredicate );
|
||||
columnDatatype.addConditionalElementBind( document.getElementById( 'title-column-entries' )!,
|
||||
stringOrNumberCheckPredicate );
|
||||
columnDatatype.addConditionalElementBind( document.getElementById( 'column-info' )!, val => val !== '' );
|
||||
columnDatatype.addConditionalElementBind( document.getElementById( 'column-info-placeholder' )!, val => val === '' );
|
||||
filename.addConditionalElementBind( document.getElementById( 'data-info' )!, val => val !== '' );
|
||||
filename.addConditionalElementBind( document.getElementById( 'data-info-placeholder' )!, val => val === '' );
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -18,6 +18,11 @@ const renderList = <T extends StringIndexedObject>(
|
||||
const renderer = <T extends StringIndexedObject>( data: T, template: RenderTemplate ): HTMLElement => {
|
||||
const parent = document.createElement( template.type );
|
||||
|
||||
for ( let i = 0; i < template.cssClasses.length; i++ ) {
|
||||
console.log( 'Adding css class', template.cssClasses[i]! );
|
||||
parent.classList.add( template.cssClasses[i]! );
|
||||
}
|
||||
|
||||
for ( let i = 0; i < template.children.length; i++ ) {
|
||||
const element = template.children[i]!;
|
||||
|
||||
|
||||
@@ -64,6 +64,7 @@ export const ref = <T>( elements: HTMLElement[], data: T ): Ref<T> => {
|
||||
} );
|
||||
|
||||
conditionalClasses.forEach( el => {
|
||||
// FIXME: Use add and remove!
|
||||
el.element.classList.value = el.predicate( data ) ? el.onTrue : el.onFalse;
|
||||
} );
|
||||
|
||||
|
||||
Reference in New Issue
Block a user