Docs, guidelines and compromising photos
To make changes to these pages, checkout the wego.github.io project and the GitHub Pages docs.
This is a living draft, please feel free to submit pull requests (with use cases/reasons) for improvements to what are stated here.
Some of these guide lines are simple in theory but difficult in practice. Just try because they are not being followed very thoroughly at the moment either. (troll)
is-visible
for accordion) and use CSS to style the
opened and/or closed state instead of directly using JavaScript (something.hide()
).
This allows simpler styling through different media sizes instead of having to
dig into JavaScript to perform many if-else statements based on screenState
.To ease debugging with inspector, use $el.data('something')
instead of $el.attr('data-something')
only IF all of these are true:
data-something
is read-onlydata-something
is JSONUse meaningful class names whenever it makes sense to. It doesn't hurt to be clearer.
noun-{verb,adjective}
style.// Not so good
<del>$50</del>
<ins>$20</ins>
del { color: red; }
// Better
<del class="rate-original">$50</del>
<ins class="rate-discounted">$20</ins>
.rate-original { color: red; }
hide-for-*
) will start haunting you once you re-use a partial in another page.// partial.html.erb
<div class="room-rates">
<span class="rates hide-for-medium-down">$100</span>
</div>
// show_rates_for_large_only.html
<%= render 'partial' %>
// show_rates_for_all_sizes.html, wait what.
<%= render 'partial' %>
// Bad...
<a class="orange-round-button">...</a>
<a class="orange round-button">...</a>
// Because what if we want blue button for static page? :(
<a class="orange but_blue_for_static round button">...</a>
// Now we're talking.
<a class="button internal loading">loading button</a>
.button {
// .. default button styles ...
// orange, round, blah
&.internal {
// style for internal linking button
// maybe diff shade of orange
}
&.external {
// style for external linking
// make it purple maybe?
}
&.loading {
// patterns for when loading...
}
}
x
is true
)// Verbose
.example1 {
@include respond-to(desktop) {
display: none;
}
}
.example2 {
display: none;
@include respond-to(desktop) {
display: block;
}
}
.example3 {
display: none;
@include respond-to(tablet) {
display: block;
}
@include respond-to(desktop) {
display: none;
}
}
// Precise
<div class="example1 hide-for-large">...</div>
<div class="example2 show-for-large">...</div>
<div class="example3 hide-for-small hide-for-large">...</div>
%placeholder
instead of a CSS selector when @extend
ing, see SASS Placeholders Versus Mixins and ExtendsPresentational class names are those that are modifiers and have no meaning on their own:
blue
, small
, fade
book
, reviews
, button
Use "
instead of '
for HTML attributes.
Wrap inline elements (such as icon fonts) in an inline element when using show-for-*
and hide-for-*
because these classes use inherit
and will take block
if the parent is a block. See Foundation discussion.
<span>
<i class="icon-search show-for-small"></i>
</span>
id
, try to give it a class
of the same name if you need one.<div id="help" class="help">halp!</div>
columns
and not column
.div
for styling block-level elements. Use the element section
only if you answer yes to the following:
table
if the content is tabular data. Don't abuse ul
, ol
or dl
.row
when:
columns
.columns
when there is accompanying small-*
, medium-*
, or large-*
in the same element.id
for elements used throughout the app.
<i>
for icon fonts.<span>
or <div>
for styling purposes. Most other elements have meanings.
<b>
, <a>
or <em>
just because they're shorter to type.href="#"
or href="javascript:void(0)"
for fake links (those that don't change the page URLs) because it'll affect SEO.
div
, span
, i
, b
em
or strong
ONLY if they should be emphasized..js-
prefixed class names only for JS stuff. Don't reference it from CSS files..is-
, .has-
prefixed class names for state rules that are shared between CSS and JS.// nope
.test {
display: none;
}
.test {
display: block;
}
// yes
.test {
display: none;
}
span.test {
display: block;
}
.segment_name-page_name
instead of .page_name .segment_name
body
/html
/parent element/etc.)star
-related will be in stars.scss
)// Not so good
.listings .stars {}
// Good
.stars.stars-listings {}
// Not so good
.hotels .card
// Good
.card.card-hotels
.card { &.card-hotel {} &.card-airfare {} }
.stars {} ```
respond-to
, add all @include mixins;
at the top of declaration to avoid unintentional overwriting..breadcrumbs {
@include something;
@include else;
text-align: right;
}
id
s, try to stick to using class
es so we can re-use them (whether or not we do, is another issue).overflow: hidden
to clear floats, use @include clearfix
instead..help {
@include clearfix;
...
}
px
for font-size.
px
directly on the element since px
doesn't inherit from the parent unlike em
.em
for others: margin
, padding
, left
, etc.$variable
.
$money-color: #FAFAFA;
.money { color: $money-color; }
$variables
into _variables.scss
so it can be re-used in different apps.:
in property declarations-
to delimit class
es/id
s:
long-name
long_name
longName
LoNgNaMeHeHe
//
for comment blocks, instead of /* */
.respond-to()
top-down in source order - mobile
, tablet
, desktop
.respond-to(mobile)
is implied when no respond-to
is used, so omit it.@include section(
$section-type: accordion,
$title-color: $primary-color
);
emCalc
without unit..// Good
padding: emCalc(10, 1);
padding: emCalc(10);
// Not so good
padding: emCalc(10px) emCalc(11px);
:
, ,
and before {
..subheader {
@include respond-to(mobile) {
font-size: emCalc(16, 10);
border-bottom: 1px solid;
}
}
$start
or $end
. $start
and $end
is left
and right
respectively in LTR orientation and vice versa in RTL.right
or left
class because RTL.