Skip to content

Commit

Permalink
feat: Add property-dependant CSS class for Table layout blocks
Browse files Browse the repository at this point in the history
  • Loading branch information
miscoined committed Jul 17, 2024
1 parent e267351 commit 065d69f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
11 changes: 11 additions & 0 deletions src/settings/layout/blocks/ui/block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -926,6 +926,17 @@ class TableModal extends BasicModal<TableItem> {
this.block.calculate = v;
});
});
new Setting(el)
.setName("Do Not Add Property as CSS Class")
.setDesc(
"Disable this to prevent adding the property to the containing HTML element as a CSS class. This can be used to avoid collisions with native Obsidian CSS."
)
.addToggle((t) => {
t.setValue(this.block.doNotAddClass).onChange((v) => {
this.block.doNotAddClass = v;
this.display();
});
});
}
}
class TraitsModal extends MarkdownEnabledModal<TraitsItem> {
Expand Down
6 changes: 4 additions & 2 deletions src/view/ui/Table.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import type { Monster } from "index";
import type { TableItem } from "src/layouts/layout.types";
import { stringify } from "src/util/util";
import { slugify, stringify } from "src/util/util";
import TextContentHolder from "./TextContentHolder.svelte";
export let monster: Monster;
Expand Down Expand Up @@ -48,9 +48,11 @@
const headers = item.headers ?? [
...Array(values.length > 0 ? values.length : 1).keys()
];
$: cssClass = item.doNotAddClass ? "" : slugify(item.properties[0]);
</script>

<div class="statblock-table">
<div class="statblock-table {cssClass}">
{#each [...valueMap.entries()].slice(0, headers.length) as [index, values]}
<div class="table-item">
<span class="statblock-table-header">{headers[index]}</span>
Expand Down

0 comments on commit 065d69f

Please sign in to comment.