Standardize on some nomenclature

This commit is contained in:
Timothy Farrell 2017-11-27 09:41:01 -06:00
parent 7c8a9598ca
commit a3b4ea2920
5 changed files with 19 additions and 17 deletions

View File

@ -6,7 +6,7 @@ import { pouchDocArrayHash, pouchDocHash } from '../utils/conversion.js';
import { ThumbnailTemplate } from './thumbnail.js'; import { ThumbnailTemplate } from './thumbnail.js';
import { prop, computed } from 'frptools'; import { prop, computed } from 'frptools';
export function AlbumView(vm, doc) { export function AlbumView(vm, params) {
const model = prop({}, pouchDocHash); const model = prop({}, pouchDocHash);
const images = prop([], pouchDocArrayHash); const images = prop([], pouchDocArrayHash);
@ -57,9 +57,11 @@ export function AlbumView(vm, doc) {
subscriptions.forEach(s => s()); subscriptions.forEach(s => s());
} }
model(doc); model(params);
return function() {
const album = model();
return function(vm, album, key, opts) {
return el('.album', [ return el('.album', [
el('h2', title), el('h2', title),
el('button', { onclick: [removeAlbum, album] }, 'X'), el('button', { onclick: [removeAlbum, album] }, 'X'),

View File

@ -5,8 +5,8 @@ import { ImageType } from '../../data/image.js';
import { FileType } from '../../data/file.js'; import { FileType } from '../../data/file.js';
import { pouchDocHash } from '../../utils/conversion.js'; import { pouchDocHash } from '../../utils/conversion.js';
export function AttachmentImageView(vm, image) { export function AttachmentImageView(vm, params) {
const model = prop(image, pouchDocHash); const model = prop(params, pouchDocHash);
const id = computed(pouchDocHash, [model]); const id = computed(pouchDocHash, [model]);
const sizes = computed(d => d.sizes, [model]); // always update const sizes = computed(d => d.sizes, [model]); // always update
@ -45,7 +45,7 @@ export function AttachmentImageView(vm, image) {
URL.revokeObjectURL(blobURL()); URL.revokeObjectURL(blobURL());
} }
return function render(vm, doc) { return function render() {
return el('img', { return el('img', {
src: imageURL, src: imageURL,
onerror: loadImageFromBlob, onerror: loadImageFromBlob,

View File

@ -15,8 +15,8 @@ const CSS_DROPZONE_ACTIVE = {
backgroundColor: '#eee' backgroundColor: '#eee'
}; };
export function Dropzone(vm, model) { export function Dropzone(vm, params) {
const { ondrop, ondragenter, ondragleave, className, activeClassName, children } = model; const { ondrop, ondragenter, ondragleave, className, activeClassName, content } = params;
const baseClassName = className || injectStyle(CSS_DROPZONE); const baseClassName = className || injectStyle(CSS_DROPZONE);
const hoverClassName = `${baseClassName} ${activeClassName || injectStyle(CSS_DROPZONE_ACTIVE)}`; const hoverClassName = `${baseClassName} ${activeClassName || injectStyle(CSS_DROPZONE_ACTIVE)}`;
@ -54,7 +54,7 @@ export function Dropzone(vm, model) {
} }
} }
return function render(vm, model) { return function render() {
return el( return el(
'div', 'div',
{ {
@ -64,7 +64,7 @@ export function Dropzone(vm, model) {
ondragleave: onDragLeave, ondragleave: onDragLeave,
ondrop: onDrop ondrop: onDrop
}, },
children() content()
); );
}; };
} }

View File

@ -37,9 +37,9 @@ const ICON_PATHS = {
// const sizeBasis = 24; // const sizeBasis = 24;
export function Icon(props) { export function Icon(params) {
const { name, size } = props; const { name, size } = params;
const otherProps = Object.assign({}, props); const attrs = Object.assign({}, params);
const _size = (size || 1) + 1; const _size = (size || 1) + 1;
const [boxBounds, path] = ICON_PATHS[name] || ICON_PATHS.unknown; const [boxBounds, path] = ICON_PATHS[name] || ICON_PATHS.unknown;
@ -54,7 +54,7 @@ export function Icon(props) {
width: `${_size}em`, width: `${_size}em`,
height: `${_size}em` height: `${_size}em`
}, },
otherProps attrs
), ),
[sv('svg', { viewBox: `0 0 ${boxBounds}` }, [sv('path', { d: path })])] [sv('svg', { viewBox: `0 0 ${boxBounds}` }, [sv('path', { d: path })])]
); );

View File

@ -9,7 +9,7 @@ import { Dropzone } from './components/dropzone.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';
export function GalleryView(vm, model) { export function GalleryView(vm) {
const NAV_OPTIONS = { const NAV_OPTIONS = {
images: { images: {
data: ImageType.find( data: ImageType.find(
@ -79,7 +79,7 @@ export function GalleryView(vm, model) {
]; ];
} }
return function render(vm, params, key, opts) { return function render() {
if (!data || !data.ready()) { if (!data || !data.ready()) {
return el('h1', 'Loading...'); return el('h1', 'Loading...');
} }
@ -103,7 +103,7 @@ export function GalleryView(vm, model) {
type: 'file', type: 'file',
multiple: true, // FIXME - these don't carry through to the input tag multiple: true, // FIXME - these don't carry through to the input tag
accept: 'image/jpeg', accept: 'image/jpeg',
children: renderDropzone content: renderDropzone
}, },
'dz' 'dz'
) )