Skip to content
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

feat(demo): custom component from mson #273

Merged
merged 1 commit into from
Aug 7, 2021
Merged
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
27 changes: 25 additions & 2 deletions src/demo/components/custom-component.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React from 'react';
import attach from '../../attach';
import Typography from '@material-ui/core/Typography';

import UIComponent from 'mson/lib/ui-component';
import Form from 'mson/lib/form';
import TextField from 'mson/lib/fields/text-field';
import attach from '../../attach';
import Typography from '@material-ui/core/Typography';

class CustomComponent extends UIComponent {
_className = 'CustomComponent';
Expand All @@ -26,6 +27,28 @@ class CustomComponent extends UIComponent {
}
}

// Or, you can use MSON instead of JS
//
// import compiler from 'mson/lib/compiler';
//
// const CustomComponent = compiler.compile({
// component: 'UIComponent',
// name: 'CustomComponent',
// schema: {
// component: 'Form',
// fields: [
// {
// component: 'TextField',
// name: 'name'
// },
// {
// component: 'TextField',
// name: 'label'
// }
// ]
// }
// });

let CustomComponentUI = (props) => {
const { name, label } = props;
return (
Expand Down