docks_theme_api 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (237) hide show
  1. checksums.yaml +15 -0
  2. data/.babelrc +4 -0
  3. data/.editorconfig +8 -0
  4. data/.eslintrc +115 -0
  5. data/.gitignore +24 -0
  6. data/.rubocop.yml +20 -0
  7. data/.travis.yml +16 -0
  8. data/Gemfile +4 -0
  9. data/README.md +5 -0
  10. data/Rakefile +3 -0
  11. data/assets/images/icons.svg +63 -0
  12. data/assets/scripts/coffeescript/pattern_library_helpers.coffee +8 -0
  13. data/assets/scripts/javascript/pattern_library_helpers.js +11 -0
  14. data/assets/scripts/pattern_library.js +10380 -0
  15. data/assets/scripts/pattern_library_demo.js +0 -0
  16. data/assets/styles/less/pattern-library-helpers.less +103 -0
  17. data/assets/styles/pattern-library-demo.css +1882 -0
  18. data/assets/styles/pattern-library.css +1882 -0
  19. data/assets/styles/sass/pattern-library-helpers.sass +90 -0
  20. data/assets/styles/scss/pattern-library-helpers.scss +99 -0
  21. data/assets/styles/stylus/pattern-library-helpers.styl +90 -0
  22. data/assets/templates/erb/demo.erb +26 -0
  23. data/assets/templates/erb/layouts/demo.erb +17 -0
  24. data/assets/templates/erb/layouts/pattern.erb +76 -0
  25. data/assets/templates/erb/partials/sidebar.erb +124 -0
  26. data/assets/templates/erb/partials/symbols/class.erb +1 -0
  27. data/assets/templates/erb/partials/symbols/demo.erb +40 -0
  28. data/assets/templates/erb/partials/symbols/factory.erb +70 -0
  29. data/assets/templates/erb/partials/symbols/function.erb +103 -0
  30. data/assets/templates/erb/partials/symbols/mixin.erb +62 -0
  31. data/assets/templates/erb/partials/symbols/variable.erb +59 -0
  32. data/assets/templates/erb/pattern.erb +102 -0
  33. data/assets/templates/haml/demo.haml +14 -0
  34. data/assets/templates/haml/layouts/demo.haml +6 -0
  35. data/assets/templates/haml/layouts/pattern.haml +38 -0
  36. data/assets/templates/haml/partials/sidebar.haml +68 -0
  37. data/assets/templates/haml/partials/symbols/class.haml +1 -0
  38. data/assets/templates/haml/partials/symbols/demo.haml +23 -0
  39. data/assets/templates/haml/partials/symbols/factory.haml +38 -0
  40. data/assets/templates/haml/partials/symbols/function.haml +54 -0
  41. data/assets/templates/haml/partials/symbols/mixin.haml +31 -0
  42. data/assets/templates/haml/partials/symbols/variable.haml +22 -0
  43. data/assets/templates/haml/pattern.haml +54 -0
  44. data/assets/templates/slim/demo.slim +24 -0
  45. data/assets/templates/slim/layouts/demo.slim +5 -0
  46. data/assets/templates/slim/layouts/pattern.slim +48 -0
  47. data/assets/templates/slim/partials/sidebar.slim +112 -0
  48. data/assets/templates/slim/partials/symbols/class.slim +1 -0
  49. data/assets/templates/slim/partials/symbols/demo.slim +30 -0
  50. data/assets/templates/slim/partials/symbols/factory.slim +57 -0
  51. data/assets/templates/slim/partials/symbols/function.slim +81 -0
  52. data/assets/templates/slim/partials/symbols/mixin.slim +45 -0
  53. data/assets/templates/slim/partials/symbols/variable.slim +35 -0
  54. data/assets/templates/slim/pattern.slim +63 -0
  55. data/docks_config.rb +32 -0
  56. data/docks_theme_api.gemspec +37 -0
  57. data/gulpfile.js +88 -0
  58. data/karma.conf.js +6 -0
  59. data/lib/docks_theme_api/components/base_component.rb +99 -0
  60. data/lib/docks_theme_api/components/code_block_component.rb +10 -0
  61. data/lib/docks_theme_api/components/popover_component.rb +15 -0
  62. data/lib/docks_theme_api/components/table_component.rb +34 -0
  63. data/lib/docks_theme_api/components/tablist_component.rb +11 -0
  64. data/lib/docks_theme_api/components.rb +21 -0
  65. data/lib/docks_theme_api/helpers/ui_helper.rb +69 -0
  66. data/lib/docks_theme_api/theme.rb +21 -0
  67. data/lib/docks_theme_api.rb +1 -0
  68. data/package.json +60 -0
  69. data/source/behaviors/filterable/filterable.coffee +353 -0
  70. data/source/behaviors/filterable/filterable.js +0 -0
  71. data/source/behaviors/filterable/filterable.scss +34 -0
  72. data/source/behaviors/filterable/package.json +3 -0
  73. data/source/behaviors/index.js +0 -0
  74. data/source/components/avatar/avatar.erb +20 -0
  75. data/source/components/avatar/avatar.js +142 -0
  76. data/source/components/avatar/avatar.scss +200 -0
  77. data/source/components/avatar/avatar_container.erb +13 -0
  78. data/source/components/avatar/package.json +3 -0
  79. data/source/components/avatar/spec/avatar_spec.js +81 -0
  80. data/source/components/badge/badge.scss +158 -0
  81. data/source/components/button/button.scss +213 -0
  82. data/source/components/card/card.scss +32 -0
  83. data/source/components/code_block/code-block.scss +353 -0
  84. data/source/components/code_block/code_block.erb +95 -0
  85. data/source/components/code_block/code_block.js +444 -0
  86. data/source/components/code_block/package.json +3 -0
  87. data/source/components/code_block/spec/code_block_spec.js +10 -0
  88. data/source/components/demo/demo.js +244 -0
  89. data/source/components/demo/demo.scss +90 -0
  90. data/source/components/demo/package.json +3 -0
  91. data/source/components/exploded/exploded.erb +25 -0
  92. data/source/components/exploded/exploded.js +694 -0
  93. data/source/components/exploded/exploded.scss +166 -0
  94. data/source/components/exploded/package.json +3 -0
  95. data/source/components/field/field.js +24 -0
  96. data/source/components/field/field.scss +101 -0
  97. data/source/components/field/package.json +3 -0
  98. data/source/components/header/header.scss +33 -0
  99. data/source/components/iframe/iframe.erb +12 -0
  100. data/source/components/iframe/iframe.js +381 -0
  101. data/source/components/iframe/package.json +3 -0
  102. data/source/components/index.js +37 -0
  103. data/source/components/inline_group/inline-group.scss +14 -0
  104. data/source/components/internal_link/internal_link.js +49 -0
  105. data/source/components/internal_link/package.json +3 -0
  106. data/source/components/list/list.scss +230 -0
  107. data/source/components/modal/modal.coffee +84 -0
  108. data/source/components/modal/modal.erb +19 -0
  109. data/source/components/modal/modal.js +0 -0
  110. data/source/components/modal/modal.scss +57 -0
  111. data/source/components/modal/package.json +3 -0
  112. data/source/components/notice/notice.scss +48 -0
  113. data/source/components/popover/package.json +3 -0
  114. data/source/components/popover/popover.coffee +562 -0
  115. data/source/components/popover/popover.erb +21 -0
  116. data/source/components/popover/popover.js +0 -0
  117. data/source/components/popover/popover.scss +139 -0
  118. data/source/components/range/range.scss +78 -0
  119. data/source/components/resizable/package.json +3 -0
  120. data/source/components/resizable/resizable.erb +30 -0
  121. data/source/components/resizable/resizable.js +250 -0
  122. data/source/components/resizable/resizable.scss +245 -0
  123. data/source/components/resizable/size_buttons.js +249 -0
  124. data/source/components/scroll_container/package.json +3 -0
  125. data/source/components/scroll_container/scroll-container.scss +4 -0
  126. data/source/components/scroll_container/scroll_container.js +24 -0
  127. data/source/components/section/section.scss +99 -0
  128. data/source/components/select/package.json +3 -0
  129. data/source/components/select/select.erb +21 -0
  130. data/source/components/select/select.js +35 -0
  131. data/source/components/select/select.scss +163 -0
  132. data/source/components/table/package.json +3 -0
  133. data/source/components/table/table.erb +16 -0
  134. data/source/components/table/table.js +351 -0
  135. data/source/components/table/table.scss +236 -0
  136. data/source/components/tablist/package.json +3 -0
  137. data/source/components/tablist/tablist.erb +13 -0
  138. data/source/components/tablist/tablist.js +246 -0
  139. data/source/components/tablist/tablist.scss +191 -0
  140. data/source/components/tablist/tablist_panel.erb +14 -0
  141. data/source/components/tablist/tablist_tab.erb +20 -0
  142. data/source/components/toggle/package.json +3 -0
  143. data/source/components/toggle/toggle.erb +11 -0
  144. data/source/components/toggle/toggle.js +211 -0
  145. data/source/components/toggle/toggle_container.erb +30 -0
  146. data/source/components/vertical_spacer/vertical-spacer.scss +3 -0
  147. data/source/components/vertical_stack/vertical-stack.scss +19 -0
  148. data/source/components/xray/package.json +3 -0
  149. data/source/components/xray/xray.erb +50 -0
  150. data/source/components/xray/xray.js +123 -0
  151. data/source/components/xray/xray.scss +79 -0
  152. data/source/foundation/app/app.js +15 -0
  153. data/source/foundation/app/package.json +3 -0
  154. data/source/pattern-library-demo.scss +13 -0
  155. data/source/pattern-library.scss +13 -0
  156. data/source/pattern_library.js +8 -0
  157. data/source/pattern_library_demo.js +8 -0
  158. data/source/structures/index.js +11 -0
  159. data/source/structures/sidebar/package.json +3 -0
  160. data/source/structures/sidebar/sidebar.js +69 -0
  161. data/source/structures/sidebar/sidebar.scss +79 -0
  162. data/source/utilities/builder/builder.js +138 -0
  163. data/source/utilities/builder/package.json +3 -0
  164. data/source/utilities/client/client.js +7 -0
  165. data/source/utilities/client/package.json +3 -0
  166. data/source/utilities/colors/colors.scss +112 -0
  167. data/source/utilities/defaults/defaults.scss +38 -0
  168. data/source/utilities/dom_cache/dom_cache.js +24 -0
  169. data/source/utilities/dom_cache/package.json +3 -0
  170. data/source/utilities/events/events.js +25 -0
  171. data/source/utilities/events/package.json +3 -0
  172. data/source/utilities/font_sizes/font-sizes.scss +85 -0
  173. data/source/utilities/foundation/a11y.scss +10 -0
  174. data/source/utilities/foundation/base.scss +29 -0
  175. data/source/utilities/foundation/icon.scss +114 -0
  176. data/source/utilities/foundation/layout.scss +67 -0
  177. data/source/utilities/foundation/page.scss +39 -0
  178. data/source/utilities/foundation/type.scss +208 -0
  179. data/source/utilities/functions/functions.scss +127 -0
  180. data/source/utilities/keycodes/keycodes.js +23 -0
  181. data/source/utilities/keycodes/package.json +3 -0
  182. data/source/utilities/markup/markup.js +90 -0
  183. data/source/utilities/markup/package.json +3 -0
  184. data/source/utilities/media/media.scss +172 -0
  185. data/source/utilities/mixins/mixins.scss +89 -0
  186. data/source/utilities/naming_convention/naming_convention.js +3 -0
  187. data/source/utilities/naming_convention/package.json +3 -0
  188. data/source/utilities/numbers/numbers.js +14 -0
  189. data/source/utilities/numbers/package.json +3 -0
  190. data/source/utilities/painting/package.json +3 -0
  191. data/source/utilities/painting/painting.js +7 -0
  192. data/source/utilities/pattern/package.json +3 -0
  193. data/source/utilities/pattern/pattern.js +50 -0
  194. data/source/utilities/query_string/package.json +3 -0
  195. data/source/utilities/query_string/query_string.js +24 -0
  196. data/source/utilities/template/package.json +3 -0
  197. data/source/utilities/template/template.js +10 -0
  198. data/source/utilities/text_range/package.json +3 -0
  199. data/source/utilities/text_range/text_range.js +30 -0
  200. data/source/utilities/ui_events/package.json +3 -0
  201. data/source/utilities/ui_events/ui_events.js +85 -0
  202. data/source/utilities/variables/variables.scss +18 -0
  203. data/source/utilities/z_indexes/z-indexes.scss +88 -0
  204. data/source/vendor/array_includes.js +28 -0
  205. data/source/vendor/highlight.js +1142 -0
  206. data/source/vendor/index.js +1 -0
  207. data/source/vendor/matrix.js +399 -0
  208. data/source/vendor/query_string.js +66 -0
  209. data/spec/assets/.eslintrc +9 -0
  210. data/spec/assets/spec_fixture.js +33 -0
  211. data/spec/assets/spec_helper.js +19 -0
  212. data/spec/lib/components/base_component_spec.rb +156 -0
  213. data/spec/lib/components_spec.rb +30 -0
  214. data/spec/lib/helpers/ui_helper_spec.rb +62 -0
  215. data/spec/lib/theme_spec.rb +25 -0
  216. data/spec/spec_helper.rb +15 -0
  217. data/tasks/gulp/.eslintrc +6 -0
  218. data/tasks/gulp/browser_sync.js +8 -0
  219. data/tasks/gulp/code_quality/scripts.js +10 -0
  220. data/tasks/gulp/config/index.js +116 -0
  221. data/tasks/gulp/minify/scripts.js +13 -0
  222. data/tasks/gulp/minify/styles.js +13 -0
  223. data/tasks/gulp/pattern_library/index.js +5 -0
  224. data/tasks/gulp/pattern_library/scripts.js +10 -0
  225. data/tasks/gulp/pattern_library/styles.js +10 -0
  226. data/tasks/gulp/scripts.js +8 -0
  227. data/tasks/gulp/spec/scripts.js +11 -0
  228. data/tasks/gulp/styles.js +17 -0
  229. data/tasks/gulp/utilities/babel/relative_require.js +22 -0
  230. data/tasks/gulp/utilities/babel/spec_helper.js +20 -0
  231. data/tasks/gulp/utilities/browserify_bundler.js +22 -0
  232. data/tasks/gulp/utilities/handle_errors.js +13 -0
  233. data/tasks/gulp/watch.js +9 -0
  234. data/tasks/rake/rspec.rake +7 -0
  235. data/tasks/rake/rubocop.rake +8 -0
  236. data/tasks/rake/templates.rake +50 -0
  237. metadata +470 -0
@@ -0,0 +1,30 @@
1
+ require "spec_helper"
2
+
3
+ describe Docks::Themes::API::Components do
4
+ subject { described_class }
5
+
6
+ describe ".component_for" do
7
+ it "returns the base component when no custom component class exists" do
8
+ expect(subject.component_for(:foo)).to be subject::Base
9
+ end
10
+
11
+ it "returns the custom component class if one exists" do
12
+ expect(subject.component_for(:code_block)).to be subject::CodeBlock
13
+ expect(subject.component_for("code_block")).to be subject::CodeBlock
14
+ end
15
+ end
16
+
17
+ describe ".template_path" do
18
+ let(:expected_path) { }
19
+
20
+ it "returns the path to the component's template" do
21
+ path = subject.template_path(:code_block)
22
+ expect(path).to eq Docks::Themes::API.instance.assets.path_for("components/code_block/code_block.erb")
23
+ expect(File.exists?(path)).to be true
24
+ end
25
+
26
+ it "returns the path to a nested template" do
27
+ expect(subject.template_path("tablist:tab")).to eq Docks::Themes::API.instance.assets.path_for("components/tablist/tablist_tab.erb")
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,62 @@
1
+ require "spec_helper"
2
+
3
+ describe Docks::Themes::API::Helpers do
4
+ let(:includer) do
5
+ Class.new { include Docks::Themes::API::Helpers }.new
6
+ end
7
+
8
+ describe "#unique_iframe_id" do
9
+ it "generates a unique id each time" do
10
+ ids = (1..100).map { includer.unique_iframe_id }
11
+ expect(ids).to eq ids.uniq
12
+ end
13
+ end
14
+
15
+ describe "#docks_icons" do
16
+ it "returns the contents of the icon file" do
17
+ expect(File).to receive(:read).with(Docks::Themes::API.instance.assets.path_for("images/icons.svg")).and_return("foo")
18
+ expect(includer.docks_icons).to eq "foo"
19
+ end
20
+ end
21
+
22
+ describe "#docks_icon" do
23
+ it "creates an SVG icon with the passed name" do
24
+ expect(includer.docks_icon("foo")).to have_tag :svg, with: { class: "icon" }
25
+ expect(includer.docks_icon("foo")).to include "<use xlink:href='#icon--foo'></use>"
26
+ end
27
+
28
+ it "creates an SVG icon with the passed size" do
29
+ expect(includer.docks_icon("foo", size: 20)).to have_tag :svg, with: { class: ["icon--20"] }
30
+ end
31
+
32
+ it "creates and SVG icon with the passed color" do
33
+ expect(includer.docks_icon("foo", color: :blue)).to have_tag :svg, with: { class: ["icon--blue"] }
34
+ expect(includer.docks_icon("foo", color: :blue_darker)).to have_tag :svg, with: { class: ["icon--blue-darker"] }
35
+ end
36
+ end
37
+
38
+ describe "#docks_demo" do
39
+ it "renders the demo template/ layout" do
40
+ expect(includer).to receive(:render).with(Docks::Templates.demo.path, hash_including(layout: Docks::Templates.demo.layout)).and_return "foo"
41
+ expect(includer.docks_demo("<div></div>")).to eq "foo"
42
+ end
43
+
44
+ it "passes the passed demo along as the demo local" do
45
+ demo = "foo bar"
46
+ expect(includer).to receive(:render).with(anything, hash_including(locals: hash_including(demo: demo)))
47
+ includer.docks_demo(demo)
48
+ end
49
+
50
+ it "passes other locals along to the render call" do
51
+ locals = { foo: "bar", baz: "qux" }
52
+ expect(includer).to receive(:render).with(anything, hash_including(locals: hash_including(locals)))
53
+ includer.docks_demo("foo bar", locals)
54
+ end
55
+
56
+ it "defaults the id local to a unique iframe ID" do
57
+ expect(includer).to receive(:unique_iframe_id).and_return 1
58
+ expect(includer).to receive(:render).with(anything, hash_including(locals: hash_including(id: 1)))
59
+ includer.docks_demo("foo bar")
60
+ end
61
+ end
62
+ end
@@ -0,0 +1,25 @@
1
+ require "spec_helper"
2
+
3
+ describe Docks::Themes::API do
4
+ subject { described_class.instance }
5
+
6
+ describe "#configure" do
7
+ let(:config) { OpenStruct.new(paginate: false, helpers: [:foo]) }
8
+
9
+ it "updates pagination to be by pattern" do
10
+ subject.configure(config)
11
+ expect(config.paginate).to be :pattern
12
+ end
13
+
14
+ it "adds the helper module to helpers" do
15
+ original_helpers = config.helpers.dup
16
+ subject.configure(config)
17
+
18
+ expect(config.helpers.length).to be original_helpers.length + 1
19
+ expect(config.helpers).to include described_class::Helpers
20
+ original_helpers.each do |helper|
21
+ expect(config.helpers).to include helper
22
+ end
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,15 @@
1
+ require "docks_theme_api"
2
+ require "fileutils"
3
+ require "ostruct"
4
+ require "awesome_print"
5
+ require "rspec-html-matchers"
6
+
7
+ RSpec.configure do |config|
8
+ config.include RSpecHtmlMatchers
9
+
10
+ config.order = "random"
11
+
12
+ config.mock_with :rspec do |c|
13
+ c.syntax = :expect
14
+ end
15
+ end
@@ -0,0 +1,6 @@
1
+ {
2
+ "env": {
3
+ "node": true,
4
+ "mocha": true
5
+ }
6
+ }
@@ -0,0 +1,8 @@
1
+ var config = require("./config").plugins.browser_sync,
2
+ browser_sync = require("browser-sync");
3
+
4
+ module.exports = function(gulp) {
5
+ return function() {
6
+ browser_sync.init(config);
7
+ };
8
+ };
@@ -0,0 +1,10 @@
1
+ var config = require("../config");
2
+
3
+ module.exports = function(gulp, plugins) {
4
+ return function() {
5
+ return gulp.src(config.source.scripts.all)
6
+ .pipe(plugins.eslint())
7
+ .pipe(plugins.eslint.format())
8
+ .pipe(plugins.eslint.failOnError());
9
+ };
10
+ };
@@ -0,0 +1,116 @@
1
+ var path = require("path"),
2
+ sources, destination, config;
3
+
4
+ sources = {
5
+ styles: {
6
+ all: ["source/**/*.scss"],
7
+ main: [
8
+ "source/pattern-library.scss",
9
+ "source/pattern-library-demo.scss"
10
+ ]
11
+ },
12
+ scripts: {
13
+ all: [
14
+ "source/**/!(spec)/*.js",
15
+ "!source/vendor/**/*.js"
16
+ ],
17
+ main: [
18
+ "source/pattern_library.js",
19
+ "source/pattern_library_demo.js"
20
+ ],
21
+ spec: ["source/**/*_spec.js"]
22
+ },
23
+ templates: {
24
+ all: ["assets/templates/erb/**/*.erb"]
25
+ }
26
+ };
27
+
28
+ destination = {
29
+ styles: "assets/styles",
30
+ scripts: "assets/scripts",
31
+ pattern_library: {
32
+ styles: "public/styles",
33
+ scripts: "public/scripts"
34
+ }
35
+ };
36
+
37
+ config = {
38
+ source: sources,
39
+ destination: destination,
40
+
41
+ plugins: {
42
+ // Might want to try this: https://www.npmjs.com/package/bs-html-injector
43
+ browser_sync: {
44
+ open: false,
45
+ files: [
46
+ "public/**/*.{css,js}",
47
+ "public/pattern-library/**/*.html"
48
+ ],
49
+ server: {
50
+ baseDir: "public"
51
+ }
52
+ },
53
+
54
+ browserify: {},
55
+
56
+ babel: {
57
+ optional: ["runtime"],
58
+ plugins: [
59
+ path.resolve(__dirname, "../utilities/babel/relative_require.js"),
60
+ path.resolve(__dirname, "../utilities/babel/spec_helper.js")
61
+ ],
62
+ stage: 0
63
+ },
64
+
65
+ docks: {
66
+ command: "docks"
67
+ },
68
+
69
+ css_globbing: {
70
+ extensions: [".scss", ".sass"]
71
+ },
72
+
73
+ sass: {
74
+ errLogToConsole: true
75
+ },
76
+
77
+ autoprefixer: {
78
+ browsers: ["last 2 versions", "> 5%"]
79
+ }
80
+ }
81
+ };
82
+
83
+ config.plugins.karma = (function() {
84
+ var files = config.source.scripts.spec,
85
+ preprocessors;
86
+ if(!Array.isArray(files)) { files = [files]; }
87
+
88
+ preprocessors = {};
89
+ files.map(function(file) {
90
+ preprocessors[file] = "browserify";
91
+ });
92
+
93
+ files = [
94
+ "https://code.jquery.com/jquery-1.11.2.min.js"
95
+ ].concat(files);
96
+
97
+ return {
98
+ basePath: "",
99
+ frameworks: ["mocha", "browserify", "es6-shim"],
100
+ files: files,
101
+ preprocessors: preprocessors,
102
+ browserify: {
103
+ debug: true,
104
+ transform: [
105
+ ["babelify", config.plugins.babel]
106
+ ]
107
+ },
108
+ reporters: ["dots"],
109
+ port: 9876,
110
+ colors: true,
111
+ autoWatch: true,
112
+ browsers: ["PhantomJS"]
113
+ };
114
+ })();
115
+
116
+ module.exports = config;
@@ -0,0 +1,13 @@
1
+ var path = require("path"),
2
+ config = require("../config");
3
+
4
+ module.exports = function(gulp, plugins) {
5
+ return function() {
6
+ // TODO
7
+ return gulp.src(path.join(config.destination.scripts, "*.js"))
8
+ .pipe(plugins.rename({ suffix: ".min" }))
9
+ .pipe(plugins.uglify())
10
+ .pipe(gulp.dest(config.destination.scripts))
11
+ .pipe(plugins.filesize());
12
+ };
13
+ };
@@ -0,0 +1,13 @@
1
+ var path = require("path"),
2
+ config = require("../config");
3
+
4
+ module.exports = function(gulp, plugins) {
5
+ return function() {
6
+ // TODO
7
+ return gulp.src(path.join(config.destination.styles, "!(min).css"))
8
+ .pipe(plugins.rename({ suffix: ".min" }))
9
+ .pipe(plugins.minifyCss())
10
+ .pipe(gulp.dest(config.destination.styles))
11
+ .pipe(plugins.filesize());
12
+ };
13
+ };
@@ -0,0 +1,5 @@
1
+ var config = require("../config");
2
+
3
+ module.exports = function(gulp, plugins) {
4
+ return plugins.shell.task(config.plugins.docks.command);
5
+ };
@@ -0,0 +1,10 @@
1
+ var destinations = require("../config").destination,
2
+ browser_sync = require("browser-sync");
3
+
4
+ module.exports = function(gulp, plugins) {
5
+ return function() {
6
+ return gulp.src(destinations.scripts + "/*.js")
7
+ .pipe(gulp.dest(destinations.pattern_library.scripts))
8
+ .pipe(browser_sync.stream());
9
+ };
10
+ };
@@ -0,0 +1,10 @@
1
+ var destinations = require("../config").destination,
2
+ browser_sync = require("browser-sync");
3
+
4
+ module.exports = function(gulp, plugins) {
5
+ return function() {
6
+ return gulp.src(destinations.styles + "/*.css")
7
+ .pipe(gulp.dest(destinations.pattern_library.styles))
8
+ .pipe(browser_sync.stream());
9
+ };
10
+ };
@@ -0,0 +1,8 @@
1
+ var browserify = require("browserify"),
2
+ browserify_bundler = require("./utilities/browserify_bundler"),
3
+ config = require("./config"),
4
+ bundler = browserify(config.source.scripts.main[0], config.plugins.browserify);
5
+
6
+ module.exports = function(gulp, plugins) {
7
+ return browserify_bundler(bundler, gulp, plugins);
8
+ };
@@ -0,0 +1,11 @@
1
+ var karma = require("karma"),
2
+ path = require("path");
3
+
4
+ module.exports = function(gulp, plugins) {
5
+ return function(done) {
6
+ karma.server.start({
7
+ configFile: path.resolve(__dirname, "../../../karma.conf.js"),
8
+ singleRun: true
9
+ }, done);
10
+ };
11
+ };
@@ -0,0 +1,17 @@
1
+ var config = require("./config"),
2
+ browser_sync = require("browser-sync"),
3
+ handle_errors = require("./utilities/handle_errors");
4
+
5
+ module.exports = function(gulp, plugins) {
6
+ return function() {
7
+ return gulp.src(config.source.styles.main)
8
+ .pipe(plugins.cssGlobbing(config.plugins.css_globbing))
9
+ .pipe(plugins.sourcemaps.init())
10
+ .pipe(plugins.sass(config.plugins.sass))
11
+ .on("error", handle_errors)
12
+ .pipe(plugins.autoprefixer(config.plugins.autoprefixer))
13
+ .pipe(plugins.sourcemaps.write())
14
+ .pipe(gulp.dest(config.destination.styles))
15
+ .pipe(browser_sync.stream());
16
+ };
17
+ };
@@ -0,0 +1,22 @@
1
+ // source: http://stackoverflow.com/questions/31068698/importing-node-modules-from-root-directory-using-es6-and-babel-node
2
+
3
+ module.exports = function(babel) {
4
+ var cwd = process.cwd();
5
+
6
+ return new babel.Transformer("babel_relative_require", {
7
+ ImportDeclaration: function(node, parent) {
8
+ var ref;
9
+
10
+ if (!babel.types.isLiteral(node.source)) { return node; }
11
+
12
+ ref = node.source.value;
13
+
14
+ // ensure a value, make sure it's not home relative e.g. ~/foo
15
+ if (!ref || ref[0] !== "~" || ref[1] === "/") { return node; }
16
+
17
+ node.source.value = cwd + "/source/" + node.source.value.slice(1);
18
+
19
+ return node;
20
+ }
21
+ });
22
+ };
@@ -0,0 +1,20 @@
1
+ module.exports = function(babel) {
2
+ var cwd = process.cwd();
3
+
4
+ return new babel.Transformer("babel_spec_helper", {
5
+ ImportDeclaration: function(node, parent) {
6
+ var ref;
7
+
8
+ if (!babel.types.isLiteral(node.source)) { return node; }
9
+
10
+ ref = node.source.value;
11
+
12
+ // ensure a value, make sure it's not home relative e.g. ~/foo
13
+ if (!ref || ref !== "spec_helper") { return node; }
14
+
15
+ node.source.value = cwd + "/spec/assets/spec_helper.js";
16
+
17
+ return node;
18
+ }
19
+ });
20
+ };
@@ -0,0 +1,22 @@
1
+ var babelify = require("babelify"),
2
+ source = require("vinyl-source-stream"),
3
+ buffer = require("vinyl-buffer"),
4
+ config = require("../config"),
5
+ browser_sync = require("browser-sync"),
6
+ handle_errors = require("../utilities/handle_errors"),
7
+ path = require("path");
8
+
9
+ module.exports = function(bundler, gulp, plugins) {
10
+ bundler.transform(babelify.configure(config.plugins.babel));
11
+
12
+ return function() {
13
+ return bundler.bundle()
14
+ .on("error", handle_errors)
15
+ .pipe(source(path.basename(config.source.scripts.main[0])))
16
+ .pipe(buffer())
17
+ .pipe(plugins.sourcemaps.init({ loadMaps: true }))
18
+ .pipe(plugins.sourcemaps.write())
19
+ .pipe(gulp.dest(config.destination.scripts))
20
+ .pipe(browser_sync.stream());
21
+ };
22
+ };
@@ -0,0 +1,13 @@
1
+ var notify = require("gulp-notify");
2
+
3
+ module.exports = function() {
4
+ var args = Array.prototype.slice.call(arguments);
5
+
6
+ notify.onError({
7
+ title: "Compile Error",
8
+ message: "<%= error %>"
9
+ }).apply(this, args);
10
+
11
+ // Keep gulp from hanging on this task
12
+ this.emit("end");
13
+ };
@@ -0,0 +1,9 @@
1
+ var sources = require("./config").source;
2
+
3
+ module.exports = function(gulp) {
4
+ return function() {
5
+ gulp.watch(sources.styles.all, ["pattern_library_styles"]);
6
+ gulp.watch(sources.scripts.all, ["pattern_library_scripts"]);
7
+ gulp.watch(sources.templates.all, ["pattern_library"]);
8
+ };
9
+ };
@@ -0,0 +1,7 @@
1
+ require "rspec/core/rake_task"
2
+
3
+ RSpec::Core::RakeTask.new(:spec) do |task|
4
+ task.rspec_opts = "--color --tty"
5
+ end
6
+
7
+ task default: :spec
@@ -0,0 +1,8 @@
1
+ require "rubocop/rake_task"
2
+
3
+ desc "Run RuboCop on the lib directory"
4
+
5
+ RuboCop::RakeTask.new(:rubocop) do |task|
6
+ task.patterns = %w(lib/**/*.rb)
7
+ task.fail_on_error = false
8
+ end
@@ -0,0 +1,50 @@
1
+ require "html2haml"
2
+ require "html2slim"
3
+ require "fileutils"
4
+
5
+ def from_root(file)
6
+ file.sub(File.expand_path("../../", __FILE__), "").sub(/^#{File::SEPARATOR}/, "")
7
+ end
8
+
9
+ def erb_templates
10
+ Dir[File.expand_path("../../../assets/templates/erb/**/*.erb", __FILE__)].sort
11
+ end
12
+
13
+ def corresponding_template(template, options = {})
14
+ language = options.fetch(:language)
15
+ template.sub("templates/erb", "templates/#{language}").sub(%r{\.erb$}, ".#{language}")
16
+ end
17
+
18
+ def convert_haml
19
+ erb_templates.each do |template|
20
+ haml_template = corresponding_template(template, language: :haml)
21
+ FileUtils.mkdir_p(File.dirname(haml_template))
22
+ `html2haml --ruby19-attributes '#{template}' '#{haml_template}'`
23
+
24
+ puts "Converted '#{from_root(template)}' to '#{from_root(haml_template)}'"
25
+ end
26
+ end
27
+
28
+ def convert_slim
29
+ erb_templates.each do |template|
30
+ slim_template = corresponding_template(template, language: :slim)
31
+ FileUtils.mkdir_p(File.dirname(slim_template))
32
+ File.open(slim_template, "w") { |file| file.write(HTML2Slim.convert!(template, :erb)) }
33
+
34
+ puts "Converted '#{from_root(template)}' to '#{from_root(slim_template)}'"
35
+ end
36
+ end
37
+
38
+ namespace :templates do
39
+ desc "convert all ERB templates that are available to the user to other template languages"
40
+
41
+ task :convert do
42
+ convert_haml
43
+ convert_slim
44
+
45
+ puts ""
46
+ Docks::Messenger.warn "Make sure to check the output of the above conversions to make sure that everything went OK!"
47
+ end
48
+ end
49
+
50
+