elemental_styleguide 1.0.0.beta1
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 +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +87 -0
- data/Rakefile +34 -0
- data/app/assets/config/elemental_styleguide_manifest.js +2 -0
- data/app/assets/javascripts/elemental_styleguide/application.js +13 -0
- data/app/assets/stylesheets/elemental_styleguide/application.css.erb +182 -0
- data/app/controllers/elemental_styleguide/application_controller.rb +7 -0
- data/app/controllers/elemental_styleguide/examples_controller.rb +12 -0
- data/app/controllers/elemental_styleguide/pages_controller.rb +14 -0
- data/app/helpers/elemental_styleguide/navigation_helper.rb +24 -0
- data/app/views/layouts/elemental_styleguide/application.html.erb +36 -0
- data/config/routes.rb +7 -0
- data/lib/elemental_styleguide.rb +27 -0
- data/lib/elemental_styleguide/engine.rb +11 -0
- data/lib/elemental_styleguide/markdown_handler.rb +17 -0
- data/lib/elemental_styleguide/markdown_renderer.rb +44 -0
- data/lib/elemental_styleguide/railtie.rb +6 -0
- data/lib/elemental_styleguide/version.rb +5 -0
- data/lib/generators/elemental_styleguide/install_generator.rb +13 -0
- data/lib/generators/elemental_styleguide/templates/install/views/layouts/styleguide/example.html.erb +12 -0
- data/lib/generators/elemental_styleguide/templates/install/views/styleguide/01_home.md +5 -0
- data/lib/tasks/elemental_styleguide_tasks.rake +6 -0
- metadata +150 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: b1a2865f90e0e078a84f26cf5a332107457baf8221b7970e28671d0b4b39d67e
|
4
|
+
data.tar.gz: c74b074123b0addcb2f13fe696814ae3e71878ba2801d4ca903bc7d8768f1308
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 158a7d09eca0402be90744b9a876921f005780e89b260b45b6e3db3b0d647e11d6c6be65009e01a626c7e04fcada49bb7b481b6aa230b13c8235c9d931086bef
|
7
|
+
data.tar.gz: ded8cfb89e67a2a0e5fe0cc3a3b99cf1f65d0b033475ffb7c1b0c775e71ed3a589f9fbcc315466b2d1945e2a8bda2ea0c6dd4a987c7baef75316445862a1a55f
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2018 Jens Ljungblad
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
# Elemental Style Guide
|
2
|
+
|
3
|
+
Simple style guide for Rails 5.1+, designed to go well with [elemental_components](https://github.com/jensljungblad/elemental_components). The two together are inspired by the works of [Brad Frost](http://bradfrost.com) and by the [thoughts behind](http://engineering.lonelyplanet.com/2014/05/18/a-maintainable-styleguide.html) Lonely Planet's style guide [Rizzo](http://rizzo.lonelyplanet.com).
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
```ruby
|
10
|
+
gem "elemental_styleguide"
|
11
|
+
```
|
12
|
+
|
13
|
+
And then execute:
|
14
|
+
|
15
|
+
```sh
|
16
|
+
$ bundle
|
17
|
+
```
|
18
|
+
|
19
|
+
Run the install generator:
|
20
|
+
|
21
|
+
```sh
|
22
|
+
$ bin/rails g elemental_styleguide:install
|
23
|
+
```
|
24
|
+
|
25
|
+
This will create the following files and directories:
|
26
|
+
|
27
|
+
```
|
28
|
+
app/
|
29
|
+
views/
|
30
|
+
layouts/
|
31
|
+
styleguide/
|
32
|
+
example.html.erb
|
33
|
+
styleguide/
|
34
|
+
01_home.md
|
35
|
+
```
|
36
|
+
|
37
|
+
The style guide can be mounted in your routes file with:
|
38
|
+
|
39
|
+
```ruby
|
40
|
+
mount ElementalStyleguide::Engine => "/styleguide"
|
41
|
+
```
|
42
|
+
|
43
|
+
You can now access the style guide at `http://localhost:3000/styleguide`.
|
44
|
+
|
45
|
+
## Pages
|
46
|
+
|
47
|
+
You can create style guide pages simply by adding markdown files to the `app/views/styleguide` directory. These can be structured by putting them in subdirectories, and sorted by prefixing the file names with a digit.
|
48
|
+
|
49
|
+
Check out Brad Frost's [Style Guide Guide](https://github.com/bradfrost/style-guide-guide) for style guide inspiration.
|
50
|
+
|
51
|
+
## Examples
|
52
|
+
|
53
|
+
A special markdown syntax, inspired by [Catalog](https://www.catalog.style), can be used to render examples of any `erb` code on the style guide page, in the context of your own application:
|
54
|
+
|
55
|
+
````markdown
|
56
|
+
# Example
|
57
|
+
|
58
|
+
```example
|
59
|
+
<%= "Hello world" %>
|
60
|
+
```
|
61
|
+
````
|
62
|
+
|
63
|
+
It is possible to pass options to the example, in order to control the width and height of the wrapping element:
|
64
|
+
|
65
|
+
|
66
|
+
````markdown
|
67
|
+
```example
|
68
|
+
width: 500
|
69
|
+
height: 200
|
70
|
+
---
|
71
|
+
<%= "Hello world" %>
|
72
|
+
```
|
73
|
+
````
|
74
|
+
|
75
|
+
Examples need your application's CSS and JS in order to function properly. There is an `app/views/layouts/styleguide/example.html.erb` layout file that examples are rendered within. This file can be modified in order to add additional tags to the header, like the `javascript_pack_tag` when using the webpacker gem, or classes and styles to the body tag.
|
76
|
+
|
77
|
+
## Acknowledgements
|
78
|
+
|
79
|
+
This library, together with [elemental_components](https://github.com/jensljungblad/elemental_components), was inspired by the writings of [Brad Frost](http://bradfrost.com) on atomic design and living style guides, and [Rizzo](http://rizzo.lonelyplanet.com), the Lonely Planet style guide. Other inspirations were:
|
80
|
+
|
81
|
+
- [Catalog](https://www.catalog.style) - style guide for React
|
82
|
+
- [Storybook](https://storybook.js.org) - style guide for React
|
83
|
+
- [React Styleguidist](https://react-styleguidist.js.org) - style guide for React
|
84
|
+
- [Cells](https://github.com/trailblazer/cells) - view components for Ruby
|
85
|
+
- [Komponent](https://github.com/komposable/komponent) - view components for Ruby
|
86
|
+
|
87
|
+
For a list of real world style guides, check out http://styleguides.io.
|
data/Rakefile
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
begin
|
4
|
+
require "bundler/setup"
|
5
|
+
rescue LoadError
|
6
|
+
puts "You must `gem install bundler` and `bundle install` to run rake tasks"
|
7
|
+
end
|
8
|
+
|
9
|
+
require "rdoc/task"
|
10
|
+
|
11
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
12
|
+
rdoc.rdoc_dir = "rdoc"
|
13
|
+
rdoc.title = "Elemental Styleguide"
|
14
|
+
rdoc.options << "--line-numbers"
|
15
|
+
rdoc.rdoc_files.include("README.md")
|
16
|
+
rdoc.rdoc_files.include("lib/**/*.rb")
|
17
|
+
end
|
18
|
+
|
19
|
+
APP_RAKEFILE = File.expand_path("test/dummy/Rakefile", __dir__)
|
20
|
+
load "rails/tasks/engine.rake"
|
21
|
+
|
22
|
+
load "rails/tasks/statistics.rake"
|
23
|
+
|
24
|
+
require "bundler/gem_tasks"
|
25
|
+
|
26
|
+
require "rake/testtask"
|
27
|
+
|
28
|
+
Rake::TestTask.new(:test) do |t|
|
29
|
+
t.libs << "test"
|
30
|
+
t.pattern = "test/**/*_test.rb"
|
31
|
+
t.verbose = false
|
32
|
+
end
|
33
|
+
|
34
|
+
task default: :test
|
@@ -0,0 +1,13 @@
|
|
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 .
|
@@ -0,0 +1,182 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or any plugin's vendor/assets/stylesheets directory can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the bottom of the
|
9
|
+
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
10
|
+
* files in this directory. Styles in this file should be added after the last require_* statement.
|
11
|
+
* It is generally better to create a new file per style scope.
|
12
|
+
*
|
13
|
+
*= require_tree .
|
14
|
+
*= require_self
|
15
|
+
*/
|
16
|
+
|
17
|
+
<%= Rouge::Themes::Base16.mode(:light).render(scope: '.highlight') %>
|
18
|
+
|
19
|
+
body {
|
20
|
+
margin: 0;
|
21
|
+
padding: 0;
|
22
|
+
font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";
|
23
|
+
line-height: 1.5;
|
24
|
+
}
|
25
|
+
|
26
|
+
a {
|
27
|
+
color: #5296b2;
|
28
|
+
text-decoration: none;
|
29
|
+
border-bottom: 2px solid #ddebf0;
|
30
|
+
transition: all .2s ease-in-out;
|
31
|
+
}
|
32
|
+
|
33
|
+
a:hover {
|
34
|
+
border-color: #5296b2;
|
35
|
+
}
|
36
|
+
|
37
|
+
p {
|
38
|
+
margin: 0 0 2em;
|
39
|
+
}
|
40
|
+
|
41
|
+
main {
|
42
|
+
width: 100%;
|
43
|
+
max-width: 1024px;
|
44
|
+
margin: 0 auto;
|
45
|
+
padding: 40px 60px 60px;
|
46
|
+
}
|
47
|
+
|
48
|
+
pre {
|
49
|
+
margin: 0 0 2em;
|
50
|
+
padding: 30px;
|
51
|
+
background: #f4f7fb;
|
52
|
+
border: 1px solid #dfe3e6;
|
53
|
+
}
|
54
|
+
|
55
|
+
code {
|
56
|
+
font-family: SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;
|
57
|
+
font-size: 15px;
|
58
|
+
}
|
59
|
+
|
60
|
+
iframe {
|
61
|
+
margin: 0;
|
62
|
+
height: 0;
|
63
|
+
border: none;
|
64
|
+
}
|
65
|
+
|
66
|
+
h1 {
|
67
|
+
margin: 0 0 1em;
|
68
|
+
padding: 0 0 .5em;
|
69
|
+
border-bottom: 2px solid #dfe3e6;
|
70
|
+
color: #333;
|
71
|
+
font-size: 50px;
|
72
|
+
font-weight: 500;
|
73
|
+
}
|
74
|
+
|
75
|
+
h2 {
|
76
|
+
color: #333;
|
77
|
+
font-weight: 600;
|
78
|
+
}
|
79
|
+
|
80
|
+
ul,
|
81
|
+
ol {
|
82
|
+
margin: 0 0 2em;
|
83
|
+
}
|
84
|
+
|
85
|
+
table {
|
86
|
+
margin: 0 0 2em;
|
87
|
+
border-collapse: collapse;
|
88
|
+
}
|
89
|
+
|
90
|
+
th,
|
91
|
+
td {
|
92
|
+
padding: .6em 2em .6em 0;
|
93
|
+
text-align: left;
|
94
|
+
}
|
95
|
+
|
96
|
+
th:last-child,
|
97
|
+
td:last-child {
|
98
|
+
padding-right: 0;
|
99
|
+
}
|
100
|
+
|
101
|
+
th {
|
102
|
+
border-bottom: 2px solid #dfe3e6;
|
103
|
+
}
|
104
|
+
|
105
|
+
td {
|
106
|
+
border-bottom: 1px solid #dfe3e6;
|
107
|
+
}
|
108
|
+
|
109
|
+
hr {
|
110
|
+
margin: 2em 0 0;
|
111
|
+
padding: 2em 0 0;
|
112
|
+
border: 1px solid #dfe3e6;
|
113
|
+
border-width: 1px 0 0;
|
114
|
+
}
|
115
|
+
|
116
|
+
blockquote {
|
117
|
+
padding-left: 25px;
|
118
|
+
border-left: 3px solid #dfe3e6;
|
119
|
+
color: #879097;
|
120
|
+
font-style: italic;
|
121
|
+
}
|
122
|
+
|
123
|
+
nav {
|
124
|
+
padding: 10px 30px 40px;
|
125
|
+
background: #f4f7fb;
|
126
|
+
min-width: 180px;
|
127
|
+
}
|
128
|
+
|
129
|
+
nav a {
|
130
|
+
text-decoration: none;
|
131
|
+
border-bottom: 2px solid transparent;
|
132
|
+
}
|
133
|
+
|
134
|
+
nav a:hover {
|
135
|
+
border-bottom: 2px solid #a9cbd9;
|
136
|
+
}
|
137
|
+
|
138
|
+
nav ul {
|
139
|
+
list-style: none;
|
140
|
+
margin: 0;
|
141
|
+
padding: 0;
|
142
|
+
font-size: 18px;
|
143
|
+
font-weight: 500;
|
144
|
+
}
|
145
|
+
|
146
|
+
nav > ul > li {
|
147
|
+
display: block;
|
148
|
+
margin: .6em 0 0;
|
149
|
+
padding: .6em 0 0;
|
150
|
+
box-shadow: 0 -1px 0 0 #dfe3e6;
|
151
|
+
}
|
152
|
+
|
153
|
+
nav > ul > li:first-child {
|
154
|
+
box-shadow: none;
|
155
|
+
}
|
156
|
+
|
157
|
+
nav ul ul {
|
158
|
+
margin: .6em 0;
|
159
|
+
padding: 0 0;
|
160
|
+
font-size: 15px;
|
161
|
+
font-weight: 400;
|
162
|
+
}
|
163
|
+
|
164
|
+
nav ul ul ul {
|
165
|
+
font-size: 14px;
|
166
|
+
padding-left: 1em;
|
167
|
+
}
|
168
|
+
|
169
|
+
.example {
|
170
|
+
display: grid;
|
171
|
+
padding: 30px;
|
172
|
+
border: 1px solid #dfe3e6;
|
173
|
+
border-width: 1px 1px 0;
|
174
|
+
}
|
175
|
+
|
176
|
+
.grid-container {
|
177
|
+
display: grid;
|
178
|
+
width: 100%;
|
179
|
+
height: 100vh;
|
180
|
+
grid-gap: 0;
|
181
|
+
grid-template-columns: auto 1fr;
|
182
|
+
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ElementalStyleguide
|
4
|
+
class ExamplesController < ApplicationController
|
5
|
+
helper Rails.application.helpers
|
6
|
+
helper Rails.application.routes.url_helpers
|
7
|
+
|
8
|
+
def show
|
9
|
+
render inline: Base64.urlsafe_decode64(params[:example]), layout: "styleguide/example"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ElementalStyleguide
|
4
|
+
class PagesController < ApplicationController
|
5
|
+
helper ElementalStyleguide::NavigationHelper
|
6
|
+
|
7
|
+
def show
|
8
|
+
unless params[:path]
|
9
|
+
params[:path] = ElementalStyleguide.page_names[0][0]
|
10
|
+
end
|
11
|
+
render "styleguide/#{params[:path]}", layout: "elemental_styleguide/application"
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ElementalStyleguide
|
4
|
+
module NavigationHelper
|
5
|
+
# rubocop:disable Metrics/AbcSize, Metrics/MethodLength
|
6
|
+
def navigation(pages = nil, paths = [])
|
7
|
+
content_tag :ul do
|
8
|
+
(pages || ElementalStyleguide.page_names).map do |page|
|
9
|
+
path, label, children = page
|
10
|
+
path = paths.dup << path
|
11
|
+
|
12
|
+
content_tag :li do
|
13
|
+
if children
|
14
|
+
[label, navigation(children, path)].join("").html_safe
|
15
|
+
else
|
16
|
+
link_to label, elemental_styleguide.page_path(path)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end.join("").html_safe
|
20
|
+
end
|
21
|
+
end
|
22
|
+
# rubocop:enable Metrics/AbcSize, Metrics/MethodLength
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Style guide</title>
|
5
|
+
<%= stylesheet_link_tag "elemental_styleguide/application", media: "all" %>
|
6
|
+
<%= javascript_include_tag "elemental_styleguide/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
<div class="grid-container">
|
11
|
+
<nav>
|
12
|
+
<%= navigation %>
|
13
|
+
</nav>
|
14
|
+
<main>
|
15
|
+
<%= yield %>
|
16
|
+
</main>
|
17
|
+
</div>
|
18
|
+
<script>
|
19
|
+
var iframes = document.getElementsByTagName('iframe');
|
20
|
+
|
21
|
+
for (var i = 0; i < iframes.length; i++) {
|
22
|
+
iframes[i].onload = function(e) {
|
23
|
+
var i = e.target;
|
24
|
+
var d = i.contentWindow.document;
|
25
|
+
var b = d.getElementsByTagName('body')[0];
|
26
|
+
|
27
|
+
if (i.height == 'auto') {
|
28
|
+
i.style.height = b.scrollHeight + 'px';
|
29
|
+
} else {
|
30
|
+
i.style.height = i.height + 'px';
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
34
|
+
</script>
|
35
|
+
</body>
|
36
|
+
</html>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "redcarpet"
|
4
|
+
require "rouge"
|
5
|
+
require "rouge/plugins/redcarpet"
|
6
|
+
require "elemental_styleguide/markdown_handler"
|
7
|
+
require "elemental_styleguide/markdown_renderer"
|
8
|
+
require "elemental_styleguide/engine"
|
9
|
+
|
10
|
+
module ElementalStyleguide
|
11
|
+
def self.pages_path
|
12
|
+
Rails.root.join("app", "views", "styleguide")
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.page_names(path = nil)
|
16
|
+
Dir.chdir(path || pages_path) do
|
17
|
+
Dir.glob("*").sort.map do |item|
|
18
|
+
[
|
19
|
+
item.sub(/\..*/, ""),
|
20
|
+
item.sub(/\..*/, "").sub(/[0-9]*_?/, "").titleize
|
21
|
+
].tap do |array|
|
22
|
+
array << page_names(item) if File.directory?(item)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ElementalStyleguide
|
4
|
+
class Engine < ::Rails::Engine
|
5
|
+
isolate_namespace ElementalStyleguide
|
6
|
+
|
7
|
+
initializer "elemental_styleguide.template_hander" do
|
8
|
+
ActionView::Template.register_template_handler :md, ElementalStyleguide::MarkdownHandler
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ElementalStyleguide
|
4
|
+
class MarkdownHandler
|
5
|
+
class << self
|
6
|
+
def call(template, _source)
|
7
|
+
@markdown_renderer ||= Redcarpet::Markdown.new(
|
8
|
+
ElementalStyleguide::MarkdownRenderer,
|
9
|
+
autolink: true,
|
10
|
+
tables: true,
|
11
|
+
fenced_code_blocks: true
|
12
|
+
)
|
13
|
+
"#{@markdown_renderer.render(template.source).inspect}.html_safe"
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ElementalStyleguide
|
4
|
+
class MarkdownRenderer < Redcarpet::Render::HTML
|
5
|
+
include Rouge::Plugins::Redcarpet
|
6
|
+
|
7
|
+
def block_code(code, language)
|
8
|
+
case language
|
9
|
+
when "example"
|
10
|
+
options, code = parse_options(code)
|
11
|
+
example(code, options)
|
12
|
+
else
|
13
|
+
super
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def example(code, options)
|
18
|
+
<<-EXAMPLE
|
19
|
+
<div class="example">
|
20
|
+
<iframe src="/styleguide/example?example=#{Base64.urlsafe_encode64(code)}"
|
21
|
+
width="#{options['width'] || '100%'}"
|
22
|
+
height="#{options['height'] || 'auto'}"></iframe>
|
23
|
+
</div>
|
24
|
+
<div class="example-source">
|
25
|
+
#{block_code(code.strip, 'erb')}
|
26
|
+
</div>
|
27
|
+
EXAMPLE
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
def parse_options(code)
|
33
|
+
pieces = code.split("---")
|
34
|
+
|
35
|
+
if pieces.length > 1
|
36
|
+
options = pieces[0].split("\n").map { |i| i.split(": ") }.to_h
|
37
|
+
[options, pieces[1]]
|
38
|
+
else
|
39
|
+
options = {}
|
40
|
+
[options, pieces[0]]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module ElementalStyleguide
|
4
|
+
class InstallGenerator < Rails::Generators::Base
|
5
|
+
desc "Install style guide"
|
6
|
+
|
7
|
+
source_root File.expand_path("templates", __dir__)
|
8
|
+
|
9
|
+
def create_style_guide
|
10
|
+
directory "install", "app"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,5 @@
|
|
1
|
+
# Style guide
|
2
|
+
|
3
|
+
The homepage of a style guide should provide high-level information around what the design system is, what benefits it provides, who it’s for, and how to get started with it.
|
4
|
+
|
5
|
+
Check out Brad Frost's [Style Guide Guide](https://github.com/bradfrost/style-guide-guide) for style guide inspiration.
|
metadata
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: elemental_styleguide
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0.beta1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Jens Ljungblad
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-02-01 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 5.1.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 5.1.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: redcarpet
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 3.5.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 3.5.0
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rouge
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 3.13.0
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 3.13.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: appraisal
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rubocop
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 0.74.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.74.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: sqlite3
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 1.4.0
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - "~>"
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: 1.4.0
|
97
|
+
description: Simple style guide for Rails 5.1+
|
98
|
+
email:
|
99
|
+
- jens.ljungblad@gmail.com
|
100
|
+
executables: []
|
101
|
+
extensions: []
|
102
|
+
extra_rdoc_files: []
|
103
|
+
files:
|
104
|
+
- MIT-LICENSE
|
105
|
+
- README.md
|
106
|
+
- Rakefile
|
107
|
+
- app/assets/config/elemental_styleguide_manifest.js
|
108
|
+
- app/assets/javascripts/elemental_styleguide/application.js
|
109
|
+
- app/assets/stylesheets/elemental_styleguide/application.css.erb
|
110
|
+
- app/controllers/elemental_styleguide/application_controller.rb
|
111
|
+
- app/controllers/elemental_styleguide/examples_controller.rb
|
112
|
+
- app/controllers/elemental_styleguide/pages_controller.rb
|
113
|
+
- app/helpers/elemental_styleguide/navigation_helper.rb
|
114
|
+
- app/views/layouts/elemental_styleguide/application.html.erb
|
115
|
+
- config/routes.rb
|
116
|
+
- lib/elemental_styleguide.rb
|
117
|
+
- lib/elemental_styleguide/engine.rb
|
118
|
+
- lib/elemental_styleguide/markdown_handler.rb
|
119
|
+
- lib/elemental_styleguide/markdown_renderer.rb
|
120
|
+
- lib/elemental_styleguide/railtie.rb
|
121
|
+
- lib/elemental_styleguide/version.rb
|
122
|
+
- lib/generators/elemental_styleguide/install_generator.rb
|
123
|
+
- lib/generators/elemental_styleguide/templates/install/views/layouts/styleguide/example.html.erb
|
124
|
+
- lib/generators/elemental_styleguide/templates/install/views/styleguide/01_home.md
|
125
|
+
- lib/tasks/elemental_styleguide_tasks.rake
|
126
|
+
homepage: https://www.github.com/jensljungblad/elemental_styleguide
|
127
|
+
licenses:
|
128
|
+
- MIT
|
129
|
+
metadata: {}
|
130
|
+
post_install_message:
|
131
|
+
rdoc_options: []
|
132
|
+
require_paths:
|
133
|
+
- lib
|
134
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - ">"
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: 1.3.1
|
144
|
+
requirements: []
|
145
|
+
rubyforge_project:
|
146
|
+
rubygems_version: 2.7.6
|
147
|
+
signing_key:
|
148
|
+
specification_version: 4
|
149
|
+
summary: Simple style guide for Rails 5.1+
|
150
|
+
test_files: []
|