Code Monkey home page Code Monkey logo

dashboard-bi's Introduction

WebApp boilerplate with React JS

Open in Gitpod

Requirements:

  • Make sure you are using node version 10
  1. Install the packages:
$ npm install
  1. Create a .env file:
$ cp .env.example .env
  1. Start coding!

Start the webpack server with live reload:

`$ npm run start` for windows, mac, linux or Gitpod.

Styles

You can update the styles/index.scss or create new .scss files inside styles/ and import them into your current scss or js files depending on your needs.

Components

Add more files into your ./src/js/components or styles folder as you need them and import them into your current files as needed.

Note (New changes): Components have been converted into functions to support the use of hooks:

  • Instead of a class component, we're using a const function.
  • Class constructor and state have been replaced by useState() hooks.
  • componentDidMount() was replaced by useEffect({}, []) - It runs at mount thanks to the second parameter ([]).
  • Actions and Store still work the same way.
// Previous "Class Oriented"
export class Demo extends React.Component {
	constructor(props) {
		super(props);

		this.state = getState('code here');
	}
}

// New "Functional Oriented"
export const Demo = () => (
	const [state, setState] = getState('code here'); //using the state (if needed)
  const { store, actions } = useContext(Context); // using the context (if needed)

);

💡Note: There is an example using the Context API inside views/demo.js;

Views (Components)

Add more files into your ./src/js/views and import them in ./src/js/layout.jsx.

Context

This boilerplate comes with a centralized general Context API. The file ./src/js/store/flux.js has a base structure for the store, we encourage you to change it and adapt it to your needs.

React Context docs BreathCode Lesson view

The Provider is already set. You can consume from any component using the useContext hook to get the store and actions from the Context. Check /views/demo.js to see a demo.

import { Context } from "../store/appContext";
const MyComponentSuper = () => {
  //here you use useContext to get store and actions
  const { store, actions } = useContext(Context);
  return <div>{/* you can use your actions or store inside the html */}</div>
}

Publish your website!

  1. ZEIT: The FREE recomended hosting provider is http://zeit.co/, you can deploy in 1 minutes by typing the following command:
$ npm i now -g && now

✎ Note: If you get asked for credentials you have to type $ now after login in.

Zeit example procedure to deploy

  1. Github Pages: This boilerplate is 100% compatible with the free github pages hosting. To publish your website you need to push your code to your github repository and run the following command after:
$ npm run deploy

Note: You will need to configure github pages for the branch gh-pages

dashboard-bi's People

Contributors

alesanchezr avatar jferragut avatar hernanjkd avatar ljavierrodriguez avatar plucodev avatar colbywtaylor avatar emily-v avatar timrodz avatar asanchez-2 avatar

Watchers

Víctor Company avatar Flor Rodriguez avatar

dashboard-bi's Issues

Clean Code

Borrad los ficheros que no necesitéis y los styles in line (en uploadProfile)

Forms

En vuestro form debéis incluir el action para saber qué ocurre cuando el usuario clicka el botón de submit.

En este caso el action debería capturar el evento y llevarnos a una función que nos redireccione a la siguiente página.

Pistas:
https://gist.github.com/elitan/5e4cab413dc201e0598ee05287ee4338
https://stackoverflow.com/questions/49738249/react-router-v4-redirecting-on-form-submit
https://stackoverflow.com/questions/52609884/react-router-redirect-after-submitting-a-form-using-the-input-value/52609908

Modulos CSS

Me parece muy buena idea que separéis el CSS, creo que os puede ayudar a verlo más claro.
Pero a la hora de separar el CSS en ficheros la mejor opción es hacer un fichero CSS por cada componente y el resto que vaya en el index.

Nota: Si una vista tiene muchos estilos es probable que podáis sacar algún componente más de ella.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.