├── .about.yml ├── .gitignore ├── .travis.yml ├── CONTRIBUTING.md ├── Gemfile ├── LICENSE.md ├── README.md ├── Rakefile ├── app └── assets │ ├── javascripts │ └── application.js │ └── stylesheets │ └── uswds_rails_overrides │ ├── all.scss │ ├── components │ ├── _accordion.scss │ ├── _alerts.scss │ ├── _footer.scss │ ├── _forms.scss │ ├── _header.scss │ └── _search.scss │ ├── core │ └── _defaults.scss │ └── elements │ ├── _inputs.scss │ └── _typography.scss ├── lib ├── tasks │ └── uswds │ │ └── rails_tasks.rake └── uswds │ ├── rails.rb │ └── rails │ ├── engine.rb │ └── version.rb ├── spec ├── feature │ ├── hello_world_spec.rb │ └── pages_spec.rb ├── spec_helper.rb └── test_app │ ├── Rakefile │ ├── app │ ├── assets │ │ └── stylesheets │ │ │ └── application.scss │ ├── controllers │ │ ├── application_controller.rb │ │ └── pages_controller.rb │ └── views │ │ ├── layouts │ │ └── application.html.erb │ │ └── pages │ │ └── root.html.erb │ ├── config.ru │ └── config │ ├── application.rb │ ├── boot.rb │ ├── environment.rb │ ├── environments │ └── test.rb │ ├── initializers │ ├── assets.rb │ ├── cookies_serializer.rb │ └── session_store.rb │ ├── locales │ └── en.yml │ ├── routes.rb │ └── secrets.yml ├── uswds-rails.gemspec └── vendor └── assets ├── fonts └── uswds │ ├── merriweather-bold-webfont.eot │ ├── merriweather-bold-webfont.ttf │ ├── merriweather-bold-webfont.woff │ ├── merriweather-bold-webfont.woff2 │ ├── merriweather-italic-webfont.eot │ ├── merriweather-italic-webfont.ttf │ ├── merriweather-italic-webfont.woff │ ├── merriweather-italic-webfont.woff2 │ ├── merriweather-light-webfont.eot │ ├── merriweather-light-webfont.ttf │ ├── merriweather-light-webfont.woff │ ├── merriweather-light-webfont.woff2 │ ├── merriweather-regular-webfont.eot │ ├── merriweather-regular-webfont.ttf │ ├── merriweather-regular-webfont.woff │ ├── merriweather-regular-webfont.woff2 │ ├── sourcesanspro-bold-webfont.eot │ ├── sourcesanspro-bold-webfont.ttf │ ├── sourcesanspro-bold-webfont.woff │ ├── sourcesanspro-bold-webfont.woff2 │ ├── sourcesanspro-italic-webfont.eot │ ├── sourcesanspro-italic-webfont.ttf │ ├── sourcesanspro-italic-webfont.woff │ ├── sourcesanspro-italic-webfont.woff2 │ ├── sourcesanspro-light-webfont.eot │ ├── sourcesanspro-light-webfont.ttf │ ├── sourcesanspro-light-webfont.woff │ ├── sourcesanspro-light-webfont.woff2 │ ├── sourcesanspro-regular-webfont.eot │ ├── sourcesanspro-regular-webfont.ttf │ ├── sourcesanspro-regular-webfont.woff │ └── sourcesanspro-regular-webfont.woff2 ├── images ├── alerts │ ├── error.png │ ├── error.svg │ ├── info.png │ ├── info.svg │ ├── success.png │ ├── success.svg │ ├── warning.png │ └── warning.svg ├── angle-arrow-down-hover.png ├── angle-arrow-down-hover.svg ├── angle-arrow-down.png ├── angle-arrow-down.svg ├── arrow-down.png ├── arrow-down.svg ├── arrow-right.png ├── arrow-right.svg ├── correct8.png ├── correct8.svg ├── correct9.png ├── correct9.svg ├── external-link-alt-hover.png ├── external-link-alt-hover.svg ├── external-link-alt.png ├── external-link-alt.svg ├── external-link-hover.png ├── external-link-hover.svg ├── external-link.png ├── external-link.svg ├── favicons │ ├── favicon-114.png │ ├── favicon-144.png │ ├── favicon-16.png │ ├── favicon-192.png │ ├── favicon-40.png │ ├── favicon-57.png │ ├── favicon-72.png │ ├── favicon.ico │ └── favicon.png ├── logo-img.png ├── minus-alt.png ├── minus-alt.svg ├── minus.png ├── minus.svg ├── plus-alt.png ├── plus-alt.svg ├── plus.png ├── plus.svg ├── search-alt.png ├── search-alt.svg ├── search.png ├── search.svg ├── social-icons │ ├── png │ │ ├── facebook25.png │ │ ├── rss25.png │ │ ├── twitter16.png │ │ └── youtube15.png │ └── svg │ │ ├── facebook25.svg │ │ ├── rss25.svg │ │ ├── twitter16.svg │ │ └── youtube15.svg └── us_flag_small.png ├── javascripts ├── components │ ├── accordion.js │ ├── footer.js │ ├── header │ │ ├── mobile.js │ │ └── search.js │ ├── toggle-field-mask.js │ ├── toggle-form-input.js │ └── validator.js ├── initializers │ ├── accordions.js │ ├── footer.js │ ├── forms.js │ ├── header.js │ ├── politespace.js │ ├── polyfills.js │ └── skip-nav.js ├── start.js ├── utils │ ├── add-class.js │ ├── dispatch.js │ ├── remove-class.js │ ├── select.js │ ├── verify-jquery.js │ └── when-dom-ready.js └── vendor │ ├── html5shiv.js │ ├── rem.min.js │ ├── respond.js │ └── selectivizr-min.js └── stylesheets └── uswds ├── all.scss ├── components ├── _accordions.scss ├── _alerts.scss ├── _disclaimer.scss ├── _footer.scss ├── _forms.scss ├── _header.scss ├── _search.scss ├── _sidenav.scss └── _skipnav.scss ├── core ├── _base.scss ├── _defaults.scss ├── _fonts.scss ├── _grid-settings.scss ├── _grid.scss ├── _utilities.scss └── _variables.scss ├── elements ├── _buttons.scss ├── _figure.scss ├── _inputs.scss ├── _labels.scss ├── _list.scss ├── _table.scss └── _typography.scss └── lib ├── _bourbon-deprecated-upcoming.scss ├── _bourbon.scss ├── _neat-helpers.scss ├── _neat.scss ├── _normalize.scss ├── addons ├── _border-color.scss ├── _border-radius.scss ├── _border-style.scss ├── _border-width.scss ├── _buttons.scss ├── _clearfix.scss ├── _ellipsis.scss ├── _font-stacks.scss ├── _hide-text.scss ├── _margin.scss ├── _padding.scss ├── _position.scss ├── _prefixer.scss ├── _retina-image.scss ├── _size.scss ├── _text-inputs.scss ├── _timing-functions.scss ├── _triangle.scss └── _word-wrap.scss ├── css3 ├── _animation.scss ├── _appearance.scss ├── _backface-visibility.scss ├── _background-image.scss ├── _background.scss ├── _border-image.scss ├── _calc.scss ├── _columns.scss ├── _filter.scss ├── _flex-box.scss ├── _font-face.scss ├── _font-feature-settings.scss ├── _hidpi-media-query.scss ├── _hyphens.scss ├── _image-rendering.scss ├── _keyframes.scss ├── _linear-gradient.scss ├── _perspective.scss ├── _placeholder.scss ├── _radial-gradient.scss ├── _selection.scss ├── _text-decoration.scss ├── _transform.scss ├── _transition.scss └── _user-select.scss ├── functions ├── _assign-inputs.scss ├── _contains-falsy.scss ├── _contains.scss ├── _is-length.scss ├── _is-light.scss ├── _is-number.scss ├── _is-size.scss ├── _modular-scale.scss ├── _new-breakpoint.scss ├── _private.scss ├── _px-to-em.scss ├── _px-to-rem.scss ├── _shade.scss ├── _strip-units.scss ├── _tint.scss ├── _transition-property-name.scss └── _unpack.scss ├── grid ├── _box-sizing.scss ├── _direction-context.scss ├── _display-context.scss ├── _fill-parent.scss ├── _media.scss ├── _omega.scss ├── _outer-container.scss ├── _pad.scss ├── _private.scss ├── _row.scss ├── _shift.scss ├── _span-columns.scss ├── _to-deprecate.scss └── _visual-grid.scss ├── helpers ├── _convert-units.scss ├── _directional-values.scss ├── _font-source-declaration.scss ├── _gradient-positions-parser.scss ├── _linear-angle-parser.scss ├── _linear-gradient-parser.scss ├── _linear-positions-parser.scss ├── _linear-side-corner-parser.scss ├── _radial-arg-parser.scss ├── _radial-gradient-parser.scss ├── _radial-positions-parser.scss ├── _render-gradients.scss ├── _shape-size-stripper.scss └── _str-to-num.scss ├── mixins └── _clearfix.scss └── settings ├── _asset-pipeline.scss ├── _disable-warnings.scss ├── _grid.scss ├── _prefixer.scss ├── _px-to-em.scss └── _visual-grid.scss /.gitignore: -------------------------------------------------------------------------------- 1 | .*.swp 2 | *.gem 3 | /coverage/ 4 | /pkg/ 5 | 6 | # for a library or gem, you might want to ignore these files since the code is 7 | # intended to run in multiple environments; otherwise, check them in: 8 | Gemfile.lock 9 | .ruby-version 10 | .ruby-gemset 11 | 12 | # unless supporting rvm < 1.11.0 or doing something fancy, ignore this: 13 | .rvmrc 14 | 15 | # tests generate throw-away files 16 | spec/test_app/log 17 | spec/test_app/tmp 18 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | notifications: 3 | email: false 4 | cache: bundler 5 | sudo: false 6 | rvm: 7 | - 2.2.2 8 | - 2.3.0 9 | - 2.3.1 10 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | ## Welcome! 2 | 3 | We're so glad you're thinking about contributing to an 18F open source project! If you're unsure about anything, just ask -- or submit the issue or pull request anyway. The worst that can happen is you'll be politely asked to change something. We love all friendly contributions. 4 | 5 | We want to ensure a welcoming environment for all of our projects. Our staff follow the [18F Code of Conduct](https://github.com/18F/code-of-conduct/blob/master/code-of-conduct.md) and all contributors should do the same. 6 | 7 | We encourage you to read this project's CONTRIBUTING policy (you are here), its [LICENSE](LICENSE.md), and its [README](README.md). 8 | 9 | If you have any questions or want to read more, check out the [18F Open Source Policy GitHub repository](https://github.com/18f/open-source-policy), or just [shoot us an email](mailto:18f@gsa.gov). 10 | 11 | ## Public domain 12 | 13 | This project is in the public domain within the United States, and 14 | copyright and related rights in the work worldwide are waived through 15 | the [CC0 1.0 Universal public domain dedication](https://creativecommons.org/publicdomain/zero/1.0/). 16 | 17 | All contributions to this project will be released under the CC0 18 | dedication. By submitting a pull request, you are agreeing to comply 19 | with this waiver of copyright interest. 20 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | gemspec 4 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # A few parts of this project are not in the public domain 2 | 3 | Some of the code in `lib/uswds/rails.rb` and `lib/uswds/rails/engine.rb` 4 | is derivative of [bootstrap-sass](https://github.com/twbs/bootstrap-sass) 5 | under the [MIT license](https://github.com/twbs/bootstrap-sass/blob/master/LICENSE). 6 | 7 | # The rest of this project is in the public domain 8 | 9 | As a work of the United States Government, this project is in the 10 | public domain within the United States. 11 | 12 | Additionally, we waive copyright and related rights in the work 13 | worldwide through the CC0 1.0 Universal public domain dedication. 14 | 15 | ## CC0 1.0 Universal Summary 16 | 17 | This is a human-readable summary of the [Legal Code (read the full text)](https://creativecommons.org/publicdomain/zero/1.0/legalcode). 18 | 19 | ### No Copyright 20 | 21 | The person who associated a work with this deed has dedicated the work to 22 | the public domain by waiving all of his or her rights to the work worldwide 23 | under copyright law, including all related and neighboring rights, to the 24 | extent allowed by law. 25 | 26 | You can copy, modify, distribute and perform the work, even for commercial 27 | purposes, all without asking permission. 28 | 29 | ### Other Information 30 | 31 | In no way are the patent or trademark rights of any person affected by CC0, 32 | nor are the rights that other persons may have in the work or in how the 33 | work is used, such as publicity or privacy rights. 34 | 35 | Unless expressly stated otherwise, the person who associated a work with 36 | this deed makes no warranties about the work, and disclaims liability for 37 | all uses of the work, to the fullest extent permitted by applicable law. 38 | When using or citing the work, you should not imply endorsement by the 39 | author or the affirmer. 40 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # uswds-rails 2 | 3 | The `uswds-rails` gem eases the use of the [US Web Design Standards](https://github.com/18F/web-design-standards) 4 | with Ruby on Rails applications. 5 | 6 | ## Usage 7 | 8 | **At the moment, we've confirmed that the fonts and stylesheets in this repo 9 | work in Rails apps. JavaScript is TBD.** 10 | 11 | Until this gem is released, you can load it via GitHub: 12 | 13 | ``` 14 | gem 'uswds-rails', github: '18F/uswds-rails-gem' 15 | ``` 16 | 17 | Then bundle and include the stylesheets in your manifest in this order: 18 | 19 | ``` 20 | # app/assets/stylesheets/application.scss 21 | 22 | @import 'uswds_rails_overrides/core/defaults'; 23 | @import 'uswds/all'; 24 | @import 'uswds_rails_overrides/all'; 25 | ``` 26 | 27 | Now, all of the standard USWDS css is available in your rails app. To learn 28 | more, visit [the docs](https://standards.usa.gov/). 29 | 30 | ## Contributing 31 | 32 | See [CONTRIBUTING](CONTRIBUTING.md) for additional information. 33 | 34 | ## Upgrading gem to use a new version of the US Web Design Standards 35 | 36 | Someday, we hope to automate this. For now, here is how to manually update to a 37 | new version of the design standards. 38 | 39 | 1. Download the latest version of the standards locally 40 | 41 | ```bash 42 | $ npm install --save uswds 43 | ``` 44 | 45 | 1. Remove the existing vendored assets 46 | 47 | ```bash 48 | $ rm vendor/assets/stylsheets/uswds/* 49 | ``` 50 | 51 | 1. Copy the downloaded assets into the correct location in `vendor` 52 | 53 | ```bash 54 | $ mv node_modules/uswds/src/stylesheets/* vendor/assets/stylesheets/uswds/ 55 | ``` 56 | 57 | 1. Repeat for fonts, images, and javascripts. 58 | 59 | ## Public domain 60 | 61 | This project is in the worldwide [public domain](LICENSE.md). As stated in [CONTRIBUTING](CONTRIBUTING.md): 62 | 63 | > This project is in the public domain within the United States, and copyright and related rights in the work worldwide are waived through the [CC0 1.0 Universal public domain dedication](https://creativecommons.org/publicdomain/zero/1.0/). 64 | > 65 | > All contributions to this project will be released under the CC0 dedication. By submitting a pull request, you are agreeing to comply with this waiver of copyright interest. 66 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | begin 2 | require 'bundler/setup' 3 | rescue LoadError 4 | puts 'You must `gem install bundler` and `bundle install` to run rake tasks' 5 | end 6 | 7 | require 'rdoc/task' 8 | 9 | RDoc::Task.new(:rdoc) do |rdoc| 10 | rdoc.rdoc_dir = 'rdoc' 11 | rdoc.title = 'Uswds::Rails' 12 | rdoc.options << '--line-numbers' 13 | rdoc.rdoc_files.include('README.md') 14 | rdoc.rdoc_files.include('lib/**/*.rb') 15 | end 16 | 17 | APP_RAKEFILE = File.expand_path("../spec/test_app/Rakefile", __FILE__) 18 | load 'rails/tasks/engine.rake' 19 | load 'rails/tasks/statistics.rake' 20 | load File.expand_path("../lib/tasks/uswds/rails_tasks.rake", __FILE__) 21 | 22 | require 'bundler/gem_tasks' 23 | require 'rspec/core/rake_task' 24 | 25 | RSpec::Core::RakeTask.new 26 | 27 | task default: :spec 28 | task test: :spec 29 | 30 | -------------------------------------------------------------------------------- /app/assets/javascripts/application.js: -------------------------------------------------------------------------------- 1 | // This is a manifest file that'll be compiled into application.js, which will include all the files 2 | // listed below. 3 | // 4 | // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, 5 | // or any plugin's vendor/assets/javascripts directory can be referenced here using a relative path. 6 | // 7 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the 8 | // compiled file. JavaScript code in this file should be added after the last require_* statement. 9 | // 10 | // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details 11 | // about supported directives. 12 | // 13 | //= require_tree . 14 | -------------------------------------------------------------------------------- /app/assets/stylesheets/uswds_rails_overrides/all.scss: -------------------------------------------------------------------------------- 1 | // Core -------------- // 2 | 3 | @import 'core/defaults'; 4 | 5 | // Elements -------------- // 6 | 7 | @import 'elements/inputs'; 8 | @import 'elements/typography'; 9 | 10 | // Components -------------- // 11 | 12 | @import 'components/accordion'; 13 | @import 'components/alerts'; 14 | @import 'components/footer'; 15 | @import 'components/forms'; 16 | @import 'components/header'; 17 | @import 'components/search'; 18 | -------------------------------------------------------------------------------- /app/assets/stylesheets/uswds_rails_overrides/components/_accordion.scss: -------------------------------------------------------------------------------- 1 | @mixin accordion-button-styles { 2 | background-image: image-url('minus.png'); 3 | background-image: image-url('minus.svg'); 4 | } 5 | 6 | @mixin accordion-button-unopened-styles { 7 | background-image: image-url('plus.png'); 8 | background-image: image-url('plus.svg'); 9 | } 10 | 11 | .usa-accordion, 12 | .usa-accordion-bordered { 13 | > ul { 14 | button { 15 | @include accordion-button-styles; 16 | } 17 | [aria-expanded=false] { 18 | @include accordion-button-unopened-styles; 19 | } 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /app/assets/stylesheets/uswds_rails_overrides/components/_alerts.scss: -------------------------------------------------------------------------------- 1 | .usa-alert-success { 2 | background-image: image-url('alerts/success.png'); 3 | background-image: image-url('alerts/success.svg'); 4 | } 5 | 6 | .usa-alert-warning { 7 | background-image: image-url('alerts/warning.png'); 8 | background-image: image-url('alerts/warning.svg'); 9 | } 10 | 11 | .usa-alert-error { 12 | background-image: image-url('alerts/error.png'); 13 | background-image: image-url('alerts/error.svg'); 14 | } 15 | 16 | .usa-alert-info { 17 | background-image: image-url('alerts/info.png'); 18 | background-image: image-url('alerts/info.svg'); 19 | } 20 | -------------------------------------------------------------------------------- /app/assets/stylesheets/uswds_rails_overrides/components/_footer.scss: -------------------------------------------------------------------------------- 1 | .usa-footer-big { 2 | .usa-footer-primary-link { 3 | background-image: image-url('arrow-down.png'); 4 | background-image: image-url('arrow-down.svg'); 5 | } 6 | 7 | ul { 8 | &.hidden { 9 | .usa-footer-primary-link { 10 | background-image: image-url('arrow-right.png'); 11 | background-image: image-url('arrow-right.svg'); 12 | } 13 | } 14 | } 15 | } 16 | 17 | .usa-link-facebook { 18 | background-image: image-url('social-icons/png/facebook25.png'); 19 | background-image: image-url('social-icons/svg/facebook25.svg'); 20 | } 21 | 22 | .usa-link-twitter { 23 | background-image: image-url('social-icons/png/twitter16.png'); 24 | background-image: image-url('social-icons/svg/twitter16.svg'); 25 | } 26 | 27 | .usa-link-youtube { 28 | background-image: image-url('social-icons/png/youtube15.png'); 29 | background-image: image-url('social-icons/svg/youtube15.svg'); 30 | } 31 | 32 | .usa-link-rss { 33 | background-image: image-url('social-icons/png/rss25.png'); 34 | background-image: image-url('social-icons/svg/rss25.svg'); 35 | } 36 | -------------------------------------------------------------------------------- /app/assets/stylesheets/uswds_rails_overrides/components/_forms.scss: -------------------------------------------------------------------------------- 1 | .usa-checklist-checked { 2 | &::before { 3 | background-image: image-url('correct9.png'); 4 | background-image: image-url('correct9.svg'); 5 | } 6 | } 7 | -------------------------------------------------------------------------------- /app/assets/stylesheets/uswds_rails_overrides/components/_header.scss: -------------------------------------------------------------------------------- 1 | .usa-nav-primary { 2 | button { 3 | &[aria-expanded=false] { 4 | background-image: image-url('plus-alt.png'); 5 | background-image: image-url('plus-alt.svg'); 6 | 7 | @include media($nav-width) { 8 | background-image: image-url('angle-arrow-down.png'); 9 | background-image: image-url('angle-arrow-down.svg'); 10 | } 11 | } 12 | 13 | &[aria-expanded=true] { 14 | background-image: image-url('minus-alt.png'); 15 | background-image: image-url('minus-alt.svg'); 16 | 17 | @include media($nav-width) { 18 | background-image: image-url('angle-arrow-down-hover.png'); 19 | background-image: image-url('angle-arrow-down-hover.svg'); 20 | } 21 | } 22 | } 23 | } 24 | 25 | .usa-nav-secondary-links { 26 | .usa-header-search-button { 27 | @include media($nav-width) { 28 | background-image: image-url('search-alt.png'); 29 | background-image: image-url('search-alt.svg'); 30 | } 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /app/assets/stylesheets/uswds_rails_overrides/components/_search.scss: -------------------------------------------------------------------------------- 1 | @mixin search-icon { 2 | background-image: image-url('search.png'); 3 | background-image: image-url('search.svg'); 4 | } 5 | 6 | .usa-search { 7 | [type="submit"], 8 | .usa-search-submit { 9 | @include search-icon; 10 | } 11 | &.usa-search-small { 12 | @include media($small-screen) { 13 | [type="submit"], 14 | .usa-search-submit { 15 | @include search-icon; 16 | } 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /app/assets/stylesheets/uswds_rails_overrides/core/_defaults.scss: -------------------------------------------------------------------------------- 1 | // Typography 2 | $font-path: 'uswds'; 3 | $asset-pipeine: true; 4 | -------------------------------------------------------------------------------- /app/assets/stylesheets/uswds_rails_overrides/elements/_inputs.scss: -------------------------------------------------------------------------------- 1 | select { 2 | background-image: image-url('arrow-down.png'); 3 | background-image: image-url('arrow-down.svg'); 4 | } 5 | 6 | input[type="checkbox"]:checked + label::before { 7 | background-image: image-url('correct8.png'); 8 | background-image: image-url('correct8.svg'); 9 | } 10 | -------------------------------------------------------------------------------- /app/assets/stylesheets/uswds_rails_overrides/elements/_typography.scss: -------------------------------------------------------------------------------- 1 | @mixin external-link($external-link, $external-link-hover) { 2 | &::after { 3 | background: image-url('#{$external-link}.png') no-repeat 0 0; 4 | background: image-url('#{$external-link}.svg') no-repeat 0 0; 5 | } 6 | 7 | &:hover::after { 8 | background-image: image-url('#{$external-link-hover}.png'); 9 | background-image: image-url('#{$external-link-hover}.svg'); 10 | } 11 | } 12 | 13 | .usa-external_link { 14 | @include external-link(external-link, external-link-hover); 15 | } 16 | 17 | .usa-external_link-alt { 18 | @include external-link(external-link-alt, external-link-alt-hover); 19 | } 20 | -------------------------------------------------------------------------------- /lib/tasks/uswds/rails_tasks.rake: -------------------------------------------------------------------------------- 1 | namespace :uswds do 2 | desc "Build the USWDS distribution" 3 | task :build do 4 | puts "Build is not yet automated" 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /lib/uswds/rails.rb: -------------------------------------------------------------------------------- 1 | require 'uswds/rails/version' 2 | 3 | module Uswds 4 | module Rails 5 | class << self 6 | 7 | def load! 8 | register_rails_engine 9 | configure_sass 10 | end 11 | 12 | # Paths 13 | def gem_path 14 | @gem_path ||= File.expand_path '..', File.dirname(__FILE__) 15 | end 16 | 17 | def stylesheets_path 18 | File.join assets_path, 'stylesheets' 19 | end 20 | 21 | def fonts_path 22 | File.join assets_path, 'fonts' 23 | end 24 | 25 | def javascripts_path 26 | File.join assets_path, 'javascripts' 27 | end 28 | 29 | def assets_path 30 | @assets_path ||= File.join gem_path, 'assets' 31 | end 32 | 33 | private 34 | 35 | def configure_sass 36 | require 'sass' 37 | 38 | ::Sass.load_paths << stylesheets_path 39 | 40 | # bootstrap requires minimum precision of 8, see https://github.com/twbs/bootstrap-sass/issues/409 41 | ::Sass::Script::Number.precision = [8, ::Sass::Script::Number.precision].max 42 | end 43 | 44 | def register_rails_engine 45 | require 'uswds/rails/engine' 46 | end 47 | end 48 | end 49 | end 50 | 51 | Uswds::Rails.load! 52 | -------------------------------------------------------------------------------- /lib/uswds/rails/engine.rb: -------------------------------------------------------------------------------- 1 | module Uswds 2 | module Rails 3 | class Engine < ::Rails::Engine 4 | isolate_namespace Uswds::Rails 5 | 6 | config.generators do |g| 7 | g.test_framework :rspec 8 | end 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /lib/uswds/rails/version.rb: -------------------------------------------------------------------------------- 1 | module Uswds 2 | module Rails 3 | VERSION = '1.0.0' 4 | USWDS_VERSION = '0.11.0' 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /spec/feature/hello_world_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | feature 'Hello World' do 4 | scenario 'can access standard uswds css' do 5 | visit '/assets/uswds/all.css' 6 | 7 | expect(page.status_code).to eq 200 8 | end 9 | 10 | scenario 'can access overrides for uswds css' do 11 | visit '/assets/uswds_rails_overrides/all.css' 12 | 13 | expect(page.status_code).to eq 200 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /spec/feature/pages_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | feature 'Pages' do 4 | scenario 'can load root page' do 5 | visit root_path 6 | 7 | expect(page.status_code).to eq 200 8 | expect(page).to have_content('U.S. Web Design Standards') 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | ENV['RAILS_ENV'] ||= 'test' 2 | 3 | require File.expand_path("../test_app/config/environment.rb", __FILE__) 4 | require 'rspec/rails' 5 | 6 | Rails.backtrace_cleaner.remove_silencers! 7 | 8 | # Load support files 9 | Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f } 10 | 11 | RSpec.configure do |config| 12 | config.mock_with :rspec 13 | config.use_transactional_fixtures = true 14 | config.infer_base_class_for_anonymous_controllers = false 15 | config.order = "random" 16 | end 17 | -------------------------------------------------------------------------------- /spec/test_app/Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require_relative 'config/application' 5 | 6 | Rails.application.load_tasks 7 | -------------------------------------------------------------------------------- /spec/test_app/app/assets/stylesheets/application.scss: -------------------------------------------------------------------------------- 1 | @import 'uswds/all'; 2 | @import 'uswds_rails_overrides/all'; 3 | -------------------------------------------------------------------------------- /spec/test_app/app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | # Prevent CSRF attacks by raising an exception. 3 | # For APIs, you may want to use :null_session instead. 4 | protect_from_forgery with: :exception 5 | end 6 | -------------------------------------------------------------------------------- /spec/test_app/app/controllers/pages_controller.rb: -------------------------------------------------------------------------------- 1 | class PagesController < ApplicationController 2 | def root 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /spec/test_app/app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |An official website of the United States government
6 |8 | This site is currently in alpha. 9 | Learn more. 10 |
11 |