refactor: btn options

This commit is contained in:
Xmader 2020-09-28 17:41:51 -04:00
parent 7489bce5b8
commit 3212bf3db8
2 changed files with 12 additions and 1 deletions

View File

@ -30,6 +30,8 @@ export const getDownloadBtn = (): BtnElement => {
interface BtnOptions {
readonly name: string;
readonly action: BtnAction;
readonly disabled?: boolean;
readonly tooltip?: string;
}
export class BtnList {
@ -57,6 +59,14 @@ export class BtnList {
this.list.push(btn)
if (options.disabled) {
btn.disabled = options.disabled
}
if (options.tooltip) {
btn.title = options.tooltip
}
return btn
}

View File

@ -49,6 +49,7 @@ const main = (): void => {
btnList.add({
name: 'Individual Parts',
tooltip: 'Download individual parts (BETA)',
action: BtnAction.mscoreWindow(async (w, score, txt) => {
const metadata = await score.metadata()
console.log('score metadata loaded by webmscore', metadata)
@ -99,7 +100,7 @@ const main = (): void => {
saveAs(data, `${filename} - ${partName}.pdf`)
}
}),
}).title = 'Download individual parts (BETA)'
})
btnList.commit()
}