-
Notifications
You must be signed in to change notification settings - Fork 852
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
Synced ComponentInfo to the current state of Component interface in gen1 builder.class.ts #2886
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { getBuilderGlobals } from './evaluate/helpers'; | ||
|
||
export function isServer(): boolean { | ||
return Boolean(getBuilderGlobals().isServer); | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,25 +7,70 @@ export interface ComponentInfo { | |
* by registering a component with the same name, e.g. 'Text', to replace the built-in text component | ||
*/ | ||
name: string; | ||
/** @hidden @deprecated */ | ||
description?: string; | ||
/** | ||
* Link to a documentation page for this component | ||
*/ | ||
docsLink?: string; | ||
/** | ||
* Link to an image to be used as an icon for this component in Builder's editor | ||
* | ||
* @example | ||
* ```js | ||
* image: 'https://some-cdn.com/my-icon-for-this-component.png' | ||
* ``` | ||
*/ | ||
image?: string; | ||
|
||
// TODO (murtaza): Implement 'screenshot' related stuff | ||
/** | ||
* Link to a screenshot shown when user hovers over the component in Builder's editor | ||
* use https://builder.io/upload to upload your screeshot, for easier resizing by Builder. | ||
*/ | ||
screenshot?: string; | ||
|
||
// TODO (murtaza): Implement 'override' related stuff | ||
/** | ||
* When overriding built-in components, if you don't want any special behavior that | ||
* the original has, set this to `true` to skip the default behavior | ||
* | ||
* Default behaviors include special "virtual options", such as a custom | ||
* aspect ratio editor for Images, or a special column editor for Columns | ||
* | ||
* Learn more about overriding built-in components here: https://www.builder.io/c/docs/custom-components-overriding | ||
*/ | ||
override?: boolean; | ||
|
||
/** | ||
* Input schema for your component for users to fill in the options | ||
*/ | ||
inputs?: Input[]; | ||
/** @hidden @deprecated */ | ||
class?: any; | ||
/** @hidden @deprecated */ | ||
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. Thanks for adding these tags. We will want to go ahead and completely remove any deprecated attributes in gen2 SDKs before we bump to v1, as this is our big chance to remove deprecated features. They can stay here for now though, and these tags will help us know what to remove in the near future 👍🏽 |
||
type?: 'angular' | 'webcomponent' | 'react' | 'vue'; | ||
/** | ||
* Default styles to apply when dropped into the Builder.io editor | ||
* | ||
* @example | ||
* ```js | ||
* defaultStyles: { | ||
* // large (default) breakpoint | ||
* large: { | ||
* backgroundColor: 'black' | ||
* }, | ||
* } | ||
* ``` | ||
*/ | ||
defaultStyles?: { [key: string]: string }; | ||
/** | ||
* Turn on if your component can accept children. Be sure to use in combination with | ||
* withChildren(YourComponent) like here | ||
* github.com/BuilderIO/builder/blob/master/examples/react-design-system/src/components/HeroWithChildren/HeroWithChildren.builder.js#L5 | ||
*/ | ||
canHaveChildren?: boolean; | ||
/** @hidden */ | ||
fragment?: boolean; | ||
/** | ||
* Do not wrap a component in a dom element. Be sure to use {...props.attributes} with this option | ||
|
@@ -45,14 +90,16 @@ export interface ComponentInfo { | |
*/ | ||
defaultChildren?: BuilderElement[]; | ||
defaults?: Partial<BuilderElement>; | ||
/** @hidden @deprecated */ | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
hooks?: { [key: string]: string | Function }; | ||
/** | ||
* Hide your component in editor, useful for gradually deprecating components | ||
*/ | ||
hideFromInsertMenu?: boolean; | ||
// For webcomponents | ||
/** Custom tag name (for custom webcomponents only) */ | ||
tag?: string; | ||
/** @hidden @deprecated */ | ||
static?: boolean; | ||
/** | ||
* Passing a list of model names will restrict using the component to only the models listed here, otherwise it'll be available for all models | ||
|
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.
I don't think we want to export these in the new SDKs. It makes little sense to provide our users with helpers like these: they have nothing to do with SDK functionality.
What is the use case for adding them here?
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.
We have exposed these helpers before in Gen1 and they are widely used in client code, example - in our site. Migrating to gen2 will require users with a substitute, thus exporting them
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.
I understand, and that's the way to go. I would rather users rely on their own isBrowser/isServer helpers than reuse ours. The Builder SDK shouldn't be exporting generic helpers such as these: they are unrelated to the Builder SDK's purpose.