Skip to content

Commit 69fb625

Browse files
refacto(css + varNames) improve css isolation
1 parent c09162d commit 69fb625

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed
Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1-
.highlighted {
1+
.react-json-path-editor-jsoneditor-container code .highlighted {
22
color: green;
33
font-weight: bold;
44
}
55

6-
code {
6+
.react-json-path-editor-jsoneditor-container code p.selectable:hover {
7+
background-color: grey;
8+
color: white;
9+
cursor: pointer;
10+
font-weight: bold;
11+
}
12+
13+
.react-json-path-editor-jsoneditor-container code {
714
color: #777;
815
font: 12px/normal 'Monaco', 'Menlo', 'Ubuntu Mono', 'Consolas', 'source-code-pro', monospace;
916
}
1017

11-
code p {
18+
.react-json-path-editor-jsoneditor-container code p {
1219
margin: 0;
1320
}

src/components/JsonPathPreviewer.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,13 @@ class JsonPathPreviewer extends Component {
5050

5151
convertTaggedJsonAsReactComponent(taggedJSON) {
5252
let increments = 0;
53-
let highlightBlock = false;
53+
let isBlockHighlighted = false;
5454
return taggedJSON.split(carriageReturnTag).map(line => {
5555
if (line.includes(indentationIncrementationTag)) increments++;
56-
if (line.includes(highlightingTags.start + '[') || line.includes(highlightingTags.start + '{')) highlightBlock = true;
56+
if (line.includes(highlightingTags.start + '[') || line.includes(highlightingTags.start + '{')) isBlockHighlighted = true;
57+
const isLineSelectable = line.includes(':');
5758
const toReturn = <React.Fragment>
58-
<p className={highlightBlock ? 'highlighted' : ''}>
59+
<p className={(isBlockHighlighted ? 'highlighted ' : '') + (isLineSelectable ? 'selectable' : '')}>
5960
{Array(increments).fill(<React.Fragment>&nbsp;</React.Fragment>)}
6061
{line.replace(new RegExp(indentationIncrementationTag,'g'), '').replace(new RegExp(indentationDecrementationTag,'g'), '')
6162
.split(highlightingTags.start).map(jsonPart => {
@@ -68,7 +69,7 @@ class JsonPathPreviewer extends Component {
6869
</p>
6970
</React.Fragment>;
7071
if (line.includes(indentationDecrementationTag)) increments--;
71-
if (line.includes(']' + highlightingTags.end) || line.includes('}' + highlightingTags.end)) highlightBlock = false;
72+
if (line.includes(']' + highlightingTags.end) || line.includes('}' + highlightingTags.end)) isBlockHighlighted = false;
7273
return toReturn;
7374
});
7475
}

0 commit comments

Comments
 (0)