Split out the AppBar
This commit is contained in:
parent
ebd04a0d72
commit
dba6f3c204
38
packages/gallery/src/interface/components/appbar.js
Normal file
38
packages/gallery/src/interface/components/appbar.js
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
import { defineElement as el } from '../../utils/domvm.js';
|
||||||
|
import { prop, computed, bundle } from 'frptools';
|
||||||
|
import { injectStyle, styled } from '../../services/style.js';
|
||||||
|
|
||||||
|
export function AppBarView(vm, params, key, opts) {
|
||||||
|
if (opts.appbar) {
|
||||||
|
throw new Error('Cannot have more than one AppBar.');
|
||||||
|
}
|
||||||
|
|
||||||
|
const title = prop(params.title);
|
||||||
|
const renderButtons = prop(params.renderButtons);
|
||||||
|
|
||||||
|
return (vm, params) => {
|
||||||
|
const { title } = params;
|
||||||
|
return header([
|
||||||
|
el('div', { style: 'font-size: 20pt' }, title),
|
||||||
|
headerRight(
|
||||||
|
{
|
||||||
|
css: { visibility: /* selectMode */ true ? 'visible' : 'hidden' }
|
||||||
|
},
|
||||||
|
renderButtons()()
|
||||||
|
)
|
||||||
|
]);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const header = styled({
|
||||||
|
justifyContent: 'space-between',
|
||||||
|
padding: '1em',
|
||||||
|
zIndex: 1,
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center'
|
||||||
|
});
|
||||||
|
|
||||||
|
const headerRight = styled({
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center'
|
||||||
|
});
|
||||||
@ -7,6 +7,7 @@ import { ThumbnailTemplate } from './thumbnail.js';
|
|||||||
import { AlbumView } from './album.js';
|
import { AlbumView } from './album.js';
|
||||||
import { Dropzone } from './components/dropzone.js';
|
import { Dropzone } from './components/dropzone.js';
|
||||||
import { Overlay } from './components/overlay.js';
|
import { Overlay } from './components/overlay.js';
|
||||||
|
import { AppBarView } from './components/appbar.js';
|
||||||
import { Icon } from './components/icon.js';
|
import { Icon } from './components/icon.js';
|
||||||
import { router, routeChanged } from '../services/router.js';
|
import { router, routeChanged } from '../services/router.js';
|
||||||
import { injectStyle, styled } from '../services/style.js';
|
import { injectStyle, styled } from '../services/style.js';
|
||||||
@ -30,6 +31,7 @@ export function GalleryView(vm) {
|
|||||||
|
|
||||||
let data = null;
|
let data = null;
|
||||||
let laCleanup = null;
|
let laCleanup = null;
|
||||||
|
const context = {};
|
||||||
const title = prop('');
|
const title = prop('');
|
||||||
|
|
||||||
function uploadImages(evt, files) {
|
function uploadImages(evt, files) {
|
||||||
@ -86,33 +88,41 @@ export function GalleryView(vm) {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function renderAppBarButtons() {
|
||||||
|
return [
|
||||||
|
el('button', [el('label', { for: 'uploadButton' }, 'Upload')]),
|
||||||
|
el('input', {
|
||||||
|
id: 'uploadButton',
|
||||||
|
name: 'uploadButton',
|
||||||
|
type: 'file',
|
||||||
|
multiple: true,
|
||||||
|
accept: '.png,.jpg,.jpeg', // no love for gifs yet
|
||||||
|
onchange: uploadImages,
|
||||||
|
class: injectStyle({ display: 'none' })
|
||||||
|
})
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
function renderMain() {
|
function renderMain() {
|
||||||
return [
|
return [
|
||||||
header([
|
vw(
|
||||||
el('div', { style: 'font-size: 20pt' }, 'Gallery'),
|
AppBarView,
|
||||||
headerRight(
|
{
|
||||||
{
|
title: 'Photos',
|
||||||
css: { visibility: /* selectMode */ true ? 'visible' : 'hidden' }
|
renderButtons: renderAppBarButtons
|
||||||
},
|
},
|
||||||
[
|
'appbar',
|
||||||
el('button', [el('label', { for: 'uploadButton' }, 'Upload')]),
|
context
|
||||||
el('input', {
|
),
|
||||||
id: 'uploadButton',
|
el(
|
||||||
name: 'uploadButton',
|
'div',
|
||||||
type: 'file',
|
{ class: fill },
|
||||||
multiple: true,
|
data().length
|
||||||
accept: '.png,.jpg,.jpeg', // no love for gifs yet
|
? data().map(i => {
|
||||||
onchange: uploadImages,
|
return ThumbnailTemplate(i, deleteImage, i._hash());
|
||||||
class: injectStyle({ display: 'none' })
|
})
|
||||||
})
|
: [renderWelcomePane()]
|
||||||
]
|
)
|
||||||
)
|
|
||||||
]),
|
|
||||||
...(data().length
|
|
||||||
? data().map(i => {
|
|
||||||
return ThumbnailTemplate(i, deleteImage, i._hash());
|
|
||||||
})
|
|
||||||
: [renderWelcomePane()])
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,19 +147,6 @@ export function GalleryView(vm) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const header = styled({
|
|
||||||
justifyContent: 'space-between',
|
|
||||||
padding: '1em',
|
|
||||||
zIndex: 1,
|
|
||||||
display: 'flex',
|
|
||||||
alignItems: 'center'
|
|
||||||
});
|
|
||||||
|
|
||||||
const headerRight = styled({
|
|
||||||
display: 'flex',
|
|
||||||
alignItems: 'center'
|
|
||||||
});
|
|
||||||
|
|
||||||
const fill = injectStyle({
|
const fill = injectStyle({
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
flex: 1,
|
flex: 1,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user