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
data/gulpfile.js ADDED
@@ -0,0 +1,88 @@
1
+ var gulp = require("gulp"),
2
+ plugins = require("gulp-load-plugins")();
3
+
4
+ function load_task(task) {
5
+ return require("./tasks/gulp/" + task)(gulp, plugins);
6
+ }
7
+
8
+ // ___ ___
9
+ // / /\ ___ ___ / /\
10
+ // / /:/_ / /\ /__/| / /:/_
11
+ // / /:/ /\ / /:/ | |:| ___ ___ / /:/ /\
12
+ // / /:/ /::\ / /:/ | |:|/__/\ / /\ / /:/ /:/_
13
+ // /__/:/ /:/\:\ / /::\ __|__|:|\ \:\ / /://__/:/ /:/ /\
14
+ // \ \:\/:/~/://__/:/\:\/__/::::\ \ \:\ /:/ \ \:\/:/ /:/
15
+ // \ \::/ /:/ \__\/ \:\ ~\~~\:\ \ \:\/:/ \ \::/ /:/
16
+ // \__\/ /:/ \ \:\ \ \:\ \ \::/ \ \:\/:/
17
+ // /__/:/ \__\/ \__\/ \__\/ \ \::/
18
+ // \__\/ \__\/
19
+
20
+ gulp.task("styles", load_task("styles"));
21
+ gulp.task("minify_styles", ["styles"], load_task("minify/styles"));
22
+
23
+ // ___ ___ ___ ___
24
+ // / /\ / /\ / /\ ___ / /\ ___
25
+ // / /:/_ / /:/ / /::\ / /\ / /::\ / /\
26
+ // / /:/ /\ / /:/ / /:/\:\ / /:/ / /:/\:\ / /:/
27
+ // / /:/ /::\ / /:/ ___ / /:/~/:/ /__/::\ / /:/~/:// /:/
28
+ // /__/:/ /:/\:\/__/:/ / /\/__/:/ /:/___\__\/\:\__ /__/:/ /:// /::\
29
+ // \ \:\/:/~/:/\ \:\ / /:/\ \:\/:::::/ \ \:\/\\ \:\/://__/:/\:\
30
+ // \ \::/ /:/ \ \:\ /:/ \ \::/~~~~ \__\::/ \ \::/ \__\/ \:\
31
+ // \__\/ /:/ \ \:\/:/ \ \:\ /__/:/ \ \:\ \ \:\
32
+ // /__/:/ \ \::/ \ \:\ \__\/ \ \:\ \__\/
33
+ // \__\/ \__\/ \__\/ \__\/
34
+
35
+ gulp.task("scripts_code_quality", load_task("code_quality/scripts"));
36
+ gulp.task("scripts", ["scripts_code_quality"], load_task("scripts"));
37
+ gulp.task("minify_scripts", ["scripts"], load_task("minify/scripts"));
38
+ gulp.task("scripts_spec", load_task("spec/scripts"));
39
+
40
+ // ___ ___ ___ ___ ___
41
+ // / /\ / /\ ___ ___ / /\ / /\ /__/\
42
+ // / /::\ / /::\ / /\ / /\ / /:/_ / /::\ \ \:\
43
+ // / /:/\:\ / /:/\:\ / /:/ / /:/ / /:/ /\ / /:/\:\ \ \:\
44
+ // / /:/~/:// /:/~/::\ / /:/ / /:/ / /:/ /:/_ / /:/~/:/ _____\__\:\
45
+ // /__/:/ /://__/:/ /:/\:\ / /::\ / /::\ /__/:/ /:/ /\/__/:/ /:/___/__/::::::::\
46
+ // \ \:\/:/ \ \:\/:/__\//__/:/\:\ /__/:/\:\\ \:\/:/ /:/\ \:\/:::::/\ \:\~~\~~\/
47
+ // \ \::/ \ \::/ \__\/ \:\\__\/ \:\\ \::/ /:/ \ \::/~~~~ \ \:\ ~~~
48
+ // \ \:\ \ \:\ \ \:\ \ \:\\ \:\/:/ \ \:\ \ \:\
49
+ // \ \:\ \ \:\ \__\/ \__\/ \ \::/ \ \:\ \ \:\
50
+ // \__\/ \__\/ \__\/ \__\/ \__\/
51
+
52
+ gulp.task("copy_pattern_library_styles", ["styles"], load_task("pattern_library/styles"));
53
+ gulp.task("copy_pattern_library_scripts", ["scripts"], load_task("pattern_library/scripts"));
54
+ gulp.task("pattern_library_styles", ["copy_pattern_library_styles"], load_task("pattern_library"));
55
+ gulp.task("pattern_library_scripts", ["copy_pattern_library_scripts"], load_task("pattern_library"));
56
+ gulp.task("pattern_library", load_task("pattern_library"));
57
+
58
+ // ___ ___ ___ ___
59
+ // /__/\ / /\ ___ / /\ /__/\
60
+ // _\_ \:\ / /::\ / /\ / /:/ \ \:\
61
+ // /__/\ \:\ / /:/\:\ / /:/ / /:/ \__\:\
62
+ // _\_ \:\ \:\ / /:/~/::\ / /:/ / /:/ ___ ___ / /::\
63
+ // /__/\ \:\ \:\/__/:/ /:/\:\ / /::\ /__/:/ / /\/__/\ /:/\:\
64
+ // \ \:\ \:\/:/\ \:\/:/__\//__/:/\:\\ \:\ / /:/\ \:\/:/__\/
65
+ // \ \:\ \::/ \ \::/ \__\/ \:\\ \:\ /:/ \ \::/
66
+ // \ \:\/:/ \ \:\ \ \:\\ \:\/:/ \ \:\
67
+ // \ \::/ \ \:\ \__\/ \ \::/ \ \:\
68
+ // \__\/ \__\/ \__\/ \__\/
69
+
70
+ gulp.task("browser_sync", load_task("browser_sync"))
71
+ gulp.task("watch", ["browser_sync"], load_task("watch"));
72
+
73
+ // ___ ___ ___ ___
74
+ // / /\ / /\ / /\ / /\
75
+ // / /:/ / /::\ / /::\ / /:/_
76
+ // / /:/ / /:/\:\ / /:/\:\ / /:/ /\
77
+ // / /:/ ___ / /:/ \:\ / /:/~/:/ / /:/ /:/_
78
+ // /__/:/ / /\/__/:/ \__\:\/__/:/ /:/___/__/:/ /:/ /\
79
+ // \ \:\ / /:/\ \:\ / /:/\ \:\/:::::/\ \:\/:/ /:/
80
+ // \ \:\ /:/ \ \:\ /:/ \ \::/~~~~ \ \::/ /:/
81
+ // \ \:\/:/ \ \:\/:/ \ \:\ \ \:\/:/
82
+ // \ \::/ \ \::/ \ \:\ \ \::/
83
+ // \__\/ \__\/ \__\/ \__\/
84
+
85
+ gulp.task("code_quality", ["scripts_code_quality"]);
86
+ gulp.task("spec", ["scripts_spec"]);
87
+ gulp.task("default", ["styles", "scripts"]);
88
+ gulp.task("production", ["minify_styles", "minify_scripts"]);
data/karma.conf.js ADDED
@@ -0,0 +1,6 @@
1
+ var karma_configuration = require("./tasks/gulp/config").plugins.karma;
2
+
3
+ module.exports = function(config) {
4
+ karma_configuration.logLevel = config.LOG_INFO;
5
+ config.set(karma_configuration);
6
+ };
@@ -0,0 +1,99 @@
1
+ require "forwardable"
2
+
3
+ module Docks::Themes
4
+ class API < Base
5
+ module Components
6
+ def self.standardize_classes(classes, base_component = :base)
7
+ return {} if classes.nil?
8
+
9
+ if classes.kind_of?(Hash)
10
+ classes.each do |key, klass|
11
+ classes[key] = klass.kind_of?(String) ? klass.split(" ") : klass
12
+ end
13
+ else
14
+ classes = classes.kind_of?(String) ? classes.split(" ") : classes
15
+ class_hash = {}
16
+ class_hash[base_component] = classes
17
+
18
+ classes = class_hash
19
+ end
20
+
21
+ classes
22
+ end
23
+
24
+ class Base
25
+ extend Forwardable
26
+ attr_reader :block
27
+
28
+ def_delegators :@view, :concat, :capture, :render
29
+
30
+ def initialize(view, opts = {}, &block)
31
+ @view = view
32
+ @attributes = opts
33
+ @classes = Components.standardize_classes(opts.delete(:classes))
34
+ @block = block
35
+ end
36
+
37
+ def config
38
+ yield Config.new(self)
39
+ end
40
+
41
+ alias_method :configure, :config
42
+
43
+ def method_missing(meth, *args)
44
+ @attributes.key?(meth) ? @attributes[meth] : super
45
+ end
46
+
47
+ def respond_to?(meth)
48
+ @attributes.has_key?(meth) || super
49
+ end
50
+
51
+ def classes_for(subcomponent = :base)
52
+ @classes.fetch(subcomponent, []).join(" ")
53
+ end
54
+
55
+ alias_method :classes, :classes_for
56
+
57
+ def ==(other)
58
+ self.class == other.class && attributes == other.instance_variable_get(:@attributes)
59
+ end
60
+
61
+ def to_s; @attributes.to_s end
62
+ def inspect; to_s end
63
+ end
64
+
65
+ class Config
66
+ def initialize(component)
67
+ @component = component
68
+ end
69
+
70
+ def defaults(opts = {})
71
+ @component.instance_variable_get(:@attributes).merge!(opts) do |key, passed, default|
72
+ passed.nil? ? default : passed
73
+ end
74
+ end
75
+
76
+ def classes(default_classes = {})
77
+ default_classes = Components.standardize_classes(default_classes)
78
+ @component.instance_variable_get(:@classes).merge!(default_classes) do |key, passed, default|
79
+ passed.concat(default).uniq
80
+ end
81
+ end
82
+
83
+ def conditional_classes(opts)
84
+ if (attribute = opts.delete(:if))
85
+ classes(opts) if @component.respond_to?(attribute) && !!@component.send(attribute)
86
+ elsif (attribute = opts.delete(:unless))
87
+ classes(opts) if !@component.respond_to?(attribute) || !@component.send(attribute)
88
+ elsif (attribute = opts.delete(:with))
89
+ return unless block_given?
90
+ classes(yield @component.send(attribute))
91
+ elsif (attribute = opts.delete(:from))
92
+ return unless @component.respond_to?(attribute)
93
+ classes(opts.fetch(@component.send(attribute), nil))
94
+ end
95
+ end
96
+ end
97
+ end
98
+ end
99
+ end
@@ -0,0 +1,10 @@
1
+ require_relative "base_component.rb"
2
+
3
+ module Docks::Themes
4
+ class API < Base
5
+ module Components
6
+ class CodeBlock < Base
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,15 @@
1
+ require_relative "base_component.rb"
2
+
3
+ module Docks::Themes
4
+ class API < Base
5
+ module Components
6
+ class Popover < Base
7
+ def pane(options = {}, &block)
8
+ klass = "popover__pane"
9
+ klass << " popover__pane--fixed" if options.fetch(:fixed?, false)
10
+ concat "<div class='#{klass}'>#{capture(&block)}</div>"
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -0,0 +1,34 @@
1
+ require_relative "base_component.rb"
2
+
3
+ module Docks::Themes
4
+ class API < Base
5
+ module Components
6
+ class Table < Base
7
+ def initialize(*args)
8
+ @cell_element = "td"
9
+ super
10
+ end
11
+
12
+ def header(&block)
13
+ old_cell_element, @cell_element = @cell_element, "th"
14
+ concat "<thead class='table__header'>#{capture(&block)}</thead>"
15
+ @cell_element = old_cell_element
16
+ end
17
+
18
+ def body(&block)
19
+ concat "<tbody class='table__body'>#{capture(&block)}</tbody>"
20
+ end
21
+
22
+ def row(&block)
23
+ concat "<tr class='table__row'>#{capture(&block)}</tr>"
24
+ end
25
+
26
+ def cell(content, options = {})
27
+ klass = "table__cell"
28
+ klass << " table__cell--centered" if options.fetch(:centered?, false)
29
+ "<#{@cell_element} class='#{klass}'>#{content}</#{@cell_element}>"
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
@@ -0,0 +1,11 @@
1
+ require_relative "base_component.rb"
2
+
3
+ module Docks::Themes
4
+ class API < Base
5
+ module Components
6
+ class Tablist < Base
7
+ def tab(*args); @view.docks_component("tablist:tab", *args) end
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,21 @@
1
+ require "pathname"
2
+
3
+ Dir[File.expand_path("../components/*.rb", __FILE__)].each do |component|
4
+ require component
5
+ end
6
+
7
+ module Docks::Themes
8
+ class API < Base
9
+ module Components
10
+ def self.component_for(name)
11
+ const = name.to_s.split(/[^a-z]/i).map(&:capitalize).join("").to_sym
12
+ const_defined?(const) ? const_get(const) : Base
13
+ end
14
+
15
+ def self.template_path(name)
16
+ name = name.to_s.split(":")
17
+ API.instance.assets.path_for(File.join("components", name.first, "#{name.join("_")}.erb"))
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,69 @@
1
+ require "docks/templates"
2
+ require_relative "../components.rb"
3
+
4
+ module Docks::Themes
5
+ class API < Base
6
+ module Helpers
7
+ def unique_iframe_id
8
+ @iframe_id ||= 0
9
+ @iframe_id += 1
10
+ "iframe--#{@iframe_id}"
11
+ end
12
+
13
+ def docks_icons
14
+ # html safe
15
+ File.read(API.instance.assets.path_for("images/icons.svg"))
16
+ end
17
+
18
+ def docks_icon(name, options = {})
19
+ klass = "icon"
20
+
21
+ size = options.delete(:size)
22
+ klass << " icon--#{size}" unless size.nil?
23
+
24
+ color = options.delete(:color)
25
+ klass << " icon--#{color.to_s.gsub("_", "-")}" unless color.nil?
26
+
27
+ "<svg class='#{klass}'><use xlink:href='#icon--#{name}'></use></svg>"
28
+ end
29
+
30
+ def docks_demo(demo, locals = {})
31
+ locals[:id] ||= unique_iframe_id
32
+ locals[:demo] = demo
33
+ render(Docks::Templates.demo.path, layout: Docks::Templates.demo.layout, locals: locals)
34
+ end
35
+
36
+ %w(
37
+ avatar
38
+ select
39
+ code_block
40
+ button
41
+ tablist
42
+ resizable
43
+ toggle
44
+ toggle_container
45
+ details_sheet
46
+ exploded
47
+ popover
48
+ xray
49
+ iframe
50
+ table
51
+ ).each do |component_name|
52
+ define_method "docks_#{component_name}".to_sym do |opts = {}, &block|
53
+ docks_component(component_name, opts, &block)
54
+ end
55
+ end
56
+
57
+ def docks_component(name, opts = {}, &block)
58
+ locals = {}
59
+ locals[name.to_s.split(":").last.to_sym] = locals[:component] = Components.component_for(name).new(self, opts, &block)
60
+
61
+ if block.nil?
62
+ render(Components.template_path(name), locals)
63
+ else
64
+ concat render(Components.template_path(name), locals)
65
+ end
66
+ end
67
+ end
68
+ end
69
+ end
@@ -0,0 +1,21 @@
1
+ require "docks_theme_base"
2
+
3
+ Dir[File.expand_path("../helpers/*.rb", __FILE__)].each do |helper|
4
+ require helper
5
+ end
6
+
7
+ module Docks
8
+ module Themes
9
+ class API < Base
10
+ def initialize
11
+ project_root = Pathname.new(File.expand_path("../../../", __FILE__))
12
+ @assets = Assets.new(root: project_root + "assets", source_root: project_root + "source")
13
+ end
14
+
15
+ def configure(config)
16
+ config.paginate = :pattern
17
+ config.helpers += [Helpers]
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1 @@
1
+ require_relative "docks_theme_api/theme.rb"
data/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "docks",
3
+ "version": "0.0.1",
4
+ "scripts": {
5
+ "test": "grunt spec",
6
+ "lint": "eslint src"
7
+ },
8
+ "description": "template-description",
9
+ "devDependencies": {
10
+ "babel": "^5.8.21",
11
+ "babel-eslint": "^4.0.5",
12
+ "babel-runtime": "^5.6.15",
13
+ "babelify": "^6.1.2",
14
+ "browser-sync": "^2.7.12",
15
+ "browserify": "^10.2.4",
16
+ "chai": "^3.2.0",
17
+ "es5-shim": "^4.1.10",
18
+ "es6-shim": "^0.28.1",
19
+ "eslint": "^1.0.0",
20
+ "gulp": "^3.9.0",
21
+ "gulp-autoprefixer": "^2.3.1",
22
+ "gulp-css-globbing": "^0.1.8",
23
+ "gulp-eslint": "^1.0.0",
24
+ "gulp-filesize": "0.0.6",
25
+ "gulp-load-plugins": "^1.0.0-rc.1",
26
+ "gulp-minify-css": "^1.1.6",
27
+ "gulp-notify": "^2.2.0",
28
+ "gulp-rename": "^1.2.2",
29
+ "gulp-sass": "^2.0.1",
30
+ "gulp-shell": "^0.4.2",
31
+ "gulp-sourcemaps": "^1.5.2",
32
+ "gulp-uglify": "^1.2.0",
33
+ "karma": "^0.13.5",
34
+ "karma-browserify": "^4.2.1",
35
+ "karma-chrome-launcher": "^0.2.0",
36
+ "karma-es6-shim": "^0.1.3",
37
+ "karma-firefox-launcher": "^0.1.6",
38
+ "karma-mocha": "^0.2.0",
39
+ "karma-phantomjs-launcher": "^0.2.0",
40
+ "karma-safari-launcher": "^0.1.1",
41
+ "karma-spec-reporter": "0.0.20",
42
+ "merge-stream": "^0.1.8",
43
+ "mocha": "^2.2.5",
44
+ "mustache": "^2.1.3",
45
+ "phantomjs": "^1.9.17",
46
+ "sinon": "^1.15.4",
47
+ "vinyl-buffer": "^1.0.0",
48
+ "vinyl-source-stream": "^1.1.0"
49
+ },
50
+ "repository": {
51
+ "type": "git",
52
+ "url": "https://github.com/lemonmade/docks.git"
53
+ },
54
+ "bugs": {
55
+ "url": "https://github.com/lemonmade/docks/issues"
56
+ },
57
+ "dependencies": {
58
+ "whatwg-fetch": "^0.9.0"
59
+ }
60
+ }