Skip to content

Commit 8625c3b

Browse files
author
Jason Enter
committed
Initial application structure of app.
0 parents  commit 8625c3b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+13052
-0
lines changed

.babelrc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"presets": [
3+
"env",
4+
"react"
5+
]
6+
}

.bowerrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"directory" : "public/libs"
3+
}

.editorconfig

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
indent_size = 2
7+
end_of_line = lf
8+
charset = utf-8
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.md]
13+
trim_trailing_whitespace = false

.env.example

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
API_BASE_URL='http://x'
2+
OAUTH_CLIENT_ID='x'
3+
OAUTH_CLIENT_SECRET='x'
4+
OAUTH_USER='x'
5+
OAUTH_PASSWORD='x'

.eslintrc.json

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{
2+
"root": true,
3+
"extends": [
4+
"eslint:recommended",
5+
"plugin:react/recommended"
6+
],
7+
"parserOptions": {
8+
"ecmaVersion": 6,
9+
"sourceType": "module",
10+
"ecmaFeatures": {
11+
"jsx": true
12+
}
13+
},
14+
"plugins": [
15+
"react"
16+
],
17+
"env": {
18+
"browser": true,
19+
"node": true,
20+
"mocha": true
21+
},
22+
"rules": {
23+
"no-console": 1,
24+
"no-undef": 1,
25+
"react/jsx-uses-react": 1,
26+
"react/jsx-uses-vars": 1,
27+
"react/prop-types": 1,
28+
"react/jsx-no-target-blank": 1,
29+
"react/no-unescaped-entities": 1
30+
},
31+
"globals": {
32+
"Promise": true
33+
}
34+
}

.gitignore

+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
8+
# Runtime data
9+
pids
10+
*.pid
11+
*.seed
12+
*.pid.lock
13+
14+
# Directory for instrumented libs generated by jscoverage/JSCover
15+
lib-cov
16+
17+
# Coverage directory used by tools like istanbul
18+
coverage
19+
20+
# nyc test coverage
21+
.nyc_output
22+
23+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
24+
.grunt
25+
26+
# Bower dependency directory (https://bower.io/)
27+
bower_components
28+
29+
# node-waf configuration
30+
.lock-wscript
31+
32+
# Compiled binary addons (http://nodejs.org/api/addons.html)
33+
build/Release
34+
35+
# Dependency directories
36+
node_modules/
37+
jspm_packages/
38+
39+
# Typescript v1 declaration files
40+
typings/
41+
42+
# Optional npm cache directory
43+
.npm
44+
45+
# Optional eslint cache
46+
.eslintcache
47+
48+
# Optional REPL history
49+
.node_repl_history
50+
51+
# Output of 'npm pack'
52+
*.tgz
53+
54+
# Yarn Integrity file
55+
.yarn-integrity
56+
57+
# dotenv environment variables file
58+
.env
59+
60+
dist/*

.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
save-exact=true

.travis.yml

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
language: node_js
2+
node_js:
3+
- "6"

README.md

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
2+
## React Starter Application for Acquia PS
3+
4+
### About
5+
6+
This is a starter application built as a baseline for creating React applications which rely heavily on API data from external sources. This application was forked from the [React Slingshot](https://github.com/coryhouse/react-slingshot) application and the full documentation has been moved in `docs\React-Slingshot.md`. This application has included a considerable amount of features to be leveraged as best practices around workflow, structure, testing, and much more. The examples are intentionally basic to provide clarity around the intents of the components.
7+
8+
### Installation
9+
10+
- Install <a href="https://yarnpkg.com/lang/en/docs/install/">yarn</a> or also use `npm` for dependencies.
11+
- Install packages with `yarn install` or `npm install`
12+
- Stand up the application with `yarn start` or `npm start` and visit `http://localhost:8080`
13+
14+
15+
### Configuration Summary
16+
17+
Here is a quick summary of elements included within this application stack, but make sure to review the documentation for proper explanation and context.
18+
19+
[React](https://facebook.github.io/react/) // [Redux](http://redux.js.org) // [React Router](https://github.com/reactjs/react-router) // [Babel](http://babeljs.io) // [Webpack](https://webpack.js.org) // [Browsersync](https://www.browsersync.io/) // [Jest](https://facebook.github.io/jest/) // [TrackJS](https://trackjs.com/) // [ESLint](http://eslint.org/) // [SASS](http://sass-lang.com/) // [PostCSS](https://github.com/postcss/postcss) // [Editor Config](http://editorconfig.org) // [NPM Build Scripts](https://docs.npmjs.com/misc/scripts)
20+
21+
22+
### Architecture Summary
23+
24+
**`package.json`** - includes all the proper packages references, along with the references for each of the build and testing npm scripts. Both local and production builds are separated by running either `yarn start` or `yarn build`. These build scripts are also used in tandem with the webpack config files in the root named as `webpack.config.*.js`.
25+
26+
**Components** - the sample application is a collection of components located in `src/components/*.js`. The reasoning for this organization is to demonstrate React functionality around `state`, `props`, `redux` and how these relate on both the component and application level.
27+
28+
**Routing** - this application uses the React Router module to set the paths. We have broken out the application in a separate route (/app) from the homepage, to illustrate how this is accomplished. You can find the code in `src/components/App.js`.
29+
30+
**Redux** - most of the components will illustrate simple and real-world examples of managing state with Redux. This is being used in the API, GraphQL, and key:pair form values being stored with the standard workflow (/actions /containers /reducers) with `connect(mapStateToProps, MapDispatchToProps)`. Make sure to use the [Redux DevTools Chrome extension](https://chrome.google.com/webstore/detail/redux-devtools/lmhkpmbekcpmknklioeibfkpmmfibljd?hl=en) to properly track the component states.
31+
32+
**Styles** - this application imports the Foundation framework for the baseline styles. SASS is compiled using the PostCSS module, which allows for JS-level imports (ie. `import '../styles/graphql.scss';`). The styles are broken out by component in `src/styles/*.scss`.
33+
34+
### Components
35+
36+
**Sample Application** - `src/components/SampleApp.js` this component acts as the core files in which the other components will nest. Within this file you will see the various modular pieces included for render, ie. `<TimeTracker />`
37+
38+
**Time Tracker** - `src/components/timeTracker.js` this component was built to illustrate some common workflow functions within the `React.Component` class. The functions `componentDidMount()` and `componentWillUnmount()` are included to update and clear the time interval as an easy example.
39+
40+
**Search** - `src/components/SearchApp.js` this component was constructed to illustrate the binding of input fields as controlled components, in addition to matching and updated `props` and `state`. This component serves as the simpler example of property tracking before diving into Redux examples.
41+
42+
**Increment Redux** - `src/components/IncrementApp.js` this component utilizes a basic example of the Redux workflow with the tracking an integer. This component has namespace files (increment*) for each of the workflow matching in `\actions`, `\reducers` to store and retrieve the state of the store. This component is targeted as the simplest Redux example to build upon.
43+
44+
**User Redux** - `src/components/UserAppForm.js` `src/components/UserApp.js` this component builds upon the prior examples by combining controlled fields, storing state with redux, and displaying on the `render()` level. This component is intentionally broken out in 2 files to illustrate child components and how to designate the passing of those values. As with the other components, the associated redux files are located and namespace in `\actions` and `\reducers`.
45+
46+
**StarWars API pt. 1** - `src/components/StarWarsApp.js` this component utilizes an external Star Wars API to illustrate the use of `promises` and `fetch` within a state-aware redux workflow. The associated redux files are located and namespace in `\actions` and `\reducers`, but also includes a `src/api/starwarsAPI.js` file which is called from the `loadStarWars()` load function.
47+
48+
**StarWars API pt. 2** - `src/components/StarWarsExternalApp.js` the purpose of this component is to illustrate the accessing of stored state data from a sibling component (pt 1). It uses the data pulled from the redux functions which are then passed to `super(props, store)`, and manipulates in an alternative way as a pure render component.
49+
50+
**GraphQL Client** - `src/components/GraphqlClientApp.js` this (optional) component uses an external GraphQL server to pull data for display within the application. The component pulls various sample data which is filtered by button / input choices to illustrate query calls to the server. As with the prior components, it uses a combination of redux (same namespace locations) along with promises and typical API methods.
51+
52+
### Setting up the GraphQL server
53+
54+
The final component requires a GraphQL server to pull data from, so we have included a sample application in [this repository](https://github.com/acquia-pso/javascript-ps-starter-graphql). If you used the [PS JavaScript Generator](https://www.npmjs.com/package/generator-js-acquia-ps) to build this application and chose 'yes' for GraphQL server, then this application will already be available root folder under the directory `/__graphql_server`.
55+
56+
57+
<br />
58+
59+
------------------------------------
60+
61+
**Visual References**
62+
63+
<img src="https://content.screencast.com/users/BedimStudios/folders/Jing/media/77b2b73e-9b64-4cef-b1c4-571080b40176/00002805.png" />
64+
65+
<img src="https://content.screencast.com/users/BedimStudios/folders/Jing/media/dd01df46-01b9-46df-b32a-8068ae1a6b61/00002807.png" />
66+
67+
<img src="https://content.screencast.com/users/BedimStudios/folders/Jing/media/a8b5d7d2-35ad-44af-977f-bdc556fd0c17/00002806.png" />
68+
69+
<img src="https://content.screencast.com/users/BedimStudios/folders/Jing/media/230b782c-a6ef-4533-afa3-16801d1f3723/00002808.png" />
70+
71+
72+
73+
74+
75+
76+

__graphql_server/.babelrc

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"presets": ["env"],
3+
"plugins": [
4+
"babel-plugin-inline-import"
5+
]
6+
}

__graphql_server/.gitignore

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
2+
# Created by https://www.gitignore.io/api/node
3+
4+
### Node ###
5+
# Logs
6+
logs
7+
*.log
8+
npm-debug.log*
9+
yarn-debug.log*
10+
yarn-error.log*
11+
12+
# Runtime data
13+
pids
14+
*.pid
15+
*.seed
16+
*.pid.lock
17+
18+
# Directory for instrumented libs generated by jscoverage/JSCover
19+
lib-cov
20+
21+
# Coverage directory used by tools like istanbul
22+
coverage
23+
24+
# nyc test coverage
25+
.nyc_output
26+
27+
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
28+
.grunt
29+
30+
# Bower dependency directory (https://bower.io/)
31+
bower_components
32+
33+
# node-waf configuration
34+
.lock-wscript
35+
36+
# Compiled binary addons (http://nodejs.org/api/addons.html)
37+
build/Release
38+
39+
# Dependency directories
40+
node_modules/
41+
jspm_packages/
42+
43+
# Typescript v1 declaration files
44+
typings/
45+
46+
# Optional npm cache directory
47+
.npm
48+
49+
# Optional eslint cache
50+
.eslintcache
51+
52+
# Optional REPL history
53+
.node_repl_history
54+
55+
# Output of 'npm pack'
56+
*.tgz
57+
58+
# Yarn Integrity file
59+
.yarn-integrity
60+
61+
# dotenv environment variables file
62+
.env
63+
64+
65+
# End of https://www.gitignore.io/api/node

__graphql_server/README.md

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
## GraphQL Demo Server
2+
3+
#### About
4+
5+
This is a GraphQL server application to be used with a [sibling React application](https://github.com/acquia-pso/javascript-ps-starter-react) for demo and training purposes. This application has a simple schema for the display of a handful of Marvel Villain characters. After installation, you can view the GraphQL API UI for testing at <a href="http://localhost:8082/graphiql">http://localhost:8082/graphiql</a>. The endpoint path to target from an external application is `http://localhost:8082/graphql`.
6+
7+
- Express
8+
- GraphQL
9+
- GraphQL Tools
10+
- Apollo Server Express
11+
- Babel transpiling
12+
13+
14+
#### Installation
15+
16+
- Install <a href="https://yarnpkg.com/lang/en/docs/install/">yarn</a> or also use `npm` for dependencies.
17+
- Install packages with `yarn install` or `npm install`
18+
- Run the server with `yarn start` or `npm start` and visit `http://localhost:8082`
19+
20+
21+
#### Usage
22+
23+
The GraphQL API UI will provide a method to test queries, which you can then replicate in our secondary application. Here are some quick schema constructs which have been added by default.
24+
25+
```
26+
# Show all Villains with the following properties
27+
{
28+
allVillains {
29+
id
30+
name
31+
age
32+
weight
33+
image
34+
description
35+
powers
36+
first_appearance
37+
}
38+
}
39+
40+
```
41+
```
42+
# Filter villains by ID
43+
{
44+
villain(id: 4) {
45+
id
46+
name
47+
}
48+
}
49+
```
50+
51+
```
52+
# Show count of Villains
53+
{
54+
totalVillains
55+
}
56+
```
57+
58+
---------------------------
59+
<br />
60+
<img src="https://content.screencast.com/users/BedimStudios/folders/Jing/media/b33ab56b-bbdd-46eb-aada-2bc3c2702361/00002809.png" />
61+
62+
63+
64+
65+
66+

0 commit comments

Comments
 (0)