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
@@ -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
|
data/spec/spec_helper.rb
ADDED
@@ -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,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,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,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
|
+
};
|
data/tasks/gulp/watch.js
ADDED
@@ -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,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
|
+
|