diff --git a/src/gui/Tabs.ts b/src/gui/Tabs.ts
index 62829afa..c771ac6d 100644
--- a/src/gui/Tabs.ts
+++ b/src/gui/Tabs.ts
@@ -52,7 +52,7 @@ interface TabButtons {
}
export function createTabs(container_element: HTMLElement, tabs: Tabs, activateTabId: string): TabStructure {
- const tab_header = container_element.createEl("div", {attr: {class: "SC-tab-header"}});
+ const tab_header = container_element.createEl("div", {attr: {class: "sr-tab-header"}});
const tab_content_containers: TabContentContainers = {};
const tab_buttons: TabButtons = {};
const tab_structure: TabStructure = {
@@ -69,8 +69,8 @@ export function createTabs(container_element: HTMLElement, tabs: Tabs, activateT
// Create button
const button = tab_header.createEl("button", {
attr: {
- class: "SC-tab-header-button",
- activateTab: "SC-tab-" + tab_id,
+ class: "sr-tab-header-button",
+ activateTab: "sr-tab-" + tab_id,
},
});
button.onclick = function (event: MouseEvent) {
@@ -87,7 +87,7 @@ export function createTabs(container_element: HTMLElement, tabs: Tabs, activateT
if (null === container_element) {
throw new Error("Container element is missing. Did not get a parent from tab header.");
}
- const tab_contents = container_element.findAll("div.SC-tab-content"); // Do not get all tab contents that exist, because there might be multiple tab systems open at the same time.
+ const tab_contents = container_element.findAll("div.sr-tab-content"); // Do not get all tab contents that exist, because there might be multiple tab systems open at the same time.
const is_main_settings_modal = container_element.hasClass("vertical-tab-content");
for (const index in tab_contents) {
const tab_content = tab_contents[index];
@@ -95,7 +95,7 @@ export function createTabs(container_element: HTMLElement, tabs: Tabs, activateT
// Get the maximum tab dimensions so that all tabs can have the same dimensions.
// But don't do it if this is the main settings modal
if (!is_main_settings_modal) {
- tab_content.addClass("SC-tab-active"); // Need to make the tab visible temporarily in order to get the dimensions.
+ tab_content.addClass("sr-tab-active"); // Need to make the tab visible temporarily in order to get the dimensions.
if (tab_content.offsetHeight > max_height) {
max_height = tab_content.offsetHeight;
}
@@ -105,18 +105,18 @@ export function createTabs(container_element: HTMLElement, tabs: Tabs, activateT
}
// Finally hide the tab
- tab_content.removeClass("SC-tab-active");
+ tab_content.removeClass("sr-tab-active");
}
// Remove active status from all buttons
- const adjacent_tab_buttons = tab_header.findAll(".SC-tab-header-button"); // Do not get all tab buttons that exist, because there might be multiple tab systems open at the same time.
+ const adjacent_tab_buttons = tab_header.findAll(".sr-tab-header-button"); // Do not get all tab buttons that exist, because there might be multiple tab systems open at the same time.
for (const index in adjacent_tab_buttons) {
const tab_button = adjacent_tab_buttons[index];
- tab_button.removeClass("SC-tab-active");
+ tab_button.removeClass("sr-tab-active");
}
// Activate the clicked tab
- tab_button.addClass("SC-tab-active");
+ tab_button.addClass("sr-tab-active");
const activateTabAttribute: Attr | null = tab_button.attributes.getNamedItem("activateTab");
if (null === activateTabAttribute) {
throw new Error("Tab button has no 'activateTab' HTML attribute! Murr!");
@@ -126,13 +126,13 @@ export function createTabs(container_element: HTMLElement, tabs: Tabs, activateT
if (null === tab_content) {
throw new Error("No tab content was found with activate_tab_id '"+activate_tab_id+"'! Hmph!");
}
- tab_content.addClass("SC-tab-active");
+ tab_content.addClass("sr-tab-active");
// Mark the clicked tab as active in TabStructure (just to report which tab is currently active)
- tab_structure.active_tab_id = activate_tab_id.replace(/^SC-tab-/, ""); // Remove "SC-tab" prefix.
+ tab_structure.active_tab_id = activate_tab_id.replace(/^sr-tab-/, ""); // Remove "sr-tab" prefix.
// Focus an element (if a focusable element is present)
- tab_content.find(".SC-focus-element-on-tab-opening")?.focus(); // ? = If not found, do nothing.
+ tab_content.find(".sr-focus-element-on-tab-opening")?.focus(); // ? = If not found, do nothing.
// Apply the max dimensions to this tab
// But don't do it if this is the main settings modal
@@ -151,7 +151,7 @@ export function createTabs(container_element: HTMLElement, tabs: Tabs, activateT
tab_buttons[tab_id] = button;
// Create content container
- tab_content_containers[tab_id] = container_element.createEl("div", {attr: {class: "SC-tab-content", id: "SC-tab-" + tab_id}});
+ tab_content_containers[tab_id] = container_element.createEl("div", {attr: {class: "sr-tab-content", id: "sr-tab-" + tab_id}});
// Generate content
tab_structure.contentGeneratorPromises[tab_id] = tab.content_generator(tab_content_containers[tab_id]);
diff --git a/src/settings.ts b/src/settings.ts
index 893a1d69..46de2002 100644
--- a/src/settings.ts
+++ b/src/settings.ts
@@ -143,7 +143,7 @@ export class SRSettingTab extends PluginSettingTab {
containerEl.empty();
- const header = containerEl.createEl("h1", { text: `${t("SETTINGS_HEADER")}` });
+ const header = containerEl.createEl("h4", { text: `${t("SETTINGS_HEADER")}` });
header.addClass("sr-centered");
this.tab_structure = createTabs(
@@ -910,7 +910,7 @@ console.log(`tabNotes`);
// Copyright notice
const copyright_paragraph = containerEl.createEl("p");
- copyright_paragraph.addClass("SC-small-font");
+ copyright_paragraph.addClass("sr-small-font");
copyright_paragraph.insertAdjacentHTML("beforeend", `
Shell commands plugin Copyright © 2021 - 2023 Jarkko Linnanvirta. This program comes with ABSOLUTELY NO WARRANTY. This is free software, and you are welcome to redistribute it under certain conditions. See more information in the license: GNU GPL-3.0.
`); */
diff --git a/styles.css b/styles.css
index af8e7a1d..4329ee1d 100644
--- a/styles.css
+++ b/styles.css
@@ -282,3 +282,58 @@ body:not(.native-scrollbars) #sr-modal .modal-close-button {
appearance: menulist;
border-right: 8px solid transparent;
}
+
+/*
+ * Tab elements
+ * This CSS is copied from https://github.com/Taitava/obsidian-shellcommands
+ * Jarkko Linnanvirta https://github.com/Taitava comments below...
+ * - Renamed classes
+ *
+ * This CSS is copied 2021-10-21 from https://www.w3schools.com/howto/howto_js_tabs.asp
+ * Modifications:
+ * - Renamed classes
+ * - Added tab icons.
+ * - Changed colors.
+ * - Changed/removed borders.
+ * - Removed button transition.
+ * - Changed button border-radiuses
+ * - Added margin-right rule to .sr-tab-header-button .
+ */
+
+/* Style the tab */
+.sr-tab-header {
+ border-bottom: 6px solid var(--background-modifier-border);
+}
+
+/* Style the buttons that are used to open the tab content */
+button.sr-tab-header-button {
+ background-color: unset;
+ border: none;
+ box-shadow: none; /* Remove a "border" that came via Obsidian 0.16.0. */
+ outline: none;
+ cursor: pointer;
+ padding: 14px 16px;
+ margin-right: 6px; /* Reduced margin. Obsidian's default margin-right for button is 12px (0 for other margins). */
+ border-radius: 10px 10px 0 0; /* 0 0 = No border-radius at bottom */
+}
+
+/* Create an active/current tablink class */
+button.sr-tab-header-button.sr-tab-active,
+button.sr-tab-header-button:hover {
+ background-color: var(--background-modifier-border);
+}
+
+.sr-tab-header-button svg {
+ vertical-align: middle; /* Not middle but close enough. */
+}
+
+/* Style the tab content */
+.sr-tab-content {
+ display: none;
+ padding: 6px 12px;
+}
+
+.sr-tab-content.sr-tab-active {
+ display: block;
+}
+