Skip to content

Commit ba60ae3

Browse files
authored
Add Gen 2 Remix to snippets folder (BuilderIO#4062)
1 parent 39ae29e commit ba60ae3

28 files changed

+2024
-6
lines changed

.github/workflows/ci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ jobs:
130130
'nextjs-sdk-next-app',
131131
'react-sdk-next-14-app',
132132
'react-sdk-next-pages',
133+
'remix',
133134
'svelte',
134135
'sveltekit',
135136
'solid',
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/**
2+
* This is intended to be a basic starting point for linting in your app.
3+
* It relies on recommended configs out of the box for simplicity, but you can
4+
* and should modify this configuration to best suit your team's needs.
5+
*/
6+
7+
/** @type {import('eslint').Linter.Config} */
8+
module.exports = {
9+
root: true,
10+
parserOptions: {
11+
ecmaVersion: 'latest',
12+
sourceType: 'module',
13+
ecmaFeatures: {
14+
jsx: true,
15+
},
16+
},
17+
env: {
18+
browser: true,
19+
commonjs: true,
20+
es6: true,
21+
},
22+
ignorePatterns: ['!**/.server', '!**/.client'],
23+
24+
// Base config
25+
extends: ['eslint:recommended'],
26+
rules: {
27+
'import/no-unresolved': ['error', { ignore: ['@builder.io/sdk-react'] }],
28+
},
29+
overrides: [
30+
// React
31+
{
32+
files: ['**/*.{js,jsx,ts,tsx}'],
33+
plugins: ['react', 'jsx-a11y'],
34+
extends: [
35+
'plugin:react/recommended',
36+
'plugin:react/jsx-runtime',
37+
'plugin:react-hooks/recommended',
38+
'plugin:jsx-a11y/recommended',
39+
],
40+
settings: {
41+
react: {
42+
version: 'detect',
43+
},
44+
formComponents: ['Form'],
45+
linkComponents: [
46+
{ name: 'Link', linkAttribute: 'to' },
47+
{ name: 'NavLink', linkAttribute: 'to' },
48+
],
49+
'import/resolver': {
50+
typescript: {},
51+
},
52+
},
53+
},
54+
55+
// Typescript
56+
{
57+
files: ['**/*.{ts,tsx}'],
58+
plugins: ['@typescript-eslint', 'import'],
59+
parser: '@typescript-eslint/parser',
60+
settings: {
61+
'import/internal-regex': '^~/',
62+
'import/resolver': {
63+
node: {
64+
extensions: ['.ts', '.tsx'],
65+
},
66+
typescript: {
67+
alwaysTryTypes: true,
68+
},
69+
},
70+
},
71+
extends: [
72+
'plugin:@typescript-eslint/recommended',
73+
'plugin:import/recommended',
74+
'plugin:import/typescript',
75+
],
76+
},
77+
78+
// Node
79+
{
80+
files: ['.eslintrc.cjs'],
81+
env: {
82+
node: true,
83+
},
84+
},
85+
],
86+
};
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
node_modules
2+
3+
/.cache
4+
/build
5+
.env
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# Welcome to Remix!
2+
3+
- 📖 [Remix docs](https://remix.run/docs)
4+
5+
## Development
6+
7+
Run the dev server:
8+
9+
```shellscript
10+
npm run dev
11+
```
12+
13+
## Deployment
14+
15+
First, build your app for production:
16+
17+
```sh
18+
npm run build
19+
```
20+
21+
Then run the app in production mode:
22+
23+
```sh
24+
npm start
25+
```
26+
27+
Now you'll need to pick a host to deploy it to.
28+
29+
### DIY
30+
31+
If you're familiar with deploying Node applications, the built-in Remix app server is production-ready.
32+
33+
Make sure to deploy the output of `npm run build`
34+
35+
- `build/server`
36+
- `build/client`
37+
38+
## Styling
39+
40+
This template comes with [Tailwind CSS](https://tailwindcss.com/) already configured for a simple default starting experience. You can use whatever css framework you prefer. See the [Vite docs on css](https://vitejs.dev/guide/features.html#css) for more information.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import {
2+
Blocks,
3+
BuilderBlock,
4+
RegisteredComponent,
5+
} from '@builder.io/sdk-react';
6+
7+
interface CustomColumnsProps {
8+
column1: BuilderBlock[];
9+
column2: BuilderBlock[];
10+
builderBlock: BuilderBlock;
11+
}
12+
13+
const CustomColumns = (props: CustomColumnsProps) => {
14+
return (
15+
<>
16+
<Blocks
17+
blocks={props.column1}
18+
path="column1"
19+
parent={props.builderBlock.id}
20+
/>
21+
22+
<Blocks
23+
blocks={props.column2}
24+
path="column2"
25+
parent={props.builderBlock.id}
26+
/>
27+
</>
28+
);
29+
};
30+
31+
export const customColumnsInfo: RegisteredComponent = {
32+
name: 'MyColumns',
33+
component: CustomColumns,
34+
shouldReceiveBuilderProps: {
35+
builderBlock: true,
36+
},
37+
inputs: [
38+
{
39+
name: 'column1',
40+
type: 'uiBlocks',
41+
defaultValue: [],
42+
},
43+
{
44+
name: 'column2',
45+
type: 'uiBlocks',
46+
defaultValue: [],
47+
},
48+
],
49+
};
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
import { RegisteredComponent } from '@builder.io/sdk-react';
2+
import { ReactNode } from 'react';
3+
4+
interface CustomHeroProps {
5+
children: ReactNode;
6+
}
7+
8+
const CustomHero = (props: CustomHeroProps) => {
9+
return (
10+
<>
11+
<div>This is text from your component</div>
12+
13+
{props.children}
14+
</>
15+
);
16+
};
17+
18+
export const customHeroInfo: RegisteredComponent = {
19+
component: CustomHero,
20+
name: 'CustomHero',
21+
inputs: [],
22+
canHaveChildren: true,
23+
defaultChildren: [
24+
{
25+
'@type': '@builder.io/sdk:Element',
26+
component: {
27+
name: 'Text',
28+
options: {
29+
text: 'This is Builder text',
30+
},
31+
},
32+
},
33+
],
34+
};
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
import {
2+
Blocks,
3+
BuilderBlock,
4+
RegisteredComponent,
5+
} from '@builder.io/sdk-react';
6+
import { useState } from 'react';
7+
8+
interface TabProps {
9+
tabList?: { tabName: string; blocks: BuilderBlock[] }[];
10+
builderBlock: BuilderBlock;
11+
}
12+
13+
export const CustomTabs = ({ tabList, builderBlock }: TabProps) => {
14+
const [activeTab, setActiveTab] = useState(0);
15+
16+
if (!tabList?.length) return null;
17+
18+
return (
19+
<>
20+
<div className="tab-buttons">
21+
{tabList.map((tab, index) => (
22+
<button
23+
key={index}
24+
className={`tab-button ${activeTab === index ? 'active' : ''}`}
25+
onClick={() => setActiveTab(index)}
26+
>
27+
{tab.tabName}
28+
</button>
29+
))}
30+
</div>
31+
32+
<Blocks
33+
parent={builderBlock?.id}
34+
path={`tabList.${activeTab}.blocks`}
35+
blocks={tabList[activeTab].blocks}
36+
/>
37+
</>
38+
);
39+
};
40+
41+
export const customTabsInfo: RegisteredComponent = {
42+
component: CustomTabs,
43+
name: 'TabFields',
44+
shouldReceiveBuilderProps: {
45+
builderBlock: true,
46+
},
47+
inputs: [
48+
{
49+
name: 'tabList',
50+
type: 'list',
51+
subFields: [
52+
{
53+
name: 'tabName',
54+
type: 'string',
55+
},
56+
{
57+
name: 'blocks',
58+
type: 'uiBlocks',
59+
defaultValue: [],
60+
},
61+
],
62+
},
63+
],
64+
};
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export default function FooterComponent() {
2+
return (
3+
<div>
4+
<p>© 2024 Acme Corp. All rights reserved.</p>
5+
</div>
6+
);
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export default function HeaderComponent() {
2+
return (
3+
<div>
4+
<h1>Acme Corp</h1>
5+
</div>
6+
);
7+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
export type Product = {
2+
id: number;
3+
title: string;
4+
price: number;
5+
description: string;
6+
category: string;
7+
image: string;
8+
rating: {
9+
rate: number;
10+
count: number;
11+
};
12+
};
13+
14+
export default function ProductInfoComponent({
15+
product,
16+
}: {
17+
product: Product | null;
18+
}) {
19+
if (!product) return null;
20+
21+
return (
22+
<div>
23+
<div className="product-image">
24+
<img src={product.image} alt={product.title} />
25+
</div>
26+
<div className="product-info">
27+
<h2>{product.title}</h2>
28+
<p>{product.description}</p>
29+
<p>Price: {product.price} $</p>
30+
<p>Rating: {product.rating.rate} / 5</p>
31+
<button>Buy now</button>
32+
</div>
33+
</div>
34+
);
35+
}

0 commit comments

Comments
 (0)