Skip to content

Commit 0bb82ea

Browse files
committed
chore: update demo app
1 parent 3feec73 commit 0bb82ea

File tree

8 files changed

+44
-205
lines changed

8 files changed

+44
-205
lines changed

demo/components/formatter/formatter.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import React from 'react';
22
import ReactJson from 'react-json-view';
3-
import is from "@cookbook/dot-notation/utils/is";
3+
import is from '@cookbook/mapper-js/utils/is';
44

55
interface Formatter {
66
title?: string;
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React from 'react';
2+
import data from '@cookbook/mapper-js/__mocks__/data'
3+
4+
import Formatter from '../../../components/formatter';
5+
import styles from '../../shared/styles';
6+
7+
import mapping from './mapping';
8+
9+
const Playground: React.FunctionComponent<Record<string, unknown>> = () => {
10+
11+
return (
12+
<div style={styles.row}>
13+
<div style={styles.col}>
14+
<div style={styles.row}>
15+
<Formatter title="Data source" source={data} />
16+
</div>
17+
</div>
18+
<div style={styles.col}>
19+
<Formatter title="Output" source={mapping(data)} />
20+
</div>
21+
</div>
22+
);
23+
};
24+
25+
export default Playground;
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import mapper from '@cookbook/mapper-js';
2+
3+
const mapping = mapper((map) => ({
4+
active: map<boolean>('isActive').value,
5+
'account.balance': map<string>('balance').value,
6+
'person.age': map<string>('age').value,
7+
'person.address': map('address').value,
8+
commonFriends: map('commonFriends').value,
9+
}));
10+
11+
export default mapping;

demo/screens/playground/demos/parse-key.tsx

Lines changed: 0 additions & 58 deletions
This file was deleted.

demo/screens/playground/demos/parse.tsx

Lines changed: 0 additions & 45 deletions
This file was deleted.

demo/screens/playground/demos/pick.tsx

Lines changed: 0 additions & 79 deletions
This file was deleted.

demo/screens/playground/playground.tsx

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,18 @@ import React from 'react';
22

33
import Menu from '../shared/menu';
44

5-
import Pick from './demos/pick';
6-
import Parse from './demos/parse';
7-
import ParseKey from './demos/parse-key';
5+
import Mapper from './demos/mapper';
86

97
const selectView = (state: string, action: string ): React.ReactNode => {
108
switch (action) {
11-
case 'parse':
12-
return Parse;
13-
14-
case 'parse-key':
15-
return ParseKey;
16-
17-
case 'pick':
9+
case 'mapper':
1810
default:
19-
return Pick;
11+
return Mapper;
2012
}
2113
}
2214

2315
const Playground: React.FunctionComponent<Record<string, unknown>> = () => {
24-
const [View, dispatch] = React.useReducer(selectView, Pick);
16+
const [View, dispatch] = React.useReducer(selectView, Mapper);
2517

2618
const handleOnClick = (value: string): void => {
2719
dispatch(value);
@@ -37,6 +29,7 @@ const Playground: React.FunctionComponent<Record<string, unknown>> = () => {
3729
color: '#fff',
3830
height: '100%',
3931
padding: 22,
32+
overflow: 'auto',
4033
}}
4134
className="bg-pan-left"
4235
>

demo/screens/shared/menu/menu.tsx

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,8 @@ interface Category {
88

99
const menu: Category[] = [
1010
{
11-
label: 'Pick',
12-
value: 'pick'
13-
},
14-
{
15-
label: 'Parse',
16-
value: 'parse'
17-
},
18-
{
19-
label: 'Parse key',
20-
value: 'parse-key'
11+
label: 'Default',
12+
value: 'mapper'
2113
},
2214
];
2315

0 commit comments

Comments
 (0)