tjmonsi / spa-lite

Single Page Architecture using lite components
MIT License
0 stars 4 forks source link

Coding Conventions #1

Open Rokuto opened 6 years ago

Rokuto commented 6 years ago

Create the coding conventions of spa-lite. Things that will be set are:

Rokuto commented 6 years ago

General Coding Conventions from projects:

Naming Conventions:

Creating a Page:

  1. Create a new folder at src/pages following the naming convention on creating a page.
  2. Inside the newly created folder: a. Create a new file named template.js this will be used for writing html. b. Create a new file named style.styl this will be used for writing stylus css c. Create a new file named index.js this will be used for writing the functions used in the page.
  3. Update the fragments at spa-lite.config.js. In the code:
    const fragments = {
      'page-home': 'src/pages/page-home/index.js',
      'page-not-found': 'src/pages/page-not-found/index.js'
    }

    add another property with a key that is the same as the name of the page and has a value of the location of the index.js of the page. Example: 'page-about': 'src/pages/page-about/index.js'

  4. Update the routes at spa-lite.config.js. In the code:
    const routes = [
      {
        route: '/',
        page: 'page-home'
      },
      {
        route: 'no-page',
        page: 'page-not-found'
      }
    ];

    add another object:

    {
      route: '/about', // the route of the page
      page: 'page-about' // the page location
    }

Creating a Component

  1. Create a new folder at src/components for dumb components or at src/smart-components for smart components. Note: Do following the naming convention on creating a component.
  2. Inside the newly created folder: a. Create a new file named template.js this will be used for writing html. b. Create a new file named style.styl this will be used for writing stylus css c. Create a new file named index.js this will be used for writing the functions used in the component.
  3. Import the component in the index.js then use the tag of your component in template.js.
Rokuto commented 6 years ago

Questions:

Rokuto commented 6 years ago

Flex or Grid

Use grid for any two-dimentional layout and flex for one-dimentional layout. To understand the reasons you may read: Should I use Grid or Flexbox and The ultimate CSS battle: Grid vs Flexbox. To understand Grid and Flex you may read: A Complete Guide to Grid, CSS Grid Layout, A Complete Guide to Flexbox, and Flex.

Rokuto commented 6 years ago

Spacers

Use FLEX justify-content: space-between instead of a div class="spacer".

Form Inputs

  1. Encapsulate <input>s in a <form>.
  2. Do <form on-submit=${}>.
  3. Remove on-submit form the <button>.

Any Repeating video

Do not use gif but use an mp4 video that loops.