2.2.198 • Published 1 year ago

cra-template-react-declarative v2.2.198

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

⚛️ cra-template-react-declarative

Contains the most advanced todo-list which you ever seen!

npm

screenshot

Usage

yarn create react-app --template cra-template-react-declarative .

or

npx create-react-app . --template=react-declarative

What's inside

  1. TypeScript
  2. MUI
  3. Mobx
  4. MSW
  5. tss-react
  6. react-declarative

Code sample

import { FetchView, Breadcrumbs, One, FieldType, IField, usePreventLeave } from 'react-declarative';

import fetchApi from '../../helpers/fetchApi';
import history from '../../helpers/history';

interface ITodoOnePageProps {
    id: string;
}

const fields: IField[] = [
    {
        type: FieldType.Line,
        title: 'System info'
    },
    {
        type: FieldType.Div,
        style: {
          display: 'grid',
          gridTemplateColumns: '1fr auto',
        },
        fields: [
            {
                type: FieldType.Text,
                name: 'userId',
                title: 'User id',
                outlined: false,
                disabled: true,
            },
            {
                type: FieldType.Checkbox,
                fieldBottomMargin: "0",
                name: 'completed',
                title: "Completed",
                disabled: true,
            },
        ]
    },
    {
        type: FieldType.Line,
        title: 'Common info'
    },
    {
        type: FieldType.Text,
        name: 'title',
        title: 'Title',
    }
];

export const TodoOnePage = ({
    id,
}: ITodoOnePageProps) => {

    const fetchState = async () => await fetchApi(`/api/v1/todos/${id}`);

    const Content = (props: any) => {

        const {
            data,
            oneProps,
            beginSave,
        } = usePreventLeave({
            history,
            onSave: async () => {
                alert(JSON.stringify(data, null, 2));
                return true; // HTTP 200
            },
        });

        return (
            <>
                <Breadcrumbs
                    withSave
                    saveDisabled={!data}
                    title="Todo list"
                    subtitle={props.todo.title}
                    onSave={beginSave}
                    onBack={() => history.push('/todos')}
                />
                <One
                    handler={() => props.todo}
                    fields={fields}
                    {...oneProps}
                />
            </>
        );
    };

    return (
        <FetchView state={fetchState}>
            {(todo) => (
                <Content todo={todo} />
            )}
        </FetchView>
    );
};

export default TodoOnePage;
2.2.198

1 year ago

2.2.187

1 year ago

2.2.162

1 year ago

2.2.168

1 year ago

2.2.167

1 year ago

2.2.166

1 year ago

2.2.157

1 year ago

2.2.156

1 year ago

2.2.147

1 year ago

2.2.139

1 year ago

2.2.138

1 year ago

2.2.99

1 year ago

2.2.98

1 year ago

2.2.91

1 year ago

2.2.86

1 year ago

2.2.17

1 year ago

2.2.4

1 year ago

2.2.6

1 year ago

2.2.10

1 year ago

2.1.86

1 year ago

2.1.84

1 year ago

2.1.80

1 year ago

2.1.94

1 year ago

2.1.93

1 year ago

2.1.91

1 year ago

2.1.74

1 year ago

2.1.75

1 year ago

2.1.73

1 year ago

2.1.70

1 year ago

2.1.71

1 year ago

2.1.18

2 years ago

2.1.19

2 years ago

2.1.49

1 year ago

2.1.48

1 year ago

2.1.68

1 year ago

2.1.46

1 year ago

2.1.65

1 year ago

2.1.66

1 year ago

2.1.22

2 years ago

2.1.7

2 years ago

2.1.9

2 years ago

2.1.17

2 years ago

2.1.36

1 year ago

2.0.68

2 years ago

2.1.34

1 year ago

2.1.57

1 year ago

2.1.54

1 year ago

2.1.33

1 year ago

2.0.65

2 years ago

2.1.30

1 year ago

2.1.53

1 year ago

2.0.61

2 years ago

2.0.19

2 years ago

2.0.48

2 years ago

2.0.47

2 years ago

2.0.20

2 years ago

2.0.51

2 years ago

2.0.52

2 years ago

1.9.154

2 years ago

1.9.153

2 years ago

1.9.152

2 years ago

1.9.151

2 years ago

1.9.148

2 years ago

1.9.147

2 years ago

1.9.146

2 years ago

1.9.142

2 years ago

1.9.140

2 years ago

1.9.137

2 years ago

1.9.136

2 years ago