mirror of
https://github.com/rifts-obsidian-laboratory/anki-integration.git
synced 2026-07-22 05:42:50 +00:00
Finishing Front-End Modal for the "Create Deck" feature - Editing 2 files and creating 1 file - "main.ts", "styles.css", "Modals.ts"
This commit is contained in:
parent
c2df7724a7
commit
8a443ab278
3 changed files with 83 additions and 2 deletions
46
src/Modals.ts
Normal file
46
src/Modals.ts
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
import {
|
||||
App, ButtonComponent, Modal
|
||||
} from "obsidian";
|
||||
|
||||
export class CreateDeckModal extends Modal {
|
||||
constructor(app: App) {
|
||||
super(app);
|
||||
}
|
||||
|
||||
onOpen() {
|
||||
const {contentEl} = this;
|
||||
// Adding the title of the modal
|
||||
contentEl.createEl("h1", {
|
||||
text: "Create a new deck",
|
||||
cls: [
|
||||
"ankiIntegrationModal__h1--width",
|
||||
"ankiIntegrationModal__h1--text-align"
|
||||
]
|
||||
})
|
||||
// Adding the input of the modal
|
||||
const inputEl = contentEl.createEl("input", {
|
||||
type: "text",
|
||||
placeholder: "Enter the name of your new deck.",
|
||||
cls: [
|
||||
"ankiIntegrationModal__input--width"
|
||||
]
|
||||
})
|
||||
// Adding the submitting button
|
||||
contentEl.createEl("button", {
|
||||
text: "Create deck",
|
||||
attr: {type: "submit"},
|
||||
cls: [
|
||||
"ankiIntegrationModal__button--width",
|
||||
"ankiIntegrationModal__button--margin",
|
||||
"ankiIntegrationModal__button--padding"
|
||||
]
|
||||
}).addEventListener("click", () => {
|
||||
this.close();
|
||||
})
|
||||
}
|
||||
|
||||
onClose() {
|
||||
const {contentEl} = this;
|
||||
contentEl.empty();
|
||||
}
|
||||
}
|
||||
16
src/main.ts
16
src/main.ts
|
|
@ -7,7 +7,10 @@ import {
|
|||
AnkiIntegrationSettings,
|
||||
DEFAULT_SETTINGS,
|
||||
AnkiIntegrationSettingTab
|
||||
} from "./AnkiIntegrationSettingTab"
|
||||
} from "./AnkiIntegrationSettingTab";
|
||||
import {
|
||||
CreateDeckModal
|
||||
} from "./Modals";
|
||||
|
||||
export default class AnkiIntegration extends Plugin {
|
||||
settings: AnkiIntegrationSettings;
|
||||
|
|
@ -16,7 +19,16 @@ export default class AnkiIntegration extends Plugin {
|
|||
await this.loadSetting();
|
||||
|
||||
// Adding the setting tab the user can use to edit settings.
|
||||
this.addSettingTab(new AnkiIntegrationSettingTab(this.app, this))
|
||||
this.addSettingTab(new AnkiIntegrationSettingTab(this.app, this));
|
||||
|
||||
// Adding a command to open the CreateDeckModal.
|
||||
this.addCommand({
|
||||
id: 'create-a-new-deck',
|
||||
name: 'Create a new deck',
|
||||
callback: () => {
|
||||
new CreateDeckModal(this.app).open();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async onunload() {
|
||||
|
|
|
|||
23
styles.css
23
styles.css
|
|
@ -0,0 +1,23 @@
|
|||
.ankiIntegrationModal__h1--margin {
|
||||
margin-top: 0;
|
||||
}
|
||||
|
||||
.ankiIntegrationModal__h1--text-align {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.ankiIntegrationModal__input--width {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.ankiIntegrationModal__button--width {
|
||||
width: 40%;
|
||||
}
|
||||
|
||||
.ankiIntegrationModal__button--margin {
|
||||
margin: 16px 30% 0;
|
||||
}
|
||||
|
||||
.ankiIntegrationModal__button--padding {
|
||||
padding: 4px 0;
|
||||
}
|
||||
Loading…
Reference in a new issue