shipyard-framework 0.5.81 → 0.5.82
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/assets/javascripts/shipyard.es6 +8 -6
- data/assets/javascripts/shipyard/accordion-trigger.es6 +7 -0
- data/assets/javascripts/shipyard/accordion.es6 +3 -3
- data/assets/javascripts/shipyard/alert-timer.es6 +17 -0
- data/assets/javascripts/shipyard/alert.es6 +21 -6
- data/assets/javascripts/shipyard/core.es6 +66 -21
- data/assets/javascripts/shipyard/hamburger.es6 +4 -3
- data/assets/javascripts/shipyard/modal-trigger.es6 +2 -8
- data/assets/javascripts/shipyard/modal.es6 +4 -7
- data/assets/javascripts/shipyard/scroll.es6 +4 -4
- data/assets/stylesheets/shipyard/core/_animations.sass +6 -0
- data/lib/shipyard-framework/jekyll/tags/alert_tag.rb +11 -7
- data/lib/shipyard-framework/version.rb +1 -1
- data/styleguide/Gemfile.lock +1 -1
- data/styleguide/_assets/js/application.es6 +4 -0
- data/styleguide/_assets/js/views/components/alert-trigger.es6 +20 -0
- data/styleguide/_assets/js/views/utilities/colors.es6 +2 -9
- data/styleguide/components/alerts.md +25 -0
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 27e61f49bdbd5ae0eeba8e929285f5cfaeda2a52df04b9a91a24bbce7b386b20
|
4
|
+
data.tar.gz: 6148ea0dd24160e5416f2990fd36960edfbb901140c689579073ab44a2233236
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: af369bcfb123990a1996bbb1a29f63ecd582f653d06bbacc9b735284cbcb537b00d87a0c6067fd7421c5fe889ffb739ec566e2f51232ceff553575a6a774826f
|
7
|
+
data.tar.gz: 77dcacad8a505853a62b8d2fc09fc56275b89038c807bc1fe423ddefea3df11c935465b3f140b0fc9f56122241f381c4bd8f7b728804599bac11ef1899a69609
|
@@ -2,13 +2,15 @@
|
|
2
2
|
//= require ./shipyard/scroll
|
3
3
|
//= require ./shipyard/hamburger
|
4
4
|
//= require ./shipyard/alert
|
5
|
+
//= require ./shipyard/alert-timer
|
5
6
|
//= require ./shipyard/accordion
|
7
|
+
//= require ./shipyard/accordion-trigger
|
6
8
|
//= require ./shipyard/modal
|
7
9
|
//= require ./shipyard/modal-trigger
|
8
10
|
|
9
|
-
var shipyard = new Shipyard(
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
11
|
+
var shipyard = new Shipyard(document.documentElement)
|
12
|
+
shipyard.windowScroll = new Scroll(window)
|
13
|
+
shipyard.hamburger = new Shipyard('[shipyard=hamburger]', Hamburger)
|
14
|
+
shipyard.alerts = new Shipyard('[shipyard=alert]', Alert)
|
15
|
+
shipyard.modalTriggers = new Shipyard('[modal-trigger]', ModalTrigger)
|
16
|
+
shipyard.accordionTriggers = new Shipyard('[accordion]', AccordionTrigger)
|
@@ -1,10 +1,10 @@
|
|
1
1
|
class Accordion extends Shipyard {
|
2
2
|
constructor (el) {
|
3
3
|
super(el)
|
4
|
-
this.on('
|
4
|
+
this.on('toggle', () => { this.toggle() })
|
5
5
|
}
|
6
6
|
|
7
|
-
toggle (
|
8
|
-
|
7
|
+
toggle () {
|
8
|
+
this.toggleClass('accordion-closed')
|
9
9
|
}
|
10
10
|
}
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class AlertTimer extends Shipyard {
|
2
|
+
constructor (el, alert) {
|
3
|
+
super(el)
|
4
|
+
this.alert = alert
|
5
|
+
this.duration = this.data('duration')
|
6
|
+
if (this.duration) this.css('animation-duration', `${this.duration}s`)
|
7
|
+
this.on('start', () => { this.start() })
|
8
|
+
}
|
9
|
+
|
10
|
+
start () {
|
11
|
+
setTimeout(() => { this.end() }, this.duration * 1000)
|
12
|
+
}
|
13
|
+
|
14
|
+
end () {
|
15
|
+
this.alert.trigger('close')
|
16
|
+
}
|
17
|
+
}
|
@@ -1,13 +1,28 @@
|
|
1
1
|
class Alert extends Shipyard {
|
2
2
|
constructor (el) {
|
3
3
|
super(el)
|
4
|
-
this.
|
5
|
-
|
6
|
-
|
7
|
-
|
4
|
+
this.on('show', (e) => { this.show(e) })
|
5
|
+
this.on('close', (e) => { this.close(e) })
|
6
|
+
this.on('click', '[shipyard=alert-close]', (e) => { this.close(e) })
|
7
|
+
|
8
|
+
// Initiate the Alert Timer if it exists.
|
9
|
+
this.timer = this.child('.alert-timer')
|
10
|
+
if (this.timer) this.timer = new AlertTimer(this.timer, this)
|
11
|
+
}
|
12
|
+
|
13
|
+
options(options) {
|
14
|
+
this.on('afterClose', options.afterClose)
|
15
|
+
}
|
16
|
+
|
17
|
+
show (e) {
|
18
|
+
this.options(e.detail)
|
19
|
+
this.removeClass('alert-closed')
|
20
|
+
if (this.timer) this.timer.trigger('start')
|
8
21
|
}
|
9
22
|
|
10
|
-
close (
|
11
|
-
|
23
|
+
close (e) {
|
24
|
+
e.preventDefault()
|
25
|
+
this.addClass('alert-closed')
|
26
|
+
this.trigger('afterClose')
|
12
27
|
}
|
13
28
|
}
|
@@ -1,45 +1,90 @@
|
|
1
1
|
class Shipyard {
|
2
|
-
constructor (el) {
|
3
|
-
|
4
|
-
|
2
|
+
constructor (el, subClass) {
|
3
|
+
if (subClass) {
|
4
|
+
this.els = []
|
5
|
+
document.querySelectorAll(el).forEach((el) => {
|
6
|
+
this.els.push(new subClass(el))
|
7
|
+
})
|
8
|
+
} else if (typeof el === 'string') {
|
9
|
+
this.el = document.querySelector(el)
|
10
|
+
} else {
|
11
|
+
this.el = el
|
12
|
+
}
|
5
13
|
return this
|
6
14
|
}
|
7
15
|
|
8
|
-
on (events, callback) {
|
9
|
-
|
16
|
+
on (events, selector, callback) {
|
17
|
+
if (typeof selector != 'string') callback = selector
|
18
|
+
let objects = (typeof selector === 'string') ? this.find(selector) : [this]
|
19
|
+
|
20
|
+
objects.forEach((obj) => {
|
10
21
|
events.split(' ').forEach((eventName) => {
|
11
|
-
el.addEventListener(eventName,
|
12
|
-
callback(e, el)
|
13
|
-
})
|
22
|
+
obj.el.addEventListener(eventName, callback)
|
14
23
|
})
|
15
24
|
})
|
16
25
|
return this
|
17
26
|
}
|
18
27
|
|
19
|
-
trigger (
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
28
|
+
trigger () {
|
29
|
+
let events = arguments[0]
|
30
|
+
events.split(' ').forEach((eventName) => {
|
31
|
+
this.el.dispatchEvent(
|
32
|
+
new CustomEvent(eventName, { detail: arguments[1] })
|
33
|
+
)
|
24
34
|
})
|
25
35
|
return this
|
26
36
|
}
|
27
37
|
|
28
|
-
|
29
|
-
|
38
|
+
find (selector) {
|
39
|
+
let els = []
|
40
|
+
this.el.querySelectorAll(selector).forEach((el) => {
|
41
|
+
els.push(new Shipyard(el))
|
42
|
+
})
|
43
|
+
return els
|
44
|
+
}
|
45
|
+
|
46
|
+
filter (selector) {
|
47
|
+
let els = this.els.filter(obj => obj.el == document.querySelector(selector))
|
48
|
+
return els[0]
|
49
|
+
}
|
50
|
+
|
51
|
+
child (selector) {
|
52
|
+
return this.el.querySelector(selector)
|
53
|
+
}
|
54
|
+
|
55
|
+
data (name) {
|
56
|
+
return this.el.dataset[name]
|
57
|
+
}
|
58
|
+
|
59
|
+
html (value) {
|
60
|
+
this.el.innerHTML = value
|
61
|
+
return this
|
62
|
+
}
|
63
|
+
|
64
|
+
css (property, value) {
|
65
|
+
if (value) {
|
66
|
+
this.el.style[property] = value
|
67
|
+
} else {
|
68
|
+
return window.getComputedStyle(this.el).getPropertyValue(property)
|
69
|
+
}
|
70
|
+
}
|
71
|
+
|
72
|
+
attr (name) {
|
73
|
+
return this.el.getAttribute(name)
|
30
74
|
}
|
31
75
|
|
32
76
|
addClass(className) {
|
33
|
-
this.el.
|
34
|
-
el.classList.add(className)
|
35
|
-
})
|
77
|
+
this.el.classList.add(className)
|
36
78
|
return this
|
37
79
|
}
|
38
80
|
|
39
81
|
removeClass(className) {
|
40
|
-
this.el.
|
41
|
-
|
42
|
-
|
82
|
+
this.el.classList.remove(className)
|
83
|
+
return this
|
84
|
+
}
|
85
|
+
|
86
|
+
toggleClass(className, condition) {
|
87
|
+
this.el.classList.toggle(className, condition)
|
43
88
|
return this
|
44
89
|
}
|
45
90
|
}
|
@@ -1,10 +1,11 @@
|
|
1
1
|
class Hamburger extends Shipyard {
|
2
2
|
constructor (el) {
|
3
3
|
super(el)
|
4
|
-
this.on('click',
|
4
|
+
this.on('click', this.toggle)
|
5
5
|
}
|
6
6
|
|
7
|
-
|
8
|
-
|
7
|
+
toggle (e) {
|
8
|
+
e.preventDefault()
|
9
|
+
shipyard.toggleClass('hamburger-button-clicked')
|
9
10
|
}
|
10
11
|
}
|
@@ -1,13 +1,7 @@
|
|
1
1
|
class ModalTrigger extends Shipyard {
|
2
2
|
constructor (el) {
|
3
3
|
super(el)
|
4
|
-
this.
|
5
|
-
this.
|
6
|
-
this.modal = new Modal(`[modal=${el.getAttribute('modal-trigger')}]`)
|
7
|
-
})
|
8
|
-
}
|
9
|
-
|
10
|
-
open () {
|
11
|
-
this.modal.open()
|
4
|
+
this.modal = new Modal(`[modal=${el.getAttribute('modal-trigger')}]`)
|
5
|
+
this.on('click', (e) => { this.modal.trigger('open') })
|
12
6
|
}
|
13
7
|
}
|
@@ -1,20 +1,17 @@
|
|
1
1
|
class Modal extends Shipyard {
|
2
2
|
constructor (el) {
|
3
3
|
super(el)
|
4
|
+
this.on('open', () => { this.open() })
|
5
|
+
this.on('click', '[modal-close]', () => { this.close() })
|
4
6
|
}
|
5
7
|
|
6
8
|
open () {
|
7
9
|
this.removeClass('display-none')
|
8
|
-
|
9
|
-
this.el.forEach((el) => {
|
10
|
-
el.querySelectorAll('[modal-close]').forEach((btn) => {
|
11
|
-
btn.addEventListener('click', () => { this.close() })
|
12
|
-
})
|
13
|
-
})
|
10
|
+
shipyard.addClass('modal-open')
|
14
11
|
}
|
15
12
|
|
16
13
|
close () {
|
17
14
|
this.addClass('display-none')
|
18
|
-
|
15
|
+
shipyard.removeClass('modal-open')
|
19
16
|
}
|
20
17
|
}
|
@@ -1,12 +1,12 @@
|
|
1
1
|
class Scroll extends Shipyard {
|
2
2
|
constructor (el) {
|
3
3
|
super(el)
|
4
|
-
this.on('scroll resize',
|
4
|
+
this.on('scroll resize', this.scroll).trigger('scroll')
|
5
5
|
}
|
6
6
|
|
7
7
|
scroll () {
|
8
|
-
|
9
|
-
|
10
|
-
|
8
|
+
shipyard.toggleClass('scrolling', window.pageYOffset > 0)
|
9
|
+
shipyard.toggleClass('scroll-top', window.pageYOffset <= 0)
|
10
|
+
shipyard.toggleClass('scroll-bottom', window.pageYOffset + window.innerHeight >= document.body.scrollHeight)
|
11
11
|
}
|
12
12
|
}
|
@@ -5,17 +5,21 @@ module Shipyard
|
|
5
5
|
class Alert < Liquid::Block
|
6
6
|
include Shipyard::AlertHelper
|
7
7
|
|
8
|
-
def initialize(tag_name,
|
8
|
+
def initialize(tag_name, params, options)
|
9
9
|
super
|
10
|
-
@
|
10
|
+
@params = params.strip.split(',').map(&:strip)
|
11
|
+
@args = []
|
12
|
+
@params.each do |param|
|
13
|
+
if param.start_with?(':')
|
14
|
+
@args << param.tr(':','').to_sym
|
15
|
+
else
|
16
|
+
@args << eval("{#{param}}")
|
17
|
+
end
|
18
|
+
end
|
11
19
|
end
|
12
20
|
|
13
21
|
def render(context)
|
14
|
-
|
15
|
-
flash_alert @type, super
|
16
|
-
else
|
17
|
-
flash_alert super
|
18
|
-
end
|
22
|
+
flash_alert(*@args, super)
|
19
23
|
end
|
20
24
|
end
|
21
25
|
end
|
data/styleguide/Gemfile.lock
CHANGED
@@ -0,0 +1,20 @@
|
|
1
|
+
class AlertTrigger extends Shipyard {
|
2
|
+
constructor (el) {
|
3
|
+
super(el)
|
4
|
+
this.alert = shipyard.alerts.filter(this.attr('alert-trigger'))
|
5
|
+
this.on('click', (e) => { this.click(e) })
|
6
|
+
}
|
7
|
+
|
8
|
+
click (e) {
|
9
|
+
e.preventDefault()
|
10
|
+
this.addClass('btn-loading')
|
11
|
+
this.el.blur()
|
12
|
+
this.alert.trigger('show', {
|
13
|
+
afterClose: () => { this.reset() }
|
14
|
+
})
|
15
|
+
}
|
16
|
+
|
17
|
+
reset () {
|
18
|
+
this.removeClass('btn-loading')
|
19
|
+
}
|
20
|
+
}
|
@@ -1,12 +1,7 @@
|
|
1
|
-
class
|
1
|
+
class ShadeColor extends Shipyard {
|
2
2
|
constructor (el) {
|
3
3
|
super(el)
|
4
|
-
|
5
|
-
this.el.forEach((list) => {
|
6
|
-
list.querySelectorAll('[shade-color]').forEach((shade) => {
|
7
|
-
shade.innerHTML = this.rgbToHex(this.css(shade, 'background-color'))
|
8
|
-
})
|
9
|
-
})
|
4
|
+
this.html(this.rgbToHex(this.css('background-color')))
|
10
5
|
}
|
11
6
|
|
12
7
|
rgbToHex (rgb) {
|
@@ -17,5 +12,3 @@ class ShadeList extends Shipyard {
|
|
17
12
|
return `#${hex}`;
|
18
13
|
}
|
19
14
|
}
|
20
|
-
|
21
|
-
new ShadeList('[shade-list]')
|
@@ -7,6 +7,31 @@ description: Alerts should be used to grab a user's attention before proceeding
|
|
7
7
|
|
8
8
|
---
|
9
9
|
|
10
|
+
### Timed Alerts
|
11
|
+
Useful when you want to display an alert for a predetermined amount of time.
|
12
|
+
{: .section-description }
|
13
|
+
|
14
|
+
{% alert :success, :dismissible, id: 'timed-alert-5s', class: 'alert-closed' %}
|
15
|
+
Pack your bags! You'll be on the next flight to Hawaii.
|
16
|
+
<div class="alert-timer alert-timer-on" data-duration="5"></div>
|
17
|
+
{% endalert %}
|
18
|
+
|
19
|
+
{% alert :success, :dismissible, id: 'timed-alert-10s', class: 'alert-closed' %}
|
20
|
+
Pack your bags! You'll be on the next flight to Tahiti.
|
21
|
+
<div class="alert-timer alert-timer-on" data-duration="10"></div>
|
22
|
+
{% endalert %}
|
23
|
+
|
24
|
+
{% alert :success, :dismissible, id: 'timed-alert-15s', class: 'alert-closed' %}
|
25
|
+
Pack your bags! You'll be on the next flight to Corsica.
|
26
|
+
<div class="alert-timer alert-timer-on" data-duration="15"></div>
|
27
|
+
{% endalert %}
|
28
|
+
|
29
|
+
<button class="btn btn-primary margin-right-xs" alert-trigger="#timed-alert-5s">5 Seconds</button>
|
30
|
+
<button class="btn btn-primary margin-right-xs" alert-trigger="#timed-alert-10s">10 Seconds</button>
|
31
|
+
<button class="btn btn-primary" alert-trigger="#timed-alert-15s">15 Seconds</button>
|
32
|
+
|
33
|
+
---
|
34
|
+
|
10
35
|
### Dismissible
|
11
36
|
Used to display notes, tips, and other non-critical information.
|
12
37
|
{: .section-description }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shipyard-framework
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.82
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Codeship
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-12-
|
11
|
+
date: 2017-12-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionview
|
@@ -202,7 +202,9 @@ files:
|
|
202
202
|
- assets/images/arrows/down.svg
|
203
203
|
- assets/images/checkmark.svg
|
204
204
|
- assets/javascripts/shipyard.es6
|
205
|
+
- assets/javascripts/shipyard/accordion-trigger.es6
|
205
206
|
- assets/javascripts/shipyard/accordion.es6
|
207
|
+
- assets/javascripts/shipyard/alert-timer.es6
|
206
208
|
- assets/javascripts/shipyard/alert.es6
|
207
209
|
- assets/javascripts/shipyard/core.es6
|
208
210
|
- assets/javascripts/shipyard/hamburger.es6
|
@@ -318,6 +320,7 @@ files:
|
|
318
320
|
- styleguide/_assets/img/arrows/down.svg
|
319
321
|
- styleguide/_assets/img/checkmark.svg
|
320
322
|
- styleguide/_assets/js/application.es6
|
323
|
+
- styleguide/_assets/js/views/components/alert-trigger.es6
|
321
324
|
- styleguide/_assets/js/views/utilities/colors.es6
|
322
325
|
- styleguide/_config.yml
|
323
326
|
- styleguide/_data/breakpoints.yml
|