Skip to content

Commit 1d61492

Browse files
committed
Centered the alignment of text in Table Cell for "DataTable" component
1 parent 27ca8db commit 1d61492

File tree

2 files changed

+37
-9
lines changed

2 files changed

+37
-9
lines changed

src/components/BottomTabs.tsx

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ import Tree from 'react-d3-tree';
77
import Props from './Props';
88
import HtmlAttr from './HtmlAttr';
99
import CodePreview from './CodePreview';
10-
import { ComponentInt, ComponentsInt, PropInt, PropsInt } from '../utils/Interfaces';
10+
import {
11+
ComponentInt,
12+
ComponentsInt,
13+
PropInt,
14+
PropsInt
15+
} from '../utils/Interfaces';
1116

1217
interface BottomTabsPropsInt extends PropsInt {
1318
deleteProp(id: number): void;
@@ -109,7 +114,9 @@ class BottomTabs extends Component<BottomTabsPropsInt, StateInt> {
109114

110115
component.childrenArray.forEach(child => {
111116
if (child.childType === 'COMP') {
112-
tree.children.push(this.generateComponentTree(child.childComponentId, components));
117+
tree.children.push(
118+
this.generateComponentTree(child.childComponentId, components)
119+
);
113120
} else {
114121
tree.children.push({
115122
name: child.componentName,
@@ -122,13 +129,21 @@ class BottomTabs extends Component<BottomTabsPropsInt, StateInt> {
122129
}
123130

124131
render(): JSX.Element {
125-
const { classes, components, focusComponent, deleteProp, addProp, focusChild } = this.props;
132+
const {
133+
classes,
134+
components,
135+
focusComponent,
136+
deleteProp,
137+
addProp,
138+
focusChild
139+
} = this.props;
126140
const { value } = this.state;
127141

128142
// display count on the tab. user can see without clicking into tab
129143
const propCount = focusComponent.props.length;
130-
const htmlAttribCount = focusComponent.childrenArray.filter(child => child.childType === 'HTML')
131-
.length;
144+
const htmlAttribCount = focusComponent.childrenArray.filter(
145+
child => child.childType === 'HTML'
146+
).length;
132147

133148
return (
134149
<div className={classes.root}>
@@ -155,7 +170,9 @@ class BottomTabs extends Component<BottomTabsPropsInt, StateInt> {
155170
<Tab
156171
disableRipple
157172
classes={{ root: classes.tabRoot, selected: classes.tabSelected }}
158-
label={`HTML Element Attributes ${htmlAttribCount ? `(${htmlAttribCount})` : ''} `}
173+
label={`HTML Element Attributes ${
174+
htmlAttribCount ? `(${htmlAttribCount})` : ''
175+
} `}
159176
/>
160177
<Tab
161178
disableRipple
@@ -199,7 +216,12 @@ class BottomTabs extends Component<BottomTabsPropsInt, StateInt> {
199216
/>
200217
</div>
201218
)}
202-
{value === 1 && <CodePreview focusComponent={focusComponent} components={components} />}
219+
{value === 1 && (
220+
<CodePreview
221+
focusComponent={focusComponent}
222+
components={components}
223+
/>
224+
)}
203225
{value === 2 && <Props />}
204226
{value === 3 && focusChild.childType === 'HTML' && <HtmlAttr />}
205227
{value === 3 && focusChild.childType !== 'HTML' && (

src/components/DataTable.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,9 @@ function dataTable(props: any) {
3131
const { classes, rowData, rowHeader, deletePropHandler } = props;
3232

3333
const renderHeader = rowHeader.map((col: any, idx: number) => (
34-
<TableCell key={`head_+${idx}`}>{col}</TableCell>
34+
<TableCell align={'center'} key={`head_+${idx}`}>
35+
{col}
36+
</TableCell>
3537
));
3638

3739
function renderRowCells(row: any) {
@@ -50,7 +52,11 @@ function dataTable(props: any) {
5052
<TableRow key={`row-${row.id}`}>
5153
{renderRowCells(row)}
5254
<TableCell align={'center'} padding={'none'}>
53-
<IconButton color="default" fontSize="small" onClick={() => deletePropHandler(row.id)}>
55+
<IconButton
56+
color='default'
57+
fontSize='small'
58+
onClick={() => deletePropHandler(row.id)}
59+
>
5460
<DeleteIcon />
5561
</IconButton>
5662
{/* <Button style={{height: 20}} onClick={() => deletePropHandler(row.id)}>Delete</Button> */}

0 commit comments

Comments
 (0)