Giter VIP home page Giter VIP logo

youtube-clone's Introduction

Coding Standards

Hello, and welcome to this project repository by Virtual Tech School! This project is a community maintained responsive clone of YouTube and this document contains the coding standards that needs to be followed in order to contribute to the project.

HTML & CSS

  1. Always use 4 spaces for indentation!

    Instead of

    <div>
      <p>This is a paragraph!</p>
      <ol>
    	<li>This is a list item</li>
      </ol>
    </div>
    

    Do

    <div>
    	<p>This is a paragraph!</p>
    	<ol>
    		<li>This is a list item</li>
    	</ol>
    </div>
    
  2. Always use "double quotes" for attirbutes and values.

    Instead of

    <div class='div-container'></div>

    Do

    <div class="div-container"></div>

  3. Use lowercase letters for tags, attributes, values, url(s), etc.

    Instead of

    <DIV CLASS="DIV-CONTAINER"></DIV>

    Do

    <div class="div-container"></div>

  4. Remove trailing white spaces (if any).

  5. Don't add spaces before and after equal to (=) sign.

    Instead of

    <div class = "div-container"></div>

    Do

    <div class="div-container"></div>

  6. Add blank lines between different sections of code.

    Example

    <div class="navbar">
    	...
    </div>
    
    <div class="side-bar">
    	...
    </div>
    
    <div class="header">
    	...
    </div>
    
    <div class="body">
    	...
    </div>
    
    <div class="footer">
    	...
    </div>
    
  7. Give a space between attributes.

    Example <input class="full-name" placeholder="Enter your name" />

  8. Don't give more than 1 blank line anywhere in the code.

  9. Import all style sheets and scripts (CDN) in the <head> tag only.

  10. Add comments before sections.

    Example

    <!-- Navbar -->
    <div class="navbar">
    	...
    </div>
    
    <!-- Sidebar -->
    <div class="side-bar">
    	...
    </div>
    
    <!-- Page header -->
    <div class="header">
    	...
    </div>
    
    <!-- Main content -->
    <div class="body">
    	...
    </div>
    
    <!-- Footer -->
    <div class="footer">
    	...
    </div>
    
  11. Any additional JS scripts created should be added at the end of the body.

  12. Always quote attribute values.

    Instead of

    <div class=div-container></div>

    Do

    <div class="div-container"></div>

  13. Specify alt attribute for images.

  14. Use semantic element tags instead of div tags. Reference here.

  15. Omit type attribute for stylesheets and scripts.

  16. Use meaningful class and id names in HTML.

  17. Use hyphens - instead of underscores _ in id(s) and classes.

  18. Avoid using type selectors with class names in CSS and JS unless absolutely necessary.

    Instead of

    div.container {}

    Do

    .container {}

  19. There should never be multiple elements with same id. Each id should only be associated to one element. They are meant to be unique.

  20. Avoid using "!important" declaration as much as possible.

  21. Write CSS properties in alphabetical order.

  22. Use a space after property name's colon :

  23. Use shorthand properties wherever possible in CSS.

    Instead of

    .container {
    	margin-top: 1px;
    	margin-bottom: 1px;
    	margin-left: 1px;
    	margin-right: 1px;
    }
    

    Do

    .container {
    	margin: 1px;
    }
    
  24. Avoid using inline CSS.

  25. HTML attributes should be in the following precedence order -

    • src, for, type, href, value
    • class
    • id, name
    • title, alt
    • data
  26. Additional references can be found here and here.

JavaScript

  1. Use camelCase for variable/function names.

  2. Put 1 space before and after any operator.

  3. Use 4 spaces for indentation.

  4. Use semicolon ; for simple statements.

  5. For compound statements and objects, put curly bracket { after a space at the end of the first line, and closing bracket } in a new line.

    Example

    for (let i = 0; i < 10; i++) {
    	...
    }
    
  6. For objects, put a space after the colons : and don't put a comma , after the last property

    Example

    let newObj = {
    	property1: value1,
    	property2: value2
    };
    
  7. End an object with a semicolon.

  8. Initialise a variable while declaring it (there may be a few edge cases where this won't be applicable).

  9. Avoid using var to declare variables. Use let and const.

Bootstrap

  1. Use row and col classes for any <div> or semantic HTML tags created.
  2. Each and every col should always be inside of a row.
  3. There should always be values for -
    • col-sm-*
    • col-md-*
    • col-lg-*
  4. Define them in the same order and mentioned above for consistency.

jQuery

Refer to the following link for guidelines.

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.