Skip to content

Commit 0fd53ae

Browse files
ValentinHCompuIves
authored andcommitted
Add the "Clear console" action for the console preview panel (codesandbox#697)
1 parent 248e983 commit 0fd53ae

File tree

3 files changed

+57
-28
lines changed

3 files changed

+57
-28
lines changed
Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,29 @@
11
import React from 'react';
22
import Console from 'app/components/Preview/DevTools/Console';
33

4+
import VerticalAlign from 'app/src/app/components/Preview/Navigator/VerticalAlign';
5+
import HorizontalAlign from 'app/src/app/components/Preview/Navigator/HorizontalAlign';
6+
47
import Navigator from './Navigator';
58

6-
export default ({ alignRight, alignBottom }) => (
7-
<div style={{ height: '100%' }}>
8-
<Navigator
9-
alignRight={alignRight}
10-
alignBottom={alignBottom}
11-
title="Console"
12-
/>
13-
<Console.Content />
14-
</div>
15-
);
9+
export default ({ alignRight, alignBottom }) => {
10+
const actions = [
11+
...Console.actions,
12+
{
13+
title: 'Align To Bottom',
14+
onClick: alignBottom,
15+
Icon: HorizontalAlign,
16+
},
17+
{
18+
title: 'Align To Right',
19+
onClick: alignRight,
20+
Icon: VerticalAlign,
21+
},
22+
];
23+
return (
24+
<div style={{ height: '100%' }}>
25+
<Navigator title="Console" actions={actions} />
26+
<Console.Content />
27+
</div>
28+
);
29+
};

packages/app/src/app/pages/Sandbox/Editor/Content/Preview/DevTools/Navigator.js

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import React from 'react';
22
import styled from 'styled-components';
33

4-
import VerticalAlign from 'app/src/app/components/Preview/Navigator/VerticalAlign';
5-
import HorizontalAlign from 'app/src/app/components/Preview/Navigator/HorizontalAlign';
4+
import Tooltip from 'common/components/Tooltip';
65

76
const Container = styled.div`
87
display: flex;
@@ -24,7 +23,7 @@ const Title = styled.div`
2423
flex: 1;
2524
`;
2625

27-
const Icons = styled.div`
26+
const Actions = styled.div`
2827
z-index: 20;
2928
svg {
3029
transition: 0.3s ease color;
@@ -37,12 +36,15 @@ const Icons = styled.div`
3736
}
3837
`;
3938

40-
export default ({ title, alignBottom, alignRight }) => (
39+
export default ({ title, actions }) => (
4140
<Container className="flying-container-handler">
4241
<Title>{title}</Title>
43-
<Icons>
44-
<HorizontalAlign onClick={alignBottom} />
45-
<VerticalAlign onClick={alignRight} />
46-
</Icons>
42+
<Actions>
43+
{actions.map(({ title: actionTitle, onClick, Icon }) => (
44+
<Tooltip title={actionTitle} key={actionTitle}>
45+
<Icon onClick={onClick} key={actionTitle} />
46+
</Tooltip>
47+
))}
48+
</Actions>
4749
</Container>
4850
);
Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,28 @@
11
import React from 'react';
22
import Tests from 'app/components/Preview/DevTools/Tests';
33

4+
import VerticalAlign from 'app/src/app/components/Preview/Navigator/VerticalAlign';
5+
import HorizontalAlign from 'app/src/app/components/Preview/Navigator/HorizontalAlign';
6+
47
import Navigator from './Navigator';
58

6-
export default ({ alignRight, alignBottom }) => (
7-
<div>
8-
<Navigator
9-
alignRight={alignRight}
10-
alignBottom={alignBottom}
11-
title="Tests"
12-
/>
13-
<Tests.Content standalone />
14-
</div>
15-
);
9+
export default ({ alignRight, alignBottom }) => {
10+
const actions = [
11+
{
12+
title: 'Align To Bottom',
13+
onClick: alignBottom,
14+
Icon: HorizontalAlign,
15+
},
16+
{
17+
title: 'Align To Right',
18+
onClick: alignRight,
19+
Icon: VerticalAlign,
20+
},
21+
];
22+
return (
23+
<div>
24+
<Navigator title="Tests" actions={actions} />
25+
<Tests.Content standalone />
26+
</div>
27+
);
28+
};

0 commit comments

Comments
 (0)