added text size settings

This commit is contained in:
Marius 2025-03-07 19:13:48 +01:00
parent 5a90ef1d6b
commit f26a119269
5 changed files with 91 additions and 15 deletions

12
main.js

File diff suppressed because one or more lines are too long

View file

@ -7,6 +7,11 @@
*/
export type CardPreset = 'grid' | 'portrait' | 'square' | 'compact' | 'dense';
/**
* Font size options
*/
export type FontSize = 'larger' | 'large' | 'default' | 'small' | 'smaller';
/**
* Image fitting options
*/
@ -49,6 +54,7 @@ export interface DataCardsSettings {
enableShadows: boolean;
propertiesAlign: 'left' | 'center' | 'right'; // Alignment for properties and labels
titleAlign: 'left' | 'center' | 'right'; // Alignment for the title (filename)
fontSize: FontSize; // Font size for all text elements
// Formatting settings
defaultDateFormat: string;
@ -98,6 +104,7 @@ export const DEFAULT_SETTINGS: DataCardsSettings = {
enableShadows: true,
propertiesAlign: 'left', // Default to left alignment
titleAlign: 'left', // Default to left alignment
fontSize: 'default', // Default font size
// Formatting settings
defaultDateFormat: 'YYYY-MM-DD',

View file

@ -108,6 +108,16 @@ export class RendererService {
cardsContainer.addClass('datacards-no-shadows');
}
// Apply font size class if specified
if (settings.fontSize && settings.fontSize !== 'default') {
cardsContainer.addClass(`datacards-font-${settings.fontSize}`);
Logger.debug(`Applied font size class: datacards-font-${settings.fontSize}`);
} else if (settings.preset === 'dense' && (!settings.fontSize || settings.fontSize === 'default')) {
// For dense preset, automatically use small font size if not explicitly overridden
cardsContainer.addClass('datacards-font-small');
Logger.debug('Applied small font size for dense preset');
}
// Set only the non-preset specific CSS variables
// This allows the preset class to control preset-specific variables
cardsContainer.style.setProperty('--card-gap', `${settings.cardSpacing}px`);

View file

@ -118,6 +118,21 @@ export class DataCardsSettingTab extends PluginSettingTab {
this.plugin.settings.titleAlign = value as any;
await this.plugin.saveSettings();
}));
new Setting(containerEl)
.setName('Font Size')
.setDesc('Text size for all card elements (properties, labels, and title)')
.addDropdown(dropdown => dropdown
.addOption('larger', 'Larger (120%)')
.addOption('large', 'Large (110%)')
.addOption('default', 'Default (100%)')
.addOption('small', 'Small (90% - similar to dense preset)')
.addOption('smaller', 'Smaller (80%)')
.setValue(this.plugin.settings.fontSize)
.onChange(async (value: string) => {
this.plugin.settings.fontSize = value as any;
await this.plugin.saveSettings();
}));
// Card Content Settings
containerEl.createEl('h3', { text: 'Card Content Settings' });

View file

@ -317,6 +317,59 @@ a.datacards-tag:hover {
text-decoration: none;
}
/* Font size variations */
/* Larger - 120% of default */
.datacards-font-larger .datacards-property {
font-size: 1.2em;
}
.datacards-font-larger .datacards-property-label {
font-size: 0.96em;
}
.datacards-font-larger .datacards-file-property .internal-link {
font-size: 1.44em;
}
/* Large - 110% of default */
.datacards-font-large .datacards-property {
font-size: 1.1em;
}
.datacards-font-large .datacards-property-label {
font-size: 0.88em;
}
.datacards-font-large .datacards-file-property .internal-link {
font-size: 1.32em;
}
/* Small - 90% of default (similar to dense preset) */
.datacards-font-small .datacards-property {
font-size: 0.9em;
}
.datacards-font-small .datacards-property-label {
font-size: 0.72em;
}
.datacards-font-small .datacards-file-property .internal-link {
font-size: 1.08em;
}
/* Smaller - 80% of default */
.datacards-font-smaller .datacards-property {
font-size: 0.8em;
}
.datacards-font-smaller .datacards-property-label {
font-size: 0.64em;
}
.datacards-font-smaller .datacards-file-property .internal-link {
font-size: 0.96em;
}
.datacards-file-property .internal-link:hover {
text-decoration: underline;
}
@ -501,21 +554,12 @@ a.datacards-tag:hover {
.datacards-preset-dense .datacards-property {
margin-bottom: 4px;
font-size: 0.9em;
}
.datacards-preset-dense .datacards-property-label {
font-size: 0.7em;
}
.datacards-preset-dense .datacards-file-property {
margin-bottom: 6px;
}
.datacards-preset-dense .datacards-file-property .internal-link {
font-size: 1em;
}
/* Responsive adjustments - these are now handled by the mobile settings in the plugin */
/* These media queries serve as fallbacks for blocks without explicit settings */
@media (max-width: 1200px) {