-
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: fixed types of web sandbox components
- Loading branch information
Showing
36 changed files
with
315 additions
and
196 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
import { Variant } from "@morfeo/react" | ||
import { ComponentProps } from "react" | ||
import { MorfeoComponent } from "./MorfeoComponent" | ||
import { MorfeoComponent, MorfeoComponentProps } from './MorfeoComponent'; | ||
|
||
type Props = { | ||
variant?: Variant<'Box'>; | ||
} & Omit<ComponentProps<typeof MorfeoComponent>, 'componentName'> | ||
type Props = Omit<MorfeoComponentProps<'Box'>, 'componentName'>; | ||
|
||
export const Box: React.FC<Props> = ({ variant, children, ...props }) => { | ||
return <MorfeoComponent componentName="Box" variant={variant} {...props}>{children}</MorfeoComponent> | ||
} | ||
export const Box: React.FC<Props> = props => ( | ||
<MorfeoComponent componentName="Box" {...props} /> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
import { Variant } from "@morfeo/react" | ||
import { ComponentProps } from "react" | ||
import { MorfeoComponent } from "./MorfeoComponent" | ||
import { MorfeoComponent, MorfeoComponentProps } from './MorfeoComponent'; | ||
|
||
type Props = { | ||
variant?: Variant<'Card'>; | ||
} & Omit<ComponentProps<typeof MorfeoComponent>, 'componentName'> | ||
type Props = Omit<MorfeoComponentProps<'Card'>, 'componentName'>; | ||
|
||
export const Card: React.FC<Props> = ({ variant, children, ...props }) => { | ||
return <MorfeoComponent componentName="Card" variant={variant} {...props}>{children}</MorfeoComponent> | ||
} | ||
export const Card: React.FC<Props> = props => ( | ||
<MorfeoComponent componentName="Card" {...props} /> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
import { ComponentProps } from "react" | ||
import { MorfeoComponent } from "../MorfeoComponent" | ||
import { MorfeoComponent, MorfeoComponentProps } from '../MorfeoComponent'; | ||
|
||
type Props = Omit<ComponentProps<typeof MorfeoComponent>, 'componentName'> | ||
type Props = Omit<MorfeoComponentProps<'Button'>, 'componentName'>; | ||
|
||
export const Button: React.FC<Props> = ({ variant, children, ...props }) => { | ||
return <MorfeoComponent componentName="Button" variant={variant} {...props}>{children}</MorfeoComponent> | ||
} | ||
export const Button: React.FC<Props> = props => ( | ||
<MorfeoComponent componentName="Button" {...props} /> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
import { ComponentProps } from "react" | ||
import { MorfeoComponent } from "../MorfeoComponent" | ||
import { MorfeoComponent, MorfeoComponentProps } from '../MorfeoComponent'; | ||
|
||
type Props = Omit<ComponentProps<typeof MorfeoComponent>, 'componentName'> | ||
type Props = Omit<MorfeoComponentProps<'Input'>, 'componentName'>; | ||
|
||
export const Input: React.FC<Props> = ({ variant, children, ...props }) => { | ||
return <MorfeoComponent componentName="Input" variant={variant} {...props}>{children}</MorfeoComponent> | ||
} | ||
export const Input: React.FC<Props> = props => { | ||
return <MorfeoComponent componentName="Input" {...props} />; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
import { ComponentProps } from "react" | ||
import { MorfeoComponent } from "../MorfeoComponent" | ||
import { MorfeoComponent, MorfeoComponentProps } from '../MorfeoComponent'; | ||
|
||
type Props = Omit<ComponentProps<typeof MorfeoComponent>, 'componentName'> | ||
type Props = Omit<MorfeoComponentProps<'InputFeedback'>, 'componentName'>; | ||
|
||
export const InputFeedback: React.FC<Props> = ({ variant, children, ...props }) => { | ||
return <MorfeoComponent componentName="InputFeedback" variant={variant} {...props}>{children}</MorfeoComponent> | ||
} | ||
export const InputFeedback: React.FC<Props> = props => ( | ||
<MorfeoComponent componentName="InputFeedback" {...props} /> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,7 @@ | ||
import { ComponentProps } from "react" | ||
import { MorfeoComponent } from "../MorfeoComponent" | ||
import { MorfeoComponent, MorfeoComponentProps } from '../MorfeoComponent'; | ||
|
||
type Props = Omit<ComponentProps<typeof MorfeoComponent>, 'componentName'> | ||
type Props = Omit<MorfeoComponentProps<'Label'>, 'componentName'>; | ||
|
||
export const Label: React.FC<Props> = ({ variant, children, ...props }) => { | ||
return <MorfeoComponent componentName="Label" variant={variant} {...props}>{children}</MorfeoComponent> | ||
} | ||
export const Label: React.FC<Props> = props => ( | ||
<MorfeoComponent componentName="Label" {...props} /> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
import { Variant } from "@morfeo/react" | ||
import { ComponentProps } from "react" | ||
import { MorfeoComponent } from "../MorfeoComponent" | ||
import { MorfeoComponent, MorfeoComponentProps } from '../MorfeoComponent'; | ||
|
||
type Props = { | ||
variant?: Variant<'Container'>; | ||
} & Omit<ComponentProps<typeof MorfeoComponent>, 'componentName'> | ||
type Props = Omit<MorfeoComponentProps<'Container'>, 'componentName'>; | ||
|
||
export const Container: React.FC<Props> = ({ variant, children, ...props }) => { | ||
return <MorfeoComponent componentName="Container" variant={variant} {...props}>{children}</MorfeoComponent> | ||
} | ||
export const Container: React.FC<Props> = props => ( | ||
<MorfeoComponent componentName="Container" {...props} /> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
import { Variant } from "@morfeo/react" | ||
import { ComponentProps } from "react" | ||
import { MorfeoComponent } from "../MorfeoComponent" | ||
import { MorfeoComponent, MorfeoComponentProps } from '../MorfeoComponent'; | ||
|
||
type Props = { | ||
variant?: Variant<'Grid'>; | ||
} & Omit<ComponentProps<typeof MorfeoComponent>, 'componentName'> | ||
type Props = Omit<MorfeoComponentProps<'Grid'>, 'componentName'>; | ||
|
||
export const Grid: React.FC<Props> = ({ variant, children, ...props }) => { | ||
return <MorfeoComponent componentName="Grid" variant={variant} {...props}>{children}</MorfeoComponent> | ||
} | ||
export const Grid: React.FC<Props> = props => ( | ||
<MorfeoComponent componentName="Grid" {...props} /> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
import { Variant } from "@morfeo/react" | ||
import { ComponentProps } from "react" | ||
import { MorfeoComponent } from "./MorfeoComponent" | ||
import { MorfeoComponent, MorfeoComponentProps } from './MorfeoComponent'; | ||
|
||
type Props = { | ||
variant?: Variant<'Hr'>; | ||
} & Omit<ComponentProps<typeof MorfeoComponent>, 'componentName'> | ||
type Props = Omit<MorfeoComponentProps<'Hr'>, 'componentName'>; | ||
|
||
export const Hr: React.FC<Props> = ({ variant, children, ...props }) => { | ||
return <MorfeoComponent componentName="Hr" variant={variant} {...props}>{children}</MorfeoComponent> | ||
} | ||
export const Hr: React.FC<Props> = props => ( | ||
<MorfeoComponent componentName="Hr" {...props} /> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
import { Variant } from "@morfeo/react" | ||
import { ComponentProps } from "react" | ||
import { MorfeoComponent } from "./MorfeoComponent" | ||
import { MorfeoComponent, MorfeoComponentProps } from './MorfeoComponent'; | ||
|
||
type Props = { | ||
variant?: Variant<'List'>; | ||
} & Omit<ComponentProps<typeof MorfeoComponent>, 'componentName'> | ||
type Props = Omit<MorfeoComponentProps<'List'>, 'componentName'>; | ||
|
||
export const List: React.FC<Props> = ({ variant, children, ...props }) => { | ||
return <MorfeoComponent componentName="List" variant={variant} {...props}>{children}</MorfeoComponent> | ||
} | ||
export const List: React.FC<Props> = props => ( | ||
<MorfeoComponent componentName="List" {...props} /> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,54 @@ | ||
import { Variant, useClassName, Component, component, useTheme, Style } from '@morfeo/react'; | ||
import { | ||
Style, | ||
Variant, | ||
useTheme, | ||
Component, | ||
component, | ||
useClassName, | ||
} from '@morfeo/react'; | ||
import React, { ReactNode, HTMLProps, useMemo } from 'react'; | ||
|
||
|
||
type Props<T extends Component> = { | ||
export type MorfeoComponentProps<T extends Component> = { | ||
style?: Style; | ||
variant?: Variant<T>; | ||
componentName: T; | ||
children?: ReactNode; | ||
style?: Style; | ||
} & Omit<HTMLProps<HTMLElement>, 'style'> | ||
componentName: T; | ||
} & Omit<HTMLProps<HTMLElement>, 'style'>; | ||
|
||
export function MorfeoComponent<T extends Component>({ | ||
style, | ||
variant, | ||
children, | ||
componentName, | ||
...props | ||
}: MorfeoComponentProps<T>) { | ||
const { | ||
tag = 'div', | ||
props: componentProps, | ||
style: componentStyle, | ||
} = component(componentName, variant).get(); | ||
|
||
export function MorfeoComponent<T extends Component>({ componentName , variant, children, style, ...props }: Props<T>) { | ||
const componentObj = component(componentName, variant).get(); | ||
const componentStyle = component(componentName, variant).getStyle(); | ||
const theme = useTheme(); | ||
|
||
const className = useClassName({ ...componentStyle, ...style }); | ||
|
||
const render = useMemo(() => { | ||
if (componentObj.tag && theme) { | ||
return React.createElement(componentObj.tag, { | ||
...componentObj.props, | ||
className, | ||
if (tag && theme) { | ||
return React.createElement( | ||
tag, | ||
{ | ||
...componentProps, | ||
...props, | ||
className: props.className | ||
? [className, props.className].join(' ') | ||
: className, | ||
}, | ||
children, | ||
...props | ||
}) | ||
); | ||
} | ||
|
||
return <></> | ||
|
||
}, [children, className, componentObj.props, componentObj.tag, props, theme]) | ||
|
||
return render | ||
} | ||
return <></>; | ||
}, [children, className, componentProps, props, tag, theme]); | ||
|
||
return render; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
import { Variant } from "@morfeo/react" | ||
import { ComponentProps } from "react" | ||
import { MorfeoComponent } from "../MorfeoComponent" | ||
import { MorfeoComponent, MorfeoComponentProps } from '../MorfeoComponent'; | ||
|
||
type Props = { | ||
variant?: Variant<'Footer'>; | ||
} & Omit<ComponentProps<typeof MorfeoComponent>, 'componentName'> | ||
type Props = Omit<MorfeoComponentProps<'Footer'>, 'componentName'>; | ||
|
||
export const Footer: React.FC<Props> = ({ variant, children, ...props }) => { | ||
return <MorfeoComponent componentName="Footer" variant={variant} {...props}>{children}</MorfeoComponent> | ||
} | ||
export const Footer: React.FC<Props> = props => ( | ||
<MorfeoComponent componentName="Footer" {...props} /> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
import { Variant } from "@morfeo/react" | ||
import { ComponentProps } from "react" | ||
import { MorfeoComponent } from "../MorfeoComponent" | ||
import { MorfeoComponent, MorfeoComponentProps } from '../MorfeoComponent'; | ||
|
||
type Props = { | ||
variant?: Variant<'Header'>; | ||
} & Omit<ComponentProps<typeof MorfeoComponent>, 'componentName'> | ||
type Props = Omit<MorfeoComponentProps<'Header'>, 'componentName'>; | ||
|
||
export const Header: React.FC<Props> = ({ variant, children, ...props }) => { | ||
return <MorfeoComponent componentName="Header" variant={variant} {...props}>{children}</MorfeoComponent> | ||
} | ||
export const Header: React.FC<Props> = props => ( | ||
<MorfeoComponent componentName="Header" {...props} /> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
import { Variant } from "@morfeo/react" | ||
import { ComponentProps } from "react" | ||
import { MorfeoComponent } from "../MorfeoComponent" | ||
import { MorfeoComponent, MorfeoComponentProps } from '../MorfeoComponent'; | ||
|
||
type Props = { | ||
variant?: Variant<'Main'>; | ||
} & Omit<ComponentProps<typeof MorfeoComponent>, 'componentName'> | ||
type Props = Omit<MorfeoComponentProps<'Main'>, 'componentName'>; | ||
|
||
export const Main: React.FC<Props> = ({ variant, children, ...props }) => { | ||
return <MorfeoComponent componentName="Main" variant={variant} {...props}>{children}</MorfeoComponent> | ||
} | ||
export const Main: React.FC<Props> = props => ( | ||
<MorfeoComponent componentName="Main" {...props} /> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
import { Variant } from "@morfeo/react" | ||
import { ComponentProps } from "react" | ||
import { MorfeoComponent } from "../MorfeoComponent" | ||
import { MorfeoComponent, MorfeoComponentProps } from '../MorfeoComponent'; | ||
|
||
type Props = { | ||
variant?: Variant<'Page'>; | ||
} & Omit<ComponentProps<typeof MorfeoComponent>, 'componentName'> | ||
type Props = Omit<MorfeoComponentProps<'Page'>, 'componentName'>; | ||
|
||
export const Page: React.FC<Props> = ({ children, variant, ...props }) => { | ||
return <MorfeoComponent componentName="Page" variant={variant} {...props}>{children}</MorfeoComponent> | ||
} | ||
export const Page: React.FC<Props> = props => ( | ||
<MorfeoComponent componentName="Page" {...props} /> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
import { Variant } from "@morfeo/react" | ||
import { ComponentProps } from "react" | ||
import { MorfeoComponent } from "../MorfeoComponent" | ||
import { MorfeoComponent, MorfeoComponentProps } from '../MorfeoComponent'; | ||
|
||
type Props = { | ||
variant?: Variant<'Section'>; | ||
} & Omit<ComponentProps<typeof MorfeoComponent>, 'componentName'> | ||
type Props = Omit<MorfeoComponentProps<'Section'>, 'componentName'>; | ||
|
||
export const Section: React.FC<Props> = ({ children, variant, ...props }) => { | ||
return <MorfeoComponent componentName="Section" variant={variant} {...props}>{children}</MorfeoComponent> | ||
} | ||
export const Section: React.FC<Props> = props => ( | ||
<MorfeoComponent componentName="Section" {...props} /> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,7 @@ | ||
import { Variant } from "@morfeo/react" | ||
import { ComponentProps } from "react" | ||
import { MorfeoComponent } from "./MorfeoComponent" | ||
import { MorfeoComponent, MorfeoComponentProps } from './MorfeoComponent'; | ||
|
||
type Props = { | ||
variant?: Variant<'Typography'>; | ||
} & Omit<ComponentProps<typeof MorfeoComponent>, 'componentName'> | ||
type Props = Omit<MorfeoComponentProps<'Typography'>, 'componentName'>; | ||
|
||
export const Typography: React.FC<Props> = ({ variant, children, ...props }) => { | ||
return <MorfeoComponent componentName="Typography" variant={variant} {...props}>{children}</MorfeoComponent> | ||
} | ||
export const Typography: React.FC<Props> = props => ( | ||
<MorfeoComponent componentName="Typography" {...props} /> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.