Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GridItem to list of supported components as a child of Grid. #150

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/components/editor/ComponentPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ const ComponentPreview: React.FC<{
case 'TabList':
case 'TabPanels':
case 'Grid':
case 'GridItem':
case 'Center':
case 'Container':
return (
Expand Down
18 changes: 18 additions & 0 deletions src/components/inspector/panels/components/GridItemPanel.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React, { memo } from 'react'
import TextControl from '~components/inspector/controls/TextControl'

const GridItemPanel = () => {
return (
<>
<TextControl label="Area" name="area" />
<TextControl label="Column Span" name="colSpan" />
<TextControl label="Column Start" name="colStart" />
<TextControl label="Column End" name="colEnd" />
<TextControl label="Row Span" name="rowSpan" />
<TextControl label="Row Start" name="rowStart" />
<TextControl label="Row End" name="rowEnd" />
</>
)
}

export default memo(GridItemPanel)
8 changes: 7 additions & 1 deletion src/componentsList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@ export const menuItems: MenuItems = {
FormErrorMessage: {},
},
},
Grid: {},
Grid: {
children: {
Grid: {},
GridItem: {},
}
},
Heading: {},
Highlight: {},
Icon: {},
Expand Down Expand Up @@ -141,6 +146,7 @@ export const componentsList: ComponentType[] = [
'FormHelperText',
'FormLabel',
'Grid',
'GridItem',
'Heading',
'Highlight',
'Icon',
Expand Down
1 change: 1 addition & 0 deletions src/react-app-env.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type ComponentType =
| 'FormHelperText'
| 'FormErrorMessage'
| 'Grid'
| 'GridItem'
| 'Heading'
| 'Highlight'
| 'Icon'
Expand Down
5 changes: 5 additions & 0 deletions src/utils/defaultProps.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import {
BreadcrumbLinkProps,
ListProps,
HighlightProps,
GridItemProps,
} from '@chakra-ui/react'

import iconsList from '~iconsList'
Expand Down Expand Up @@ -106,6 +107,7 @@ type PreviewDefaultProps = {
FormHelperText?: PropsWithForm<TextProps>
FormErrorMessage?: PropsWithForm<FormErrorMessageProps>
Grid?: PropsWithForm<GridProps>
GridItem?: PropsWithForm<GridItemProps>
TabList?: PropsWithForm<TabListProps>
TabPanel?: PropsWithForm<TabPanelProps>
TabPanels?: PropsWithForm<TabPanelsProps>
Expand Down Expand Up @@ -210,6 +212,9 @@ export const DEFAULT_PROPS: PreviewDefaultProps = {
display: 'grid',
},
},
GridItem: {
colSpan: 1,
},
Heading: {
children: 'Heading title',
},
Expand Down
1 change: 1 addition & 0 deletions src/utils/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export const COMPONENTS: (ComponentType | MetaComponentType)[] = [
'FormHelperText',
'FormErrorMessage',
'Grid',
'GridItem',
'Heading',
'Highlight',
'Icon',
Expand Down