diff --git a/README.md b/README.md
index b2c59d58..8ddf25b3 100644
--- a/README.md
+++ b/README.md
@@ -33,7 +33,7 @@ jsonpanel({
arr: [0, 1, 2, 3]
}
},
- valTransformer: str => str.trim() // function to transform values before render
+ valueTransformer: str => str.trim() // function to transform values before render
});
```
diff --git a/src/pair.js b/src/pair.js
index 82ecdee1..fe2e868c 100644
--- a/src/pair.js
+++ b/src/pair.js
@@ -4,8 +4,8 @@ import Panel from './panel.js';
class Pair {
constructor(key, value, valueTransformer) {
this.key = key;
- this.val = value;
- this.valTransformer = valueTransformer;
+ this.value = value;
+ this.valueTransformer = valueTransformer;
}
static create(key, value, valueTransformer) {
@@ -20,18 +20,18 @@ class Pair {
return `${this.key}`;
}
- get valType() {
- return typeof this.val;
+ get valueType() {
+ return typeof this.value;
}
- getValInnerMarkup() {
- return JSON.stringify(this.val);
+ getValueInnerMarkup() {
+ return JSON.stringify(this.value);
}
createTagInnerMarkup() {
- return `${this.getKeyMarkup()}: ${this.getValInnerMarkup()}`;
+ return `${this.getKeyMarkup()}: ${this.getValueInnerMarkup()}`;
}
get class() {
@@ -55,30 +55,30 @@ class SimplePair extends Pair {
return `${super.class} simple`;
}
- getValInnerMarkup() {
- if (this.valTransformer instanceof Function) {
- return this.valTransformer(super.getValInnerMarkup());
+ getValueInnerMarkup() {
+ if (this.valueTransformer instanceof Function) {
+ return this.valueTransformer(super.getValueInnerMarkup());
}
- return super.getValInnerMarkup();
+ return super.getValueInnerMarkup();
}
}
class ExpandablePair extends Pair {
- get valType() {
- return Array.isArray(this.val) ? 'array' : 'object';
+ get valueType() {
+ return Array.isArray(this.value) ? 'array' : 'object';
}
get class() {
return `${super.class} expandable`;
}
- getValInnerMarkup() {
- const valueString = super.getValInnerMarkup();
- // Truncate the array / object preview using val-inner class.
- // eg. { key: "val" } -> {key: "val"}
+ getValueInnerMarkup() {
+ const valueString = super.getValueInnerMarkup();
+ // Truncate the array / object preview using value-inner class.
+ // eg. { key: "value" } -> {key: "value"}
const valueMatch = valueString.match(/^([{[])(.*)([}\]])$/);
- return `${valueMatch[1]}${valueMatch[2]}${valueMatch[3]}`;
+ return `${valueMatch[1]}${valueMatch[2]}${valueMatch[3]}`;
}
createTagInnerMarkup() {
@@ -99,8 +99,8 @@ class ExpandablePair extends Pair {
expand() {
// Open new panel
Panel.renderToEl(this.el, {
- data: this.val,
- valTransformer: this.valTransformer,
+ data: this.value,
+ valueTransformer: this.valueTransformer,
});
this.el.classList.add('expanded');
}
diff --git a/src/panel.js b/src/panel.js
index 0778150c..92864605 100644
--- a/src/panel.js
+++ b/src/panel.js
@@ -13,8 +13,8 @@ export default class Panel {
return this.options.data;
}
- get valTransformer() {
- return this.options.valTransformer;
+ get valueTransformer() {
+ return this.options.valueTransformer;
}
isArray() {
@@ -35,7 +35,7 @@ export default class Panel {
}
createListItem(key, value) {
- const pair = createPair(key, value, this.valTransformer);
+ const pair = createPair(key, value, this.valueTransformer);
pair.render();
return pair.el;
}
diff --git a/src/styles/jsonpanel-next.scss b/src/styles/jsonpanel-next.scss
index 3f2ecc77..10a9f71d 100644
--- a/src/styles/jsonpanel-next.scss
+++ b/src/styles/jsonpanel-next.scss
@@ -56,16 +56,16 @@
}
// Commas after every non-nested link item
- .val:after {
+ .value:after {
content: ",";
}
- &:last-child .val:after {
+ &:last-child .value:after {
display: none;
}
}
// Only applies in collapsed state
- .val-inner {
+ .value-inner {
display: inline-block;
max-width: 28em;
overflow: hidden;
@@ -101,7 +101,7 @@
content: "-";
}
- .val {
+ .value {
// Hide the Array/Object indicator
opacity: 0;
}
@@ -123,7 +123,7 @@
}
.array,
.object {
- .val-inner {
+ .value-inner {
color: #a5a5a5;
}
}
@@ -148,7 +148,7 @@
animation-fill-mode: forwards;
}
-.val {
+.value {
opacity: 1;
transition: opacity 0.4s ease;
}
diff --git a/test/jsonpanel.test.js b/test/jsonpanel.test.js
index 7024abe7..66df9400 100644
--- a/test/jsonpanel.test.js
+++ b/test/jsonpanel.test.js
@@ -91,11 +91,11 @@ describe('value transformer', () => {
data: {
testString,
},
- valTransformer: (string) => string.toLowerCase(),
+ valueTransformer: (string) => string.toLowerCase(),
});
const transformedValue =
- document.body.querySelector('.val.string').textContent;
+ document.body.querySelector('.value.string').textContent;
expect(transformedValue).toBe(`"${testString.toLowerCase()}"`);
});
@@ -108,12 +108,12 @@ describe('value transformer', () => {
testString,
},
},
- valTransformer: (string) => string.toLowerCase(),
+ valueTransformer: (string) => string.toLowerCase(),
});
document.body.querySelector('.expander').click();
const transformedValue =
- document.body.querySelector('.val.string').textContent;
+ document.body.querySelector('.value.string').textContent;
expect(transformedValue).toBe(`"${testString.toLowerCase()}"`);
});
});