aboutsummaryrefslogtreecommitdiff
path: root/src/view
diff options
context:
space:
mode:
authorJoris2023-09-09 23:07:03 +0200
committerJoris2023-09-09 23:07:03 +0200
commit327f59797558343e00abe761d92c55e4e32347bb (patch)
tree7129e8d03a44c6eca15fc463e3157d8dd0e3beec /src/view
parent82429caf3c2886c2d94e09d020e645b06bd4680d (diff)
Improve modal style
Diffstat (limited to 'src/view')
-rw-r--r--src/view/books.ts29
-rw-r--r--src/view/components/modal.ts24
2 files changed, 33 insertions, 20 deletions
diff --git a/src/view/books.ts b/src/view/books.ts
index 6ea0c12..4229774 100644
--- a/src/view/books.ts
+++ b/src/view/books.ts
@@ -42,20 +42,25 @@ interface BookDetailModalParams {
function bookDetailModal({ book, onClose }: BookDetailModalParams): Html {
return Modal.view({
- content: h('div',
+ header: h('div',
+ h('div', { className: 'g-BookDetail__Title' }, `${book.title}, ${book.date}`),
+ book.subtitle && h('div', { className: 'g-BookDetail__Subtitle' }, book.subtitle)
+ ),
+ body: h('div',
{ className: 'g-BookDetail' },
- h('div',
- h('div', { className: 'g-BookDetail__Title' }, `${book.title}, ${book.date}`),
- book.subtitle && h('div', { className: 'g-BookDetail__Subtitle' }, book.subtitle),
- book.authors.join(', '),
- h('div',
- { className: 'g-BookDetail__Genres' },
- book.genres.length > 1 ? 'Genres : ' : 'Genre : ',
- book.genres.join(', ')
- )
- ),
- h('img', { src: book.cover })
+ h('img', { src: book.cover }),
+ h('dl',
+ metadata('Auteur', book.authors),
+ metadata('Genre', book.genres)
+ )
),
onClose
})
}
+
+function metadata(term: string, descriptions: Array<string>): Html {
+ return h('div',
+ h('dt', term, descriptions.length > 1 && 's', ' :'),
+ h('dd', ' ', descriptions.join(', '))
+ )
+}
diff --git a/src/view/components/modal.ts b/src/view/components/modal.ts
index fe08272..95f907c 100644
--- a/src/view/components/modal.ts
+++ b/src/view/components/modal.ts
@@ -1,11 +1,12 @@
import { h, Html } from 'lib/rx'
interface Params {
- content: Html,
+ header: Html,
+ body: Html,
onClose: () => void
}
-export function view({ content, onClose }: Params): Html {
+export function view({ header, body, onClose }: Params): Html {
return h('div',
{ className: 'g-Modal',
onclick: () => onClose()
@@ -14,13 +15,20 @@ export function view({ content, onClose }: Params): Html {
{ className: 'g-Modal__Content',
onclick: (e: Event) => e.stopPropagation()
},
- h('button',
- { className: 'g-Modal__Close',
- onclick: () => onClose()
- },
- '✖'
+ h('div',
+ { className: 'g-Modal__Header' },
+ header,
+ h('button',
+ { className: 'g-Modal__Close',
+ onclick: () => onClose()
+ },
+ '✕'
+ )
),
- content
+ h('div',
+ { className: 'g-Modal__Body' },
+ body
+ )
)
)
}