Skip to content
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
7 changes: 2 additions & 5 deletions packages/sdks-tests/src/snippet-tests/custom-child.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,7 @@ test.describe('Div with Hero class, and text', () => {
const builderBlock = page.locator('div.builder-block').first();
await expect(builderBlock).toBeVisible();

const column1Text = page.locator('text=This is text from your component');
await expect(column1Text).toBeVisible();

const column2Text = page.locator('text=This is Builder text');
await expect(column2Text).toBeVisible();
const componentText = page.locator('text=This is text from your component');
await expect(componentText).toBeVisible();
});
});
38 changes: 22 additions & 16 deletions packages/sdks/snippets/react/src/components/CustomHero.tsx
Original file line number Diff line number Diff line change
@@ -1,34 +1,40 @@
import { RegisteredComponent } from '@builder.io/sdk-react';
import { ReactNode } from 'react';
import {
Blocks,
BuilderBlock,
RegisteredComponent,
} from '@builder.io/sdk-react';

interface CustomHeroProps {
children: ReactNode;
content: BuilderBlock[];
builderBlock: BuilderBlock;
}

const CustomHero = (props: CustomHeroProps) => {
return (
<>
<div>This is text from your component</div>
<h2>This is text from your component</h2>

{props.children}
<Blocks
blocks={props.content}
parent={props.builderBlock.id}
path="content"
/>
</>
);
};

export const customHeroInfo: RegisteredComponent = {
component: CustomHero,
name: 'CustomHero',
inputs: [],
canHaveChildren: true,
defaultChildren: [
component: CustomHero,
shouldReceiveBuilderProps: {
builderBlock: true,
},
inputs: [
{
'@type': '@builder.io/sdk:Element',
component: {
name: 'Text',
options: {
text: 'This is Builder text',
},
},
name: 'content',
type: 'uiBlocks',
hideFromUI: true,
defaultValue: [],
},
],
};
Loading