generated from obsidianmd/obsidian-sample-plugin
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added possibility to not include chess Hanayama Huzzle puzzles
- Loading branch information
Showing
10 changed files
with
83 additions
and
11 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
40 changes: 40 additions & 0 deletions
40
src/recipes/hanayama_huzzles/settings/HanayamaHuzzlesRecipeExtraSettingsAdder.ts
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,40 @@ | ||
import { Setting } from 'obsidian'; | ||
import { RecipeExtraSettingsAdder } from 'src/settings/RecipeExtraSettingsAdder'; | ||
import { SettingsAdder } from 'src/settings/SettingsAdder'; | ||
import { HanayamaHuzzlesRecipe } from '../HanayamaHuzzlesRecipe'; | ||
import { HanayamaHuzzlesRecipeSettings } from './HanayamaHuzzlesRecipeSettings'; | ||
|
||
export class HanayamaHuzzlesRecipeExtraSettingsAdder implements RecipeExtraSettingsAdder { | ||
private includeChessPuzzlesSetting: Setting; | ||
|
||
constructor( | ||
private root: HTMLElement, | ||
private settingsAdder: SettingsAdder, | ||
private settings: HanayamaHuzzlesRecipeSettings | ||
) {} | ||
|
||
add(): Setting[] { | ||
this.includeChessPuzzlesSetting = this.settingsAdder.add( | ||
'Include chess puzzles', | ||
this.root.createFragment( | ||
this.root.createText('span', 'Whether to include the chess puzzles ('), | ||
this.root.createLink(HanayamaHuzzlesRecipe.CHESS_PUZZLES_WEBPAGE), | ||
this.root.createText('span', ') or not.') | ||
) | ||
); | ||
|
||
return [this.includeChessPuzzlesSetting]; | ||
} | ||
|
||
activate(onChange: () => Promise<void>) { | ||
this.includeChessPuzzlesSetting.addToggle(toggle => { | ||
return toggle | ||
.setValue(this.settings.includeChessPuzzles) | ||
.onChange(async (value) => { | ||
this.settings.includeChessPuzzles = value; | ||
|
||
await onChange(); | ||
}); | ||
}); | ||
} | ||
} |
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
File renamed without changes.
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,6 @@ | ||
import { Setting } from 'obsidian'; | ||
|
||
export interface RecipeExtraSettingsAdder { | ||
add(): Setting[]; | ||
activate(onChange: () => Promise<void>): void; | ||
} |
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 |
---|---|---|
|
@@ -6,3 +6,8 @@ | |
display: inline-block; | ||
margin-block-end: var(--p-spacing); | ||
} | ||
|
||
.is-disabled { | ||
pointer-events: none; | ||
opacity: 0.2; | ||
} |