Correctly applies settings css again

This commit is contained in:
Scott Tomaszewski 2025-03-16 08:11:10 -04:00
parent e293ba6f92
commit 986bd6405b
2 changed files with 51 additions and 3 deletions

View file

@ -99,15 +99,29 @@ export class BibleStyles {
/**
* Apply styles based on theme and preset
*/
public applyStyles(theme: 'light' | 'dark', presetName: string = 'default', fontSize: string = '100%'): void {
public applyStyles(theme: 'light' | 'dark', presetName: string = 'default', fontSize: string = '100%', settings?: {
wordsOfChristColor?: string;
verseNumberColor?: string;
headingColor?: string;
blockIndentation?: string;
}): void {
this.createStyleElement();
// Get the preset, defaulting to 'default' if not found
const preset = THEME_PRESETS[presetName] || THEME_PRESETS.default;
// Get the options for the current theme
// Get the options for the current theme with preset values
const options = { ...preset[theme], fontSize: fontSize || this.currentFontSize };
// Apply custom settings from DisciplesJournalSettings if provided
// These will override the preset values
if (settings) {
if (settings.wordsOfChristColor) options.wordsOfChristColor = settings.wordsOfChristColor;
if (settings.verseNumberColor) options.verseNumberColor = settings.verseNumberColor;
if (settings.headingColor) options.headingColor = settings.headingColor;
if (settings.blockIndentation) options.blockIndentation = settings.blockIndentation;
}
// Update the style element
if (this.styleElement) {
this.styleElement.textContent = this.getStylesText(options);
@ -305,6 +319,10 @@ export class BibleStyles {
margin-bottom: 8px;
color: ${options.headingColor};
}
.bible-passage-text .woc {
color: ${options.wordsOfChristColor};
}
.bible-passage-text .chapter-num,
.bible-passage-text .verse-num {

View file

@ -169,7 +169,19 @@ export default class DisciplesJournalPlugin extends Plugin {
const isDarkMode = document.body.classList.contains('theme-dark');
const theme = isDarkMode ? 'dark' : 'light';
this.bibleStyles.applyStyles(theme, this.settings.stylePreset, this.settings.bibleTextFontSize);
// Pass custom settings from DisciplesJournalSettings
this.bibleStyles.applyStyles(
theme,
this.settings.stylePreset,
this.settings.bibleTextFontSize,
{
wordsOfChristColor: this.settings.wordsOfChristColor,
verseNumberColor: this.settings.verseNumberColor,
headingColor: this.settings.headingColor,
blockIndentation: this.settings.blockIndentation
}
);
}
/**
@ -177,6 +189,24 @@ export default class DisciplesJournalPlugin extends Plugin {
*/
public updateFontSize(fontSize: string): void {
this.bibleStyles.setFontSize(fontSize);
// Refresh the styles with the new font size and current settings
const isDarkMode = document.body.classList.contains('theme-dark');
const theme = isDarkMode ? 'dark' : 'light';
// Apply styles with the new font size and current settings
this.bibleStyles.applyStyles(
theme,
this.settings.stylePreset,
fontSize,
{
wordsOfChristColor: this.settings.wordsOfChristColor,
verseNumberColor: this.settings.verseNumberColor,
headingColor: this.settings.headingColor,
blockIndentation: this.settings.blockIndentation
}
);
this.bibleReferenceRenderer.setFontSize(fontSize);
}