refactor: btn options
This commit is contained in:
parent
7489bce5b8
commit
3212bf3db8
2 changed files with 12 additions and 1 deletions
10
src/btn.ts
10
src/btn.ts
|
@ -30,6 +30,8 @@ export const getDownloadBtn = (): BtnElement => {
|
||||||
interface BtnOptions {
|
interface BtnOptions {
|
||||||
readonly name: string;
|
readonly name: string;
|
||||||
readonly action: BtnAction;
|
readonly action: BtnAction;
|
||||||
|
readonly disabled?: boolean;
|
||||||
|
readonly tooltip?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export class BtnList {
|
export class BtnList {
|
||||||
|
@ -57,6 +59,14 @@ export class BtnList {
|
||||||
|
|
||||||
this.list.push(btn)
|
this.list.push(btn)
|
||||||
|
|
||||||
|
if (options.disabled) {
|
||||||
|
btn.disabled = options.disabled
|
||||||
|
}
|
||||||
|
|
||||||
|
if (options.tooltip) {
|
||||||
|
btn.title = options.tooltip
|
||||||
|
}
|
||||||
|
|
||||||
return btn
|
return btn
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,6 +49,7 @@ const main = (): void => {
|
||||||
|
|
||||||
btnList.add({
|
btnList.add({
|
||||||
name: 'Individual Parts',
|
name: 'Individual Parts',
|
||||||
|
tooltip: 'Download individual parts (BETA)',
|
||||||
action: BtnAction.mscoreWindow(async (w, score, txt) => {
|
action: BtnAction.mscoreWindow(async (w, score, txt) => {
|
||||||
const metadata = await score.metadata()
|
const metadata = await score.metadata()
|
||||||
console.log('score metadata loaded by webmscore', metadata)
|
console.log('score metadata loaded by webmscore', metadata)
|
||||||
|
@ -99,7 +100,7 @@ const main = (): void => {
|
||||||
saveAs(data, `${filename} - ${partName}.pdf`)
|
saveAs(data, `${filename} - ${partName}.pdf`)
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
}).title = 'Download individual parts (BETA)'
|
})
|
||||||
|
|
||||||
btnList.commit()
|
btnList.commit()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue