Skip to content

Commit 517ae38

Browse files
feat(overmind-devtools): show path of operator
1 parent 2931b8c commit 517ae38

File tree

6 files changed

+74
-15
lines changed

6 files changed

+74
-15
lines changed

packages/demos/todomvc/src/app/actions.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ import { Todo } from './state'
44
import * as helpers from './helpers'
55
import * as mutations from './mutations'
66

7+
function hasLength(_, value: string) {
8+
return Boolean(value.length)
9+
}
10+
11+
function noop() {}
12+
713
export default (action: Action) => ({
814
changeNewTodoTitle: action<React.ChangeEvent<HTMLInputElement>>()
915
.map(helpers.getEventValue)

packages/node_modules/overmind-devtools/src/components/Action/elements.tsx

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,3 @@ export const Pipe = styled.div`
1515
align-items: center;
1616
margin: ${({ theme }) => `${theme.padding.small} 0`};
1717
`
18-
19-
export const Path = styled<
20-
{
21-
borderColor?: keyof Colors
22-
},
23-
'div'
24-
>('div')`
25-
border-bottom: 1px solid
26-
${({ theme, borderColor }) =>
27-
borderColor ? theme.color[borderColor] : theme.color.black};
28-
min-width: 25px;
29-
`

packages/node_modules/overmind-devtools/src/components/ActionFlush/index.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
import * as React from 'react'
22
import { connect, Connect } from '../../app'
33
import { Flush as FlushType, FlushReference } from '../../app/state'
4-
import { Pipe, Path } from '../Action/elements'
4+
import { Pipe } from '../Action/elements'
55
import { Flush, FlushHeader } from './elements'
6+
import Path from '../ActionPath'
67
import Text from '../common/Text'
78
import Icon from '../common/Icon'
89

packages/node_modules/overmind-devtools/src/components/ActionOperator/index.tsx

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import { Operator as OperatorType } from '../../app/state'
44
import ValueInspector from '../ValueInspector'
55
import Text from '../common/Text'
66
import Icon from '../common/Icon'
7-
import { Pipe, Path } from '../Action/elements'
7+
import Path from '../ActionPath'
8+
import { Pipe } from '../Action/elements'
89
import { Operator, OperatorHeader, Mutation } from './elements'
910

1011
type Props = {
@@ -21,7 +22,13 @@ const ActionOperator: React.SFC<Props> = ({ operator, value, app }) => (
2122
<Pipe>
2223
<Path
2324
borderColor={operator.type === 'mutation' ? 'primary' : 'secondary'}
24-
/>
25+
>
26+
{operator.path.length ? (
27+
<Text variant="hint">
28+
<b>{operator.path.join('.')}</b>
29+
</Text>
30+
) : null}
31+
</Path>
2532
<Operator
2633
borderColor={operator.type === 'mutation' ? 'primary' : 'secondary'}
2734
onClick={() => app.actions.toggleCollapsed(operator)}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import styled from '../../styled-components'
2+
import { Colors } from '../../theme'
3+
4+
export const Path = styled.div`
5+
position: relative;
6+
min-width: 25px;
7+
`
8+
9+
export const PathLine = styled<
10+
{
11+
borderColor?: keyof Colors
12+
},
13+
'div'
14+
>('div')`
15+
position: absolute;
16+
top: 50%;
17+
left: 0;
18+
z-index: 0;
19+
width: 100%;
20+
border-bottom: 1px solid
21+
${({ theme, borderColor }) =>
22+
borderColor ? theme.color[borderColor] : theme.color.black};
23+
`
24+
25+
export const PathText = styled<
26+
{
27+
borderColor?: keyof Colors
28+
},
29+
'div'
30+
>('div')`
31+
position: relative;
32+
z-index: 1;
33+
margin: ${({ theme }) => `0 ${theme.padding.smaller} 0 25px`};
34+
padding: ${({ theme }) =>
35+
`${theme.padding.smallest} ${theme.padding.smaller}`};
36+
border: 1px solid ${({ theme, borderColor }) => theme.color[borderColor]};
37+
background-color: #fff;
38+
border-radius: ${({ theme }) => theme.borderRadius.normal};
39+
`
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import * as React from 'react'
2+
import { Path, PathLine, PathText } from './elements'
3+
import { Colors } from '../../theme'
4+
5+
type Props = {
6+
borderColor?: keyof Colors
7+
}
8+
9+
const ActionPath: React.SFC<Props> = ({ borderColor, children }) => (
10+
<Path>
11+
<PathLine borderColor={borderColor} />
12+
{children ? (
13+
<PathText borderColor={borderColor}>{children}</PathText>
14+
) : null}
15+
</Path>
16+
)
17+
18+
export default ActionPath

0 commit comments

Comments
 (0)