diff --git a/docs/README.md b/docs/README.md index e3caf1b..968d0d0 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,8 +1,9 @@ # US Forms System Documentation - [Getting started with the Forms System Library](getting-started/README.md) - - Creating a new application with the US Forms System Starter App - - Installing the library in an existing application + - [Tools for getting started with the US Forms System](#tools-for-getting-started-with-the-us-forms-system) + - [Creating a new application with the US Forms System Starter App](getting-started/creating-a-new-application-with-the-us-forms-system-starter-app.md) + - [Installing the US Forms System in an existing application](getting-started/installing-the-library-in-an-existing-application.md) - [Building a form](building-a-form/README.md) - [About the US Forms System library](building-a-form/about-the-us-forms-system-library.md) - [Creating a form config file](building-a-form/creating-a-form-config-file.md) diff --git a/docs/getting-started.md b/docs/getting-started.md deleted file mode 100644 index 269b637..0000000 --- a/docs/getting-started.md +++ /dev/null @@ -1,30 +0,0 @@ -## Getting started - -There are two options for how to start using this library. - -### 1: Start a new application - -If you are starting a completely new application from scratch, the easiest way to get started is to use our [us-forms-system-starter-app](https://github.com/usds/us-forms-system-starter-app). This sets up the initial files, configuration, build process, and web server so you can start building the form immediately. Please refer to the set up instructions in that repo. - -### 2: Install in an existing application - -If you are installing the library into an existing application, you can follow these steps: - -1. Install the library: -`npm install --save https://github.com/usds/us-forms-system.git` - -2. Install peer dependencies: -- `npm install --save-dev uswds@^1.6.3` -- `npm install --save-dev react@^15.5.4` -- `npm install --save-dev react-dom@^15.6.2` - -3. There will be a few files you will need to configure in order for the form to work. The best reference for understanding what files you will need to create is our [us-forms-system-starter-app](https://github.com/usds/us-forms-system-starter-app). - -The essential files needed are: -- An [entry js](https://github.com/usds/us-forms-system-starter-app/blob/master/app.js) file -- A [top-level React component](https://github.com/usds/us-forms-system-starter-app/blob/master/js/components/Form.jsx) that will render the top-level us-forms-system component -- A [routes](https://github.com/usds/us-forms-system-starter-app/blob/master/js/routes.jsx) file that loads `createRoutes` from the us-forms-system, which creates the routes from the config automatically -- A [reducers](https://github.com/usds/us-forms-system-starter-app/blob/master/js/reducers.js) file that loads `createSchemaFormReducer` from us-forms-system to create the app's reducer functions -- The [form config](https://github.com/usds/us-forms-system-starter-app/blob/master/js/config/form.js) itself - -These instructions assume your existing app has a web server in order to run the app locally. diff --git a/docs/getting-started/README.md b/docs/getting-started/README.md index ce11847..bd0c089 100644 --- a/docs/getting-started/README.md +++ b/docs/getting-started/README.md @@ -1,7 +1,17 @@ -# Getting started with the Forms System Library +# Getting started with the US Forms System -### Creating a new application with the US Forms System Starter App +Depending on your needs, you can either create a brand new application from scratch or install the US Forms System in an existing application. -### Installing the library in an existing application +### [Tools for getting started with the US Forms System](#tools-for-getting-started-with-the-us-forms-system) + +Building a form using the US Forms System requires some minimum front-end development tools, as well as general knowledge of those tools. Where possible, we'll provide links to information about getting started with these tools. + +### [Creating a new application with the US Forms System Starter App](creating-a-new-application-with-the-us-forms-system-starter-app.md) + +The US Forms System Starter App creates the initial files, configuration, build process, and web server you need to start building your form immediately. + +### [Installing the US Forms System in an existing application](installing-the-library-in-an-existing-application.md) + +If you're using an existing React application, you can install the US Forms System in that app. [Back to *US Forms System Documentation*](/docs/README.md) diff --git a/docs/getting-started/creating-a-new-application-with-the-us-forms-system-starter-app.md b/docs/getting-started/creating-a-new-application-with-the-us-forms-system-starter-app.md new file mode 100644 index 0000000..c640af2 --- /dev/null +++ b/docs/getting-started/creating-a-new-application-with-the-us-forms-system-starter-app.md @@ -0,0 +1,61 @@ +# Creating a new application with the US Forms System Starter App + +The US Forms System Starter App creates the initial files, configuration, build process, and web server you need to start building your form. + +Before you begin, review "[Tools for getting started with the US Forms System](getting-started/tools-for-getting-started-with-the-us-forms-system)." + +### In this guide + +- [Clone the Starter App repository and change the remote URL](#clone-the-starter-app-repository-and-change-the-remote-url) +- [Install dependencies](#install-dependencies) +- [Build and run your app](#build-and-run-your-app) + +### Clone the Starter App repository and change the remote URL + +1. Clone the us-forms-system-starter-app repository to your computer: +```bash +$ git clone https://github.com/usds/us-forms-system-starter-app.git +``` +2. Change the current directory to the new us-forms-system-starter-app directory: +```bash +$ cd us-forms-system-starter-app +``` +3. [On GitHub, create a new repository](https://help.github.com/articles/creating-a-new-repository/) named for your new forms app. +4. From your new repository on GitHub, [copy the clone URL](https://help.github.com/articles/cloning-a-repository/). +5. In Terminal (Mac and Linux) or the Command Prompt (Windows), review the current remote URL that's set to `origin`. The `fetch` and `push` URLs should be set to `https://github.com/usds/us-forms-system-starter-app.git`: +```bash +$ git remote -v +# Lists all remote repositories, along with the URL for those remotes. +origin https://github.com/usds/us-forms-system-starter-app.git (fetch) +origin https://github.com/usds/us-forms-system-starter-app.git (push) +``` +6. Change your `origin` to use the URL for the new remote repository you created in Step 3 and copied in Step 4: +```bash +$ git remote set-url origin https://github.com/YOUR-USERNAME/YOUR-NEW-REPOSITORY-NAME.git +# Changes 'origin' to the new remote's URL +``` +7. Review your current remote URL again. `origin` should be set to *your* repository on GitHub, not https://github.com/usds/us-forms-system-starter-app.git: +```bash +$ git remote -v +# Lists all remote repositories, along with the URL for those remotes. +origin https://github.com/YOUR-USERNAME/YOUR-NEW-REPOSITORY-NAME.git (fetch) +origin https://github.com/YOUR-USERNAME/YOUR-NEW-REPOSITORY-NAME.git (push) +``` + +### Install dependencies + +Use npm to install dependencies specified in `us-forms-system-starter-app/package-lock.json`. + +1. [Make sure Node and npm are installed](tools-for-getting-started-with-the-us-forms-system#node-js-and-npm). +2. In Terminal (Mac and Linux) or the Command Prompt (Windows), use npm to install dependencies for the Starter App: +```bash +$ npm install +``` + +### Build and run your app + +Once your repository is set up and dependencies are installed, you can begin building your app by editing `/js/config/form.js`. For more information, see "[Creating a form config file](building-a-form/creating-a-form-config-file.md)." + +To run your app locally, in Terminal (Mac and Linux) or the Command Prompt (Windows), type `npm start`. Once the server has started, you can view your form in a browser window at `localhost:8080`. + +[Back to *Getting Started with the US Forms System*](README.md) diff --git a/docs/getting-started/installing-the-us-forms-system-in-an-existing-application.md b/docs/getting-started/installing-the-us-forms-system-in-an-existing-application.md new file mode 100644 index 0000000..d14fdcf --- /dev/null +++ b/docs/getting-started/installing-the-us-forms-system-in-an-existing-application.md @@ -0,0 +1,36 @@ +# Installing the US Forms System in an existing application + +If you're using an existing React application, you can install the US Forms System in that app. + +Before you begin, review "[Tools for getting started with the US Forms System](getting-started/tools-for-getting-started-with-the-us-forms-system)." + +### In this guide + +- [Install the library and dependencies](#install-the-library-and-dependencies) +- [Create required files](#create-required-files) + +### Install the library and dependencies + +1. Install the library: +```bash +npm install --save https://github.com/usds/us-forms-system.git +``` + +2. Install the [US Web Design System](https://github.com/uswds/uswds) and React dependencies: +```bash +npm install --save-dev uswds@^1.6.3 +npm install --save-dev react@^15.5.4 +npm install --save-dev react-dom@^15.6.2 +``` + +### Create required files + +To enable your form, create the following files. For an example of these files, see the [us-forms-system-starter-app repository](https://github.com/usds/us-forms-system-starter-app). + +- A [form config file](https://github.com/usds/us-forms-system-starter-app/blob/master/js/config/form.js). For more information, see "Creating a form config file." +- An entry [app.js](https://github.com/usds/us-forms-system-starter-app/blob/master/app.js) file. +- A [React component](https://github.com/usds/us-forms-system-starter-app/blob/master/js/components/Form.jsx) to render the top-level us-forms-system component. +- A [routes file](https://github.com/usds/us-forms-system-starter-app/blob/master/js/routes.jsx) that loads `createRoutes` from us-forms-system. This automatically creates the routes from the form config file. +- A [reducers file](https://github.com/usds/us-forms-system-starter-app/blob/master/js/reducers.js) that loads `createSchemaFormReducer` from us-forms-system. This creates the app's reducer functions. + +[Back to *Getting Started with the US Forms System*](README.md) diff --git a/docs/getting-started/tools-for-getting-started-with-the-us-forms-system.md b/docs/getting-started/tools-for-getting-started-with-the-us-forms-system.md new file mode 100644 index 0000000..7d8e809 --- /dev/null +++ b/docs/getting-started/tools-for-getting-started-with-the-us-forms-system.md @@ -0,0 +1,36 @@ +# Tools for getting started with the US Forms System + +Building a form using the US Forms System requires some minimum front-end development tools, as well as general knowledge of those tools. Where possible, we'll provide links to information about getting started with these tools. + +### In this guide + +- [Command line interface (CLI)](#command-line-interface-cli) +- [JavaScript](#javascript) +- [Node.js and npm](#node-js-and-npm) +- [React](#react) +- [JSON Schema](#json-schema) +- [react-jsonschema-form (rjsf)](#react-jsonschema-form-rjsf) + +### Command line interface (CLI) + +You should be comfortable using command line tools such as Terminal (Mac and Linux) or Command Prompt (Windows). These tools come pre-installed on nearly all computers. There are several tutorials of various types available online to learn about the CLI. + +### JavaScript + +Most technologies the US Forms System uses, such as React, are centered around JavaScript. We recommend basic familiarity with JavaScript to build forms with the US Forms System. For more information about JavaScript, including tutorials for getting started, see [Pluralsight's JavaScript website](https://www.javascript.com/). + +### Node.js and npm + +Node.js is a JavaScript runtime environment that allows you to execute complete JavaScript programs. When you install Node.js, it automatically installs a package manager called npm. You need both Node.js (minimum version 8.0.0) and npm to develop using the US Forms System. For more information, including installation instructions, see the [Node.js website](https://nodejs.org). + +### React + +React is a JavaScript library for building user interfaces (UI). For more information, including tutorials for getting started, see the [React.js website](https://reactjs.org/). + +##### JSON Schema + +JSON Schema is a concise method of describing JSON data. We recommend basic familiarity with JSON Schema to build forms with the US Forms System. For more information about JSON Schema, see [Understanding JSON Schema](https://spacetelescope.github.io/understanding-json-schema/) by the Space Telescope Science Institute. + +##### react-jsonschema-form (rjsf) + +rjsf is a React component maintained by Mozilla that's used to build web forms based on JSON Schema. For more information, see the [react-jsonschema-form documentation](https://github.com/mozilla-services/react-jsonschema-form#react-jsonschema-form).