diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cbbfef8 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +!.keep +*.DS_Store +*.sass-cache diff --git a/.scss-lint.yml b/.scss-lint.yml new file mode 100644 index 0000000..01d364e --- /dev/null +++ b/.scss-lint.yml @@ -0,0 +1,22 @@ +exclude: + - '_assets/stylesheets/vendor/**' + +linters: + StringQuotes: + enabled: true + style: double_quotes + + UrlFormat: + enabled: false + + SelectorDepth: + enabled: true + max_depth: 4 + + PropertySortOrder: + enabled: true + order: recess + + NestingDepth: + enabled: true + max_depth: 4 diff --git a/Gemfile b/Gemfile new file mode 100644 index 0000000..27f6042 --- /dev/null +++ b/Gemfile @@ -0,0 +1,5 @@ +source "https://rubygems.org" + +gem "autoprefixer-rails", "~> 5.1.7.1" +gem "sass", "~> 3.4.13" +gem "scss-lint", "~> 0.34.0" diff --git a/Gemfile.lock b/Gemfile.lock new file mode 100644 index 0000000..e8c0e44 --- /dev/null +++ b/Gemfile.lock @@ -0,0 +1,21 @@ +GEM + remote: https://rubygems.org/ + specs: + autoprefixer-rails (5.1.7.1) + execjs + json + execjs (2.4.0) + json (1.8.2) + rainbow (2.0.0) + sass (3.4.13) + scss-lint (0.34.0) + rainbow (~> 2.0) + sass (~> 3.4.1) + +PLATFORMS + ruby + +DEPENDENCIES + autoprefixer-rails (~> 5.1.7.1) + sass (~> 3.4.13) + scss-lint (~> 0.34.0) diff --git a/README.md b/README.md new file mode 100644 index 0000000..d399187 --- /dev/null +++ b/README.md @@ -0,0 +1,12 @@ +stacss +====== + +*The non-obtrusive SCSS framework.* + +## Usage + +Copy the contents of `/scss` into your application `scss` folder and you are ready to go! + +## License + +MIT License diff --git a/scss/_base.scss b/scss/_base.scss new file mode 100644 index 0000000..56c3d91 --- /dev/null +++ b/scss/_base.scss @@ -0,0 +1,129 @@ +// ============================================================================= +// Base +// ============================================================================= + +// Typography +// ============================================================================= + +*, +*:before, +*:after { + box-sizing: border-box; +} + +html { font-size: $base-font-size; } + +body { + margin: 0 auto; + font-family: $base-font-family; + -webkit-font-smoothing: antialiased; + font-weight: $base-font-weight; + line-height: $base-line-height; + color: $base-font-color; +} + +p { + margin: 0; + font-weight: $base-font-weight; +} + +b, +strong { + font-weight: $base-font-weight-bold; +} + +h1, +h2, +h3, +h4, +h5, +h6 { + margin: 0; + line-height: 1.25; + text-rendering: optimizeLegibility; +} + +h1 { + font-size: $base-font-size * 2.25; +} + +h2 { + font-size: $base-font-size * 2; +} + +h3 { + font-size: $base-font-size * 1.75; +} + +h4 { + font-size: $base-font-size * 1.5; +} + +h5 { + font-size: $base-font-size * 1.25; +} + +h6 { + font-size: $base-font-size; +} + +a { + color: $base-accent-color; + text-decoration: none; + transition: color $base-transition-speed linear; + + &:hover, + &:active { + color: $base-accent-highlighted-color; + } + + &:focus { + color: $base-accent-highlighted-color; + outline: none; + } +} + +hr { + margin: 0; + border-top: 0; + border-right: 0; + border-bottom: 1px solid $base-border-color; + border-left: 0; +} + +img { + display: block; + max-width: 100%; + margin: 0; +} + +abbr, +acronym { + cursor: help; + border-bottom: 1px dotted $base-border-color; +} + +blockquote { + padding-left: $base-line-height / 2; + margin: $base-line-height 0; + color: lighten($base-font-color, 15); + border-left: 2px solid $base-border-color; +} + +cite { + font-style: italic; + color: $base-accent-color; +} + +// Selections +// ============================================================================= + +::-moz-selection { + color: $white; + background: $brand-primary; +} + +::selection { + color: $white; + background: $brand-primary; +} diff --git a/scss/_mixins.scss b/scss/_mixins.scss new file mode 100644 index 0000000..b766e66 --- /dev/null +++ b/scss/_mixins.scss @@ -0,0 +1,47 @@ +// ============================================================================= +// Mixins +// ============================================================================= + +// Handling breakpoints for media queries +// @param {Number} $val the media query specification. + +@mixin breakpoint($val) { + @if $val == small { + @media all and (max-width: 767px) { + @content; + } + } @else if $val == medium { + @media all and (max-width: 1024px) { + @content; + } + } @else if $val == large { + @media all and (max-width: 1223px) { + @content; + } + } @else { + @warn "The parameter #{$val} is not valid"; + } +} + +// Generate font face +// @param {String} $font-name the font name used inside CSS +// @param {String} $font-filepath-and-name the filepath and name of the font file. +// @param {Boolean} $is-remote True if the file is located externally. + +@mixin font-face($font-name, $font-filepath-and-name, $is-remote: "false") { + @if $is-remote == "true" { + @font-face { + font-family: $font-name; + src: url($font-filepath-and-name+".eot?#iefix") format("embedded-opentype"), + url($font-filepath-and-name+".woff") format("woff"), + url($font-filepath-and-name+".ttf") format("truetype"); + } + } @else { + @font-face { + font-family: $font-name; + src: url(asset_path($font-filepath-and-name+".eot?#iefix")) format("embedded-opentype"), + url(asset_path($font-filepath-and-name+".woff")) format("woff"), + url(asset_path($font-filepath-and-name+".ttf")) format("truetype"); + } + } +} diff --git a/scss/_variables.scss b/scss/_variables.scss new file mode 100644 index 0000000..d15c684 --- /dev/null +++ b/scss/_variables.scss @@ -0,0 +1,68 @@ +// ============================================================================= +// Variables +// ============================================================================= + +// Typography +// ============================================================================= + +$sans-serif: Helvetica, Arial, sans-serif; +$serif: Courier, serif; +$base-font-family: $sans-serif; + +$base-font-weight: 300; +$base-font-weight-bold: 700; + +// Colors +// ============================================================================= + +// Shades of gray + +$black: #101111; +$gray-darkest: #292c30; +$gray-darker: #3f4850; +$gray-dark: #718087; +$gray: #8e9da5; +$gray-light: #8e98a4; +$gray-lighter: #c5ced2; +$gray-lightest: #f1f1f1; +$white: #fff; + +// Colors + +$brand-info: #0477bf; +$brand-success: #44a65c; +$brand-danger: #d94343; +$brand-primary: #b465e1; +$brand-warning: #f2bb16; + +// Font color + +$base-font-color: $gray-dark; +$base-accent-color: $brand-primary; +$base-accent-highlighted-color: darken($base-accent-color, 15); + +// Border color + +$base-border-color: $gray-lighter; + +// Sizes +// ============================================================================= + +// Grid + +$columns: 12; +$max-width: 1140px; +$gutter: 20px; +$one-column: 100% / $columns; +$negative-gutter: 0 - $gutter; + +// Font sizes + +$base-font-size: 16px; +$base-line-height: 1.5; + +// Box sizes + +$base-border-radius: 5px; +$base-box-shadow: 0 2px 0 darken($gray-lighter, 5); +$base-transition-speed: .1s; diff --git a/scss/application.scss b/scss/application.scss new file mode 100644 index 0000000..9e5b98a --- /dev/null +++ b/scss/application.scss @@ -0,0 +1,21 @@ +// Vendors + +@import "vendor/normalize"; + +// Settings + +@import "variables"; +@import "mixins"; +@import "base"; + +// Layouts + +@import "layouts/grid"; + +// Modules + +@import "modules/alerts"; +@import "modules/buttons"; +@import "modules/forms"; +@import "modules/icons"; +@import "modules/tables"; diff --git a/scss/layouts/_grid.scss b/scss/layouts/_grid.scss new file mode 100644 index 0000000..143646f --- /dev/null +++ b/scss/layouts/_grid.scss @@ -0,0 +1,50 @@ +// ============================================================================= +// Grid +// ============================================================================= + +// Settings +// ============================================================================= + +// Creates widths for each column + +@mixin column-generator() { + @for $i from 1 through ($columns - 1) { + &.with-#{$i}col { + width: $one-column * $i; + } + } +} + +// Component +// ============================================================================= + +.grid { + display: block; + padding: 0; + margin: 0 $negative-gutter; + font-size: 0; + text-align: left; +} + +// Descendants +// ============================================================================= + +.grid-cell { + @include column-generator(); + display: inline-block; + width: 100%; + padding: 0 $gutter; + margin: 0; + font-size: $base-font-size; + text-align: left; + vertical-align: top; +} + +// Modifiers +// ============================================================================= + +.grid-centered { + max-width: $max-width; + margin-right: auto; + margin-left: auto; +} diff --git a/scss/modules/_alerts.scss b/scss/modules/_alerts.scss new file mode 100644 index 0000000..dd1fa83 --- /dev/null +++ b/scss/modules/_alerts.scss @@ -0,0 +1,39 @@ +// ============================================================================= +// Alerts +// ============================================================================= + +// Settings +// ============================================================================= + +// Scaffolding buttons with a given color. +// @param {Hex} $color Color for the button background. + +@mixin alert-generator($color) { + border-color: lighten($color, 30); + background: lighten($color, 40); + + a { + color: darken($color, 10); + + &:hover { color: darken($color, 15); } + } +} + +// Component +// ============================================================================= + +.alert { + display: inline-block; + width: 100%; + padding: 20px; + border: 1px solid $base-border-color; + border-radius: $base-border-radius; +} + +// Descendant +// ============================================================================= + +.alert-info { @include alert-generator($brand-info); } +.alert-success { @include alert-generator($brand-success); } +.alert-danger { @include alert-generator($brand-danger); } +.alert-warning { @include alert-generator($brand-warning); } diff --git a/scss/modules/_buttons.scss b/scss/modules/_buttons.scss new file mode 100644 index 0000000..6500889 --- /dev/null +++ b/scss/modules/_buttons.scss @@ -0,0 +1,65 @@ +// ============================================================================= +// Buttons +// ============================================================================= + +// Settings +// ============================================================================= + +// Scaffolding buttons with a given color. +// @param {Hex} $background Color for the button background. +// @param {Hex} $font Color for the button type. + +@mixin button-generator($background, $font) { + background: $background; + color: $font; + + &:hover { + color: $font; + background: darken($background, 3); + } + + &:active { background: darken($background, 10); } + &:focus { outline: none; } +} + +// Component +// ============================================================================= + +.button { + position: relative; + display: inline-block; + padding: 10px 15px; + font-family: $base-font-family; + font-weight: $base-font-weight; + line-height: inherit; + text-align: center; + cursor: pointer; + border: 0; + border-radius: $base-border-radius; + transition: all $base-transition-speed ease-in-out; + appearance: none; + user-select: none; + + &:disabled, + &.is-disabled { + color: $base-font-color; + cursor: not-allowed; + background: transparent; + + &:hover, + &:focus + &:active { + color: $base-font-color; + background: transparent; + } + } +} + +// Descendant +// ============================================================================= + +.button-default { @include button-generator($gray-lightest, $base-font-color); } +.button-success { @include button-generator($brand-success, $white); } +.button-danger { @include button-generator($brand-danger, $white); } +.button-info { @include button-generator($brand-info, $white); } +.button-primary { @include button-generator($brand-primary, $white); } diff --git a/scss/modules/_forms.scss b/scss/modules/_forms.scss new file mode 100644 index 0000000..aa99d6f --- /dev/null +++ b/scss/modules/_forms.scss @@ -0,0 +1,68 @@ +// ============================================================================= +// Forms +// ============================================================================= + +// Component +// ============================================================================= + +form { + position: relative; + clear: both; +} + +fieldset { + padding: 20px; + margin: 0; + background: $gray-lightest; + border: 1px solid $base-border-color; +} + +label, +input, +select, +textarea { + display: inline-block; + font-family: inherit; + line-height: $base-line-height; +} + +label { + margin-bottom: 5px; + font-weight: $base-font-weight-bold; + color: $base-font-color; +} + +input, +textarea { + width: 100%; + padding: 10px 15px; + font-family: $base-font-family; + color: $base-font-color; + background-color: $white; + border: 1px solid $base-border-color; + border-radius: $base-border-radius; + transition: border-color $base-transition-speed linear; + appearance: none; + + &:hover { border-color: darken($base-border-color, 10); } + + &:focus, + &:active { + border-color: $base-accent-color; + outline: none; + } +} + +input[type="checkbox"], +input[type="radio"] { + cursor: pointer; +} + +// Descendant +// ============================================================================= + +.form-item { + position: relative; + display: block; + margin-bottom: 10px; +} diff --git a/scss/modules/_icons.scss b/scss/modules/_icons.scss new file mode 100644 index 0000000..c519c3d --- /dev/null +++ b/scss/modules/_icons.scss @@ -0,0 +1,28 @@ +// ============================================================================= +// Icons +// ============================================================================= + +// Settings +// ============================================================================= + +@charset "UTF-8"; +// @include font-face("icon-name", "icon-name", "false"); + +// Component +// ============================================================================= + +.icon { + display: inline-block; + width: 1.1em; + font-family: fontawesome-webfont; + -moz-osx-font-smoothing: grayscale; + -webkit-font-smoothing: antialiased; + font-style: normal; + font-weight: normal; + text-align: center; +} + +// Descendant +// ============================================================================= + +// Add icons here diff --git a/scss/modules/_tables.scss b/scss/modules/_tables.scss new file mode 100644 index 0000000..6bae628 --- /dev/null +++ b/scss/modules/_tables.scss @@ -0,0 +1,38 @@ +// ============================================================================= +// Tables +// ============================================================================= + +// Component +// ============================================================================= + +table { + width: 100%; + margin: 0; + border-collapse: collapse; + + tr, + td, + th { + vertical-align: middle; + } +} + +th, +td { + padding: 10px; + text-align: left; + border: 1px solid $base-border-color; +} + +th { font-weight: $base-font-weight-bold; } + +// Modifiers +// ============================================================================= + +.table-responsive { + width: 100%; + overflow-x: scroll; + overflow-y: hidden; + -ms-overflow-style: -ms-autohiding-scrollbar; + -webkit-overflow-scrolling: touch; +} diff --git a/scss/vendor/_normalize.scss b/scss/vendor/_normalize.scss new file mode 100644 index 0000000..87e37d2 --- /dev/null +++ b/scss/vendor/_normalize.scss @@ -0,0 +1,427 @@ +/*! normalize.css v3.0.2 | MIT License | github.com/necolas/normalize.css */ + +/** + * 1. Set default font family to sans-serif. + * 2. Prevent iOS text size adjust after orientation change, without disabling + * user zoom. + */ + +html { + font-family: sans-serif; /* 1 */ + -ms-text-size-adjust: 100%; /* 2 */ + -webkit-text-size-adjust: 100%; /* 2 */ +} + +/** + * Remove default margin. + */ + +body { + margin: 0; +} + +/* HTML5 display definitions + ========================================================================== */ + +/** + * Correct `block` display not defined for any HTML5 element in IE 8/9. + * Correct `block` display not defined for `details` or `summary` in IE 10/11 + * and Firefox. + * Correct `block` display not defined for `main` in IE 11. + */ + +article, +aside, +details, +figcaption, +figure, +footer, +header, +hgroup, +main, +menu, +nav, +section, +summary { + display: block; +} + +/** + * 1. Correct `inline-block` display not defined in IE 8/9. + * 2. Normalize vertical alignment of `progress` in Chrome, Firefox, and Opera. + */ + +audio, +canvas, +progress, +video { + display: inline-block; /* 1 */ + vertical-align: baseline; /* 2 */ +} + +/** + * Prevent modern browsers from displaying `audio` without controls. + * Remove excess height in iOS 5 devices. + */ + +audio:not([controls]) { + display: none; + height: 0; +} + +/** + * Address `[hidden]` styling not present in IE 8/9/10. + * Hide the `template` element in IE 8/9/11, Safari, and Firefox < 22. + */ + +[hidden], +template { + display: none; +} + +/* Links + ========================================================================== */ + +/** + * Remove the gray background color from active links in IE 10. + */ + +a { + background-color: transparent; +} + +/** + * Improve readability when focused and also mouse hovered in all browsers. + */ + +a:active, +a:hover { + outline: 0; +} + +/* Text-level semantics + ========================================================================== */ + +/** + * Address styling not present in IE 8/9/10/11, Safari, and Chrome. + */ + +abbr[title] { + border-bottom: 1px dotted; +} + +/** + * Address style set to `bolder` in Firefox 4+, Safari, and Chrome. + */ + +b, +strong { + font-weight: bold; +} + +/** + * Address styling not present in Safari and Chrome. + */ + +dfn { + font-style: italic; +} + +/** + * Address variable `h1` font-size and margin within `section` and `article` + * contexts in Firefox 4+, Safari, and Chrome. + */ + +h1 { + font-size: 2em; + margin: 0.67em 0; +} + +/** + * Address styling not present in IE 8/9. + */ + +mark { + background: #ff0; + color: #000; +} + +/** + * Address inconsistent and variable font size in all browsers. + */ + +small { + font-size: 80%; +} + +/** + * Prevent `sub` and `sup` affecting `line-height` in all browsers. + */ + +sub, +sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; +} + +sup { + top: -0.5em; +} + +sub { + bottom: -0.25em; +} + +/* Embedded content + ========================================================================== */ + +/** + * Remove border when inside `a` element in IE 8/9/10. + */ + +img { + border: 0; +} + +/** + * Correct overflow not hidden in IE 9/10/11. + */ + +svg:not(:root) { + overflow: hidden; +} + +/* Grouping content + ========================================================================== */ + +/** + * Address margin not present in IE 8/9 and Safari. + */ + +figure { + margin: 1em 40px; +} + +/** + * Address differences between Firefox and other browsers. + */ + +hr { + -moz-box-sizing: content-box; + box-sizing: content-box; + height: 0; +} + +/** + * Contain overflow in all browsers. + */ + +pre { + overflow: auto; +} + +/** + * Address odd `em`-unit font size rendering in all browsers. + */ + +code, +kbd, +pre, +samp { + font-family: monospace, monospace; + font-size: 1em; +} + +/* Forms + ========================================================================== */ + +/** + * Known limitation: by default, Chrome and Safari on OS X allow very limited + * styling of `select`, unless a `border` property is set. + */ + +/** + * 1. Correct color not being inherited. + * Known issue: affects color of disabled elements. + * 2. Correct font properties not being inherited. + * 3. Address margins set differently in Firefox 4+, Safari, and Chrome. + */ + +button, +input, +optgroup, +select, +textarea { + color: inherit; /* 1 */ + font: inherit; /* 2 */ + margin: 0; /* 3 */ +} + +/** + * Address `overflow` set to `hidden` in IE 8/9/10/11. + */ + +button { + overflow: visible; +} + +/** + * Address inconsistent `text-transform` inheritance for `button` and `select`. + * All other form control elements do not inherit `text-transform` values. + * Correct `button` style inheritance in Firefox, IE 8/9/10/11, and Opera. + * Correct `select` style inheritance in Firefox. + */ + +button, +select { + text-transform: none; +} + +/** + * 1. Avoid the WebKit bug in Android 4.0.* where (2) destroys native `audio` + * and `video` controls. + * 2. Correct inability to style clickable `input` types in iOS. + * 3. Improve usability and consistency of cursor style between image-type + * `input` and others. + */ + +button, +html input[type="button"], /* 1 */ +input[type="reset"], +input[type="submit"] { + -webkit-appearance: button; /* 2 */ + cursor: pointer; /* 3 */ +} + +/** + * Re-set default cursor for disabled elements. + */ + +button[disabled], +html input[disabled] { + cursor: default; +} + +/** + * Remove inner padding and border in Firefox 4+. + */ + +button::-moz-focus-inner, +input::-moz-focus-inner { + border: 0; + padding: 0; +} + +/** + * Address Firefox 4+ setting `line-height` on `input` using `!important` in + * the UA stylesheet. + */ + +input { + line-height: normal; +} + +/** + * It's recommended that you don't attempt to style these elements. + * Firefox's implementation doesn't respect box-sizing, padding, or width. + * + * 1. Address box sizing set to `content-box` in IE 8/9/10. + * 2. Remove excess padding in IE 8/9/10. + */ + +input[type="checkbox"], +input[type="radio"] { + box-sizing: border-box; /* 1 */ + padding: 0; /* 2 */ +} + +/** + * Fix the cursor style for Chrome's increment/decrement buttons. For certain + * `font-size` values of the `input`, it causes the cursor style of the + * decrement button to change from `default` to `text`. + */ + +input[type="number"]::-webkit-inner-spin-button, +input[type="number"]::-webkit-outer-spin-button { + height: auto; +} + +/** + * 1. Address `appearance` set to `searchfield` in Safari and Chrome. + * 2. Address `box-sizing` set to `border-box` in Safari and Chrome + * (include `-moz` to future-proof). + */ + +input[type="search"] { + -webkit-appearance: textfield; /* 1 */ + -moz-box-sizing: content-box; + -webkit-box-sizing: content-box; /* 2 */ + box-sizing: content-box; +} + +/** + * Remove inner padding and search cancel button in Safari and Chrome on OS X. + * Safari (but not Chrome) clips the cancel button when the search input has + * padding (and `textfield` appearance). + */ + +input[type="search"]::-webkit-search-cancel-button, +input[type="search"]::-webkit-search-decoration { + -webkit-appearance: none; +} + +/** + * Define consistent border, margin, and padding. + */ + +fieldset { + border: 1px solid #c0c0c0; + margin: 0 2px; + padding: 0.35em 0.625em 0.75em; +} + +/** + * 1. Correct `color` not being inherited in IE 8/9/10/11. + * 2. Remove padding so people aren't caught out if they zero out fieldsets. + */ + +legend { + border: 0; /* 1 */ + padding: 0; /* 2 */ +} + +/** + * Remove default vertical scrollbar in IE 8/9/10/11. + */ + +textarea { + overflow: auto; +} + +/** + * Don't inherit the `font-weight` (applied by a rule above). + * NOTE: the default cannot safely be changed in Chrome and Safari on OS X. + */ + +optgroup { + font-weight: bold; +} + +/* Tables + ========================================================================== */ + +/** + * Remove most spacing between table cells. + */ + +table { + border-collapse: collapse; + border-spacing: 0; +} + +td, +th { + padding: 0; +}