Skip to content

Добавляет новый тип вьюхи — Node #49

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open
4 changes: 2 additions & 2 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ gulp.task(`build-scripts`, () => {
json(),
babel({
babelrc: false,
exclude: [`node_modules/**`, `js/tests/**`],
exclude: [`node_modules/**`, `src/tests/**`],
presets: [
[`@babel/preset-env`, {modules: false, useBuiltIns: `entry`}]
]
Expand Down Expand Up @@ -115,7 +115,7 @@ gulp.task(`build-prompt`, () => {
json(),
babel({
babelrc: false,
exclude: [`node_modules/**`, `js/tests/**`],
exclude: [`node_modules/**`, `src/tests/**`],
presets: [
[`@babel/preset-env`, {modules: false}]
],
Expand Down
31 changes: 31 additions & 0 deletions sass/console-blocks/c-html.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
.c-html {
&__tag {
color: #a894a6;
}

&__tag-name {
color: #881280;
}

&__attr-name {
color: #994500;
}

&__attr-value,
&__id {
color: #1a1aa6;
}

&__comment,
&__doctype {
color: slategray;
}

// &__punctuation {
// color: #999999;
// }

&__link {
color: #4855cc;
}
}
2 changes: 1 addition & 1 deletion sass/console-blocks/console.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
.console {
font: 0.8em/normal "SFMono-Regular", "Consolas", "Liberation Mono", "Menlo", "Courier", "Courier New", monospace;
font: 0.8em/normal "Menlo", "Monaco", "Consolas", "Courier New", monospace;
line-height: 1.4;
cursor: default;

Expand Down
1 change: 1 addition & 0 deletions sass/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ __elem — element
@import "console-blocks/grey";
@import "console-blocks/error";
@import "console-blocks/nowrap";
@import "console-blocks/c-html";

// Prompt blocks
@import "prompt-blocks/prompt";
Expand Down
15 changes: 10 additions & 5 deletions src/array/array-view.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import TypeView from '../type-view';
import EntryView from '../entry-view';
import MapEntryView from '../object/map-entry-view';
import {getElement} from '../utils';
import {Mode, ViewType} from '../enums';
import {Mode, ViewType, GET_STATE_DESCRIPTORS_KEY_NAME} from '../enums';

const EMPTY = `empty`;
const MULTIPLY_SIGN = `×`;

const getStateDescriptorsKey = Symbol(GET_STATE_DESCRIPTORS_KEY_NAME);

export default class ArrayView extends TypeView {
constructor(params, cons) {
super(params, cons);
Expand All @@ -14,6 +17,8 @@ export default class ArrayView extends TypeView {
if (!params.parentView) {
this.rootView = this;
}

this._stateDescriptorsQueue.push(this[getStateDescriptorsKey]());
}

get template() {
Expand Down Expand Up @@ -42,7 +47,7 @@ export default class ArrayView extends TypeView {
this._state.isOpened = this.isOpeningAllowed;
}

_getStateDescriptors() {
[getStateDescriptorsKey]() {
const self = this;
return {
set isHeadContentShowed(bool) {
Expand Down Expand Up @@ -139,7 +144,7 @@ export default class ArrayView extends TypeView {
}
if (inHead && emptyCount !== 0 && (hasKey || i === l - 1)) {
TypeView.appendEntryElIntoFragment(
this._createEntryEl({key, el: getElement(`<span class="grey">${EMPTY}${emptyCount > 1 ? ` ${MULTIPLY_SIGN} ${emptyCount}` : ``}</span>`), withoutKey: true}),
new EntryView({key, entryEl: getElement(`<span class="grey">${EMPTY}${emptyCount > 1 ? ` ${MULTIPLY_SIGN} ${emptyCount}` : ``}</span>`), withoutKey: true}).el,
fragment
);
if (inHead && countEntriesWithoutKeys) {
Expand All @@ -150,9 +155,9 @@ export default class ArrayView extends TypeView {
if (hasKey) {
if (isMapEntriesSpecialValue) {
const pair = arr[i];
const el = new MapEntryView({val: pair, mode, depth: this.nextNestingLevel, parentView: this, propKey: this._propKey}, this._console).el;
const entryEl = new MapEntryView({val: pair, mode, depth: this.nextNestingLevel, parentView: this, propKey: this._propKey}, this._console).el;
TypeView.appendEntryElIntoFragment(
this._createEntryEl({key, el, withoutKey: inHead}),
new EntryView({key, entryEl, withoutKey: inHead}).el,
fragment
);
} else {
Expand Down
Loading