docks_theme_api 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +15 -0
- data/.babelrc +4 -0
- data/.editorconfig +8 -0
- data/.eslintrc +115 -0
- data/.gitignore +24 -0
- data/.rubocop.yml +20 -0
- data/.travis.yml +16 -0
- data/Gemfile +4 -0
- data/README.md +5 -0
- data/Rakefile +3 -0
- data/assets/images/icons.svg +63 -0
- data/assets/scripts/coffeescript/pattern_library_helpers.coffee +8 -0
- data/assets/scripts/javascript/pattern_library_helpers.js +11 -0
- data/assets/scripts/pattern_library.js +10380 -0
- data/assets/scripts/pattern_library_demo.js +0 -0
- data/assets/styles/less/pattern-library-helpers.less +103 -0
- data/assets/styles/pattern-library-demo.css +1882 -0
- data/assets/styles/pattern-library.css +1882 -0
- data/assets/styles/sass/pattern-library-helpers.sass +90 -0
- data/assets/styles/scss/pattern-library-helpers.scss +99 -0
- data/assets/styles/stylus/pattern-library-helpers.styl +90 -0
- data/assets/templates/erb/demo.erb +26 -0
- data/assets/templates/erb/layouts/demo.erb +17 -0
- data/assets/templates/erb/layouts/pattern.erb +76 -0
- data/assets/templates/erb/partials/sidebar.erb +124 -0
- data/assets/templates/erb/partials/symbols/class.erb +1 -0
- data/assets/templates/erb/partials/symbols/demo.erb +40 -0
- data/assets/templates/erb/partials/symbols/factory.erb +70 -0
- data/assets/templates/erb/partials/symbols/function.erb +103 -0
- data/assets/templates/erb/partials/symbols/mixin.erb +62 -0
- data/assets/templates/erb/partials/symbols/variable.erb +59 -0
- data/assets/templates/erb/pattern.erb +102 -0
- data/assets/templates/haml/demo.haml +14 -0
- data/assets/templates/haml/layouts/demo.haml +6 -0
- data/assets/templates/haml/layouts/pattern.haml +38 -0
- data/assets/templates/haml/partials/sidebar.haml +68 -0
- data/assets/templates/haml/partials/symbols/class.haml +1 -0
- data/assets/templates/haml/partials/symbols/demo.haml +23 -0
- data/assets/templates/haml/partials/symbols/factory.haml +38 -0
- data/assets/templates/haml/partials/symbols/function.haml +54 -0
- data/assets/templates/haml/partials/symbols/mixin.haml +31 -0
- data/assets/templates/haml/partials/symbols/variable.haml +22 -0
- data/assets/templates/haml/pattern.haml +54 -0
- data/assets/templates/slim/demo.slim +24 -0
- data/assets/templates/slim/layouts/demo.slim +5 -0
- data/assets/templates/slim/layouts/pattern.slim +48 -0
- data/assets/templates/slim/partials/sidebar.slim +112 -0
- data/assets/templates/slim/partials/symbols/class.slim +1 -0
- data/assets/templates/slim/partials/symbols/demo.slim +30 -0
- data/assets/templates/slim/partials/symbols/factory.slim +57 -0
- data/assets/templates/slim/partials/symbols/function.slim +81 -0
- data/assets/templates/slim/partials/symbols/mixin.slim +45 -0
- data/assets/templates/slim/partials/symbols/variable.slim +35 -0
- data/assets/templates/slim/pattern.slim +63 -0
- data/docks_config.rb +32 -0
- data/docks_theme_api.gemspec +37 -0
- data/gulpfile.js +88 -0
- data/karma.conf.js +6 -0
- data/lib/docks_theme_api/components/base_component.rb +99 -0
- data/lib/docks_theme_api/components/code_block_component.rb +10 -0
- data/lib/docks_theme_api/components/popover_component.rb +15 -0
- data/lib/docks_theme_api/components/table_component.rb +34 -0
- data/lib/docks_theme_api/components/tablist_component.rb +11 -0
- data/lib/docks_theme_api/components.rb +21 -0
- data/lib/docks_theme_api/helpers/ui_helper.rb +69 -0
- data/lib/docks_theme_api/theme.rb +21 -0
- data/lib/docks_theme_api.rb +1 -0
- data/package.json +60 -0
- data/source/behaviors/filterable/filterable.coffee +353 -0
- data/source/behaviors/filterable/filterable.js +0 -0
- data/source/behaviors/filterable/filterable.scss +34 -0
- data/source/behaviors/filterable/package.json +3 -0
- data/source/behaviors/index.js +0 -0
- data/source/components/avatar/avatar.erb +20 -0
- data/source/components/avatar/avatar.js +142 -0
- data/source/components/avatar/avatar.scss +200 -0
- data/source/components/avatar/avatar_container.erb +13 -0
- data/source/components/avatar/package.json +3 -0
- data/source/components/avatar/spec/avatar_spec.js +81 -0
- data/source/components/badge/badge.scss +158 -0
- data/source/components/button/button.scss +213 -0
- data/source/components/card/card.scss +32 -0
- data/source/components/code_block/code-block.scss +353 -0
- data/source/components/code_block/code_block.erb +95 -0
- data/source/components/code_block/code_block.js +444 -0
- data/source/components/code_block/package.json +3 -0
- data/source/components/code_block/spec/code_block_spec.js +10 -0
- data/source/components/demo/demo.js +244 -0
- data/source/components/demo/demo.scss +90 -0
- data/source/components/demo/package.json +3 -0
- data/source/components/exploded/exploded.erb +25 -0
- data/source/components/exploded/exploded.js +694 -0
- data/source/components/exploded/exploded.scss +166 -0
- data/source/components/exploded/package.json +3 -0
- data/source/components/field/field.js +24 -0
- data/source/components/field/field.scss +101 -0
- data/source/components/field/package.json +3 -0
- data/source/components/header/header.scss +33 -0
- data/source/components/iframe/iframe.erb +12 -0
- data/source/components/iframe/iframe.js +381 -0
- data/source/components/iframe/package.json +3 -0
- data/source/components/index.js +37 -0
- data/source/components/inline_group/inline-group.scss +14 -0
- data/source/components/internal_link/internal_link.js +49 -0
- data/source/components/internal_link/package.json +3 -0
- data/source/components/list/list.scss +230 -0
- data/source/components/modal/modal.coffee +84 -0
- data/source/components/modal/modal.erb +19 -0
- data/source/components/modal/modal.js +0 -0
- data/source/components/modal/modal.scss +57 -0
- data/source/components/modal/package.json +3 -0
- data/source/components/notice/notice.scss +48 -0
- data/source/components/popover/package.json +3 -0
- data/source/components/popover/popover.coffee +562 -0
- data/source/components/popover/popover.erb +21 -0
- data/source/components/popover/popover.js +0 -0
- data/source/components/popover/popover.scss +139 -0
- data/source/components/range/range.scss +78 -0
- data/source/components/resizable/package.json +3 -0
- data/source/components/resizable/resizable.erb +30 -0
- data/source/components/resizable/resizable.js +250 -0
- data/source/components/resizable/resizable.scss +245 -0
- data/source/components/resizable/size_buttons.js +249 -0
- data/source/components/scroll_container/package.json +3 -0
- data/source/components/scroll_container/scroll-container.scss +4 -0
- data/source/components/scroll_container/scroll_container.js +24 -0
- data/source/components/section/section.scss +99 -0
- data/source/components/select/package.json +3 -0
- data/source/components/select/select.erb +21 -0
- data/source/components/select/select.js +35 -0
- data/source/components/select/select.scss +163 -0
- data/source/components/table/package.json +3 -0
- data/source/components/table/table.erb +16 -0
- data/source/components/table/table.js +351 -0
- data/source/components/table/table.scss +236 -0
- data/source/components/tablist/package.json +3 -0
- data/source/components/tablist/tablist.erb +13 -0
- data/source/components/tablist/tablist.js +246 -0
- data/source/components/tablist/tablist.scss +191 -0
- data/source/components/tablist/tablist_panel.erb +14 -0
- data/source/components/tablist/tablist_tab.erb +20 -0
- data/source/components/toggle/package.json +3 -0
- data/source/components/toggle/toggle.erb +11 -0
- data/source/components/toggle/toggle.js +211 -0
- data/source/components/toggle/toggle_container.erb +30 -0
- data/source/components/vertical_spacer/vertical-spacer.scss +3 -0
- data/source/components/vertical_stack/vertical-stack.scss +19 -0
- data/source/components/xray/package.json +3 -0
- data/source/components/xray/xray.erb +50 -0
- data/source/components/xray/xray.js +123 -0
- data/source/components/xray/xray.scss +79 -0
- data/source/foundation/app/app.js +15 -0
- data/source/foundation/app/package.json +3 -0
- data/source/pattern-library-demo.scss +13 -0
- data/source/pattern-library.scss +13 -0
- data/source/pattern_library.js +8 -0
- data/source/pattern_library_demo.js +8 -0
- data/source/structures/index.js +11 -0
- data/source/structures/sidebar/package.json +3 -0
- data/source/structures/sidebar/sidebar.js +69 -0
- data/source/structures/sidebar/sidebar.scss +79 -0
- data/source/utilities/builder/builder.js +138 -0
- data/source/utilities/builder/package.json +3 -0
- data/source/utilities/client/client.js +7 -0
- data/source/utilities/client/package.json +3 -0
- data/source/utilities/colors/colors.scss +112 -0
- data/source/utilities/defaults/defaults.scss +38 -0
- data/source/utilities/dom_cache/dom_cache.js +24 -0
- data/source/utilities/dom_cache/package.json +3 -0
- data/source/utilities/events/events.js +25 -0
- data/source/utilities/events/package.json +3 -0
- data/source/utilities/font_sizes/font-sizes.scss +85 -0
- data/source/utilities/foundation/a11y.scss +10 -0
- data/source/utilities/foundation/base.scss +29 -0
- data/source/utilities/foundation/icon.scss +114 -0
- data/source/utilities/foundation/layout.scss +67 -0
- data/source/utilities/foundation/page.scss +39 -0
- data/source/utilities/foundation/type.scss +208 -0
- data/source/utilities/functions/functions.scss +127 -0
- data/source/utilities/keycodes/keycodes.js +23 -0
- data/source/utilities/keycodes/package.json +3 -0
- data/source/utilities/markup/markup.js +90 -0
- data/source/utilities/markup/package.json +3 -0
- data/source/utilities/media/media.scss +172 -0
- data/source/utilities/mixins/mixins.scss +89 -0
- data/source/utilities/naming_convention/naming_convention.js +3 -0
- data/source/utilities/naming_convention/package.json +3 -0
- data/source/utilities/numbers/numbers.js +14 -0
- data/source/utilities/numbers/package.json +3 -0
- data/source/utilities/painting/package.json +3 -0
- data/source/utilities/painting/painting.js +7 -0
- data/source/utilities/pattern/package.json +3 -0
- data/source/utilities/pattern/pattern.js +50 -0
- data/source/utilities/query_string/package.json +3 -0
- data/source/utilities/query_string/query_string.js +24 -0
- data/source/utilities/template/package.json +3 -0
- data/source/utilities/template/template.js +10 -0
- data/source/utilities/text_range/package.json +3 -0
- data/source/utilities/text_range/text_range.js +30 -0
- data/source/utilities/ui_events/package.json +3 -0
- data/source/utilities/ui_events/ui_events.js +85 -0
- data/source/utilities/variables/variables.scss +18 -0
- data/source/utilities/z_indexes/z-indexes.scss +88 -0
- data/source/vendor/array_includes.js +28 -0
- data/source/vendor/highlight.js +1142 -0
- data/source/vendor/index.js +1 -0
- data/source/vendor/matrix.js +399 -0
- data/source/vendor/query_string.js +66 -0
- data/spec/assets/.eslintrc +9 -0
- data/spec/assets/spec_fixture.js +33 -0
- data/spec/assets/spec_helper.js +19 -0
- data/spec/lib/components/base_component_spec.rb +156 -0
- data/spec/lib/components_spec.rb +30 -0
- data/spec/lib/helpers/ui_helper_spec.rb +62 -0
- data/spec/lib/theme_spec.rb +25 -0
- data/spec/spec_helper.rb +15 -0
- data/tasks/gulp/.eslintrc +6 -0
- data/tasks/gulp/browser_sync.js +8 -0
- data/tasks/gulp/code_quality/scripts.js +10 -0
- data/tasks/gulp/config/index.js +116 -0
- data/tasks/gulp/minify/scripts.js +13 -0
- data/tasks/gulp/minify/styles.js +13 -0
- data/tasks/gulp/pattern_library/index.js +5 -0
- data/tasks/gulp/pattern_library/scripts.js +10 -0
- data/tasks/gulp/pattern_library/styles.js +10 -0
- data/tasks/gulp/scripts.js +8 -0
- data/tasks/gulp/spec/scripts.js +11 -0
- data/tasks/gulp/styles.js +17 -0
- data/tasks/gulp/utilities/babel/relative_require.js +22 -0
- data/tasks/gulp/utilities/babel/spec_helper.js +20 -0
- data/tasks/gulp/utilities/browserify_bundler.js +22 -0
- data/tasks/gulp/utilities/handle_errors.js +13 -0
- data/tasks/gulp/watch.js +9 -0
- data/tasks/rake/rspec.rake +7 -0
- data/tasks/rake/rubocop.rake +8 -0
- data/tasks/rake/templates.rake +50 -0
- 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,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,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,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
|
+
}
|