middleman-hashicorp 0.3.15 → 0.3.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: faa6604885b0ec377d901ba569d5e6c77af4d14f
4
- data.tar.gz: abb5f50ffff04dffc4f39f7b94e14336af23c74b
3
+ metadata.gz: 8eb722264071c8c5032ec045033a27fd9d743aae
4
+ data.tar.gz: 2806cf4d941ae2d71370884c8296b0d84a53ef96
5
5
  SHA512:
6
- metadata.gz: 25f52e284323c966063293223a5852b75f5735208b5f6004bca6a3d9e43eb030e533aaf7b156cffd277648b642c6cd85f37059d65210b0f83176dc6d46bf0291
7
- data.tar.gz: 551ed2efa0fef9310eb19d825d7410b58bdeb969ff4d2805919f505189b56f15d7f90c7d335d68717beec406a921c43e534da92c5463106b2d47b39bfa5fed84
6
+ metadata.gz: 1ecd6d6c1cb0176064613fb993d2c1c986b216932b26a640875b952030e42a1955f3bcfe59370f9303e8ce5a9dc4e1d9337267d32feea2c892f0acb486615524
7
+ data.tar.gz: fd9c9bba46e9244fb4316c45d8d75fc5cebe8bbe1c9afde7fea2fee7fb20bb3715d16fa8a88c9fd0adf3b253fc54a8904534d4bd21d000c181d441cc480bfa60
data/README.md CHANGED
@@ -77,6 +77,17 @@ There are bundled things that make IE behave nicely. Include them like this:
77
77
  <![endif]-->
78
78
  ```
79
79
 
80
+ ### Inline SVGs
81
+
82
+ Getting SVGs out of the asset pipeline and into the DOM can be hard, but not
83
+ with the magic `inline_svg` helper!
84
+
85
+ ```erb
86
+ <%= inline_svg "my-asset.svg" %>
87
+ ```
88
+
89
+ It supports configuring the class, height, width, and viewbox.
90
+
80
91
  ### Turbolinks
81
92
 
82
93
  Turbolinks highjack links on the same domain and use AJAX to dynamically update
@@ -88,6 +99,56 @@ To enable turbolinks, include the javascript.
88
99
  //= require turbolinks
89
100
  ```
90
101
 
102
+ ### Mobile Sidebar
103
+
104
+ The mobile sidebar is displayed on mobile and small screens as a hamburger menu.
105
+ It requires some additional markup and css for configuration. First, define the
106
+ following variables in your scss:
107
+
108
+ ```scss
109
+ $sidebar-background-color
110
+ $sidebar-link-color
111
+ $sidebar-font-family
112
+ $sidebar-font-weight
113
+ $sidebar-font-size
114
+ $sidebar-link-color-hover
115
+ ```
116
+
117
+ Then include the scss scaffold:
118
+
119
+ ```scss
120
+ @import 'hashicorp/sidebar';
121
+ ```
122
+
123
+ Next, create some markup like this:
124
+
125
+ ```html
126
+ <div class="sidebar-overlay"></div>
127
+
128
+ <aside class="sidebar" role="navigation">
129
+ <div class="sidebar-header">
130
+ <img src="images/my-image.svg" alt="My Header" height="42">
131
+ </div>
132
+
133
+ <ul class="nav sidebar-nav">
134
+ <li><a href="/">Home</a></li>
135
+ </ul>
136
+
137
+ <!-- Optional -->
138
+ <div class="divider"></div>
139
+
140
+ <ul class="nav sidebar-nav">
141
+ <li><a href="/">Other</li>
142
+ </ul>
143
+ </aside>
144
+ ```
145
+
146
+ Finally include the required javascript:
147
+
148
+ ```js
149
+ //= require hashicorp/sidebar
150
+ ```
151
+
91
152
  ### Mega Nav
92
153
  HashiCorp has a consistent mega-nav used across all project sites. This is insertable into any document using the following:
93
154
 
@@ -2,10 +2,7 @@
2
2
  // HashiCorp Mega Nav
3
3
  // --------------------------------------------------
4
4
 
5
- $(function() {
6
-
7
- //handle active product
8
-
5
+ var HashiMegaNav = function() {
9
6
  var productClass = 'mega-nav-grid-item',
10
7
  productActiveClass = 'is-active',
11
8
  url = window.location.hostname,
@@ -24,9 +21,6 @@ $(function() {
24
21
  }
25
22
  }
26
23
 
27
-
28
- //handle functionality
29
-
30
24
  var dropDownBreakpoint = window.matchMedia("(min-width: 980px)");
31
25
 
32
26
  function megaNavModal() {
@@ -44,7 +38,6 @@ $(function() {
44
38
  $('#mega-nav-close').on('click.megaNav', function() {
45
39
  $('#mega-nav-body-ct').modal('hide');
46
40
  });
47
-
48
41
  }
49
42
 
50
43
  function megaNavModalDestroy() {
@@ -67,7 +60,6 @@ $(function() {
67
60
  }
68
61
 
69
62
  function handleDropDownBreakpoint(breakpoint) {
70
-
71
63
  if (breakpoint.matches) {
72
64
  megaNavModalDestroy();
73
65
  megaNavDropDown();
@@ -75,10 +67,11 @@ $(function() {
75
67
  megaNavDropDownDestroy();
76
68
  megaNavModal();
77
69
  }
78
-
79
70
  }
80
71
 
81
72
  dropDownBreakpoint.addListener(handleDropDownBreakpoint);
82
- handleDropDownBreakpoint(dropDownBreakpoint);
73
+ handleDropDownBreakpoint(dropDownBreakpoint);
74
+ }
83
75
 
84
- });
76
+ // Handle document ready function and the turbolinks load.
77
+ $(document).on("ready turbolinks:load", HashiMegaNav);
@@ -0,0 +1,40 @@
1
+ // HashiSidebar is the sidebar implementation for mobile websites. It
2
+ // appears at a configurable breakpoint in the CSS.
3
+ var HashiSidebar = function() {
4
+ var $sidebar = $('.sidebar');
5
+ var $toggle = $('.navbar-toggle');
6
+ var $overlay = $('.sidebar-overlay');
7
+
8
+ function sidebarActive() {
9
+ return $sidebar.hasClass('open');
10
+ }
11
+
12
+ function hideSidebar() {
13
+ if(sidebarActive()) {
14
+ $sidebar.removeClass('open');
15
+ $overlay.removeClass('active');
16
+ }
17
+ }
18
+
19
+ // Hide the sidebar when the user clicks on the overlay. The overlay is
20
+ // only "clickable" when it's active.
21
+ $overlay.on('click', function(e){
22
+ hideSidebar();
23
+ });
24
+
25
+ // Show the sidebar when the user clicks the hamburger menu.
26
+ $toggle.on('click', function(e) {
27
+ e.preventDefault(); // Don't jump page to "#"
28
+
29
+ // Only activate the sidebar if it's not already active. Since these
30
+ // are class selectors, it's possible that we are watching multiple
31
+ // elements.
32
+ if(!sidebarActive()) {
33
+ $overlay.addClass('active');
34
+ $sidebar.toggleClass('open');
35
+ }
36
+ });
37
+ }
38
+
39
+ // Handle document ready function and the turbolinks load.
40
+ $(document).on("ready turbolinks:load", HashiSidebar);
@@ -0,0 +1,96 @@
1
+ .sidebar-overlay {
2
+ background: $sidebar-background-color;
3
+ opacity: 0;
4
+ position: fixed;
5
+ visibility: hidden;
6
+ z-index: 9999;
7
+
8
+ top: 0;
9
+ left: 0;
10
+ right: 0;
11
+ bottom: 0;
12
+
13
+ &.active {
14
+ opacity: 0.3;
15
+ visibility: visible;
16
+ }
17
+ }
18
+
19
+ .sidebar {
20
+ background-color: $sidebar-background-color;
21
+ border: none;
22
+ box-shadow: 0px 2px 25px rgba(0, 0, 0, 0.15);
23
+ display: block;
24
+ position: relative;
25
+ min-height: 100%;
26
+ overflow-y: auto;
27
+ overflow-x: hidden;
28
+ position: fixed;
29
+ width: 0;
30
+ z-index: 10000;
31
+ top: 0;
32
+ bottom: 0;
33
+ right: 0;
34
+ @include transition(all 0.5s cubic-bezier(0.55, 0, 0.1, 1));
35
+ @include clearfix();
36
+
37
+ &.open {
38
+ width: 280px;
39
+ }
40
+
41
+ .sidebar-divider, .divider {
42
+ width: 80%;
43
+ height: 1px;
44
+ margin: 8px auto;
45
+ background-color: #D7D7D7;
46
+ }
47
+
48
+ .sidebar-header {
49
+ margin: 30px auto;
50
+ text-align: center;
51
+ }
52
+
53
+ .sidebar-nav {
54
+ margin: 0;
55
+ padding: 0;
56
+ text-align: center;
57
+
58
+ li {
59
+ position: relative;
60
+ list-style-type: none;
61
+ text-align: center;
62
+
63
+ a {
64
+ color: $sidebar-link-color;
65
+ position: relative;
66
+ cursor: pointer;
67
+ user-select: none;
68
+ font-family: $sidebar-font-family;
69
+ font-weight: $sidebar-font-weight;
70
+ font-size: $sidebar-font-size;
71
+
72
+ &:hover,
73
+ &:focus,
74
+ &:active {
75
+ background: transparent;
76
+ color: $sidebar-link-color-hover;
77
+ outline: 0;
78
+ text-decoration: none;
79
+
80
+ svg {
81
+ fill: $sidebar-link-color-hover;
82
+ }
83
+ }
84
+
85
+ svg {
86
+ fill: $sidebar-link-color;
87
+ top: 2px;
88
+ width: 14px;
89
+ height: 14px;
90
+ margin-bottom: -2px;
91
+ margin-right: 4px;
92
+ }
93
+ }
94
+ }
95
+ }
96
+ }
@@ -83,6 +83,61 @@ class Middleman::HashiCorpExtension < ::Middleman::Extension
83
83
  end
84
84
 
85
85
  helpers do
86
+ #
87
+ # Generate an inline svg from the given asset name.
88
+ #
89
+ # @option options [String] :class
90
+ # @option options [String] :width
91
+ # @option options [String] :height
92
+ # @option options [String] :view_box
93
+ #
94
+ # @return [String]
95
+ #
96
+ def inline_svg(filename, options = {})
97
+ asset = sprockets.find_asset(filename)
98
+
99
+ # If the file wasn't found, embed error SVG
100
+ if asset.nil?
101
+ %(
102
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 30"
103
+ width="400px" height="30px"
104
+ >
105
+ <text font-size="16" x="8" y="20" fill="#cc0000">
106
+ Error: '#{filename}' could not be found.
107
+ </text>
108
+ <rect
109
+ x="1" y="1" width="398" height="28" fill="none"
110
+ stroke-width="1" stroke="#cc0000"
111
+ />
112
+ </svg>
113
+ )
114
+
115
+ # If the file was found, parse it, add optional classes, and then embed it
116
+ else
117
+ file = asset.source.force_encoding("UTF-8")
118
+ doc = Nokogiri::HTML::DocumentFragment.parse(file)
119
+ svg = doc.at_css("svg")
120
+
121
+ if options[:class].present?
122
+ svg["class"] = options[:class]
123
+ end
124
+
125
+ if options[:width].present?
126
+ svg["width"] = options[:width]
127
+ end
128
+
129
+ if options[:height].present?
130
+ svg["height"] = options[:height]
131
+ end
132
+
133
+ if options[:view_box].present?
134
+ svg["viewBox"] = options[:view_box]
135
+ end
136
+
137
+ doc
138
+ end
139
+ end
140
+
86
141
  #
87
142
  # Output an image that corresponds to the given operating system using the
88
143
  # vendored image icons.
@@ -1,5 +1,5 @@
1
1
  module Middleman
2
2
  module HashiCorp
3
- VERSION = "0.3.15"
3
+ VERSION = "0.3.16"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: middleman-hashicorp
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.15
4
+ version: 0.3.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seth Vargo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-03-15 00:00:00.000000000 Z
11
+ date: 2017-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: middleman
@@ -192,6 +192,7 @@ files:
192
192
  - assets/images/mega-nav/logo-vault.svg
193
193
  - assets/javascripts/bootstrap.js
194
194
  - assets/javascripts/hashicorp/mega-nav.js
195
+ - assets/javascripts/hashicorp/sidebar.js
195
196
  - assets/javascripts/ie-compat.js
196
197
  - assets/javascripts/ie-compat/html5shiv-printshiv.js
197
198
  - assets/javascripts/ie-compat/html5shiv.js
@@ -199,6 +200,7 @@ files:
199
200
  - assets/javascripts/jquery.js
200
201
  - assets/stylesheets/hashicorp/anchor-links.scss
201
202
  - assets/stylesheets/hashicorp/mega-nav.scss
203
+ - assets/stylesheets/hashicorp/sidebar.scss
202
204
  - docker/Dockerfile
203
205
  - docker/entrypoint.sh
204
206
  - lib/middleman-hashicorp.rb
@@ -234,7 +236,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
234
236
  version: '0'
235
237
  requirements: []
236
238
  rubyforge_project:
237
- rubygems_version: 2.5.2
239
+ rubygems_version: 2.6.8
238
240
  signing_key:
239
241
  specification_version: 4
240
242
  summary: A series of helpers for consistency among HashiCorp's middleman sites