docks_theme_api 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (237) hide show
  1. checksums.yaml +15 -0
  2. data/.babelrc +4 -0
  3. data/.editorconfig +8 -0
  4. data/.eslintrc +115 -0
  5. data/.gitignore +24 -0
  6. data/.rubocop.yml +20 -0
  7. data/.travis.yml +16 -0
  8. data/Gemfile +4 -0
  9. data/README.md +5 -0
  10. data/Rakefile +3 -0
  11. data/assets/images/icons.svg +63 -0
  12. data/assets/scripts/coffeescript/pattern_library_helpers.coffee +8 -0
  13. data/assets/scripts/javascript/pattern_library_helpers.js +11 -0
  14. data/assets/scripts/pattern_library.js +10380 -0
  15. data/assets/scripts/pattern_library_demo.js +0 -0
  16. data/assets/styles/less/pattern-library-helpers.less +103 -0
  17. data/assets/styles/pattern-library-demo.css +1882 -0
  18. data/assets/styles/pattern-library.css +1882 -0
  19. data/assets/styles/sass/pattern-library-helpers.sass +90 -0
  20. data/assets/styles/scss/pattern-library-helpers.scss +99 -0
  21. data/assets/styles/stylus/pattern-library-helpers.styl +90 -0
  22. data/assets/templates/erb/demo.erb +26 -0
  23. data/assets/templates/erb/layouts/demo.erb +17 -0
  24. data/assets/templates/erb/layouts/pattern.erb +76 -0
  25. data/assets/templates/erb/partials/sidebar.erb +124 -0
  26. data/assets/templates/erb/partials/symbols/class.erb +1 -0
  27. data/assets/templates/erb/partials/symbols/demo.erb +40 -0
  28. data/assets/templates/erb/partials/symbols/factory.erb +70 -0
  29. data/assets/templates/erb/partials/symbols/function.erb +103 -0
  30. data/assets/templates/erb/partials/symbols/mixin.erb +62 -0
  31. data/assets/templates/erb/partials/symbols/variable.erb +59 -0
  32. data/assets/templates/erb/pattern.erb +102 -0
  33. data/assets/templates/haml/demo.haml +14 -0
  34. data/assets/templates/haml/layouts/demo.haml +6 -0
  35. data/assets/templates/haml/layouts/pattern.haml +38 -0
  36. data/assets/templates/haml/partials/sidebar.haml +68 -0
  37. data/assets/templates/haml/partials/symbols/class.haml +1 -0
  38. data/assets/templates/haml/partials/symbols/demo.haml +23 -0
  39. data/assets/templates/haml/partials/symbols/factory.haml +38 -0
  40. data/assets/templates/haml/partials/symbols/function.haml +54 -0
  41. data/assets/templates/haml/partials/symbols/mixin.haml +31 -0
  42. data/assets/templates/haml/partials/symbols/variable.haml +22 -0
  43. data/assets/templates/haml/pattern.haml +54 -0
  44. data/assets/templates/slim/demo.slim +24 -0
  45. data/assets/templates/slim/layouts/demo.slim +5 -0
  46. data/assets/templates/slim/layouts/pattern.slim +48 -0
  47. data/assets/templates/slim/partials/sidebar.slim +112 -0
  48. data/assets/templates/slim/partials/symbols/class.slim +1 -0
  49. data/assets/templates/slim/partials/symbols/demo.slim +30 -0
  50. data/assets/templates/slim/partials/symbols/factory.slim +57 -0
  51. data/assets/templates/slim/partials/symbols/function.slim +81 -0
  52. data/assets/templates/slim/partials/symbols/mixin.slim +45 -0
  53. data/assets/templates/slim/partials/symbols/variable.slim +35 -0
  54. data/assets/templates/slim/pattern.slim +63 -0
  55. data/docks_config.rb +32 -0
  56. data/docks_theme_api.gemspec +37 -0
  57. data/gulpfile.js +88 -0
  58. data/karma.conf.js +6 -0
  59. data/lib/docks_theme_api/components/base_component.rb +99 -0
  60. data/lib/docks_theme_api/components/code_block_component.rb +10 -0
  61. data/lib/docks_theme_api/components/popover_component.rb +15 -0
  62. data/lib/docks_theme_api/components/table_component.rb +34 -0
  63. data/lib/docks_theme_api/components/tablist_component.rb +11 -0
  64. data/lib/docks_theme_api/components.rb +21 -0
  65. data/lib/docks_theme_api/helpers/ui_helper.rb +69 -0
  66. data/lib/docks_theme_api/theme.rb +21 -0
  67. data/lib/docks_theme_api.rb +1 -0
  68. data/package.json +60 -0
  69. data/source/behaviors/filterable/filterable.coffee +353 -0
  70. data/source/behaviors/filterable/filterable.js +0 -0
  71. data/source/behaviors/filterable/filterable.scss +34 -0
  72. data/source/behaviors/filterable/package.json +3 -0
  73. data/source/behaviors/index.js +0 -0
  74. data/source/components/avatar/avatar.erb +20 -0
  75. data/source/components/avatar/avatar.js +142 -0
  76. data/source/components/avatar/avatar.scss +200 -0
  77. data/source/components/avatar/avatar_container.erb +13 -0
  78. data/source/components/avatar/package.json +3 -0
  79. data/source/components/avatar/spec/avatar_spec.js +81 -0
  80. data/source/components/badge/badge.scss +158 -0
  81. data/source/components/button/button.scss +213 -0
  82. data/source/components/card/card.scss +32 -0
  83. data/source/components/code_block/code-block.scss +353 -0
  84. data/source/components/code_block/code_block.erb +95 -0
  85. data/source/components/code_block/code_block.js +444 -0
  86. data/source/components/code_block/package.json +3 -0
  87. data/source/components/code_block/spec/code_block_spec.js +10 -0
  88. data/source/components/demo/demo.js +244 -0
  89. data/source/components/demo/demo.scss +90 -0
  90. data/source/components/demo/package.json +3 -0
  91. data/source/components/exploded/exploded.erb +25 -0
  92. data/source/components/exploded/exploded.js +694 -0
  93. data/source/components/exploded/exploded.scss +166 -0
  94. data/source/components/exploded/package.json +3 -0
  95. data/source/components/field/field.js +24 -0
  96. data/source/components/field/field.scss +101 -0
  97. data/source/components/field/package.json +3 -0
  98. data/source/components/header/header.scss +33 -0
  99. data/source/components/iframe/iframe.erb +12 -0
  100. data/source/components/iframe/iframe.js +381 -0
  101. data/source/components/iframe/package.json +3 -0
  102. data/source/components/index.js +37 -0
  103. data/source/components/inline_group/inline-group.scss +14 -0
  104. data/source/components/internal_link/internal_link.js +49 -0
  105. data/source/components/internal_link/package.json +3 -0
  106. data/source/components/list/list.scss +230 -0
  107. data/source/components/modal/modal.coffee +84 -0
  108. data/source/components/modal/modal.erb +19 -0
  109. data/source/components/modal/modal.js +0 -0
  110. data/source/components/modal/modal.scss +57 -0
  111. data/source/components/modal/package.json +3 -0
  112. data/source/components/notice/notice.scss +48 -0
  113. data/source/components/popover/package.json +3 -0
  114. data/source/components/popover/popover.coffee +562 -0
  115. data/source/components/popover/popover.erb +21 -0
  116. data/source/components/popover/popover.js +0 -0
  117. data/source/components/popover/popover.scss +139 -0
  118. data/source/components/range/range.scss +78 -0
  119. data/source/components/resizable/package.json +3 -0
  120. data/source/components/resizable/resizable.erb +30 -0
  121. data/source/components/resizable/resizable.js +250 -0
  122. data/source/components/resizable/resizable.scss +245 -0
  123. data/source/components/resizable/size_buttons.js +249 -0
  124. data/source/components/scroll_container/package.json +3 -0
  125. data/source/components/scroll_container/scroll-container.scss +4 -0
  126. data/source/components/scroll_container/scroll_container.js +24 -0
  127. data/source/components/section/section.scss +99 -0
  128. data/source/components/select/package.json +3 -0
  129. data/source/components/select/select.erb +21 -0
  130. data/source/components/select/select.js +35 -0
  131. data/source/components/select/select.scss +163 -0
  132. data/source/components/table/package.json +3 -0
  133. data/source/components/table/table.erb +16 -0
  134. data/source/components/table/table.js +351 -0
  135. data/source/components/table/table.scss +236 -0
  136. data/source/components/tablist/package.json +3 -0
  137. data/source/components/tablist/tablist.erb +13 -0
  138. data/source/components/tablist/tablist.js +246 -0
  139. data/source/components/tablist/tablist.scss +191 -0
  140. data/source/components/tablist/tablist_panel.erb +14 -0
  141. data/source/components/tablist/tablist_tab.erb +20 -0
  142. data/source/components/toggle/package.json +3 -0
  143. data/source/components/toggle/toggle.erb +11 -0
  144. data/source/components/toggle/toggle.js +211 -0
  145. data/source/components/toggle/toggle_container.erb +30 -0
  146. data/source/components/vertical_spacer/vertical-spacer.scss +3 -0
  147. data/source/components/vertical_stack/vertical-stack.scss +19 -0
  148. data/source/components/xray/package.json +3 -0
  149. data/source/components/xray/xray.erb +50 -0
  150. data/source/components/xray/xray.js +123 -0
  151. data/source/components/xray/xray.scss +79 -0
  152. data/source/foundation/app/app.js +15 -0
  153. data/source/foundation/app/package.json +3 -0
  154. data/source/pattern-library-demo.scss +13 -0
  155. data/source/pattern-library.scss +13 -0
  156. data/source/pattern_library.js +8 -0
  157. data/source/pattern_library_demo.js +8 -0
  158. data/source/structures/index.js +11 -0
  159. data/source/structures/sidebar/package.json +3 -0
  160. data/source/structures/sidebar/sidebar.js +69 -0
  161. data/source/structures/sidebar/sidebar.scss +79 -0
  162. data/source/utilities/builder/builder.js +138 -0
  163. data/source/utilities/builder/package.json +3 -0
  164. data/source/utilities/client/client.js +7 -0
  165. data/source/utilities/client/package.json +3 -0
  166. data/source/utilities/colors/colors.scss +112 -0
  167. data/source/utilities/defaults/defaults.scss +38 -0
  168. data/source/utilities/dom_cache/dom_cache.js +24 -0
  169. data/source/utilities/dom_cache/package.json +3 -0
  170. data/source/utilities/events/events.js +25 -0
  171. data/source/utilities/events/package.json +3 -0
  172. data/source/utilities/font_sizes/font-sizes.scss +85 -0
  173. data/source/utilities/foundation/a11y.scss +10 -0
  174. data/source/utilities/foundation/base.scss +29 -0
  175. data/source/utilities/foundation/icon.scss +114 -0
  176. data/source/utilities/foundation/layout.scss +67 -0
  177. data/source/utilities/foundation/page.scss +39 -0
  178. data/source/utilities/foundation/type.scss +208 -0
  179. data/source/utilities/functions/functions.scss +127 -0
  180. data/source/utilities/keycodes/keycodes.js +23 -0
  181. data/source/utilities/keycodes/package.json +3 -0
  182. data/source/utilities/markup/markup.js +90 -0
  183. data/source/utilities/markup/package.json +3 -0
  184. data/source/utilities/media/media.scss +172 -0
  185. data/source/utilities/mixins/mixins.scss +89 -0
  186. data/source/utilities/naming_convention/naming_convention.js +3 -0
  187. data/source/utilities/naming_convention/package.json +3 -0
  188. data/source/utilities/numbers/numbers.js +14 -0
  189. data/source/utilities/numbers/package.json +3 -0
  190. data/source/utilities/painting/package.json +3 -0
  191. data/source/utilities/painting/painting.js +7 -0
  192. data/source/utilities/pattern/package.json +3 -0
  193. data/source/utilities/pattern/pattern.js +50 -0
  194. data/source/utilities/query_string/package.json +3 -0
  195. data/source/utilities/query_string/query_string.js +24 -0
  196. data/source/utilities/template/package.json +3 -0
  197. data/source/utilities/template/template.js +10 -0
  198. data/source/utilities/text_range/package.json +3 -0
  199. data/source/utilities/text_range/text_range.js +30 -0
  200. data/source/utilities/ui_events/package.json +3 -0
  201. data/source/utilities/ui_events/ui_events.js +85 -0
  202. data/source/utilities/variables/variables.scss +18 -0
  203. data/source/utilities/z_indexes/z-indexes.scss +88 -0
  204. data/source/vendor/array_includes.js +28 -0
  205. data/source/vendor/highlight.js +1142 -0
  206. data/source/vendor/index.js +1 -0
  207. data/source/vendor/matrix.js +399 -0
  208. data/source/vendor/query_string.js +66 -0
  209. data/spec/assets/.eslintrc +9 -0
  210. data/spec/assets/spec_fixture.js +33 -0
  211. data/spec/assets/spec_helper.js +19 -0
  212. data/spec/lib/components/base_component_spec.rb +156 -0
  213. data/spec/lib/components_spec.rb +30 -0
  214. data/spec/lib/helpers/ui_helper_spec.rb +62 -0
  215. data/spec/lib/theme_spec.rb +25 -0
  216. data/spec/spec_helper.rb +15 -0
  217. data/tasks/gulp/.eslintrc +6 -0
  218. data/tasks/gulp/browser_sync.js +8 -0
  219. data/tasks/gulp/code_quality/scripts.js +10 -0
  220. data/tasks/gulp/config/index.js +116 -0
  221. data/tasks/gulp/minify/scripts.js +13 -0
  222. data/tasks/gulp/minify/styles.js +13 -0
  223. data/tasks/gulp/pattern_library/index.js +5 -0
  224. data/tasks/gulp/pattern_library/scripts.js +10 -0
  225. data/tasks/gulp/pattern_library/styles.js +10 -0
  226. data/tasks/gulp/scripts.js +8 -0
  227. data/tasks/gulp/spec/scripts.js +11 -0
  228. data/tasks/gulp/styles.js +17 -0
  229. data/tasks/gulp/utilities/babel/relative_require.js +22 -0
  230. data/tasks/gulp/utilities/babel/spec_helper.js +20 -0
  231. data/tasks/gulp/utilities/browserify_bundler.js +22 -0
  232. data/tasks/gulp/utilities/handle_errors.js +13 -0
  233. data/tasks/gulp/watch.js +9 -0
  234. data/tasks/rake/rspec.rake +7 -0
  235. data/tasks/rake/rubocop.rake +8 -0
  236. data/tasks/rake/templates.rake +50 -0
  237. metadata +470 -0
@@ -0,0 +1,32 @@
1
+ // ___ ___ ___ _____
2
+ // / /\ / /\ / /\ / /::\
3
+ // / /:/ / /::\ / /::\ / /:/\:\
4
+ // / /:/ / /:/\:\ / /:/\:\ / /:/ \:\
5
+ // / /:/ ___ / /:/~/::\ / /:/~/:/ /__/:/ \__\:|
6
+ // /__/:/ / /\/__/:/ /:/\:\/__/:/ /:/__\ \:\ / /:/
7
+ // \ \:\ / /:/\ \:\/:/__\/\ \:\/:::::/\ \:\ /:/
8
+ // \ \:\ /:/ \ \::/ \ \::/~~~~ \ \:\/:/
9
+ // \ \:\/:/ \ \:\ \ \:\ \ \::/
10
+ // \ \::/ \ \:\ \ \:\ \__\/
11
+ // \__\/ \__\/ \__\/
12
+ //
13
+ //*
14
+ // @pattern Card
15
+ //
16
+ // A simple, clean container for content that is to appear on an area with a
17
+ // colored background but that requires a completely neutral background to
18
+ // appear properly.
19
+ //
20
+ // @since 1.0.0
21
+
22
+ //*
23
+ // @markup
24
+ // <div class="card">
25
+ // <div style="height: 1rem; width: 1rem; margin: 2rem auto;"></div>
26
+ // </div>
27
+
28
+ .card {
29
+ background-color: color(white);
30
+ border-radius: default(border-radius);
31
+ overflow: hidden;
32
+ }
@@ -0,0 +1,353 @@
1
+ // ___ ___ _____ ___
2
+ // / /\ / /\ / /::\ / /\
3
+ // / /:/ / /::\ / /:/\:\ / /:/_
4
+ // / /:/ / /:/\:\ / /:/ \:\ / /:/ /\
5
+ // / /:/ ___ / /:/ \:\/__/:/ \__\:|/ /:/ /:/_
6
+ // /__/:/ / /\/__/:/ \__\:\ \:\ / /:/__/:/ /:/ /\
7
+ // \ \:\ / /:/\ \:\ / /:/\ \:\ /:/\ \:\/:/ /:/
8
+ // \ \:\ /:/ \ \:\ /:/ \ \:\/:/ \ \::/ /:/
9
+ // \ \:\/:/ \ \:\/:/ \ \::/ \ \:\/:/
10
+ // \ \::/ \ \::/ \__\/ \ \::/
11
+ // \__\/ \__\/ \__\/
12
+
13
+ //*
14
+ // @pattern Code Block
15
+ //
16
+ // This component provides a full-featured container for code demos, including
17
+ // support for multiple languages being shown in a single code block, a
18
+ // rendered demo of the code in the code block, hiding the markup, and
19
+ // switching between different components. The component can be scaled to
20
+ // include as much or as little of these features as desired.
21
+ //
22
+ // This thing needs he following components:
23
+ //
24
+ // - [`button`](@link)
25
+ //
26
+ // - [`resizable::focus_size_button`](@link)
27
+ //
28
+ // - [`exploded::Exploded#set_markup`](@link)
29
+ //
30
+ // The JavaScript part of this component also supports communication with an
31
+ // `iframe`ed demo, in-place updating of helper and rendered markup for
32
+ // components, and, through [highlight.js](https://highlightjs.org/), syntax
33
+ // highlighting of many common languages.
34
+ //
35
+ // @since 1.0.0
36
+
37
+
38
+
39
+ //*
40
+ // @title Code Block
41
+ //
42
+ // This is he overall container for the code block. It's primary purpose is to
43
+ // provide margin above and below the code block, and to provide a hook to
44
+ // make adjustments to many subcomponents through variations such as
45
+ // `code-block--condensed` and `code-block--hidden`.
46
+ //
47
+ // Code blocks can go from the incredibly complex (see the demo above), to
48
+ // more moderate levels of detail — such as a code block that gets rendered
49
+ // inline based on a templating language and a stub, and that outputs an
50
+ // attached demo:
51
+ //
52
+ // ```erb_demo
53
+ // <%= docks_code_block code: "<p style='color: gray;'>Hello world!</p>",
54
+ // language: "erb",
55
+ // demo?: true,
56
+ // hidden?: true %>
57
+ // ```
58
+ //
59
+ // All the way to an incredibly simple code block:
60
+ //
61
+ // ```erb_demo
62
+ // <%= docks_code_block code: "<p class='type type--paragraph'>Hello world!</p>" %>
63
+ // ```
64
+ //
65
+ // @helper
66
+ // <%= docks_code_block code: "<p style='color: gray;'>Hello world!</p>",
67
+ // language: "erb",
68
+ // demo?: true,
69
+ // hidden?: true %>
70
+
71
+ .code-block {
72
+ margin: default(spacing) 0;
73
+ overflow: hidden;
74
+ background: ui-color(gray, light);
75
+ @include default(border-radius);
76
+
77
+ .docks-button { display: none; }
78
+ }
79
+
80
+
81
+ //*
82
+ // A code block with less internal padding and a smaller font size. Use this
83
+ // variant for situations in which the code is secondary or would clash with
84
+ // a more important code block.
85
+ //
86
+ // @set_by :condensed?
87
+
88
+ .code-block--condensed {
89
+ margin-top: half(default(spacing));
90
+
91
+ .code-block__code {
92
+ padding-bottom: half(default(spacing));
93
+ @include font-size(code-block--condensed);
94
+ }
95
+
96
+ &:not(.code-block--with-header) {
97
+ .code-block__code {
98
+ padding-top: half(default(spacing));
99
+ }
100
+ }
101
+ }
102
+
103
+ //*
104
+ // A code block that is full-bleed within the viewport. This will remove any
105
+ // unnecessary border radius and side padding/ borders.
106
+ //
107
+ // @set_by :full_width?
108
+
109
+ .code-block--full-width {
110
+ margin-right: 0;
111
+ margin-left: 0;
112
+ border-radius: 0;
113
+
114
+ .content & {
115
+ margin-left: negative(default(spacing));
116
+ margin-right: negative(default(spacing));
117
+ }
118
+ }
119
+
120
+ //*
121
+ // A code block that has hidden the contained markup and most of its UI. Use
122
+ // this for the initial state of a code block only when it has a demo attached
123
+ // to it, otherwise the code block will appear as a strange strip of color
124
+ // with no indication of its purpose. Hideable code blocks (as set by
125
+ // `:hideable?`) can have this state toggled by clicking on the contained
126
+ // button.
127
+ //
128
+ // When the code block is hidden, all of the UI in the header except for the
129
+ // button to toggle visibility is hidden (that is, tabs to switch between
130
+ // languages and the `select` to switch between demos, if they exist).
131
+ //
132
+ // @set_by :hidden?, CodeBlock#toggle
133
+ // @javascript_action Docks.CodeBlock.for(this).toggle()
134
+
135
+ .code-block--is-hidden {
136
+ &:not(.code-block--with-demo) {
137
+ .code-block__toggler {
138
+ background-color: ui-color(gray, light);
139
+ }
140
+ }
141
+
142
+ .code-block__content {
143
+ height: 0;
144
+ }
145
+ }
146
+
147
+
148
+
149
+ //*
150
+ // This component sits in the `code-block__header` and wraps around both the
151
+ // button to hide the code block and a `select` to switch between sets of
152
+ // code that may be shown in this code block, if either or both are required.
153
+
154
+ .code-block__actions {
155
+ display: flex;
156
+ align-items: center;
157
+ }
158
+
159
+
160
+
161
+ //*
162
+ // The container for all actions related to this code block. If the code block
163
+ // includes both helper and compiled markup, the header will contain the
164
+ // tablist required to switch between them. If the code block is hideable,
165
+ // the header will also include a button to hide it. Finally, if there are
166
+ // multiple sets of code that may be shown in this code block, the header will
167
+ // contain a `select` to switch between them.
168
+
169
+ .code-block__header {
170
+ // box model
171
+ display: flex;
172
+ justify-content: space-between;
173
+ align-items: center;
174
+ padding: half(default(spacing)) default(spacing);
175
+ flex: 0 0 auto !important;
176
+
177
+ // backdrop
178
+ background: ui-color(gray, light);
179
+
180
+ .select,
181
+ .tablist {
182
+ transition: transform 0.2s ease
183
+ }
184
+
185
+ .tablist {
186
+ padding: 0;
187
+ }
188
+ }
189
+
190
+
191
+
192
+ //*
193
+ // This component allows the code to scroll both vertically and horizontally.
194
+
195
+ .code-block__code-container {
196
+ overflow: auto;
197
+ max-height: 100%;
198
+ }
199
+
200
+
201
+ //*
202
+ // The thing that toggles.
203
+
204
+ .code-block__toggler {
205
+ background-color: ui-color(gray);
206
+ width: 100%;
207
+ border: none;
208
+ display: flex;
209
+ align-items: center;
210
+ justify-content: center;
211
+ @include font-size(control);
212
+ padding: half(default(spacing)) 0;
213
+ color: ui-color(gray, darker);
214
+ transition: background-color 0.2s ease;
215
+
216
+ &:focus,
217
+ &:active {
218
+ background-color: ui-color(gray);
219
+ outline: none;
220
+ }
221
+
222
+ > .icon {
223
+ // @include icon--recolor(gray, darker);
224
+ margin-right: half(default(spacing));
225
+ opacity: 0.5;
226
+ }
227
+ }
228
+
229
+ //*
230
+ // Container around the code and header.
231
+
232
+ .code-block__content {
233
+ overflow: hidden;
234
+ transition: height 0.3s ease;
235
+ max-height: 15rem;
236
+ }
237
+
238
+
239
+
240
+ //*
241
+ // The actual code for the associated demo. This is where all of the styles
242
+ // for the syntax highlighting should go. This subcomponent wraps around the
243
+ // code and provides the required side padding so that the code is scrollable
244
+ // when it overflows.
245
+
246
+ .code-block__code {
247
+ // box model
248
+ margin: 0;
249
+ display: inline-block;
250
+
251
+ // Only provide half spacing on the top (with matching half spacing on the
252
+ // bottom of the header).
253
+ padding: half(default(spacing)) default(spacing) default(spacing);
254
+
255
+ // type
256
+ @include font-size(code-block);
257
+ line-height: 1.3;
258
+
259
+ &:focus {
260
+ outline: none;
261
+ }
262
+
263
+ // Needs full padding top when there is no header.
264
+ .code-block:not(.code-block--with-header):not(.code-block--condensed):not(.code-block--with-demo) & {
265
+ padding-top: default(spacing);
266
+ }
267
+
268
+ .code-block--with-demo:not(.code-block--with-header) & {
269
+ padding-top: 0;
270
+ }
271
+
272
+ // Ensure very basic styles for code.
273
+ > code {
274
+ @include type--monospace-font-family;
275
+ padding: 0;
276
+ background-color: transparent;
277
+ font-size: inherit !important;
278
+ border: none;
279
+ }
280
+ }
281
+
282
+
283
+
284
+ // Syntax highlighting styles.
285
+
286
+ .hljs-value,
287
+ .hljs-string,
288
+ .hljs-preprocessor {
289
+ color: color(blue)
290
+ }
291
+
292
+ .hljs-symbol {
293
+ color: color(blue-darker);
294
+ }
295
+
296
+ .hljs-at_rule,
297
+ .hljs-attribute,
298
+ .hljs-keyword {
299
+ color: color(gray-darker);
300
+ }
301
+
302
+ .hljs-comment {
303
+ color: rgba(color(gray-dark), 0.5);
304
+ font-style: italic
305
+ }
306
+
307
+ .hljs-tag,
308
+ .hljs-variable {
309
+ color: color(gray-dark);
310
+ }
311
+
312
+
313
+
314
+
315
+
316
+
317
+
318
+
319
+
320
+
321
+
322
+
323
+
324
+
325
+
326
+
327
+
328
+ .code-block--with-demo {
329
+ .code-block__content {
330
+ padding-top: 0;
331
+
332
+ > .code-block__header {
333
+ padding-top: 0;
334
+ }
335
+ }
336
+ }
337
+
338
+ .code-block__demo {
339
+ padding: default(spacing);
340
+ }
341
+
342
+ .code-block__demo__content {
343
+ display: none;
344
+ }
345
+
346
+ .code-block__iframe {
347
+ height: 10em;
348
+ background-color: color(white);
349
+ border: none;
350
+ width: 100%;
351
+ margin: 0;
352
+ @include default(border-radius);
353
+ }
@@ -0,0 +1,95 @@
1
+ <%
2
+ code_block.configure do |config|
3
+ config.defaults code: nil,
4
+ language: "html",
5
+ hideable?: false,
6
+ full_width?: false,
7
+ hidden?: false,
8
+ demo?: false,
9
+ demo: nil,
10
+ condensed?: false,
11
+ id: nil,
12
+ options: []
13
+
14
+ config.classes base: "code-block",
15
+ header: "code-block__header"
16
+
17
+ config.conditional_classes if: :hidden?, base: "code-block--is-hidden"
18
+ config.conditional_classes if: :full_width?, base: "code-block--full-width"
19
+ config.conditional_classes if: :demo?, base: "code-block--with-demo"
20
+ config.conditional_classes if: :demo, base: "code-block--with-demo"
21
+ config.conditional_classes if: :condensed?, base: "code-block--condensed"
22
+ end
23
+
24
+ code = if code_block.code.kind_of?(Array)
25
+ code_block.code
26
+ else
27
+ [{ code: code_block.code, language: code_block.language }]
28
+ end
29
+
30
+ has_tabs = code.length > 1
31
+ has_demo = code_block.demo? || !code_block.demo.nil?
32
+ has_header = has_tabs || code_block.options.length > 1
33
+ hideable = code_block.hidden? || code_block.hideable? || has_tabs
34
+ id = code_block.id || unique_iframe_id
35
+ %>
36
+
37
+ <div class="<%= component.classes_for(:base) %><%= " code-block--with-header" if has_header %>"<% if has_demo %> data-iframe-id="<%= id %>"<% end %>>
38
+ <% if has_demo %>
39
+ <div class="code-block__demo">
40
+ <%= docks_resizable demo: component.demo || code.last[:code], id: id %>
41
+ </div>
42
+ <% end %>
43
+
44
+ <div class="code-block__content">
45
+ <% if has_header %>
46
+ <header class="<%= component.classes_for(:header) %>">
47
+
48
+ <div>
49
+ <% if has_tabs %>
50
+ <% docks_tablist do |tablist| %>
51
+ <% code.each_with_index do |code_details, index| %>
52
+ <%= tablist.tab(text: code_details[:label], active?: index == 0, id: "language-tab-#{index + 1}--#{id}", panel_id: "language-tab-panel-#{index + 1}--#{id}") %>
53
+ <% end %>
54
+ <% end %>
55
+ <% end %>
56
+ </div>
57
+
58
+ <div class="code-block__actions">
59
+ <% options = component.options %>
60
+ <% if options && options.length > 1 %>
61
+ <%= docks_select code?: true, options: options %>
62
+ <% end %>
63
+
64
+ <button class="docks-button docks-button--dark"><%= component.hidden? ? "Show" : "Hide" %></button>
65
+ </div>
66
+ </header>
67
+ <% end %>
68
+
69
+ <% if has_tabs %>
70
+ <div class="tablist__panel-container">
71
+ <% code.each_with_index do |code_details, index| %>
72
+ <% docks_component("tablist:panel", active?: index == 0, tab_id: "language-tab-#{index + 1}--#{id}", id: "language-tab-panel-#{index + 1}--#{id}") do %>
73
+ <div class="code-block__code-container">
74
+ <pre class="code-block__code" data-code-block-language="<%= code_details[:language] %>" tabindex="-1"><code><%= CGI.escapeHTML(code_details[:code]).strip %></code></pre>
75
+ </div>
76
+ <% end %>
77
+ <% end %>
78
+ </div>
79
+
80
+ <% else %>
81
+ <% code_details = code.first %>
82
+ <div class="code-block__code-container">
83
+ <pre class="code-block__code" data-code-block-language="<%= code_details[:language] %>" tabindex="-1"><code><%= CGI.escapeHTML(code_details[:code]).strip %></code></pre>
84
+ </div>
85
+
86
+ <% end %>
87
+ </div>
88
+
89
+ <% if hideable %>
90
+ <button class="code-block__toggler">
91
+ <%= docks_icon :code, color: :red, size: :medium %>
92
+ <span><%= component.hidden? ? "Show" : "Hide" %></span>
93
+ </button>
94
+ <% end %>
95
+ </div>