style-guide 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. data/.gitignore +1 -0
  2. data/.travis.yml +1 -1
  3. data/Gemfile.lock +6 -4
  4. data/README.md +1 -1
  5. data/app/assets/javascripts/style_guide/docs.js +7 -152
  6. data/app/assets/javascripts/style_guide/sidebar.js +18 -0
  7. data/app/assets/stylesheets/docs.css +153 -0
  8. data/app/assets/stylesheets/responsive.css +164 -0
  9. data/app/assets/stylesheets/style_guide/ars-maquette-web.css +35 -0
  10. data/app/assets/stylesheets/style_guide/example.css +20 -0
  11. data/app/assets/stylesheets/style_guide/footer.css +23 -0
  12. data/app/assets/stylesheets/style_guide/header.css +31 -0
  13. data/app/assets/stylesheets/style_guide/layout.css +69 -0
  14. data/app/assets/stylesheets/style_guide/navbar.css +141 -0
  15. data/app/assets/stylesheets/style_guide/sidebar.css +48 -0
  16. data/app/controllers/style_guide/style_controller.rb +8 -0
  17. data/app/views/layouts/style_guide/application.html.erb +14 -25
  18. data/app/views/style_guide/partials/_button_disabled_state.erb +2 -0
  19. data/app/views/style_guide/partials/_button_element.erb +2 -0
  20. data/app/views/style_guide/partials/_button_sizes.erb +16 -0
  21. data/app/views/style_guide/partials/_buttons.erb +51 -167
  22. data/app/views/style_guide/partials/_code_blocks.erb +12 -0
  23. data/app/views/style_guide/partials/_code_inline.erb +1 -0
  24. data/app/views/style_guide/style/_header.erb +3 -0
  25. data/app/views/style_guide/style/_sidebar.erb +2 -2
  26. data/app/views/style_guide/style/show.html.erb +18 -0
  27. data/config/routes.rb +1 -1
  28. data/lib/style_guide/section.rb +2 -2
  29. data/lib/style_guide/version.rb +1 -1
  30. data/spec/controllers/style_guide/style_controller_spec.rb +27 -0
  31. data/spec/dummy/app/assets/stylesheets/application.css +38 -2
  32. data/spec/dummy/app/assets/stylesheets/swatches.css +16 -0
  33. data/spec/dummy/app/views/styles/_00swatches.erb +8 -0
  34. data/spec/spec_helper.rb +4 -6
  35. data/style-guide.gemspec +1 -0
  36. metadata +39 -5
  37. data/app/assets/stylesheets/style_guide/docs.css +0 -1015
  38. data/app/views/style_guide/partials/_code.erb +0 -31
  39. data/app/views/style_guide/style/index.html.erb +0 -23
@@ -0,0 +1,2 @@
1
+ <a href="#" class="btn btn-large btn-primary disabled">Primary link</a>
2
+ <a href="#" class="btn btn-large disabled">Link</a>
@@ -0,0 +1,2 @@
1
+ <button type="button" class="btn btn-large btn-primary disabled" disabled="disabled">Primary button</button>
2
+ <button type="button" class="btn btn-large" disabled>Button</button>
@@ -0,0 +1,16 @@
1
+ <p>
2
+ <button type="button" class="btn btn-large btn-primary">Large button</button>
3
+ <button type="button" class="btn btn-large">Large button</button>
4
+ </p>
5
+ <p>
6
+ <button type="button" class="btn btn-primary">Default button</button>
7
+ <button type="button" class="btn">Default button</button>
8
+ </p>
9
+ <p>
10
+ <button type="button" class="btn btn-small btn-primary">Small button</button>
11
+ <button type="button" class="btn btn-small">Small button</button>
12
+ </p>
13
+ <p>
14
+ <button type="button" class="btn btn-mini btn-primary">Mini button</button>
15
+ <button type="button" class="btn btn-mini">Mini button</button>
16
+ </p>
@@ -1,167 +1,51 @@
1
-
2
-
3
-
4
- <!-- Buttons
5
- ================================================== -->
6
- <section id="buttons">
7
- <div class="page-header">
8
- <h1>Buttons</h1>
9
- </div>
10
-
11
- <h2>Default buttons</h2>
12
- <p>Button styles can be applied to anything with the <code>.btn</code> class applied. However, typically you'll want to apply these to only <code>&lt;a&gt;</code> and <code>&lt;button&gt;</code> elements for the best rendering.</p>
13
- <table class="table table-bordered table-striped">
14
- <thead>
15
- <tr>
16
- <th>Button</th>
17
- <th>class=""</th>
18
- <th>Description</th>
19
- </tr>
20
- </thead>
21
- <tbody>
22
- <tr>
23
- <td><button type="button" class="btn">Default</button></td>
24
- <td><code>btn</code></td>
25
- <td>Standard gray button with gradient</td>
26
- </tr>
27
- <tr>
28
- <td><button type="button" class="btn btn-primary">Primary</button></td>
29
- <td><code>btn btn-primary</code></td>
30
- <td>Provides extra visual weight and identifies the primary action in a set of buttons</td>
31
- </tr>
32
- <tr>
33
- <td><button type="button" class="btn btn-info">Info</button></td>
34
- <td><code>btn btn-info</code></td>
35
- <td>Used as an alternative to the default styles</td>
36
- </tr>
37
- <tr>
38
- <td><button type="button" class="btn btn-success">Success</button></td>
39
- <td><code>btn btn-success</code></td>
40
- <td>Indicates a successful or positive action</td>
41
- </tr>
42
- <tr>
43
- <td><button type="button" class="btn btn-warning">Warning</button></td>
44
- <td><code>btn btn-warning</code></td>
45
- <td>Indicates caution should be taken with this action</td>
46
- </tr>
47
- <tr>
48
- <td><button type="button" class="btn btn-danger">Danger</button></td>
49
- <td><code>btn btn-danger</code></td>
50
- <td>Indicates a dangerous or potentially negative action</td>
51
- </tr>
52
- <tr>
53
- <td><button type="button" class="btn btn-inverse">Inverse</button></td>
54
- <td><code>btn btn-inverse</code></td>
55
- <td>Alternate dark gray button, not tied to a semantic action or use</td>
56
- </tr>
57
- <tr>
58
- <td><button type="button" class="btn btn-link">Link</button></td>
59
- <td><code>btn btn-link</code></td>
60
- <td>Deemphasize a button by making it look like a link while maintaining button behavior</td>
61
- </tr>
62
- </tbody>
63
- </table>
64
-
65
- <h4>Cross browser compatibility</h4>
66
- <p>IE9 doesn't crop background gradients on rounded corners, so we remove it. Related, IE9 jankifies disabled <code>button</code> elements, rendering text gray with a nasty text-shadow that we cannot fix.</p>
67
-
68
-
69
- <h2>Button sizes</h2>
70
- <p>Fancy larger or smaller buttons? Add <code>.btn-large</code>, <code>.btn-small</code>, or <code>.btn-mini</code> for additional sizes.</p>
71
- <div class="bs-docs-example">
72
- <p>
73
- <button type="button" class="btn btn-large btn-primary">Large button</button>
74
- <button type="button" class="btn btn-large">Large button</button>
75
- </p>
76
- <p>
77
- <button type="button" class="btn btn-primary">Default button</button>
78
- <button type="button" class="btn">Default button</button>
79
- </p>
80
- <p>
81
- <button type="button" class="btn btn-small btn-primary">Small button</button>
82
- <button type="button" class="btn btn-small">Small button</button>
83
- </p>
84
- <p>
85
- <button type="button" class="btn btn-mini btn-primary">Mini button</button>
86
- <button type="button" class="btn btn-mini">Mini button</button>
87
- </p>
88
- </div>
89
- <pre class="prettyprint linenums">
90
- &lt;p&gt;
91
- &lt;button class="btn btn-large btn-primary" type="button"&gt;Large button&lt;/button&gt;
92
- &lt;button class="btn btn-large" type="button"&gt;Large button&lt;/button&gt;
93
- &lt;/p&gt;
94
- &lt;p&gt;
95
- &lt;button class="btn btn-primary" type="button"&gt;Default button&lt;/button&gt;
96
- &lt;button class="btn" type="button"&gt;Default button&lt;/button&gt;
97
- &lt;/p&gt;
98
- &lt;p&gt;
99
- &lt;button class="btn btn-small btn-primary" type="button"&gt;Small button&lt;/button&gt;
100
- &lt;button class="btn btn-small" type="button"&gt;Small button&lt;/button&gt;
101
- &lt;/p&gt;
102
- &lt;p&gt;
103
- &lt;button class="btn btn-mini btn-primary" type="button"&gt;Mini button&lt;/button&gt;
104
- &lt;button class="btn btn-mini" type="button"&gt;Mini button&lt;/button&gt;
105
- &lt;/p&gt;
106
- </pre>
107
- <p>Create block level buttons&mdash;those that span the full width of a parent&mdash; by adding <code>.btn-block</code>.</p>
108
- <div class="bs-docs-example">
109
- <div class="well" style="max-width: 400px; margin: 0 auto 10px;">
110
- <button type="button" class="btn btn-large btn-block btn-primary">Block level button</button>
111
- <button type="button" class="btn btn-large btn-block">Block level button</button>
112
- </div>
113
- </div>
114
- <pre class="prettyprint linenums">
115
- &lt;button class="btn btn-large btn-block btn-primary" type="button"&gt;Block level button&lt;/button&gt;
116
- &lt;button class="btn btn-large btn-block" type="button"&gt;Block level button&lt;/button&gt;
117
- </pre>
118
-
119
-
120
- <h2>Disabled state</h2>
121
- <p>Make buttons look unclickable by fading them back 50%.</p>
122
-
123
- <h3>Anchor element</h3>
124
- <p>Add the <code>.disabled</code> class to <code>&lt;a&gt;</code> buttons.</p>
125
- <p class="bs-docs-example">
126
- <a href="#" class="btn btn-large btn-primary disabled">Primary link</a>
127
- <a href="#" class="btn btn-large disabled">Link</a>
128
- </p>
129
- <pre class="prettyprint linenums">
130
- &lt;a href="#" class="btn btn-large btn-primary disabled"&gt;Primary link&lt;/a&gt;
131
- &lt;a href="#" class="btn btn-large disabled"&gt;Link&lt;/a&gt;
132
- </pre>
133
- <p>
134
- <span class="label label-info">Heads up!</span>
135
- We use <code>.disabled</code> as a utility class here, similar to the common <code>.active</code> class, so no prefix is required. Also, this class is only for aesthetic; you must use custom JavaScript to disable links here.
136
- </p>
137
-
138
- <h3>Button element</h3>
139
- <p>Add the <code>disabled</code> attribute to <code>&lt;button&gt;</code> buttons.</p>
140
- <p class="bs-docs-example">
141
- <button type="button" class="btn btn-large btn-primary disabled" disabled="disabled">Primary button</button>
142
- <button type="button" class="btn btn-large" disabled>Button</button>
143
- </p>
144
- <pre class="prettyprint linenums">
145
- &lt;button type="button" class="btn btn-large btn-primary disabled" disabled="disabled"&gt;Primary button&lt;/button&gt;
146
- &lt;button type="button" class="btn btn-large" disabled&gt;Button&lt;/button&gt;
147
- </pre>
148
-
149
-
150
- <h2>One class, multiple tags</h2>
151
- <p>Use the <code>.btn</code> class on an <code>&lt;a&gt;</code>, <code>&lt;button&gt;</code>, or <code>&lt;input&gt;</code> element.</p>
152
- <form class="bs-docs-example">
153
- <a class="btn" href="">Link</a>
154
- <button class="btn" type="submit">Button</button>
155
- <input class="btn" type="button" value="Input">
156
- <input class="btn" type="submit" value="Submit">
157
- </form>
158
- <pre class="prettyprint linenums">
159
- &lt;a class="btn" href=""&gt;Link&lt;/a&gt;
160
- &lt;button class="btn" type="submit"&gt;Button&lt;/button&gt;
161
- &lt;input class="btn" type="button" value="Input"&gt;
162
- &lt;input class="btn" type="submit" value="Submit"&gt;
163
- </pre>
164
- <p>As a best practice, try to match the element for your context to ensure matching cross-browser rendering. If you have an <code>input</code>, use an <code>&lt;input type="submit"&gt;</code> for your button.</p>
165
-
166
- </section>
167
-
1
+ <table class="table table-bordered table-striped">
2
+ <thead>
3
+ <tr>
4
+ <th>Button</th>
5
+ <th>class=""</th>
6
+ <th>Description</th>
7
+ </tr>
8
+ </thead>
9
+ <tbody>
10
+ <tr>
11
+ <td><button type="button" class="btn">Default</button></td>
12
+ <td><code>btn</code></td>
13
+ <td>Standard gray button with gradient</td>
14
+ </tr>
15
+ <tr>
16
+ <td><button type="button" class="btn btn-primary">Primary</button></td>
17
+ <td><code>btn btn-primary</code></td>
18
+ <td>Provides extra visual weight and identifies the primary action in a set of buttons</td>
19
+ </tr>
20
+ <tr>
21
+ <td><button type="button" class="btn btn-info">Info</button></td>
22
+ <td><code>btn btn-info</code></td>
23
+ <td>Used as an alternative to the default styles</td>
24
+ </tr>
25
+ <tr>
26
+ <td><button type="button" class="btn btn-success">Success</button></td>
27
+ <td><code>btn btn-success</code></td>
28
+ <td>Indicates a successful or positive action</td>
29
+ </tr>
30
+ <tr>
31
+ <td><button type="button" class="btn btn-warning">Warning</button></td>
32
+ <td><code>btn btn-warning</code></td>
33
+ <td>Indicates caution should be taken with this action</td>
34
+ </tr>
35
+ <tr>
36
+ <td><button type="button" class="btn btn-danger">Danger</button></td>
37
+ <td><code>btn btn-danger</code></td>
38
+ <td>Indicates a dangerous or potentially negative action</td>
39
+ </tr>
40
+ <tr>
41
+ <td><button type="button" class="btn btn-inverse">Inverse</button></td>
42
+ <td><code>btn btn-inverse</code></td>
43
+ <td>Alternate dark gray button, not tied to a semantic action or use</td>
44
+ </tr>
45
+ <tr>
46
+ <td><button type="button" class="btn btn-link">Link</button></td>
47
+ <td><code>btn btn-link</code></td>
48
+ <td>Deemphasize a button by making it look like a link while maintaining button behavior</td>
49
+ </tr>
50
+ </tbody>
51
+ </table>
@@ -0,0 +1,12 @@
1
+ <p>
2
+ Use <code>&lt;pre&gt;</code> for multiple lines of code. Be sure to escape any angle brackets in the code for proper rendering.
3
+ </p>
4
+
5
+ <pre>
6
+ def find(*file_names)
7
+ pathname.ascend do |path|
8
+ file_name = file_names.detect { |fn| path.join(fn).file? }
9
+ break path.join(file_name) if file_name
10
+ end
11
+ end
12
+ </pre>
@@ -0,0 +1 @@
1
+ Wrap inline snippets of code with <code>&lt;code&gt;</code>.
@@ -0,0 +1,3 @@
1
+ <div class="style-guide-header">
2
+ <h1><%= @active.title %></h1>
3
+ </div>
@@ -1,5 +1,5 @@
1
- <ul class="nav nav-list bs-docs-sidenav">
1
+ <ul>
2
2
  <% @active.partials.each do |partial| %>
3
- <li><a href="#<%= partial.id %>"><i class="icon-chevron-right"></i> <%= partial.title %></a></li>
3
+ <li><a href="#<%= partial.id %>"><i>&rsaquo;</i> <%= partial.title %></a></li>
4
4
  <% end %>
5
5
  </ul>
@@ -0,0 +1,18 @@
1
+ <%= render :partial => "header" %>
2
+
3
+ <div class="style-guide-content">
4
+ <div class="style-guide-sidebar">
5
+ <%= render :partial => "sidebar" %>
6
+ </div>
7
+
8
+ <div class="style-guide-sections">
9
+ <% @active.partials.each do |partial| %>
10
+ <section id="<%= partial.id %>">
11
+ <h1><%= partial.title %></h1>
12
+ <div class="style-guide-partial">
13
+ <%= render :file => partial.path %>
14
+ </div>
15
+ </section>
16
+ <% end %>
17
+ </div>
18
+ </div>
data/config/routes.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  StyleGuide::Engine.routes.draw do
2
2
  root :to => "style#index"
3
- resource :style, :path => '', :only => [:index]
3
+ match "/style/:id" => "style#show", :as => :style
4
4
  end
@@ -9,7 +9,7 @@ module StyleGuide
9
9
  end
10
10
 
11
11
  def id
12
- @id ||= path.gsub(/[^a-zA-Z0-9]/, " ").strip.gsub(/\s+/, "_")
12
+ @id ||= path.to_s.downcase.gsub(/[^a-zA-Z0-9]/, " ").strip.gsub(/\s+/, "_")
13
13
  end
14
14
 
15
15
  def title
@@ -17,7 +17,7 @@ module StyleGuide
17
17
  end
18
18
 
19
19
  def partials
20
- partial_paths.map { |path| StyleGuide::Partial.new(path) }
20
+ partial_paths.map { |path| StyleGuide::Partial.new(path) }.sort_by { |p| p.title }
21
21
  end
22
22
 
23
23
  private
@@ -1,3 +1,3 @@
1
1
  module StyleGuide
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -1,16 +1,43 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe StyleGuide::StyleController do
4
+ let(:temp_path) { Dir.mktmpdir }
5
+ let(:partial_path) { File.join(temp_path, "monkey_hammer") }
6
+
7
+ before do
8
+ FileUtils.mkdir_p(partial_path)
9
+ StyleGuide::Engine.config.style_guide.stub(:partial_paths => [partial_path])
10
+ end
11
+
4
12
  describe "#index" do
5
13
  it "assigns sections" do
6
14
  get :index, use_route: :styles
7
15
  assigns(:sections).should be
16
+ assigns(:sections).should have(1).section
8
17
  assigns(:sections).first.should be_a StyleGuide::Section
9
18
  end
10
19
 
11
20
  it "sets the active section to the first one" do
12
21
  get :index, use_route: :styles
13
22
  assigns(:active).should == assigns(:sections).first
23
+ assigns(:active).title.should == "Monkey Hammer"
24
+ end
25
+ end
26
+
27
+ describe "#show" do
28
+ let(:fake_section) { StyleGuide::Section.new(partial_path) }
29
+
30
+ it "assigns sections" do
31
+ get :show, id: fake_section.id, use_route: :styles
32
+ assigns(:sections).should be
33
+ assigns(:sections).should have(1).section
34
+ assigns(:sections).first.should be_a StyleGuide::Section
35
+ end
36
+
37
+ it "assigns the section" do
38
+ get :show, id: fake_section.id, use_route: :styles
39
+ assigns(:active).should be_a StyleGuide::Section
40
+ assigns(:active).title.should == "Monkey Hammer"
14
41
  end
15
42
  end
16
43
  end
@@ -9,6 +9,42 @@
9
9
  * compiled file, but it's generally better to create a new file per style scope.
10
10
  *
11
11
  *= require_self
12
- *= require bootstrap
13
- *= require bootstrap-responsive
12
+ *= require_tree .
14
13
  */
14
+
15
+
16
+ html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video {
17
+ margin: 0;
18
+ padding: 0;
19
+ border: 0;
20
+ font-size: 100%;
21
+ font: inherit;
22
+ vertical-align: baseline;
23
+ }
24
+
25
+ article, aside, details, figcaption, figure, footer, header, hgroup, menu, nav, section {
26
+ display: block;
27
+ }
28
+
29
+ body {
30
+ line-height: 1;
31
+ }
32
+
33
+ ol, ul {
34
+ list-style: none;
35
+ }
36
+
37
+ blockquote, q {
38
+ quotes: none;
39
+ }
40
+
41
+ blockquote:before, blockquote:after, q:before, q:after {
42
+ content: '';
43
+ content: none;
44
+ }
45
+
46
+ table {
47
+ border-collapse: collapse;
48
+ border-spacing: 0;
49
+ }
50
+
@@ -0,0 +1,16 @@
1
+ .swatch {
2
+ display: inline-block;
3
+ height: 50px;
4
+ width: 50px;
5
+ margin:10px;
6
+ }
7
+
8
+ .freshBlue { background-color: #6D99D3; }
9
+ .freshRed { background-color: #B90020; }
10
+ .freshGold { background-color: #C59E16; }
11
+ .freshBlack { background-color: #5D5C5C; }
12
+ .freshDarkGray { background-color: #5D5C5C; }
13
+ .freshGray { background-color: #888; }
14
+ .freshLightGray { background-color: #ddd; }
15
+ .freshLighterGray { background-color: #f5f5f5; }
16
+
@@ -0,0 +1,8 @@
1
+ <div class="swatch freshBlue "></div>
2
+ <div class="swatch freshRed "></div>
3
+ <div class="swatch freshGold "></div>
4
+ <div class="swatch freshBlack "></div>
5
+ <div class="swatch freshDarkGray "></div>
6
+ <div class="swatch freshGray "></div>
7
+ <div class="swatch freshLightGray "></div>
8
+ <div class="swatch freshLighterGray "></div>