Skip to content

Commit

Permalink
chore: uploader cases tune WIP 2
Browse files Browse the repository at this point in the history
  • Loading branch information
foxeyes committed Apr 12, 2022
1 parent fc312d1 commit 6a78077
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 29 deletions.
5 changes: 0 additions & 5 deletions .stylelintrc

This file was deleted.

1 change: 1 addition & 0 deletions .stylelintrc.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = {
'declaration-block-no-redundant-longhand-properties': null,
'custom-property-empty-line-before': null,
'length-zero-no-unit': null,
'no-descending-specificity': null,
'value-keyword-case': [
'lower',
{
Expand Down
13 changes: 9 additions & 4 deletions abstract/Block.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,11 @@ export class Block extends BaseComponent {
'confirm-upload',
'init-activity',
'done-activity',
'cancel-activity',
];
unprefixedCfgProps.forEach((prop) => {
this.bindCssData(`--cfg-${prop}`);
});
}, true);
Block._cssDataBindingsList.push(this.ctxName);
}
}
Expand Down Expand Up @@ -202,12 +203,16 @@ export class Block extends BaseComponent {
};
}

get initActivity() {
return this.$['*--cfg-init-activity'];
}

get doneActivity() {
return this.getAttribute('done-activity');
return this.$['*--cfg-done-activity'];
}

get cancelActivity() {
return this.getAttribute('cancel-activity');
return this.$['*--cfg-cancel-activity'];
}

get isActivityActive() {
Expand Down Expand Up @@ -332,7 +337,7 @@ export class Block extends BaseComponent {

/** @enum {String} */
Block.activities = Object.freeze({
SOURCE_SELECT: 'source-select',
START_FROM: 'start-from',
CAMERA: 'camera',
DRAW: 'draw',
UPLOAD_LIST: 'upload-list',
Expand Down
2 changes: 1 addition & 1 deletion blocks/CameraSource/CameraSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class CameraSource extends Block {

onCancel: () => {
this.set$({
'*currentActivity': Block.activities.SOURCE_SELECT,
'*currentActivity': this.cancelActivity,
});
},
onShot: () => {
Expand Down
2 changes: 1 addition & 1 deletion blocks/ExternalSource/ExternalSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export class ExternalSource extends Block {
},
onCancel: () => {
this.set$({
'*currentActivity': Block.activities.SOURCE_SELECT,
'*currentActivity': this.cancelActivity,
});
},
};
Expand Down
2 changes: 1 addition & 1 deletion blocks/SimpleBtn/SimpleBtn.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class SimpleBtn extends Block {
});
} else {
this.set$({
'*currentActivity': Block.activities.SOURCE_SELECT,
'*currentActivity': Block.activities.START_FROM,
});
}
};
Expand Down
7 changes: 6 additions & 1 deletion blocks/StartFrom/StartFrom.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import { Block } from '../../abstract/Block.js';

export class StartFrom extends Block {
activityType = 'source-select';
activityType = 'start-from';

init$ = {
'*activityCaption': '',
'*activityIcon': '',
};

initCallback() {
this.registerActivity(this.activityType, () => {
Expand Down
6 changes: 4 additions & 2 deletions blocks/UploadList/UploadList.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export class UploadList extends Block {
hasFiles: false,
moreBtnDisabled: true,
onAdd: () => {
this.$['*currentActivity'] = Block.activities.SOURCE_SELECT;
this.$['*currentActivity'] = Block.activities.START_FROM;
},
onUpload: () => {
this.set$({
Expand Down Expand Up @@ -77,6 +77,8 @@ export class UploadList extends Block {
}

initCallback() {
super.initCallback();

this.bindCssData('--cfg-show-empty-list');

this.registerActivity(this.activityType, () => {
Expand All @@ -96,7 +98,7 @@ export class UploadList extends Block {

this.sub('*uploadList', (/** @type {String[]} */ list) => {
if (list && list.length === 0 && !this.$['*--cfg-show-empty-list']) {
this.$['*currentActivity'] = Block.activities.SOURCE_SELECT;
this.$['*currentActivity'] = Block.activities.START_FROM;
return;
}

Expand Down
2 changes: 1 addition & 1 deletion blocks/UrlSource/UrlSource.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class UrlSource extends Block {
},
onCancel: () => {
this.set$({
'*currentActivity': Block.activities.SOURCE_SELECT,
'*currentActivity': this.cancelActivity,
});
},
onInput: (e) => {
Expand Down
11 changes: 7 additions & 4 deletions blocks/themes/uc-basic/config.css
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
.uc-wgt-cfg, .uc-wgt-common, :host {
.uc-wgt-cfg,
.uc-wgt-common,
:host {
--cfg-multiple: 1;
--cfg-confirm-upload: 1;
--cfg-img-only: 0;
Expand All @@ -15,11 +17,12 @@

--cfg-modal-scroll-lock: 1;
--cfg-modal-backdrop-strokes: 1;

--cfg-source-list-wrap: 1;

--cfg-init-activity: 'source-select';
--cfg-done-activity: 'source-select';
--cfg-init-activity: 'start-from';
--cfg-done-activity: 'start-from';
--cfg-cancel-activity: 'start-from';

--cfg-data-output-console: 1;
--cfg-data-output-fire-events: 1;
Expand Down
3 changes: 2 additions & 1 deletion solutions/file-uploader/minimal/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
:host {
--cfg-multiple: 0;
--cfg-confirm-upload: 0;
--cfg-init-activity: 'source-select';
--cfg-init-activity: 'start-from';
--cfg-done-activity: 'upload-list';
}

uc-start-from {
Expand Down
9 changes: 1 addition & 8 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,7 @@
"target": "esnext",
"module": "esnext",
"moduleResolution": "node",
"lib": [
"es2017",
"ESNext",
"ESNext.Array",
"DOM",
"DOM.Iterable",
"WebWorker"
],
"lib": ["es2017", "ESNext", "ESNext.Array", "DOM", "DOM.Iterable", "WebWorker"],
"allowJs": true,
"checkJs": true,
"strict": false,
Expand Down

0 comments on commit 6a78077

Please sign in to comment.