Skip to content

Commit

Permalink
finish all required features
Browse files Browse the repository at this point in the history
  • Loading branch information
erykpiast committed Jun 10, 2015
1 parent d741245 commit 27f2926
Show file tree
Hide file tree
Showing 13 changed files with 247 additions and 80 deletions.
30 changes: 22 additions & 8 deletions demo/demo.index.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion demo/index.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
import fileManager from '../src/file-manager/js';

fileManager(document.body);
fileManager(document.body);

// import test from '../src/test/js';

// test(document.body);
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
"bem-cn": "^1.0.0",
"core-js": "^0.9.11",
"cyclejs": "^0.22.0",
"cyclejs-group": "^0.5.0",
"cyclejs-group": "^0.6.0",
"cyclejs-stream": "^0.3.2",
"dedent": "^0.4.0",
"ramda": "~0.14",
Expand Down
21 changes: 2 additions & 19 deletions src/file-manager/css/_components/files-list-item.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
.files-list-item {
$buttons-space: .5em;
$input-offset: 4px; // to make text indent equal for label end rename form

height: 2em;
height: $file-list-item-height;
line-height: $file-list-item-height;

&:before,
&__rename-form,
Expand All @@ -22,21 +20,6 @@
margin-left: $input-offset;
}

&__rename-form {
.file-rename-form__input {
$border-width: 2px;

// make text indent equal for label end rename form
margin-left: 0;
border-width: $border-width;
padding-left: $input-offset - $border-width;

margin-right: $buttons-space; // pull buttons

max-width: 8em;
}
}

&__button--rename-cancel {
margin-left: $buttons-space;
margin-top: 1.5px; // accidental offset
Expand Down
6 changes: 5 additions & 1 deletion src/file-manager/css/_vars.scss
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@ $color: (
background: #FFF,
row-even: #EEE,
row-odd: #FFF
);
);

$file-list-item-height: 2em;
$buttons-space: .5em;
$input-offset: 4px; // to make text indent equal for label end rename form
36 changes: 33 additions & 3 deletions src/file-manager/css/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,43 @@ body {
}

.files {



.add-new {
height: $file-list-item-height;
line-height: $file-list-item-height;

& > * {
display: inline-block;
vertical-align: middle;
}

.file-rename-form__input {
margin-right: $buttons-space; // pull buttons
}

&__cancel {
margin-left: $buttons-space;
margin-top: 1.5px; // accidental offset
}
}

.file-rename-form__input {
$border-width: 2px;

// make text indent equal for label end rename form
margin-left: 0;
border-width: $border-width;
padding-left: $input-offset - $border-width;

margin-right: $buttons-space; // pull buttons

max-width: 8em;
}
}

.removal-confirmation {
background-color: map-get($color, 'background');

&__message {
margin-top: 0;
white-space: pre-wrap;
Expand Down
16 changes: 11 additions & 5 deletions src/file-manager/js/components/file-rename-form/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { registerCustomElement, h, Rx } from 'cyclejs';
import FocusHook from 'cyclejs/node_modules/virtual-dom/virtual-hyperscript/hooks/focus-hook';
import createGroup from 'cyclejs-group';

import modelDefinition from './model';


export default function createFileRenameFormElement(tagName) {
let formClass = tagName;
Expand All @@ -11,10 +10,16 @@ export default function createFileRenameFormElement(tagName) {
let applyButtonClass = buttonClass + '--apply';

registerCustomElement(tagName, (interactions, properties) => {
let model = createGroup(modelDefinition);
let model = createGroup({
value$: (initialValue$, apply$, input$) =>
apply$.withLatestFrom(
input$.merge(initialValue$),
(apply, input) => input
).merge(initialValue$)
});

model.inject({
initialValue$: properties.get('value'),
initialValue$: properties.get('value').take(1),
apply$: interactions.get(`.${formClass}`, 'submit')
.tap((e) => e.preventDefault()),
input$: interactions.get(`.${inputClass}`, 'input')
Expand All @@ -30,7 +35,8 @@ export default function createFileRenameFormElement(tagName) {
h('input', {
className: `${inputClass}`,
type: 'text',
value: value
value: value,
'focus-hook': new FocusHook()
}),
h('button', {
type: 'submit',
Expand Down
7 changes: 0 additions & 7 deletions src/file-manager/js/components/file-rename-form/model.js

This file was deleted.

5 changes: 1 addition & 4 deletions src/file-manager/js/components/files-list-item/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { registerCustomElement, h, Rx } from 'cyclejs';
import createGroup from 'cyclejs-group';

import fileRenameForm from '../file-rename-form';
import modelDefinition from './model';

fileRenameForm('file-rename-form');


export default function createFilesListItemElement(tagName) {
let itemClass = tagName;
Expand Down Expand Up @@ -49,7 +46,7 @@ export default function createFilesListItemElement(tagName) {
return {
vtree$,
name$: interactions.get(`.${renameFormClass}`, 'value')
.map(({ detail}) => detail)
.map(({ detail }) => detail)
};
});

Expand Down
4 changes: 2 additions & 2 deletions src/file-manager/js/components/selectable-list/model.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
export default {
options$: (children$, change$, selectAll$, options$) =>
change$.withLatestFrom(
options$,
options$.delay(1),
(change, options) =>
options.map(({ element, id, selected }) => ({
id,
Expand All @@ -15,7 +15,7 @@ export default {
)
.merge(
selectAll$.withLatestFrom(
options$,
options$.delay(1),
(selected, options) =>
options.map(({ element, id }) => ({
id,
Expand Down
Loading

0 comments on commit 27f2926

Please sign in to comment.