Skip to content

Commit

Permalink
feat: Indexes on labels for lists and partials.
Browse files Browse the repository at this point in the history
  • Loading branch information
Zoramite committed Aug 12, 2021
1 parent a328f15 commit 4c8c210
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 13 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@
"webpack-merge": "^5.8.0"
},
"dependencies": {
"@blinkk/selective-edit": "^3.0.1",
"@blinkk/selective-edit": "^3.1.0",
"@toast-ui/editor": "^3.0.2",
"bent": "^7.3.12",
"codemirror": "^5.62.2",
Expand Down
6 changes: 6 additions & 0 deletions src/sass/selective/_selective.sass
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@
border: $le-border-size-medium dashed var(--color-warning)
color: var(--color-warning)

.selective__index
margin-right: $le-space-small

&::after
content: '.'

@import './field'
@import './fields'
@import './mixins'
2 changes: 1 addition & 1 deletion src/sass/selective/field/_generic_partials.sass
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

> .selective__list__fields__header > .selective__list__item__preview,
> .selective__list__item__preview
span
.selective__field__partials__preview
margin-left: $le-space-small
font-size: $le-font-size-small

Expand Down
19 changes: 12 additions & 7 deletions src/ts/projectType/generic/field/partials.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,8 @@ import {
findPreviewValue,
} from '@blinkk/selective-edit/dist/utility/preview';

import {
EVENT_RENDER_COMPLETE,
EVENT_UNLOCK,
} from '@blinkk/selective-edit/dist/selective/events';
import {EVENT_RENDER_COMPLETE} from '../../../editor/events';
import {EVENT_UNLOCK} from '@blinkk/selective-edit/dist/selective/events';
import {PartialData} from '../../../editor/api';
import cloneDeep from 'lodash.clonedeep';
import merge from 'lodash.merge';
Expand Down Expand Up @@ -357,6 +355,9 @@ class GenericPartialListFieldItem extends ListFieldItem {
data: DeepObject,
index?: number
): TemplateResult {
const indexLabel = html`${index !== undefined
? html`<span class="selective__index">${index + 1}</span>`
: ''}`;
const partialValue = this.fields.value;
const partialKey = partialValue?.partial;
if (partialKey && this.listField.partials) {
Expand All @@ -371,10 +372,14 @@ class GenericPartialListFieldItem extends ListFieldItem {
);

if (partial.editor?.label) {
return html`${partial.editor?.label}
${previewValue ? html`<span>${previewValue}</span>` : ''}`;
return html`${indexLabel}${partial.editor?.label}
${previewValue
? html`<span class="selective__field__partials__preview"
>${previewValue}</span
>`
: ''}`;
}
return html`${partialKey}`;
return html`${indexLabel}${partialKey}`;
}

return super.templatePreviewValue(editor, data, index);
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -208,10 +208,10 @@
"@babel/helper-validator-identifier" "^7.14.9"
to-fast-properties "^2.0.0"

"@blinkk/selective-edit@^3.0.1":
version "3.0.1"
resolved "https://registry.yarnpkg.com/@blinkk/selective-edit/-/selective-edit-3.0.1.tgz#fe54b76144f6abfde508d33276e5468c0580c9c9"
integrity sha512-WbW/r3v53iTdAoPBxRuIMNh3P4nvyamSQLDVswoFwhFZY/U2TONF11VwvHr3QL9DcsGe51N5Qph0nXkvAwWitA==
"@blinkk/selective-edit@^3.1.0":
version "3.1.0"
resolved "https://registry.yarnpkg.com/@blinkk/selective-edit/-/selective-edit-3.1.0.tgz#6c8e52347db8e0c17d7fcc25c364cd34175a92b7"
integrity sha512-btUdFpjio592QsUYpBCPfwY+yy+7ASuTSVDNkekkFCa9EfoqCYlutBGknqsabWnJvTCRaemU1NuDhmYTGftiLQ==
dependencies:
json-stable-stringify "^1.0.1"
lit-html "^1.4.1"
Expand Down

0 comments on commit 4c8c210

Please sign in to comment.