Skip to content

Commit 5c70696

Browse files
author
Jakub Jankowski
authored
feat: new JSV design (#103)
* feat: new design * feat: move to mosaic * fix: simplify vlidations and address review * fix: scrolling and divider * fix: dark mode * fix: tests * fix: icon typing * fix: linting * test: update * chore: cleanup * feat: use interactive mode
1 parent 0635f1f commit 5c70696

26 files changed

+2163
-2093
lines changed

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,14 @@
4242
"react-dom": ">=16.8"
4343
},
4444
"dependencies": {
45+
"@fortawesome/free-solid-svg-icons": "^5.15.2",
4546
"@stoplight/json": "^3.10.0",
4647
"@stoplight/json-schema-tree": "^1.0.0",
48+
"@stoplight/mosaic": "^1.0.0-beta.22",
4749
"@stoplight/react-error-boundary": "^1.0.0",
4850
"@stoplight/tree-list": "^5.0.3",
49-
"classnames": "^2.2.6"
51+
"classnames": "^2.2.6",
52+
"lodash": "^4.17.19"
5053
},
5154
"devDependencies": {
5255
"@rollup/plugin-typescript": "^3.1.1",
@@ -61,6 +64,7 @@
6164
"@types/enzyme": "^3.10.8",
6265
"@types/jest": "^26.0.18",
6366
"@types/json-schema": "^7.0.6",
67+
"@types/lodash": "^4.14.149",
6468
"@types/node": "^12.7.2",
6569
"@types/react": "16.9.2",
6670
"@types/react-dom": "16.9.0",

setupTests.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
const Enzyme = require('enzyme');
22
const Adapter = require('enzyme-adapter-react-16');
33

4+
jest.mock('react-virtualized-auto-sizer', () => ({ children }: any) => children({ height: 600, width: 600 }));
5+
46
Enzyme.configure({ adapter: new Adapter() });
57

68
jest.mock('react');

src/__stories__/JsonSchemaViewer.tsx

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Button, Checkbox, Icon } from '@stoplight/ui-kit';
1+
import { Button, Flex, InvertTheme, subscribeTheme } from '@stoplight/mosaic';
22
import { action } from '@storybook/addon-actions';
33
import { boolean, number, object, select, withKnobs } from '@storybook/addon-knobs';
44
import { storiesOf } from '@storybook/react';
@@ -12,6 +12,8 @@ const allOfSchema = require('../__fixtures__/combiners/allOfs/base.json');
1212
const schema = require('../__fixtures__/default-schema.json');
1313
const stressSchema = require('../__fixtures__/stress-schema.json');
1414

15+
subscribeTheme({ mode: 'light' });
16+
1517
storiesOf('JsonSchemaViewer', module)
1618
.addDecorator(withKnobs)
1719
.addDecorator(storyFn => <Wrapper>{storyFn()}</Wrapper>)
@@ -47,10 +49,10 @@ storiesOf('JsonSchemaViewer', module)
4749
return (
4850
<>
4951
<SchemaRow treeListNode={node} rowOptions={rowOptions} />
50-
<div className="flex h-full items-center">
51-
<Button className="pl-1 mr-1" small minimal icon={<Icon color="grey" iconSize={12} icon="issue" />} />
52-
<Checkbox className="mb-0" />
53-
</div>
52+
<Flex h="full" alignItems="center">
53+
<Button pl={1} mr={1} size="sm" appearance="minimal" icon="issue" />
54+
<input type="checkbox" />
55+
</Flex>
5456
</>
5557
);
5658
};
@@ -149,14 +151,18 @@ storiesOf('JsonSchemaViewer', module)
149151
mergeAllOf={boolean('mergeAllOf', true)}
150152
/>
151153
))
152-
.add('dark', () => (
153-
<div style={{ height: '100vh' }} className="bp3-dark bg-gray-8">
154-
<JsonSchemaViewer
155-
schema={schema as JSONSchema4}
156-
defaultExpandedDepth={number('defaultExpandedDepth', 2)}
157-
expanded={boolean('expanded', false)}
158-
onGoToRef={action('onGoToRef')}
159-
mergeAllOf={boolean('mergeAllOf', true)}
160-
/>
161-
</div>
162-
));
154+
.add('dark', () => {
155+
return (
156+
<InvertTheme>
157+
<div style={{ height: '100vh' }}>
158+
<JsonSchemaViewer
159+
schema={schema as JSONSchema4}
160+
defaultExpandedDepth={number('defaultExpandedDepth', 2)}
161+
expanded={boolean('expanded', false)}
162+
onGoToRef={action('onGoToRef')}
163+
mergeAllOf={boolean('mergeAllOf', true)}
164+
/>
165+
</div>
166+
</InvertTheme>
167+
);
168+
});

src/__stories__/_styles.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
@import "~@stoplight/tree-list/styles/_tree-list.scss";
22
@import "~@stoplight/ui-kit/styles/_ui-kit.scss";
3+
@import "~@stoplight/mosaic/styles.css";
4+
@import "~@stoplight/mosaic/themes/default.css";
35

46
.JsonSchemaViewer {
57
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', system-ui, sans-serif,

0 commit comments

Comments
 (0)