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,20 @@
|
|
1
|
+
<%
|
2
|
+
tab.configure do |config|
|
3
|
+
config.defaults text: "Tab",
|
4
|
+
active?: false,
|
5
|
+
id: "tab",
|
6
|
+
panel_id: "tab_panel",
|
7
|
+
icon: nil
|
8
|
+
|
9
|
+
config.classes(base: "tablist__tab")
|
10
|
+
config.conditional_classes(if: :active?, base: "tablist__tab--is-active")
|
11
|
+
end
|
12
|
+
%>
|
13
|
+
|
14
|
+
<a class="<%= tab.classes_for(:base) %>" role="tab" tabindex="<%= tab.active? ? 0 : -1 %>" aria-controls="<%= tab.panel_id %>" href="#<%= tab.panel_id %>" id="<%= tab.id %>">
|
15
|
+
<% if tab.icon %>
|
16
|
+
<%= docks_icon(tab.icon, style: :stroke) %>
|
17
|
+
<% end %>
|
18
|
+
|
19
|
+
<span class="tablist__tab__text"><%= tab.text %></span>
|
20
|
+
</a>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<% variation = toggle.variation %>
|
2
|
+
|
3
|
+
<div class="toggle" id="toggle--<%= variation.name %>" role="button" tabindex="0" data-variation-name="<%= variation.name %>">
|
4
|
+
<div class="toggle__main">
|
5
|
+
<span class="toggle__type"><%= variation.symbol_type %></span>
|
6
|
+
<% base_toggle = Docks.config.naming_convention.toggle(variation.name) %>
|
7
|
+
<span class="toggle__name"><%= variation.name.gsub(base_toggle, "<span class='helper--visually-hidden'>#{base_toggle}</span>") %></span>
|
8
|
+
</div>
|
9
|
+
|
10
|
+
<span class="toggle__info">?</span>
|
11
|
+
</div>
|
@@ -0,0 +1,211 @@
|
|
1
|
+
import Modal from "~components/modal";
|
2
|
+
import { Communicator } from "~components/iframe";
|
3
|
+
import Keycodes from "~utilities/keycodes";
|
4
|
+
import Pattern from "~utilities/pattern";
|
5
|
+
import Builder from "~utilities/builder";
|
6
|
+
import Events from "~utilities/events";
|
7
|
+
import { naming_convention } from "~utilities/naming_convention";
|
8
|
+
|
9
|
+
const classes = {
|
10
|
+
root: "toggle",
|
11
|
+
info: "toggle__info",
|
12
|
+
container: "toggle__container"
|
13
|
+
};
|
14
|
+
|
15
|
+
const states = {
|
16
|
+
root: {
|
17
|
+
locked: "toggle--is-locked",
|
18
|
+
active: "toggle--is-active",
|
19
|
+
partially_active: "toggle--is-partially-active"
|
20
|
+
}
|
21
|
+
};
|
22
|
+
|
23
|
+
const attrs = {
|
24
|
+
name: "data-variation-name"
|
25
|
+
};
|
26
|
+
|
27
|
+
var Toggle, Toggles,
|
28
|
+
handle_keypress, info_click, toggle_click, update_toggle_state;
|
29
|
+
|
30
|
+
//*
|
31
|
+
// Listens and responds to keypress events while focused on a toggle. If either
|
32
|
+
// space or enter are pressed, the toggle will be toggled as if it had been
|
33
|
+
// clicked on. This allows for keyboard-only navigation and manipulation of
|
34
|
+
// toggles.
|
35
|
+
//
|
36
|
+
// @param {Object} event - The `keypress` event.
|
37
|
+
// @private
|
38
|
+
|
39
|
+
handle_keypress = (event) => {
|
40
|
+
if(![Keycodes.ENTER, Keycodes.SPACE].include(event.which)) { return; }
|
41
|
+
event.preventDefault();
|
42
|
+
update_toggle_state(event.target);
|
43
|
+
};
|
44
|
+
|
45
|
+
//*
|
46
|
+
// Listens for clicks on the information icon in the toggle and activates the
|
47
|
+
// modal to present details on that variation.
|
48
|
+
//
|
49
|
+
// @param {Object} event - The `click` event.
|
50
|
+
// @private
|
51
|
+
|
52
|
+
info_click = (event) => {
|
53
|
+
var variation_name;
|
54
|
+
|
55
|
+
// Prevent the click event from propagating to the toggle.
|
56
|
+
event.stopImmediatePropagation();
|
57
|
+
event.preventDefault();
|
58
|
+
|
59
|
+
variation_name = $(event.target).closest(`.${classes.root}`)[0].getAttribute(attrs.name);
|
60
|
+
Modal.present(Pattern.find(variation_name, { search_all: true }));
|
61
|
+
};
|
62
|
+
|
63
|
+
//*
|
64
|
+
// Listens for click events on a toggle and updates the state of the toggle
|
65
|
+
// appropriately.
|
66
|
+
//
|
67
|
+
// @param {Object} event - The `click` event.
|
68
|
+
// @private
|
69
|
+
|
70
|
+
toggle_click = (event) => {
|
71
|
+
event.preventDefault();
|
72
|
+
update_toggle_state(event.target);
|
73
|
+
};
|
74
|
+
|
75
|
+
//*
|
76
|
+
// Updates the status of the passed changer. If the `add` attribute of the
|
77
|
+
// `option` argument is defined, a truthy value will activate the changer
|
78
|
+
// and a falsey one will deactivate it. Otherwise, the changer will simply
|
79
|
+
// have its state toggled.
|
80
|
+
//
|
81
|
+
// @private
|
82
|
+
//
|
83
|
+
// @param {HTMLElement, Toggle, String} toggle - The whose state should be
|
84
|
+
// updated. Anything that can be resolved to a `Toggle` via `Toggle.for`
|
85
|
+
// can be used here, including a `Toggle`, the `HTMLElement` that is the root
|
86
|
+
// of the toggle, or a `String` that is the name of a toggle.
|
87
|
+
//
|
88
|
+
// @param {Object} [options = {}] - The options to use for this update. Currently,
|
89
|
+
// only the `add` option is read to determine whether the toggle should be
|
90
|
+
// activated or deactivated. If no `options` argument is passed, the `toggle`
|
91
|
+
// will simply be toggled.
|
92
|
+
|
93
|
+
update_toggle_state = (toggle, options = {}) => {
|
94
|
+
var toggle_node, all_toggles, variation, add, currently_active,
|
95
|
+
activate_with, activate_with_toggle, preclude;
|
96
|
+
|
97
|
+
toggle = Toggle.for(toggle);
|
98
|
+
if(toggle.locked) { return; }
|
99
|
+
toggle_node = toggle.root;
|
100
|
+
toggle.lock();
|
101
|
+
|
102
|
+
all_toggles = Toggles.for(toggle_node);
|
103
|
+
variation = Pattern.for(toggle_node.getAttribute(attrs.name), { search_all: true });
|
104
|
+
add = (options.add ? !!options.add : !toggle.active);
|
105
|
+
|
106
|
+
// Update the state of all variations that should be activated with the
|
107
|
+
// current toggle.
|
108
|
+
for(activate_with of ((variation && variation.activate_with) || [])) {
|
109
|
+
if(naming_convention.is_component(variation)) { continue; }
|
110
|
+
|
111
|
+
activate_with_toggle = Toggle.for(activate_with);
|
112
|
+
|
113
|
+
if(activate_with_toggle) {
|
114
|
+
currently_active = activate_with_toggle.active;
|
115
|
+
if((currently_active && !add) || (!currently_active && add)) {
|
116
|
+
update_toggle_state(activate_with_toggle, { add: add });
|
117
|
+
}
|
118
|
+
} else {
|
119
|
+
all_toggles.trigger({
|
120
|
+
add,
|
121
|
+
details: {
|
122
|
+
for: naming_convention.component_name(activate_with),
|
123
|
+
name: activate_with
|
124
|
+
}
|
125
|
+
});
|
126
|
+
}
|
127
|
+
}
|
128
|
+
|
129
|
+
// TODO: something about filters.
|
130
|
+
if(add) {
|
131
|
+
toggle.activate();
|
132
|
+
|
133
|
+
// Deactivates any currently active variations that are precluded from being
|
134
|
+
// active with the current variation.
|
135
|
+
for(preclude of ((variation && variation.precludes) || [])) {
|
136
|
+
preclude = Toggle.for(preclude);
|
137
|
+
if(preclude && preclude.active) { update_toggle_state(preclude, { add: false }); }
|
138
|
+
}
|
139
|
+
} else {
|
140
|
+
toggle.deactivate();
|
141
|
+
}
|
142
|
+
|
143
|
+
toggle.unlock();
|
144
|
+
all_toggles.trigger({ add, details: variation });
|
145
|
+
};
|
146
|
+
|
147
|
+
//*
|
148
|
+
// A constructor around a single `Toggle`. The returned object gives the ability
|
149
|
+
// to update the toggle's state, locking or unlocking the toggle from further
|
150
|
+
// changes, and getting the current state of the toggle.
|
151
|
+
//
|
152
|
+
// @param {HTMLElement} root - The root node of a toggle.
|
153
|
+
// @return {Toggle}
|
154
|
+
|
155
|
+
Toggle = (root) => {
|
156
|
+
if(!root) { return null; }
|
157
|
+
if(root instanceof Toggle) { return root; }
|
158
|
+
|
159
|
+
return {
|
160
|
+
root,
|
161
|
+
lock() { root.classList.add(states.root.locked); },
|
162
|
+
unlock() { root.classList.remove(states.root.locked); },
|
163
|
+
activate() { root.classList.add(states.root.active); },
|
164
|
+
deactivate() { root.classList.remove(states.root.active); },
|
165
|
+
get is_locked() { return root.classList.contains(states.root.locked); },
|
166
|
+
get is_active() {
|
167
|
+
return root.classList.contains(states.root.active) ||
|
168
|
+
root.classList.contains(states.root.partially_active);
|
169
|
+
},
|
170
|
+
constructor: Toggle
|
171
|
+
};
|
172
|
+
};
|
173
|
+
|
174
|
+
//*
|
175
|
+
// Gets the toggle for the passed variation.
|
176
|
+
//
|
177
|
+
// @param {Toggle, String, HTMLElement} variation - The source of the desired
|
178
|
+
// `Toggle` — either as the HTMLElement that roots the toggle, a `Toggle` (which
|
179
|
+
// is returned as-is) or a `String` that is the name of a toggle.
|
180
|
+
//
|
181
|
+
// @return {Toggle}
|
182
|
+
|
183
|
+
Toggle.for = (variation) => {
|
184
|
+
if(variation instanceof Toggle) {
|
185
|
+
return variation;
|
186
|
+
} else if(typeof variation === "string") {
|
187
|
+
return Toggle(document.querySelector(`[${attrs.name}='${variation.name}']`));
|
188
|
+
} else {
|
189
|
+
return Toggle($(variation).closest(`.${classes.root}`)[0]);
|
190
|
+
}
|
191
|
+
};
|
192
|
+
|
193
|
+
Toggles = (root) => {
|
194
|
+
var communicator = Communicator();
|
195
|
+
communicator.register.from_node(root);
|
196
|
+
|
197
|
+
return {
|
198
|
+
trigger(...args) { communicator.trigger(Events.types.class_change, ...args); }
|
199
|
+
};
|
200
|
+
};
|
201
|
+
|
202
|
+
Toggles.init = () => {
|
203
|
+
$(document)
|
204
|
+
.on("keypress", `.${classes.root}`, handle_keypress)
|
205
|
+
.on("click", `.${classes.info}`, info_click)
|
206
|
+
.on("click", `.${classes.root}`, toggle_click);
|
207
|
+
|
208
|
+
Builder.build(Toggles, { name: classes.container, cache: true });
|
209
|
+
};
|
210
|
+
|
211
|
+
export default Toggles;
|
@@ -0,0 +1,30 @@
|
|
1
|
+
<%
|
2
|
+
toggle_container.configure do |config|
|
3
|
+
config.defaults variations: {},
|
4
|
+
base_class: "class",
|
5
|
+
group_by: :base_class
|
6
|
+
end
|
7
|
+
%>
|
8
|
+
|
9
|
+
<% unless toggle_container.variations.empty? %>
|
10
|
+
<div class="toggle__container" data-iframe-id="<%= toggle_container.base_class %>">
|
11
|
+
<% toggle_container.variations.each do |base_class, variations| %>
|
12
|
+
<% if toggle_container.group_by == :base_class %>
|
13
|
+
<div class="toggle__toggle_container-group">
|
14
|
+
<h3 class="toggle__heading"><%= base_class %></h3>
|
15
|
+
|
16
|
+
<section class="toggle__scroller">
|
17
|
+
<% variations.each do |variation| %>
|
18
|
+
<%= docks_toggle(variation: variation) %>
|
19
|
+
<% end %>
|
20
|
+
</section>
|
21
|
+
</div>
|
22
|
+
|
23
|
+
<% else %>
|
24
|
+
<% variations.each do |variation| %>
|
25
|
+
<%= docks_toggle(variation: variation) %>
|
26
|
+
<% end %>
|
27
|
+
<% end %>
|
28
|
+
<% end %>
|
29
|
+
</div>
|
30
|
+
<% end %>
|
@@ -0,0 +1,19 @@
|
|
1
|
+
.vertical-stack {
|
2
|
+
display: flex;
|
3
|
+
flex-direction: column;
|
4
|
+
align-self: stretch;
|
5
|
+
width: 100%;
|
6
|
+
}
|
7
|
+
|
8
|
+
.vertical-stack__item {
|
9
|
+
flex: 1 1 0px;
|
10
|
+
max-width: 100%;
|
11
|
+
overflow-x: hidden;
|
12
|
+
overflow-y: auto;
|
13
|
+
-webkit-overflow-scrolling: touch;
|
14
|
+
}
|
15
|
+
|
16
|
+
.vertical-stack__item--fixed {
|
17
|
+
flex: 0 0 auto;
|
18
|
+
overflow: visible;
|
19
|
+
}
|
@@ -0,0 +1,50 @@
|
|
1
|
+
<div class="x-ray">
|
2
|
+
<header class="page-header">
|
3
|
+
<div class="grid grid--vertically-centered">
|
4
|
+
<div class="grid__item">
|
5
|
+
<h1 class="type type--heading type--heading-1"></h1>
|
6
|
+
</div>
|
7
|
+
|
8
|
+
<div class="grid__item grid__item--no-flex">
|
9
|
+
<button class="x-ray__closer" data-xray-dismiss="true">
|
10
|
+
<span class="helper--visually-hidden">Close X-ray</span>
|
11
|
+
<div class="icon icon--action icon--close"></div>
|
12
|
+
</button>
|
13
|
+
</div>
|
14
|
+
</div>
|
15
|
+
</header>
|
16
|
+
|
17
|
+
<div class="x-ray__content">
|
18
|
+
<div class="x-ray__diagram">
|
19
|
+
<%= docks_exploded %>
|
20
|
+
</div>
|
21
|
+
|
22
|
+
<aside class="x-ray__list"></aside>
|
23
|
+
<div class="x-ray__details"></div>
|
24
|
+
</div>
|
25
|
+
|
26
|
+
<script type="text/template" data-xray-template="list">
|
27
|
+
<ul class="link-list"></ul>
|
28
|
+
</script>
|
29
|
+
|
30
|
+
<script type="text/template" data-xray-template="details">
|
31
|
+
<div class="content">
|
32
|
+
<div class="type type--heading type--heading-3">
|
33
|
+
<span class="x-ray__details__tagname type--code"></span>
|
34
|
+
<span class="x-ray__details__class type--code"></span>
|
35
|
+
</div>
|
36
|
+
|
37
|
+
<div class="type-container">
|
38
|
+
<div class="x-ray__details__description"></div>
|
39
|
+
</div>
|
40
|
+
|
41
|
+
<div class="x-ray__details__variations">
|
42
|
+
<h4 class="type type--heading type--heading-4">Variations</h4>
|
43
|
+
<div class="type-container type-container--small">
|
44
|
+
<ul class="unstyled-list"></ul>
|
45
|
+
</div>
|
46
|
+
</div>
|
47
|
+
</div>
|
48
|
+
</script>
|
49
|
+
</div>
|
50
|
+
|
@@ -0,0 +1,123 @@
|
|
1
|
+
import Template from "~utilities/template";
|
2
|
+
import Pattern from "~utilities/pattern";
|
3
|
+
import Events from "~utilities/events";
|
4
|
+
import Exploded, { events as exploded_events } from "~components/exploded";
|
5
|
+
import { Communicator } from "~components/iframe";
|
6
|
+
|
7
|
+
const classes = {
|
8
|
+
root: "x-ray",
|
9
|
+
details: "x-ray__details",
|
10
|
+
list: "x-ray__list"
|
11
|
+
};
|
12
|
+
|
13
|
+
const states = {
|
14
|
+
root: { active: "x-ray--is-active" }
|
15
|
+
};
|
16
|
+
|
17
|
+
const helpers = {
|
18
|
+
active: "x-ray__helpers--x-ray-is-active"
|
19
|
+
};
|
20
|
+
|
21
|
+
const attrs = {
|
22
|
+
dismiss: "data-xray-dismiss",
|
23
|
+
present: "data-xray-present",
|
24
|
+
template: "data-xray-template"
|
25
|
+
};
|
26
|
+
|
27
|
+
const template_names = {
|
28
|
+
details: "details",
|
29
|
+
list: "list"
|
30
|
+
};
|
31
|
+
|
32
|
+
var Xray,
|
33
|
+
structure, exploded, templates, component,
|
34
|
+
hook_up_iframe_communication, communicator,
|
35
|
+
toggle, present, dismiss, set_component, set_details;
|
36
|
+
|
37
|
+
hook_up_iframe_communication = () => {
|
38
|
+
var registered;
|
39
|
+
|
40
|
+
communicator = Communicator();
|
41
|
+
registered = communicator.register.from_node(structure.root);
|
42
|
+
|
43
|
+
if(!registered) { return; }
|
44
|
+
|
45
|
+
communicator.on(Events.types.markup_request, (event) => {
|
46
|
+
exploded.set_markup(event.markup);
|
47
|
+
});
|
48
|
+
};
|
49
|
+
|
50
|
+
set_component = (component_name) => {
|
51
|
+
component = Pattern.find(component_name, { search_all: true });
|
52
|
+
structure.heading.innerHTML = component.title ? component.title : `<code class='type--code'>${component_name}</code>`;
|
53
|
+
structure.list.innerHTML = Template.render(templates.list, {
|
54
|
+
components: [component_name].concat(component.subcomponent || [])
|
55
|
+
});
|
56
|
+
set_details(component);
|
57
|
+
};
|
58
|
+
|
59
|
+
set_details = (symbol, other_content = {}) => {
|
60
|
+
var options = Object.assign(other_content, symbol);
|
61
|
+
structure.details.innerHTML = Template.render(templates.details, options);
|
62
|
+
};
|
63
|
+
|
64
|
+
present = () => {
|
65
|
+
communicator.trigger(Events.types.markup_request);
|
66
|
+
structure.root.classList.add(states.root.active);
|
67
|
+
document.body.classList.add(helpers.active);
|
68
|
+
};
|
69
|
+
|
70
|
+
dismiss = () => {
|
71
|
+
exploded.set_markup();
|
72
|
+
structure.root.classList.remove(states.root.active);
|
73
|
+
document.body.classList.remove(helpers.active);
|
74
|
+
};
|
75
|
+
|
76
|
+
toggle = () => {
|
77
|
+
return (structure.root.classList.contains(states.root.active) ? dismiss() : present());
|
78
|
+
};
|
79
|
+
|
80
|
+
Xray = {
|
81
|
+
toggle,
|
82
|
+
present,
|
83
|
+
dismiss,
|
84
|
+
|
85
|
+
init() {
|
86
|
+
var root = document.querySelector(`.${classes.root}`);
|
87
|
+
if(!root) { return; }
|
88
|
+
|
89
|
+
exploded = Exploded.within(root)[0];
|
90
|
+
|
91
|
+
structure = {
|
92
|
+
root,
|
93
|
+
heading: root.querySelector(".type-heading"),
|
94
|
+
details: root.querySelector(`.${classes.details}`),
|
95
|
+
list: root.querySelector(`.${classes.list}`)
|
96
|
+
};
|
97
|
+
|
98
|
+
templates = {
|
99
|
+
details: root.querySelector(`[${attrs.template}='${template_names.details}']`),
|
100
|
+
list: root.querySelector(`[${attrs.template}='${template_names.list}']`)
|
101
|
+
};
|
102
|
+
|
103
|
+
hook_up_iframe_communication();
|
104
|
+
|
105
|
+
exploded.on(exploded_events.pane_selected, (event) => {
|
106
|
+
component = Pattern.find(event.component, { search_all: true });
|
107
|
+
if(component) { set_details(component, { tagname: event.node.tagName }); }
|
108
|
+
});
|
109
|
+
|
110
|
+
$(root)
|
111
|
+
.on("click", `[${attrs.dismiss}]`, dismiss)
|
112
|
+
.on("click", "[href^='#']", (event) => {
|
113
|
+
event.preventDefault();
|
114
|
+
exploded.select_component(event.target.textContent);
|
115
|
+
});
|
116
|
+
|
117
|
+
$(document).on("click", `[${attrs.present}]`, (event) => {
|
118
|
+
set_component(event.getAttribute(attrs.present));
|
119
|
+
});
|
120
|
+
}
|
121
|
+
};
|
122
|
+
|
123
|
+
export default Xray;
|
@@ -0,0 +1,79 @@
|
|
1
|
+
body {
|
2
|
+
position: relative;
|
3
|
+
|
4
|
+
&.x-ray__helpers--x-ray-is-active {
|
5
|
+
overflow: hidden;
|
6
|
+
}
|
7
|
+
}
|
8
|
+
|
9
|
+
.x-ray {
|
10
|
+
background: ui-color(white);
|
11
|
+
position: absolute;
|
12
|
+
top: 0; bottom: 0;
|
13
|
+
left: 0; right: 0;
|
14
|
+
z-index: -1;
|
15
|
+
overflow-x: hidden;
|
16
|
+
overflow-y: auto;
|
17
|
+
opacity: 0;
|
18
|
+
transition: opacity 0.3s ease;
|
19
|
+
min-height: 100%;
|
20
|
+
|
21
|
+
.page-header {
|
22
|
+
flex: 0 0 auto;
|
23
|
+
}
|
24
|
+
}
|
25
|
+
|
26
|
+
.x-ray--is-active {
|
27
|
+
opacity: 1;
|
28
|
+
z-index: 1200;
|
29
|
+
}
|
30
|
+
|
31
|
+
|
32
|
+
|
33
|
+
.x-ray__content {
|
34
|
+
padding-bottom: 3rem;
|
35
|
+
}
|
36
|
+
|
37
|
+
|
38
|
+
.x-ray__list {
|
39
|
+
padding: default(spacing);
|
40
|
+
background-color: ui-color(gray, light);
|
41
|
+
}
|
42
|
+
|
43
|
+
.x-ray__closer {
|
44
|
+
background: transparent;
|
45
|
+
border: none;
|
46
|
+
padding: 0;
|
47
|
+
appearance: none;
|
48
|
+
}
|
49
|
+
|
50
|
+
|
51
|
+
|
52
|
+
.x-ray__diagram {
|
53
|
+
padding: default(spacing) 0 0;
|
54
|
+
background: ui-color(gray);
|
55
|
+
}
|
56
|
+
|
57
|
+
|
58
|
+
.x-ray__details {
|
59
|
+
display: none;
|
60
|
+
}
|
61
|
+
|
62
|
+
.x-ray__details--is-visible {
|
63
|
+
display: block;
|
64
|
+
}
|
65
|
+
|
66
|
+
.x-ray__details__tagname {
|
67
|
+
display: inline-block;
|
68
|
+
font-size: 0.75em;
|
69
|
+
background-color: ui-color(gray, light);
|
70
|
+
padding: 0.3em 0.4em 0.2em;
|
71
|
+
@include default(border-radius);
|
72
|
+
line-height: 1;
|
73
|
+
color: ui-color(gray, darker);
|
74
|
+
margin-right: 0.25rem;
|
75
|
+
}
|
76
|
+
|
77
|
+
.x-ray__details__description {
|
78
|
+
margin-bottom: (2 * default(spacing));
|
79
|
+
}
|
@@ -0,0 +1,13 @@
|
|
1
|
+
@import "utilities/functions/*";
|
2
|
+
@import "utilities/mixins/*";
|
3
|
+
@import "utilities/variables/*";
|
4
|
+
@import "utilities/colors/*";
|
5
|
+
@import "utilities/font_sizes/*";
|
6
|
+
@import "utilities/z_indexes/*";
|
7
|
+
@import "utilities/media/*";
|
8
|
+
@import "utilities/defaults/*";
|
9
|
+
|
10
|
+
@import "utilities/foundation/*";
|
11
|
+
|
12
|
+
@import "components/**/*";
|
13
|
+
@import "structures/**/*";
|
@@ -0,0 +1,13 @@
|
|
1
|
+
@import "utilities/functions/*";
|
2
|
+
@import "utilities/mixins/*";
|
3
|
+
@import "utilities/variables/*";
|
4
|
+
@import "utilities/colors/*";
|
5
|
+
@import "utilities/font_sizes/*";
|
6
|
+
@import "utilities/z_indexes/*";
|
7
|
+
@import "utilities/media/*";
|
8
|
+
@import "utilities/defaults/*";
|
9
|
+
|
10
|
+
@import "utilities/foundation/*";
|
11
|
+
|
12
|
+
@import "components/**/*";
|
13
|
+
@import "structures/**/*";
|