Advertisement
Guest User

Untitled

a guest
Nov 21st, 2014
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. General
  2.  
  3. Indent using 2 spaces
  4. All filenames should be lowercased
  5.  
  6. Javascript
  7.  
  8. Naming Convention
  9.  
  10. d-a-s-h-e-s for file names, folder names, ember components
  11. camelCase Javascript, JSON
  12.  
  13. Code convention
  14.  
  15. Varibles declaration with var: always
  16. Declare one variable per var statement, it makes it easier to re-order the lines
  17. Prefer ' over "
  18. Always use semicolons ;
  19. Always use parentheses (also for if statement of one line)
  20. Prefer forEach over for loop
  21. General advices
  22.  
  23. BE CONSISTENT. If you're editing code, take a few minutes to look at the code around you and determine its style. If they use spaces around all their arithmetic operators, you should too. If their comments have little boxes of hash marks around them, make your comments have little boxes of hash marks around them too. The point of having style guidelines is to have a common vocabulary of coding so people can concentrate on what you're saying rather than on how you're saying it. We present global style rules here so people know the vocabulary, but local style is also important. If code you add to a file looks drastically different from the existing code around it, it throws readers out of their rhythm when they go to read it. Avoid this.
  24.  
  25. CSS
  26.  
  27. General
  28.  
  29. app.less is used only for importing other styles
  30. Do not use selectors based on Id
  31. Avoid element selectors, prefer classes
  32. // wrong
  33. <div class="folder">
  34. <span>Folder Name</span>
  35. </div>
  36.  
  37. /* The Folder Module */
  38. .fld > span { ... }
  39.  
  40. // right
  41. <div class="folder">
  42. <span class="folder--name">Folder Name</span>
  43. <span class="folder--items">(32 items)</span>
  44. </div>
  45.  
  46. .fld--items { ... }
  47. .fld--name { ... }
  48.  
  49.  
  50. In less files avoid using deep nesting (more than 3 levels).
  51. Avoid extending classes, use mixins instead. Extending a class leads to ugly output in term of css selectors.
  52. Design Principles
  53.  
  54. Modules are entities that are aware of the context in which they are placed and can be used as standalone components. They are the reusable, modular parts of our design. Buttons, navs, dropdowns, forms, etc are great examples of components. Class name convention for module is .moduleName
  55. Sub Modules are variations of a module in term of graphics, these variations are based on context, for example if we have a .btn class for rapresenting a button with 100px width and we want a button with 200px width we can create a submodule .btn-large that redefines the width property. Class name convention for sub-module is .module-subModule
  56.  
  57. Sub Components are necessarly placed inside a module and rappresent pieces of the module structure e.g
  58. .modal {}
  59. .modal-large {}
  60. .modal--header {}
  61.  
  62. <div class="modal modal-large">
  63. <div class="modal--header">...</div>
  64. <div class="modal--body">...</div>
  65. <div class="modal--footer">...</div>
  66. </div>
  67. Class name convention for sub-components is .module--subComponent
  68.  
  69. States are modifiers that describe how our modules will look when they are in a particular state. Generally speaking the difference between sub-modules and states is that the second one is used when the state depends on some javascript properties e.g:
  70. // Normally we have the 'btn' module
  71. <button class="btn">OK</button>
  72.  
  73. // If some javascript can alter the state of the button and make it disabled
  74. // then we have to add the state btn-is-disabled
  75. <button class="btn btn-is-disabled">OK</button>
  76. Class name convention for states is .module-is-state
  77.  
  78. Try to avoid conditional styling based on location. If you are changing the look of a module for usage elsewhere on the page or site, sub-class the module instead.
  79. For state class (i.e when need to change appearance based on behavior) use something like: .tab-is-active where 'tab' is the name of the module or the name of the component.
  80.  
  81. Common situations
  82.  
  83. <button class="btn">Cancel</button>
  84.  
  85. <div class="modal modal-large">
  86. <div class="modal--header">...</div>
  87. <div class="modal--body">...</div>
  88. <div class="modal--footer">
  89. <button></button>
  90. </div>
  91. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement