-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Can now specify Weekday Abbreviations (#45)
- Loading branch information
1 parent
1b5b030
commit ac5928f
Showing
12 changed files
with
228 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<div class="setting-item-info"> | ||
<span class="setting-item-name"> | ||
<slot name="name" /> | ||
</span> | ||
<div class="setting-item-description"> | ||
<slot name="desc" /> | ||
</div> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,69 @@ | ||
import { App, Modal } from "obsidian"; | ||
import { App, ButtonComponent, Modal } from "obsidian"; | ||
import type { TimeSpan } from "src/@types"; | ||
|
||
export abstract class CalendariumModal extends Modal { | ||
constructor(public app: App) { | ||
super(app); | ||
this.containerEl.addClass("calendarium-modal") | ||
this.containerEl.addClass("calendarium-modal"); | ||
} | ||
} | ||
onOpen(): void { | ||
this.display(); | ||
} | ||
abstract display(): Promise<void>; | ||
} | ||
|
||
export abstract class CanceableCalendariumModal< | ||
T extends TimeSpan | ||
> extends CalendariumModal { | ||
constructor() { | ||
super(app); | ||
this.containerEl.addClasses(["has-buttons", "cancelable"]); | ||
} | ||
item: T; | ||
override onOpen(): void { | ||
this.display(); | ||
this.addButtons(); | ||
} | ||
addButtons() { | ||
const buttons = this.modalEl.createDiv( | ||
"calendarium-modal-buttons setting-item" | ||
); | ||
new ButtonComponent(buttons) | ||
.setButtonText("Cancel") | ||
.setCta() | ||
.onClick(this.cancel.bind(this)); | ||
} | ||
cancel() { | ||
this.onClose = () => {}; | ||
this.close(); | ||
this.onCancel(); | ||
} | ||
onCancel() {} | ||
} | ||
export abstract class SaveableCalendariumModal< | ||
T extends TimeSpan | ||
> extends CanceableCalendariumModal<T> { | ||
constructor() { | ||
super(); | ||
this.containerEl.addClasses(["saveable"]); | ||
} | ||
override onOpen(): void { | ||
this.display(); | ||
this.addButtons(); | ||
} | ||
addButtons() { | ||
const buttons = this.modalEl.createDiv("calendarium-modal-buttons"); | ||
new ButtonComponent(buttons) | ||
.setButtonText("Save") | ||
.setCta() | ||
.onClick(this.save.bind(this)); | ||
new ButtonComponent(buttons) | ||
.setButtonText("Cancel") | ||
.onClick(this.cancel.bind(this)); | ||
} | ||
save() { | ||
this.close(); | ||
this.onSave(); | ||
} | ||
onSave() {} | ||
} |
Oops, something went wrong.