"""
Base framework class for CSS framework support
"""
[docs]
class BaseFramework:
"""Base class for CSS framework implementations"""
name = "base"
# CSS classes for different elements
form_classes = {
'form': '',
'field': '',
'label': '',
'input': '',
'textarea': '',
'select': '',
'checkbox': '',
'radio': '',
'submit': '',
'error': '',
'help_text': '',
}
table_classes = {
'table': '',
'table_responsive': '',
'thead': '',
'tbody': '',
'tr': '',
'th': '',
'td': '',
'actions': '',
}
button_classes = {
'primary': '',
'secondary': '',
'success': '',
'danger': '',
'warning': '',
'info': '',
'light': '',
'dark': '',
}
[docs]
def get_table_html(self, headers, rows):
"""Generate HTML for a data table"""
header_html = "".join(f'<th class="{self.table_classes["th"]}">{h}</th>' for h in headers)
# Build rows HTML without nested f-strings
rows_html = []
for row in rows:
cells_html = []
for cell in row:
cells_html.append(f'<td class="{self.table_classes["td"]}">{cell}</td>')
row_html = f'<tr class="{self.table_classes["tr"]}">{"".join(cells_html)}</tr>'
rows_html.append(row_html)
return f'''
<table class="{self.table_classes["table"]}">
<thead class="{self.table_classes["thead"]}">
<tr class="{self.table_classes["tr"]}">
{header_html}
</tr>
</thead>
<tbody class="{self.table_classes["tbody"]}">
{"".join(rows_html)}
</tbody>
</table>
'''