Skip to content

Commit 23e26d4

Browse files
authored
CSDEV-8224 mark rows of required properties (#2)
Add a data attribute to allow styling through CSS *in the application*.
1 parent 1ec5dc6 commit 23e26d4

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@stoplight/json-schema-viewer",
3-
"version": "4.16.401",
3+
"version": "4.16.402",
44
"description": "A beautiful React component for viewing JSON Schema",
55
"keywords": [],
66
"sideEffects": false,

src/__tests__/__snapshots__/index.spec.tsx.snap

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -861,6 +861,7 @@ exports[`HTML Output > given anyOf combiner placed next to allOf > given allOf m
861861
>
862862
<div
863863
class="sl-flex sl-items-center sl-max-w-full"
864+
data-required="true"
864865
>
865866
<div
866867
class="sl-flex sl-items-baseline sl-text-base"
@@ -1381,6 +1382,7 @@ exports[`HTML Output > given oneOf combiner placed next to allOf > given allOf m
13811382
>
13821383
<div
13831384
class="sl-flex sl-items-center sl-max-w-full"
1385+
data-required="true"
13841386
>
13851387
<div
13861388
class="sl-flex sl-items-baseline sl-text-base"

src/components/SchemaRow/SchemaRow.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,11 @@ export const SchemaRow: React.FunctionComponent<SchemaRowProps> = React.memo(
117117
maxW="full"
118118
onClick={isCollapsible ? () => setExpanded(!isExpanded) : undefined}
119119
cursor={isCollapsible ? 'pointer' : undefined}
120+
// The Flex component extends Box.
121+
// node_modules/@stoplight/mosaic/components/Box/types.d.ts line 5 defines that all data-xxx attributes must be of type string.
122+
// export declare type DatasetProps = Record<`data-${string}`, string>;
123+
// --> we can't use the boolean 'required' directly
124+
data-required={required ? 'true' : undefined}
120125
>
121126
{isCollapsible ? <Caret isExpanded={isExpanded} /> : null}
122127
<Flex alignItems="baseline" fontSize="base">

0 commit comments

Comments
 (0)