/*
 * Copyright (c) 2020 XMLmind Software. All rights reserved.
 *
 * This file is part of the XMLmind XML Editor project.
 * For conditions of distribution and use, see the accompanying legal.txt file.
 */

@namespace "http://www.ibm.com/xmlns/prod/2009/jsonx";

@property-value object-color() blue;
@property-value array-color() green;
@property-value string-color() #404040;
@property-value number-color() purple;
@property-value boolean-color() teal;
@property-value null-color() fuchsia;
@property-value vertical-margin() 1.5ex;
/* base_indent=1.2em, width("* ")~0.6em, width("[" or "{")~0.4em */
@property-value item-indent() 1.8em; /* ~base_indent+width("* ") */
@property-value list-indent() 2.2em; /* ~item-indent()+width("[" or "{") */
@property-value member-indent() 0.9em; /* ~base_indent */
@property-value member-body-indent() 1.5em; /* ~member-indent()+width("* ") */

object,
array {
    display: block;
    collapsible: yes;
    collapsed-content-align: center;
    margin-top: vertical-margin();
    margin-bottom: vertical-margin();
    margin-left: list-indent();
    margin-right: list-indent();
}

object {
    collapsed-content: text("...", font-size, larger, font-weight, bold,
                            color, object-color());
    color: object-color();
}

array {
    collapsed-content: text("...", font-size, larger, font-weight, bold,
                            color, array-color());
    color: array-color();
}

object:before,
object:after,
array:before,
array:after {
    display: marker;
    font-weight: bold;
}

object:before {
    content: collapser() " {";
}

object:after {
    content: "}";
}

array:before {
    content: collapser() " [";
}

array:after {
    content: "]";
}

string,
number,
boolean,
null {
    display: block;
    margin-top: vertical-margin();
    margin-bottom: vertical-margin();
    margin-left: item-indent();
}

string {
    white-space: pre;
    color: string-color();
    border: 1px dotted;
    padding: 0.25ex;
}

number {
    color: number-color();
    border: 1px dotted;
    padding: 0.25ex;
}

boolean {
    content: radio-buttons();
    color: boolean-color();
}

null {
    content: text("null", font-weight, bold);
    color: null-color();
}

string:before,
number:before,
boolean:before,
null:before {
    display: marker;
    content: icon(filled-square, 0) " ";
}

object > object,
object > array,
object > string,
object > number,
object > boolean,
object > null {
    margin-top: 0.25ex;
    margin-left: member-body-indent();
}

@property-value name-field()
                text-field(attribute, name,
                           columns, 20,
                           font-size, 0.92em,
                           font-weight, normal,
                           color, inherit,
                           background-color, normal);

object > object:before,
object > array:before,
object > string:before,
object > number:before,
object > boolean:before,
object > null:before {
    display: block;
    margin-top: vertical-margin();
    margin-bottom: 0;
    margin-left: member-indent();
}

object > object:before {
    content: collapser() " { " name-field();
}

object > array:before {
    content: collapser() " [ " name-field();
}

object > string:before,
object > number:before,
object > boolean:before,
object > null:before {
    content: icon(disc, 0) " " name-field();
}

