Routing changes for focusView
This commit is contained in:
parent
26cd0660ed
commit
fed32d6f86
@ -102,12 +102,12 @@ export function AllImagesView(vm, params, key, { appbar }) {
|
|||||||
function photoClick(evt, node, vm) {
|
function photoClick(evt, node, vm) {
|
||||||
if (selectMode()) {
|
if (selectMode()) {
|
||||||
toggleSelect(evt, node, vm);
|
toggleSelect(evt, node, vm);
|
||||||
} else {
|
|
||||||
// todo implement zoom-view
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggleSelect(evt, node, vm) {
|
function toggleSelect(evt, node, vm) {
|
||||||
|
evt.preventDefault();
|
||||||
|
|
||||||
const imageNode = nodeParentWithType(node, 'image');
|
const imageNode = nodeParentWithType(node, 'image');
|
||||||
const id = imageNode.data._id;
|
const id = imageNode.data._id;
|
||||||
if (selectedIds.has(id)) {
|
if (selectedIds.has(id)) {
|
||||||
|
|||||||
@ -7,19 +7,16 @@ import {
|
|||||||
patchNodeStyle,
|
patchNodeStyle,
|
||||||
subscribeToRender
|
subscribeToRender
|
||||||
} from '../../utils/domvm.js';
|
} from '../../utils/domvm.js';
|
||||||
|
import { router } from '../../services/router.js';
|
||||||
import { injectStyle, styled } from '../../services/style.js';
|
import { injectStyle, styled } from '../../services/style.js';
|
||||||
import { DEFAULT_TRANSITION, CSS_FULL_SIZE, IMAGE_MARGIN, CLICKABLE } from '../styles.js';
|
import { DEFAULT_TRANSITION, CSS_FULL_SIZE, IMAGE_MARGIN, CLICKABLE } from '../styles.js';
|
||||||
import { Icon } from './icon.js';
|
import { Icon } from './icon.js';
|
||||||
import { AttachmentImageView } from './attachmentImage.js';
|
import { AttachmentImageView } from './attachmentImage.js';
|
||||||
|
|
||||||
const _imageHover = false;
|
|
||||||
const dim = 'opacity: 0.7;';
|
|
||||||
const off = 'opacity: 0;';
|
|
||||||
const full = 'opacity: 1;';
|
|
||||||
|
|
||||||
export function AlbumPhotoTemplate(vm, { doc }) {
|
export function AlbumPhotoTemplate(vm, { doc }) {
|
||||||
const photoSelectButtonRef = `pSB${doc._id}`;
|
const photoSelectButtonRef = `pSB${doc._id}`;
|
||||||
const photoOverlayRef = `pBkd${doc._id}`;
|
const photoOverlayRef = `pBkd${doc._id}`;
|
||||||
|
const href = router.href('focus', { id: doc._id });
|
||||||
const hover = prop(false);
|
const hover = prop(false);
|
||||||
const hoverSelectButton = prop(false);
|
const hoverSelectButton = prop(false);
|
||||||
|
|
||||||
@ -28,6 +25,7 @@ export function AlbumPhotoTemplate(vm, { doc }) {
|
|||||||
return function render(vm, { isSelected, selectMode }) {
|
return function render(vm, { isSelected, selectMode }) {
|
||||||
return photoContainer(
|
return photoContainer(
|
||||||
{
|
{
|
||||||
|
href,
|
||||||
class: 'photoContainer',
|
class: 'photoContainer',
|
||||||
onmouseenter: [hover, true],
|
onmouseenter: [hover, true],
|
||||||
onmouseleave: [hover, false],
|
onmouseleave: [hover, false],
|
||||||
@ -74,7 +72,7 @@ export function AlbumPhotoTemplate(vm, { doc }) {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const photoContainer = styled({
|
const photoContainer = styled('a', {
|
||||||
position: 'relative',
|
position: 'relative',
|
||||||
perspective: '1000px',
|
perspective: '1000px',
|
||||||
backgroundColor: '#eee',
|
backgroundColor: '#eee',
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import { prop } from 'frptools';
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
subscribeToRender,
|
subscribeToRender,
|
||||||
|
renderSwitch,
|
||||||
defineView as vw,
|
defineView as vw,
|
||||||
createView as cv,
|
createView as cv,
|
||||||
defineElement as el,
|
defineElement as el,
|
||||||
@ -19,30 +20,34 @@ import { routeChanged } from '../services/router.js';
|
|||||||
import { injectStyle, styled } from '../services/style.js';
|
import { injectStyle, styled } from '../services/style.js';
|
||||||
|
|
||||||
export function GalleryView(vm) {
|
export function GalleryView(vm) {
|
||||||
let data = null;
|
|
||||||
let laCleanup = null;
|
|
||||||
const context = {};
|
const context = {};
|
||||||
const hasData = prop(null);
|
|
||||||
const appbar = cv(AppBarView, {}, 'appbar', context);
|
const appbar = cv(AppBarView, {}, 'appbar', context);
|
||||||
|
const routeName = prop();
|
||||||
|
const routeParams = prop();
|
||||||
|
|
||||||
routeChanged.subscribe(function onRouteChange(name, params) {
|
routeChanged.subscribe(function onRouteChange(name, params) {
|
||||||
if (name == 'photos') {
|
routeName(name);
|
||||||
ImageType.find({
|
routeParams(params);
|
||||||
['sizes.thumbnail']: { $exists: true }
|
|
||||||
}).then(results => {
|
|
||||||
hasData(results.length > 0);
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
throw new Error('Should not happen');
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
function handleContentScroll(evt) {
|
function handleContentScroll(evt) {
|
||||||
context.appbar.companionScrollTop(evt.target.scrollTop);
|
context.appbar.companionScrollTop(evt.target.scrollTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderWelcomePane() {
|
function renderMain() {
|
||||||
return [Overlay([el('h1', 'Hi')])];
|
return [
|
||||||
|
iv(appbar),
|
||||||
|
content(
|
||||||
|
{ onscroll: handleContentScroll },
|
||||||
|
renderSwitch(
|
||||||
|
{
|
||||||
|
photos: [AllImagesView, {}, 'allImages', context]
|
||||||
|
// focus: renderFocus
|
||||||
|
},
|
||||||
|
routeName()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderDropPane() {
|
function renderDropPane() {
|
||||||
@ -57,25 +62,7 @@ export function GalleryView(vm) {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderMain() {
|
|
||||||
return [
|
|
||||||
iv(appbar),
|
|
||||||
content(
|
|
||||||
{
|
|
||||||
onscroll: handleContentScroll
|
|
||||||
},
|
|
||||||
hasData() ? [vw(AllImagesView, {}, 'allImages', context)] : [renderWelcomePane()]
|
|
||||||
)
|
|
||||||
];
|
|
||||||
}
|
|
||||||
|
|
||||||
subscribeToRender(vm, [hasData]);
|
|
||||||
|
|
||||||
return function render() {
|
return function render() {
|
||||||
if (hasData() === null) {
|
|
||||||
return Overlay([el('h1', 'Loading...')]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return el('.gallery', { class: fill }, [
|
return el('.gallery', { class: fill }, [
|
||||||
vw(
|
vw(
|
||||||
Dropzone,
|
Dropzone,
|
||||||
|
|||||||
@ -11,6 +11,14 @@ export const router = Router([
|
|||||||
path: '/',
|
path: '/',
|
||||||
enter: (r, route) => fire('photos', route)
|
enter: (r, route) => fire('photos', route)
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: 'focus',
|
||||||
|
path: '/focus/:id',
|
||||||
|
vars: {
|
||||||
|
id: /^[_A-Za-z0-9]+$/
|
||||||
|
},
|
||||||
|
enter: (r, route) => fire('image', route)
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: '404',
|
id: '404',
|
||||||
path: ':vars',
|
path: ':vars',
|
||||||
|
|||||||
@ -1,5 +1,6 @@
|
|||||||
// export * from 'domvm/dist/dev/domvm.dev.js';
|
// export * from 'domvm/dist/dev/domvm.dev.js';
|
||||||
export * from 'domvm/dist/mini/domvm.mini.js';
|
export * from 'domvm/dist/mini/domvm.mini.js';
|
||||||
|
import { defineView } from 'domvm/dist/mini/domvm.mini.js';
|
||||||
import { call } from 'frptools';
|
import { call } from 'frptools';
|
||||||
import { deepAssign } from './conversion.js';
|
import { deepAssign } from './conversion.js';
|
||||||
import { error } from '../services/console.js';
|
import { error } from '../services/console.js';
|
||||||
@ -44,3 +45,8 @@ export function nodeParentWithType(node, type) {
|
|||||||
}
|
}
|
||||||
return parentNode;
|
return parentNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function renderSwitch(renderMap, switchValue) {
|
||||||
|
const params = renderMap[switchValue];
|
||||||
|
return params ? defineView.apply(null, params) : 'NOT FOUND';
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user