diff --git a/schemas/entity-styles.json b/schemas/entity-styles.json index 03a0516..7d6f5a5 100644 --- a/schemas/entity-styles.json +++ b/schemas/entity-styles.json @@ -1,8 +1,55 @@ { "$schema": "http://json-schema.org/draft-07/schema#", "title": "Entity Styles", - "type": "object", "definitions": { + "styles": { + "type": "object", + "additionalProperties": false, + "properties": { + "thumbnail": { + "$ref": "#/definitions/image" + }, + "hero": { + "$ref": "#/definitions/image" + }, + "background": { + "$ref": "#/definitions/color" + }, + "text": { + "$ref": "#/definitions/color" + }, + "style_modes": { + "type": "array", + "items": { + "type": "object", + "additionalProperties": false, + "properties": { + "mode": { "type": "string" }, + "styles": { "$ref": "#/definitions/nestedStyles" } + }, + "required": ["mode", "styles"] + } + } + } + }, + "nestedStyles": { + "type": "object", + "additionalProperties": false, + "properties": { + "thumbnail": { + "$ref": "#/definitions/image" + }, + "hero": { + "$ref": "#/definitions/image" + }, + "background": { + "$ref": "#/definitions/color" + }, + "text": { + "$ref": "#/definitions/color" + } + } + }, "image": { "type": "object", "properties": { @@ -27,18 +74,16 @@ "required": ["color"] } }, - "properties": { - "thumbnail": { - "$ref": "#/definitions/image" - }, - "hero": { - "$ref": "#/definitions/image" - }, - "background": { - "$ref": "#/definitions/color" - }, - "text": { - "$ref": "#/definitions/color" + "oneOf": [ + { "$ref": "#/definitions/styles" }, + { + "type": "object", + "minProperties": 1, + "additionalProperties": false, + "properties": { + "light": { "$ref": "#/definitions/styles" }, + "dark": { "$ref": "#/definitions/styles" } + } } - } + ] } diff --git a/spec/spec.md b/spec/spec.md index fc07799..b7cfa8f 100644 --- a/spec/spec.md +++ b/spec/spec.md @@ -56,8 +56,9 @@ _Entity Style Descriptors_ are a resource format that defines a set of suggested ``` ::: +An _Entity Style Descriptor_ ****must**** be an object composed in one of the follow ways: -An _Entity Style Descriptor_ ****must**** be an object composed of the following properties: +### Basic - The object ****MAY**** contain a `thumbnail` property, and if present, its value ****MUST**** be an object with the following optional properties: - The object ****MUST**** contain a `uri` property, and if present its value ****MUST**** be a valid URI string to an image resource. @@ -69,6 +70,35 @@ An _Entity Style Descriptor_ ****must**** be an object composed of the following - The object ****MAY**** contain a `color` property, and if present its value ****MUST**** be a HEX string color value (e.g. #000000). - The object ****MAY**** contain a `text` property, and if present, its value ****MUST**** be an object with the following optional properties: - The object ****MAY**** contain a `color` property, and if present its value ****MUST**** be a HEX string color value (e.g. #000000). +- The object ****MAY**** contain a `style_modes` property, and if present, its value ****MUST**** be an array of [ref:Style Mode Objects]. + +### Light and Dark Mode + +::: example Light and Dark Mode +```json +[[insert: ./test/entity-styles/simple-light-dark.json]] +``` +::: + +- The object ****MAY**** contain `light` and/or `dark` properties, and if present, their values ****MUST**** be Basic Entity Style Descriptors + +## Entity Style Modes + +::: example Modes +```json +[[insert: ./test/entity-styles/simple-light-dark.json]] +``` +::: + +A _Entity Style Mode_ ****must**** be an object composed of the following properties: + +- The object ****MUST**** contain a `mode` property and its value ****MUST**** be a string + - This string ****MUST**** be unique within the containing `style_modes` array +- The object ****MUST**** contain a `styles` property and its value ****MUST**** be a [ref:Entity Style Descriptor] omitting the `style_modes` property + +### Applying Modes + +When a style mode its `styles` property ****MUST**** be merged with its containing [ref:Entity Style Descriptor] ## Data Display diff --git a/test/entity-styles/modes.json b/test/entity-styles/modes.json new file mode 100644 index 0000000..598b12e --- /dev/null +++ b/test/entity-styles/modes.json @@ -0,0 +1,44 @@ +{ + "light": { + "thumbnail": { + "uri": "https://dol.wa.com/logo.png", + "alt": "Washington State Seal" + }, + "hero": { + "uri": "https://dol.wa.com/people-working.png", + "alt": "People working on serious things" + }, + "background": { + "color": "#ff0000" + }, + "text": { + "color": "#d4d400" + }, + "style_modes": [ + { + "mode": "red-green-color-blind", + "styles": { + "background": { + "color": "#800080" + } + } + } + ] + }, + "dark": { + "thumbnail": { + "uri": "https://dol.wa.com/logo-alt.png", + "alt": "Washington State Seal" + }, + "hero": { + "uri": "https://dol.wa.com/people-working-alt.png", + "alt": "People working on serious things" + }, + "background": { + "color": "#00FFFF" + }, + "text": { + "color": "#0000D4" + } + } +} diff --git a/test/entity-styles/simple-light-dark.json b/test/entity-styles/simple-light-dark.json new file mode 100644 index 0000000..49afe3e --- /dev/null +++ b/test/entity-styles/simple-light-dark.json @@ -0,0 +1,34 @@ +{ + "light": { + "thumbnail": { + "uri": "https://dol.wa.com/logo.png", + "alt": "Washington State Seal" + }, + "hero": { + "uri": "https://dol.wa.com/people-working.png", + "alt": "People working on serious things" + }, + "background": { + "color": "#ff0000" + }, + "text": { + "color": "#d4d400" + } + }, + "dark": { + "thumbnail": { + "uri": "https://dol.wa.com/logo-alt.png", + "alt": "Washington State Seal" + }, + "hero": { + "uri": "https://dol.wa.com/people-working-alt.png", + "alt": "People working on serious things" + }, + "background": { + "color": "#00FFFF" + }, + "text": { + "color": "#0000D4" + } + } +}