-
Notifications
You must be signed in to change notification settings - Fork 10
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
create HeadingComponent #11
Changes from 4 commits
258e4f8
51cccb0
6654e38
06ba5ac
789455b
682fea1
5e85627
fa9d0d2
0b7da3b
978440d
17f3717
ce4338e
4e1745f
a9d6219
b9c4c4f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's also think about what this component does. How can you add different heading levels, like h1, h2 or h3? |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { ComponentConfig } from "@measured/puck"; | ||
import React from "react"; | ||
|
||
export type HeadingComponentProps = { | ||
text: string, | ||
textAlign: any, | ||
}; | ||
|
||
function HeadingComponent({text, textAlign}: HeadingComponentProps){ | ||
silvio2402 marked this conversation as resolved.
Show resolved
Hide resolved
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also, make sure the component is export default. |
||
return ( | ||
<div style={{padding: 64}}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this padding needed, or is there a way to use the margin and min-height on the h1 tag? |
||
<h1 style={{ textAlign }}>{text}</h1> | ||
</div> | ||
) | ||
}; | ||
|
||
export const headingComponentConfig: ComponentConfig<HeadingComponentProps> = { | ||
render: HeadingComponent, | ||
fields:{ | ||
text: {type: "text"}, | ||
textAlign: { | ||
type: "radio", | ||
options: [ | ||
{ label: "Left", value: "left" }, | ||
{ label: "Center", value: "center" }, | ||
{ label: "Right", value: "right" }, | ||
], | ||
}, | ||
}, | ||
defaultProps: { | ||
text: "HeadingComponent", | ||
silvio2402 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
textAlign: "center", | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
import type { Config } from "@measured/puck"; | ||
import type { TextProps } from "./components/Text"; | ||
import Text from "./components/Text"; | ||
import type { HeadingComponentProps } from "./components/HeadingComponent"; | ||
import { headingComponentConfig } from "./components/HeadingComponent"; | ||
|
||
type Props = { | ||
HeadingComponent: HeadingComponentProps | ||
HeadingBlock: { title: string }; | ||
Text: TextProps; | ||
}; | ||
|
@@ -30,6 +33,7 @@ export const config: Config<Props> = { | |
</div> | ||
), | ||
}, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since you created the component can you please also remove the HeadingBlock component here. It's no longer needed. |
||
HeadingComponent: headingComponentConfig, | ||
}, | ||
}; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please format the file. Tip: turn on format on save