Skip to content
This repository was archived by the owner on Mar 11, 2024. It is now read-only.

Commit e22a209

Browse files
committed
updated style, coverage script
1 parent 4e56edf commit e22a209

File tree

6 files changed

+46
-28
lines changed

6 files changed

+46
-28
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ example/example-react.js
44
webpack.config.template.js
55

66
# Coverage directory used by tools like istanbul
7-
coverage
7+
coverage
8+
9+
.nyc_output

.npmignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ example/example-react.js
1010
webpack.config.template.js
1111

1212
# Coverage directory used by tools like istanbul
13-
coverage
13+
coverage
14+
15+
.nyc_output

docker/coverage.sh

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ echo "Running with NODE_ENV=$NODE_ENV"
66

77
rm -rf ./coverage/*
88

9-
mkdir .nyc_output
10-
119
# run the workbench container
1210
docker run \
1311
-v $(pwd)/src:/react/src \
@@ -22,5 +20,3 @@ docker run \
2220
--entrypoint=/react/entrypoints/coverage.sh \
2321
-t react-json-view
2422

25-
26-
rm -rf .nyc_output

src/js/components/DataTypes/Object.js

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,9 @@ class rjvObject extends React.Component {
6161
}
6262

6363
getObjectContent = (depth, src, props) => {
64-
const {indentWidth} = this.state;
6564
return (<div class="pushed-content object-container">
6665
<div class="object-content"
67-
style={{marginLeft:(indentWidth*SINGLE_INDENT + "px")}}>
66+
style={{marginLeft: '6px'}}>
6867
{this.renderObjectContents(src, props)}
6968
</div>
7069
</div>);
@@ -92,21 +91,28 @@ class rjvObject extends React.Component {
9291
// `indentWidth` and `collapsed` props will
9392
// perpetuate to children via `...rest`
9493
const {
95-
depth, src, namespace, name, type, parent_type, theme, jsvRoot,
94+
depth, src, namespace, name, type,
95+
parent_type, theme, jsvRoot,
9696
...rest
9797
} = this.props;
9898
const {
9999
object_type, display_name, expanded
100100
} = this.state;
101101
//expanded/collapsed icon
102-
let expanded_icon;
102+
let expanded_icon, object_padding_left = 0;
103+
103104
if (expanded) {
104105
expanded_icon = <CircleMinus {...Theme(theme, 'expanded-icon')} />
105106
} else {
106107
expanded_icon = <CirclePlus {...Theme(theme, 'collapsed-icon')} />
107108
}
108109

109-
return (<div {...Theme(theme, jsvRoot ? 'jsv-root' : 'object-key-val')}>
110+
if (!jsvRoot) {
111+
object_padding_left = this.props.indentWidth * SINGLE_INDENT;
112+
}
113+
114+
115+
return (<div {...Theme(theme, jsvRoot ? 'jsv-root' : 'objectKeyVal', object_padding_left)}>
110116
<span>
111117
<span onClick={this.toggleCollapsed} {...Theme(theme, 'brace-row')}>
112118
<span class="icon-container">{expanded_icon}</span>
@@ -131,7 +137,10 @@ class rjvObject extends React.Component {
131137
: this.getElipsis()
132138
}
133139
<span class="brace-row">
134-
<span {...Theme(theme, 'brace')} >
140+
<span style={{
141+
...Theme(theme, 'brace').style,
142+
paddingLeft:(expanded ? '3px' : '0px')
143+
}} >
135144
{object_type == 'array' ? ']' : '}'}
136145
</span>
137146
{expanded ? null : this.getObjectMetaData(src)}
@@ -170,12 +179,12 @@ class rjvObject extends React.Component {
170179
/>);
171180
} else {
172181
elements.push(
173-
<div {...Theme(props.theme, 'object-key-val')}
182+
<div {...Theme(theme, 'objectKeyVal', this.props.indentWidth * SINGLE_INDENT)}
174183
key={variable.name}>
175184
{
176185
this.props.type == 'array'
177186
? (
178-
<div {...Theme(props.theme, 'array-key')}
187+
<div {...Theme(theme, 'array-key')}
179188
key={variable.name + '_' + namespace}>
180189
{variable.name}
181190
<div {...Theme(props.theme, 'colon')}>:</div>

src/js/themes/getStyle.js

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const colorMap = theme => ({
2525
}
2626
});
2727

28-
const getDefaultThemeStyling = theme => {
28+
const getDefaultThemeStyling = (theme, args) => {
2929
const colors = colorMap(theme);
3030

3131
return {
@@ -62,15 +62,20 @@ const getDefaultThemeStyling = theme => {
6262
margin: styleConstants.keyMargin,
6363
color: colors.keyColor
6464
},
65-
'object-key-val': {
66-
padding: styleConstants.keyValPadding,
67-
borderLeft: styleConstants.keyValBorderLeft
68-
+ ' ' + colors.objectBorder,
69-
':hover': {
70-
padding: styleConstants.keyValPaddingHover,
71-
borderLeft: styleConstants.keyValBorderHover
72-
+ ' ' + colors.objectBorder
73-
}
65+
objectKeyVal: (component, paddingLeft) => {
66+
return {style: {
67+
paddingLeft: paddingLeft + 'px',
68+
paddingTop: styleConstants.keyValPaddingTop,
69+
paddingRight: styleConstants.keyValPaddingRight,
70+
paddingBottom: styleConstants.keyValPaddingBottom,
71+
borderLeft: styleConstants.keyValBorderLeft
72+
+ ' ' + colors.objectBorder,
73+
':hover': {
74+
paddingLeft: (paddingLeft - 1) + 'px',
75+
borderLeft: styleConstants.keyValBorderHover
76+
+ ' ' + colors.objectBorder
77+
}
78+
}};
7479
},
7580
'object-key-val-no-border': {
7681
padding: styleConstants.keyValPadding
@@ -165,15 +170,17 @@ const getStyle = (theme) => {
165170
if (theme === false || theme === 'none') {
166171
rjv_theme = rjv_grey;
167172
}
173+
168174
return createStyling(
169175
getDefaultThemeStyling,
170-
{defaultBase16: rjv_theme},
176+
{defaultBase16: rjv_theme}
171177
)(theme);
172178
}
173179

174-
export default function style(theme, component) {
180+
export default function style(theme, component, args) {
175181
if (!theme) {
176182
console.error('theme has not been set')
177183
}
178-
return getStyle(theme)(component);
184+
185+
return getStyle(theme)(component, args);
179186
}

src/js/themes/styleConstants.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,9 @@ export default {
2525
keyOpacity: '0.85',
2626
keyOpacityHover: '1',
2727

28-
keyValPadding: '3px 5px 3px 5px',
28+
keyValPaddingTop: '3px',
29+
keyValPaddingBottom: '3px',
30+
keyValPaddingRight: '5px',
2931
keyValBorderLeft: '1px solid',
3032
keyValBorderHover: '2px solid',
3133
keyValPaddingHover: '3px 5px 3px 4px',

0 commit comments

Comments
 (0)