Skip to content

Commit

Permalink
add keyboard key component (premieroctet#152)
Browse files Browse the repository at this point in the history
* add keyboard key component

* add defaultProps
  • Loading branch information
PierreCrb authored Sep 14, 2022
1 parent 26f08c3 commit a25d7b9
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/components/editor/ComponentPreview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ const ComponentPreview: React.FC<{
case 'Radio':
case 'ListItem':
case 'BreadcrumbLink':
case 'Kbd':
return (
<PreviewContainer
component={component}
Expand Down
2 changes: 2 additions & 0 deletions src/components/inspector/panels/Panels.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import AspectRatioPanel from '~components/inspector/panels/components/AspectRati
import BreadcrumbPanel from '~components/inspector/panels/components/BreadcrumbPanel'
import BreadcrumbItemPanel from '~components/inspector/panels/components/BreadcrumbItemPanel'
import HighlightPanel from '~components/inspector/panels/components/HighlightPanel'
import KbdPanel from './components/KbdPanel'

const Panels: React.FC<{ component: IComponent; isRoot: boolean }> = ({
component,
Expand Down Expand Up @@ -114,6 +115,7 @@ const Panels: React.FC<{ component: IComponent; isRoot: boolean }> = ({
{type === 'Breadcrumb' && <BreadcrumbPanel />}
{type === 'BreadcrumbItem' && <BreadcrumbItemPanel />}
{type === 'BreadcrumbLink' && <LinkPanel />}
{type === 'Kbd' && <KbdPanel />}
</>
)
}
Expand Down
10 changes: 10 additions & 0 deletions src/components/inspector/panels/components/KbdPanel.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { memo } from 'react'
import ChildrenControl from '~components/inspector/controls/ChildrenControl'

const KdbPanel = () => (
<>
<ChildrenControl />
</>
)

export default memo(KdbPanel)
2 changes: 2 additions & 0 deletions src/componentsList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ export const menuItems: MenuItems = {
ListItem: {},
},
},
Kbd: {},
NumberInput: {},
Progress: {},
Radio: {},
Expand Down Expand Up @@ -152,6 +153,7 @@ export const componentsList: ComponentType[] = [
'InputLeftElement',
'InputRightAddon',
'InputRightElement',
'Kbd',
'Link',
'List',
'ListIcon',
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 @@ -52,6 +52,7 @@ type ComponentType =
| 'List'
| 'ListItem'
| 'ListIcon'
| 'Kbd'
| 'Menu'
| 'NumberInput'
| 'Progress'
Expand Down
3 changes: 3 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,
KbdProps,
} from '@chakra-ui/react'

import iconsList from '~iconsList'
Expand Down Expand Up @@ -132,6 +133,7 @@ type PreviewDefaultProps = {
ListItem?: PropsWithForm<any>
Center?: PropsWithForm<CenterProps>
Container?: PropsWithForm<ContainerProps>
Kbd?: PropsWithForm<KbdProps>
}

export const DEFAULT_PROPS: PreviewDefaultProps = {
Expand Down Expand Up @@ -239,6 +241,7 @@ export const DEFAULT_PROPS: PreviewDefaultProps = {
},
},
ListItem: { children: 'list' },
Kbd: { children: 'shift' },
Progress: {
value: 60,
min: 0,
Expand Down
1 change: 1 addition & 0 deletions src/utils/editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ export const COMPONENTS: (ComponentType | MetaComponentType)[] = [
'Switch',
'Tag',
'Text',
'Kbd',
'Textarea',
'Tab',
'Accordion',
Expand Down

0 comments on commit a25d7b9

Please sign in to comment.