Skip to content

Commit 280f7d9

Browse files
Merge pull request #77 from ChristianEdwardPadilla/development
CodePreview tab
2 parents bc77427 + bdd8b66 commit 280f7d9

File tree

10 files changed

+62
-26
lines changed

10 files changed

+62
-26
lines changed

src/components/BottomPanel.jsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
import React, { Component } from 'react';
22
import { connect } from 'react-redux';
3-
import { some } from 'bluebird-lst';
43
import { handleClose, deleteCompProp, addCompProp } from '../actions/components';
5-
import RightTabs from './RightTabs.jsx';
4+
import BottomTabs from './BottomTabs';
65

76
const IPC = require('electron').ipcRenderer;
87

@@ -46,7 +45,7 @@ class BottomPanel extends Component {
4645

4746
return (
4847
<div className="bottom-panel" style={{ width: '100%' }}>
49-
<RightTabs
48+
<BottomTabs
5049
components={components}
5150
focusComponent={focusComponent}
5251
deleteProp={deleteProp}

src/components/RightTabs.jsx renamed to src/components/BottomTabs.jsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ const styles = theme => ({
6262
},
6363
});
6464

65-
class RightTabs extends Component {
65+
class BottomTabs extends Component {
6666
state = {
6767
value: 0,
6868
};
@@ -98,9 +98,7 @@ class RightTabs extends Component {
9898
newChildrenArray.push(newTree);
9999
tree.children = newChildrenArray;
100100
if (component.childrenArray[i].childType === 'COMP') {
101-
const newFocusComp = components.find(
102-
comp => comp.title === component.childrenArray[i].componentName,
103-
);
101+
const newFocusComp = components.find(comp => comp.title === component.childrenArray[i].componentName);
104102
this.findChildren(newFocusComp, components, newTree);
105103
}
106104
}
@@ -111,7 +109,7 @@ class RightTabs extends Component {
111109
const component = components.find(comp => comp.id === componentId);
112110
const tree = { name: component.title, attributes: {}, children: [] };
113111

114-
component.childrenArray.forEach((child) => {
112+
component.childrenArray.forEach(child => {
115113
if (child.childType === 'COMP') {
116114
tree.children.push(this.generateComponentTree(child.childComponentId, components));
117115
} else {
@@ -133,6 +131,11 @@ class RightTabs extends Component {
133131
} = this.props;
134132
const { value } = this.state;
135133

134+
// display count on the tab. user can see without clicking into tab
135+
const propCount = focusComponent.props.length;
136+
const htmlAttribCount = focusComponent.childrenArray.filter(child => child.childType === 'HTML').length;
137+
138+
// const counters = focusComponent.ch
136139
const tree = {
137140
name: focusComponent.title,
138141
attributes: {},
@@ -154,7 +157,7 @@ class RightTabs extends Component {
154157
<Tab
155158
disableRipple
156159
classes={{ root: classes.tabRoot, selected: classes.tabSelected }}
157-
label="Component Props"
160+
label={`Component Props ${propCount ? `(${propCount})` : ''} `}
158161
/>
159162
<Tab
160163
disableRipple
@@ -164,7 +167,7 @@ class RightTabs extends Component {
164167
<Tab
165168
disableRipple
166169
classes={{ root: classes.tabRoot, selected: classes.tabSelected }}
167-
label="HTML Element Attributes"
170+
label={`HTML Element Attributes ${htmlAttribCount ? `(${htmlAttribCount})` : ''} `}
168171
/>
169172
</Tabs>
170173

@@ -206,13 +209,10 @@ class RightTabs extends Component {
206209
)}
207210
{value === 1 && <Props />}
208211
{value === 3 && focusChild.childType === 'HTML' && <HtmlAttr />}
209-
{value === 3
210-
&& focusChild.childType !== 'HTML' && (
211-
<p>Please select an HTML element to view attributes</p>
212-
)}
212+
{value === 3 && focusChild.childType !== 'HTML' && <p>Please select an HTML element to view attributes</p>}
213213
</div>
214214
);
215215
}
216216
}
217217

218-
export default withStyles(styles)(RightTabs);
218+
export default withStyles(styles)(BottomTabs);

src/components/CodePreview.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import React, { Component, Fragment } from 'react';
2+
import { withStyles } from '@material-ui/core/styles';
3+
import { format } from 'prettier';
4+
import componentRender from '../utils/componentRender.util';
5+
6+
class CodePreview extends Component {
7+
render(): JSX.Element {
8+
const { focusComponent, components } = this.props;
9+
return (
10+
<div
11+
style={{
12+
width: '500px',
13+
height: '290px',
14+
direction: 'rtl',
15+
paddingLeft: '20px',
16+
color: '#D3D3D3',
17+
fontSize: 16,
18+
overflow: 'auto',
19+
}}
20+
>
21+
<pre style={{ direction: 'ltr' }}>
22+
{format(componentRender(focusComponent, components))}
23+
</pre>
24+
</div>
25+
);
26+
}
27+
}
28+
29+
export default CodePreview;

src/components/KonvaStage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ class KonvaStage extends Component {
221221
imageSource={child.htmlElement == 'Image' && child.HTMLInfo.Src ? child.HTMLInfo.Src : null}
222222
/>
223223
))
224-
.sort((rectA, rectB) => rectA.props.width * rectA.props.height < rectB.props.width * rectB.props.height) // shouldnt this be subtraction instead of < ? see MDN
224+
.sort((rectA, rectB) => rectB.props.width * rectB.props.height - rectA.props.width * rectA.props.height)
225225
// reasoning for the sort:
226226
// Konva determines zIndex (which rect is clicked on if rects overlap) based on rendering order
227227
// as long as the smallest components are rendered last they will always be accessible over the big boys

src/components/__tests__/App.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import React from 'react';
22
// import '../../setupTests';
33
import { shallow } from 'enzyme';
4-
import App from '../App.tsx';
5-
import AppContainer from '../../containers/AppContainer.tsx';
4+
import App from '../App';
5+
import AppContainer from '../../containers/AppContainer';
66

77
it('contains a AppContainer', () => {
88
// wrapped version of react component

src/containers/LeftContainer.tsx

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,10 @@ import { withStyles } from '@material-ui/core/styles';
1010
import LeftColExpansionPanel from '../components/LeftColExpansionPanel.jsx';
1111
import HTMLComponentPanel from '../components/HTMLComponentPanel.jsx';
1212
import * as actions from '../actions/components';
13-
1413
const mapDispatchToProps = dispatch => ({
1514
addComponent: ({ title }) => dispatch(actions.addComponent({ title })),
16-
updateComponent: ({ id, index, newParentId = null, color = null, stateful = null }) =>
1715
dispatch(
1816
actions.updateComponent({
19-
id,
2017
index,
2118
newParentId,
2219
color,

src/containers/MainContainer.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ import { MuiThemeProvider } from '@material-ui/core/styles';
55
import List from '@material-ui/core/List';
66
import ListItem from '@material-ui/core/ListItem';
77
import ListItemText from '@material-ui/core/ListItemText';
8-
import BottomPanel from '../components/BottomPanel.jsx';
9-
import theme from '../components/theme.ts';
8+
import BottomPanel from '../components/BottomPanel';
9+
import theme from '../components/theme';
1010
import {
1111
openExpansionPanel,
1212
handleTransform,
@@ -16,8 +16,8 @@ import {
1616
deleteComponent,
1717
createApplication,
1818
} from '../actions/components';
19-
import KonvaStage from '../components/KonvaStage.jsx';
20-
import MainContainerHeader from '../components/MainContainerHeader.jsx';
19+
import KonvaStage from '../components/KonvaStage';
20+
import MainContainerHeader from '../components/MainContainerHeader';
2121
import createModal from '../utils/createModal.util';
2222
import SortChildren from '../components/SortChildren.jsx';
2323

src/containers/RightContainer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { connect } from 'react-redux';
33
// import PropTypes from 'prop-types';
44
import { handleClose, deleteCompProp, addCompProp } from '../actions/components';
55
// import Snackbars from '../components/Snackbars.jsx';
6-
// import RightTabs from '../components/RightTabs.jsx';
6+
// import BottomTabs from '../components/BottomTabs.jsx';
77

88
const IPC = require('electron').ipcRenderer;
99

src/public/styles/style.css

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
box-sizing: inherit;
55
}
66

7+
* {
8+
overflow: hidden;
9+
overflow-y: hidden;
10+
-ms-overflow-style: none;
11+
scrollbar-width: none;
12+
}
13+
714
html {
815
box-sizing: border-box;
916
overflow: hidden;
@@ -14,6 +21,7 @@ body {
1421
padding: 0;
1522
font-family: "Open sans", sans-serif;
1623
font-weight: 400;
24+
overflow: hidden;
1725
}
1826

1927
/*

webpack.config.development.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ module.exports = {
1515
context: SRC_DIR,
1616
entry: ['babel-polyfill', './index.js'],
1717
devtool: 'eval-source-map',
18+
resolve: {
19+
extensions: ['.ts', '.tsx', '.js', '.jsx'],
20+
},
1821
output: {
1922
path: BUILD_DIR,
2023
filename: 'js/bundle.js',

0 commit comments

Comments
 (0)