The dashboard
When no book is open, the welcome screen is the writer's dashboard. It shows cards from plugins instead of its quote. If a plugin is turned off, its card goes away, and when no plugin has a card, the quote comes back. This needs "apiVersion": 2. A Bläck Studio that supports only API 1 tells the writer that the plugin needs a newer version.
export default class WordsToday extends Plugin {
onload() {
this.addDashboardWidget({ id: 'today', name: 'Today', size: 'half', order: 20, render: () => <Today app={this.app} /> })
}
}addDashboardWidget({ id, name, size?, order?, render }): adds a card.sizeis'half'(half the dashboard's width, the default) or'full'. Cards are sorted byorder, lowest first (100 if you don't give one), and then by name. Window only. These values only set where a card starts. The writer can drag it elsewhere and make it wider or narrower, and Bläck Studio remembers that. A card the writer hasn't placed yet (one just turned on) goes after the others.app.library, with thelibrary:readpermission:books(): the books on the recent list and every book in their series. Each book is summarised from its files: title, words, goal and deadline, the daily goal, the words written each day (history), scenes by status, its series and its place in it, and the scene written in most recently, with the end of its text. Every card asks for this as the screen needs it, but Bläck Studio reads the files only once for all of them.activity(): the latest saved versions (git), zip backups, and each book's last push of its history, whether it failed or not.open(path, { select? }): opens one of these books, at one of its documents.
app.ui.startSprint(minutes): starts a writing sprint in the open book.
Draw cards with Bläck Studio's classes, so they look like the rest of the dashboard:
dash-big: a large number.dash-muted: a quiet line.dash-rowsanddash-row: a list of rows, with a name at the start and a number at the end.dash-bar: progress, with a<span style="width: 40%">inside it. Adddoneto make it green.dash-quote: a passage of the book.dash-warn: a warning.btn,btn primaryandbtn ghost smfor buttons.