Skip to content

Commit c85c2e0

Browse files
committed
adds separate style for the expandable object fields container
previous version allowed to change container style only with ".basic-element-style > ul {" like css.
1 parent 8eded61 commit c85c2e0

File tree

4 files changed

+8
-4
lines changed

4 files changed

+8
-4
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ https://anyroad.github.io/react-json-view-lite/
115115
| Name | Type | Description |
116116
| ----------------------- | ------- | ----------------------------------------------------------------------------------------------------------------- |
117117
| container | string | CSS class name for rendering parent block |
118+
| childFieldsContainer | string | CSS class name for rendering parent block of array or object |
118119
| basicChildStyle | string | CSS class name for property block containing property name and value |
119120
| collapseIcon | string | CSS class name for rendering button collapsing Object and Array nodes. Default content is ``. |
120121
| expandIcon | string | CSS class name for rendering button expanding Object and Array nodes. Default content is ``. |

src/DataRenderer.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ export interface StyleProps {
1717
expandIcon: string;
1818
collapseIcon: string;
1919
collapsedContent: string;
20+
childFieldsContainer: string;
2021
noQuotesForStringValues?: boolean;
2122
quotesForFieldNames?: boolean;
2223
}
@@ -161,7 +162,7 @@ function ExpandableObject({
161162
<span className={style.punctuation}>{openBracket}</span>
162163

163164
{expanded ? (
164-
<ul id={contentsId} role='group'>
165+
<ul id={contentsId} role='group' className={style.childFieldsContainer}>
165166
{data.map((dataElement, index) => (
166167
<DataRender
167168
key={dataElement[0] || index}

src/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export interface Props extends React.AriaAttributes {
1212
export const defaultStyles: StyleProps = {
1313
container: styles['container-light'],
1414
basicChildStyle: styles['basic-element-style'],
15+
childFieldsContainer: styles['child-fields-container'],
1516
label: styles['label-light'],
1617
clickableLabel: styles['clickable-label-light'],
1718
nullValue: styles['value-null-light'],
@@ -31,6 +32,7 @@ export const defaultStyles: StyleProps = {
3132
export const darkStyles: StyleProps = {
3233
container: styles['container-dark'],
3334
basicChildStyle: styles['basic-element-style'],
35+
childFieldsContainer: styles['child-fields-container'],
3436
label: styles['label-dark'],
3537
clickableLabel: styles['clickable-label-dark'],
3638
nullValue: styles['value-null-dark'],

src/styles.module.css

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,11 +53,11 @@
5353
}
5454

5555
.basic-element-style {
56-
margin: 0 10px;
57-
padding: 0;
56+
margin: 0;
57+
padding: 0 10px;
5858
}
5959

60-
.basic-element-style > ul {
60+
.child-fields-container {
6161
margin: 0;
6262
padding: 0;
6363
}

0 commit comments

Comments
 (0)