tao_ui 0.2.5 → 0.2.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: bb8a02f1c7f7b6522ea02c956475b444076f4c22
4
- data.tar.gz: e70c4aa00d59f75c309c6dffa99cd77c03822676
3
+ metadata.gz: 841fce6a55ee514e77c1ed90b33f6c61d24e45e3
4
+ data.tar.gz: 50243fe3e1cc627cc8aee3e790fb6ad5ff74f712
5
5
  SHA512:
6
- metadata.gz: f1def1930ba3cc284b08eec3e707f647b33c4e3293951a3d1c43146871ba3e059cde031aef6216deb638dc99cd2f4a79350fef381829a278d89464429236392b
7
- data.tar.gz: b6f1c33e518f9b645564ceffd4b5b5b784c1ec9b2bdc5ae8b75653ba70385be4731a895b01bbbc540612526152d5040466a945bc6b3d6ad7ddb50f6d21305a1f
6
+ metadata.gz: 64a759788b0e0926fb9aef4a0ffd76aa8ca556fbe750b6933369f7e5d735025df26dd0b54d2bdfe389b14d874af931388a856fac836c79d4de44956321a02ca0
7
+ data.tar.gz: 4feec975f323094c0d032a7a41a7592d4b55ce9dc1c06b8340acdfe087f86c21c3a8c73e6b995f125b6732810848c1aaeb0e188d4e3dffc0507c3401c5cc8c08
@@ -51,12 +51,20 @@ class Tao.Dialog.Element extends TaoComponent
51
51
  @jq.show()
52
52
  @reflow()
53
53
  else
54
+ reset = =>
55
+ if @autoDestroy
56
+ @remove()
57
+ else
58
+ @jq.hide()
59
+
60
+ # in case the dialog is hidden too fast
54
61
  if @jq.is(':visible')
55
- @one 'transitionend', =>
56
- if @autoDestroy
57
- @remove()
58
- else
59
- @jq.hide()
62
+ if @jq.css('opacity') * 1 == 0
63
+ reset()
64
+ else
65
+ @one 'transitionend', ->
66
+ reset()
67
+
60
68
  null
61
69
 
62
70
  _activeChanged: ->
@@ -3,6 +3,7 @@
3
3
  #= require ./icons
4
4
  #= require ./slide_box
5
5
  #= require ./popover
6
+ #= require ./tooltip
6
7
  #= require ./dialog
7
8
 
8
9
  window.Tao ||= {}
@@ -17,15 +17,9 @@ class Tao.Popover.Element extends TaoComponent
17
17
 
18
18
  @attribute 'boundarySelector', 'direction', 'size'
19
19
 
20
- @attribute 'arrowAlign', default: 'center'
21
-
22
- @attribute 'arrowVerticalAlign', default: 'middle'
23
-
24
20
  @attribute 'offset', type: 'number', default: 0
25
21
 
26
- @attribute 'autoHide', type: 'boolean'
27
-
28
- @attribute 'autoDestroy', type: 'boolean'
22
+ @attribute 'autoHide', 'autoDestroy', 'withArrow', 'disabled', type: 'boolean'
29
23
 
30
24
  _connected: ->
31
25
  @_initTarget()
@@ -52,18 +46,43 @@ class Tao.Popover.Element extends TaoComponent
52
46
  if @triggerAction == 'click'
53
47
  @triggerEl.on 'click.tao-popover', (e) =>
54
48
  @toggleActive()
49
+ null
55
50
  else if @triggerAction == 'hover'
56
51
  @triggerEl.on 'mouseenter.tao-popover', (e) =>
57
52
  @active = true
53
+ null
58
54
  .on 'mouseleave.tao-popover', (e) =>
59
55
  @active = false
56
+ null
60
57
 
61
58
  _initSize: ->
62
59
  @jq.width(@size) if @size
63
60
 
61
+ _beforeActiveChanged: (active) ->
62
+ return false if @disabled
63
+
64
+ if active
65
+ @jq.show()
66
+ @refresh()
67
+ @reflow()
68
+ else
69
+ reset = =>
70
+ if @autoDestroy
71
+ @remove()
72
+ else
73
+ @jq.hide()
74
+
75
+ # in case the popover is hidden too fast
76
+ if @jq.is(':visible')
77
+ if @jq.css('opacity') * 1 == 0
78
+ reset()
79
+ else
80
+ @one 'transitionend', ->
81
+ reset()
82
+ null
83
+
64
84
  _activeChanged: ->
65
85
  if @active
66
- @refresh()
67
86
  @target.addClass 'tao-popover-active'
68
87
  @_enableAutoHide() if @autoHide
69
88
  @trigger 'tao:show'
@@ -71,7 +90,6 @@ class Tao.Popover.Element extends TaoComponent
71
90
  @target.removeClass 'tao-popover-active'
72
91
  @_disableAutoHide() if @autoHide
73
92
  @trigger 'tao:hide'
74
- @jq.remove() if @autoDestroy
75
93
 
76
94
  _enableAutoHide: ->
77
95
  $(document).on "mousedown.tao-popover-#{@taoId}", (e) =>
@@ -96,8 +114,7 @@ class Tao.Popover.Element extends TaoComponent
96
114
  popover: @jq
97
115
  target: @target
98
116
  direction: @direction.split('-')
99
- arrowAlign: @arrowAlign
100
- arrowVerticalAlign: @arrowVerticalAlign
117
+ withArrow: @withArrow
101
118
  offset: @offset
102
119
 
103
120
  @jq.css
@@ -128,6 +145,7 @@ class Tao.Popover.Element extends TaoComponent
128
145
  if @autoDestroy
129
146
  @remove()
130
147
  else
148
+ @jq.hide()
131
149
  @active = false
132
150
 
133
151
  remove: ->
@@ -3,20 +3,18 @@ class Tao.Popover.Position extends TaoModule
3
3
 
4
4
  @option 'direction', 'popover', 'target'
5
5
 
6
- @option 'arrowAlign', default: 'center'
7
-
8
- @option 'arrowVerticalAlign', default: 'middle'
6
+ @option 'withArrow', default: false
9
7
 
10
8
  @option 'offset', type: 'number', default: 0
11
9
 
12
- ARROW_OFFSET: 16
10
+ @property 'arrowOffset', default: 16
13
11
 
14
12
  _init: ->
15
13
  @top = 0
16
14
  @left = 0
15
+ @arrowOffset = 0 unless @withArrow
17
16
 
18
17
  @_setPosition()
19
- @_setArrowAlign()
20
18
  @_setOffset()
21
19
 
22
20
  _setPosition: ->
@@ -26,9 +24,14 @@ class Tao.Popover.Position extends TaoModule
26
24
  popoverWidth = @popover.outerWidth()
27
25
  popoverHeight = @popover.outerHeight()
28
26
  parentOffset = @popover.offsetParent().offset()
29
- $arrow = @popover.find('.tao-popover-arrow')
30
- arrowWidth = $arrow.outerWidth()
31
- arrowHeight = $arrow.outerHeight()
27
+
28
+ if @withArrow
29
+ $arrow = @popover.find('.tao-popover-arrow')
30
+ arrowWidth = $arrow.outerWidth()
31
+ arrowHeight = $arrow.outerHeight()
32
+ else
33
+ arrowWidth = 8
34
+ arrowHeight = 8
32
35
 
33
36
  switch @direction[0]
34
37
  when 'left'
@@ -42,33 +45,18 @@ class Tao.Popover.Position extends TaoModule
42
45
 
43
46
  switch @direction[1]
44
47
  when 'top'
45
- @top = targetOffset.top - popoverHeight + targetHeight / 2 + arrowHeight / 2 + @ARROW_OFFSET - parentOffset.top
48
+ @top = targetOffset.top - popoverHeight + targetHeight - parentOffset.top
46
49
  when 'bottom'
47
- @top = targetOffset.top + targetHeight / 2 - arrowHeight / 2 - @ARROW_OFFSET - parentOffset.top
50
+ @top = targetOffset.top - parentOffset.top
48
51
  when 'left'
49
- @left = targetOffset.left - popoverWidth + targetWidth / 2 + arrowWidth / 2 + @ARROW_OFFSET - parentOffset.left
52
+ @left = targetOffset.left - popoverWidth + targetWidth - parentOffset.left
50
53
  when 'right'
51
- @left = targetOffset.left + targetWidth / 2 - arrowWidth / 2 - @ARROW_OFFSET - parentOffset.left
54
+ @left = targetOffset.left - parentOffset.left
52
55
  when 'center'
53
56
  @left = targetOffset.left + targetWidth / 2 - popoverWidth / 2 - parentOffset.left
54
57
  when 'middle'
55
58
  @top = targetOffset.top + targetHeight / 2 - popoverHeight / 2 - parentOffset.top
56
59
 
57
- _setArrowAlign: ->
58
- if /top|bottom/.test @direction[0]
59
- switch @arrowAlign
60
- when 'left'
61
- @left -= @target.width() / 2
62
- when 'right'
63
- @left += @target.width() / 2
64
-
65
- if /left|right/.test @direction[0]
66
- switch @arrowVerticalAlign
67
- when 'top'
68
- @top -= @target.height() / 2
69
- when 'bottom'
70
- @top += @target.height() / 2
71
-
72
60
  _setOffset: ->
73
61
  return unless @offset
74
62
 
@@ -51,12 +51,19 @@ class Tao.SlideBox.ElementBase extends TaoComponent
51
51
  @jq.show()
52
52
  @reflow()
53
53
  else
54
+ reset = =>
55
+ if @autoDestroy
56
+ @remove()
57
+ else
58
+ @jq.hide()
59
+
60
+ # in case the slide box is hidden too fast
54
61
  if @jq.is(':visible')
55
- @one 'transitionend', =>
56
- if @autoDestroy
57
- @remove()
58
- else
59
- @jq.hide()
62
+ if @jq.css('opacity') * 1 == 0
63
+ reset()
64
+ else
65
+ @one 'transitionend', ->
66
+ reset()
60
67
  null
61
68
 
62
69
  _activeChanged: ->
@@ -0,0 +1,5 @@
1
+ class Tao.Tooltip extends Tao.Popover.Element
2
+
3
+ @tag 'tao-tooltip'
4
+
5
+ TaoComponent.register Tao.Tooltip
@@ -4,6 +4,7 @@
4
4
  a {
5
5
  &:hover {
6
6
  color: $link-hover-color;
7
+ fill: $link-hover-color;
7
8
  }
8
9
 
9
10
  &.warn {
@@ -6,4 +6,5 @@
6
6
  //= require ./tables
7
7
  //= require ./slide_box
8
8
  //= require ./popover
9
+ //= require ./tooltip
9
10
  //= require ./dialog
@@ -2,15 +2,17 @@
2
2
 
3
3
  $arrowSize: 1rem;
4
4
 
5
- tao-popover,
6
5
  .tao-popover {
7
6
  display: none;
8
7
  position: absolute;
9
8
  left: -9999px;
10
9
  top: -9999px;
11
10
  z-index: $z-index-popover;
11
+ opacity: 0;
12
+ transition: opacity 200ms;
12
13
 
13
14
  &[active] {
15
+ opacity: 1;
14
16
  display: block;
15
17
  }
16
18
 
@@ -41,6 +43,7 @@ tao-popover,
41
43
  }
42
44
 
43
45
  .tao-popover-arrow {
46
+ display: none;
44
47
  position: absolute;
45
48
  width: $arrowSize;
46
49
  height: $arrowSize;
@@ -57,6 +60,10 @@ tao-popover,
57
60
  }
58
61
  }
59
62
 
63
+ &[with-arrow] .tao-popover-arrow {
64
+ display: block;
65
+ }
66
+
60
67
  &[direction='right-top'],
61
68
  &[direction='right-bottom'],
62
69
  &[direction='right-middle'] {
@@ -1,7 +1,7 @@
1
1
  @import 'tao/ui/globals';
2
2
  @import 'tao/ui/shared/slide_box';
3
3
 
4
- tao-slide-box {
4
+ .tao-slide-box {
5
5
  & > .slide-box-wrapper > .link-close {
6
6
  display: none;
7
7
  justify-content: center;
@@ -25,4 +25,5 @@ tao-slide-box {
25
25
  &[with-close-button] > .slide-box-wrapper > .link-close {
26
26
  display: flex;
27
27
  }
28
+
28
29
  }
@@ -0,0 +1,147 @@
1
+ @import 'tao/ui/globals';
2
+
3
+ $arrowSize: 0.75rem;
4
+
5
+ .tao-tooltip {
6
+ display: none;
7
+ position: absolute;
8
+ left: -9999px;
9
+ top: -9999px;
10
+ z-index: $z-index-popover;
11
+ opacity: 0;
12
+ transition: opacity 200ms;
13
+
14
+ &[active] {
15
+ opacity: 1;
16
+ display: block;
17
+ }
18
+
19
+ .tao-popover-content {
20
+ padding: 0.5rem 0.75rem;
21
+ background: $grey-color;
22
+ color: $white-color;
23
+ border-radius: $border-radius;
24
+ white-space: nowrap;
25
+ font-size: 0.875rem;
26
+ }
27
+
28
+ .tao-popover-arrow {
29
+ display: none;
30
+ position: absolute;
31
+ width: $arrowSize;
32
+ height: $arrowSize;
33
+
34
+ .arrow {
35
+ font-size: 0;
36
+ height: 0;
37
+ width: 0;
38
+ border-style: solid;
39
+ border-width: $arrowSize / 2;
40
+ border-color: $grey-color;
41
+ position: absolute;
42
+ left: 0;
43
+ top: 0;
44
+ }
45
+
46
+ .arrow-border,
47
+ .arrow-shadow {
48
+ display: none;
49
+ }
50
+ }
51
+
52
+ &[with-arrow] .tao-popover-arrow {
53
+ display: block;
54
+ }
55
+
56
+ &[direction='right-top'],
57
+ &[direction='right-bottom'],
58
+ &[direction='right-middle'] {
59
+ .tao-popover-arrow {
60
+ left: -$arrowSize;
61
+ }
62
+
63
+ .arrow-basic {
64
+ border-color: transparent $grey-color transparent transparent;
65
+ }
66
+ }
67
+
68
+ &[direction='left-top'],
69
+ &[direction='left-bottom'],
70
+ &[direction='left-middle'] {
71
+ .tao-popover-arrow {
72
+ right: -$arrowSize;
73
+ }
74
+
75
+ .arrow-basic {
76
+ border-color: transparent transparent transparent $grey-color;
77
+ }
78
+ }
79
+
80
+ &[direction='left-top'],
81
+ &[direction='right-top'] {
82
+ .tao-popover-arrow {
83
+ bottom: $arrowSize;
84
+ }
85
+ }
86
+
87
+ &[direction='left-bottom'],
88
+ &[direction='right-bottom'] {
89
+ .tao-popover-arrow {
90
+ top: $arrowSize;
91
+ }
92
+ }
93
+
94
+ &[direction='left-middle'],
95
+ &[direction='right-middle'] {
96
+ .tao-popover-arrow {
97
+ top: 50%;
98
+ margin-top: -$arrowSize / 2;
99
+ }
100
+ }
101
+
102
+ &[direction='top-left'],
103
+ &[direction='top-right'],
104
+ &[direction='top-center'] {
105
+ .tao-popover-arrow {
106
+ bottom: -$arrowSize;
107
+ }
108
+
109
+ .arrow-basic {
110
+ border-color: $grey-color transparent transparent transparent;
111
+ }
112
+ }
113
+
114
+ &[direction='bottom-left'],
115
+ &[direction='bottom-right'],
116
+ &[direction='bottom-center'] {
117
+ .tao-popover-arrow {
118
+ top: -$arrowSize;
119
+ }
120
+
121
+ .arrow-basic {
122
+ border-color: transparent transparent $grey-color transparent;
123
+ }
124
+ }
125
+
126
+ &[direction='top-left'],
127
+ &[direction='bottom-left'] {
128
+ .tao-popover-arrow {
129
+ right: $arrowSize;
130
+ }
131
+ }
132
+
133
+ &[direction='top-right'],
134
+ &[direction='bottom-right'] {
135
+ .tao-popover-arrow {
136
+ left: $arrowSize;
137
+ }
138
+ }
139
+
140
+ &[direction='top-center'],
141
+ &[direction='bottom-center'] {
142
+ .tao-popover-arrow {
143
+ left: 50%;
144
+ margin-left: -$arrowSize / 2;
145
+ }
146
+ }
147
+ }
@@ -5,6 +5,8 @@ module Tao
5
5
 
6
6
  class_option :paths, type: :array, default: ['app/assets/icons', 'lib/assets/icons'], desc: 'Find svg files in specified paths.'
7
7
 
8
+ class_option :remove_color, type: :boolean, default: false, desc: 'Remove all fill attributes in svg.'
9
+
8
10
  attr_reader :icons_html
9
11
 
10
12
  def create_icons_file
@@ -23,7 +25,14 @@ module Tao
23
25
  def symbol(path)
24
26
  name = File.basename(path, ".*").underscore().dasherize()
25
27
  document = Nokogiri::XML(File.read(path))
26
- document.css('[id="Main"], [id="Main"] [fill], [fill="none"]').each {|n| n.delete 'fill' }
28
+
29
+ if options[:remove_color] && !name.include?('with-color')
30
+ document.css('[fill]').each {|n| n.delete 'fill' }
31
+ else
32
+ document.css('[id="Main"], [id="main"], [fill="none"]')
33
+ .each {|n| n.delete 'fill' }
34
+ end
35
+
27
36
  content = document.to_s
28
37
  content.gsub(/<?.+\?>/,'')
29
38
  .gsub(/<!.+?>/,'')
@@ -9,7 +9,7 @@ module TaoUi
9
9
  private
10
10
 
11
11
  def default_options
12
- {class: 'tao-popover', auto_hide: true}
12
+ {class: 'tao-popover', auto_hide: true, with_arrow: true}
13
13
  end
14
14
 
15
15
  end
@@ -0,0 +1,21 @@
1
+ module TaoUi
2
+ module Components
3
+ class TooltipComponent < TaoOnRails::Components::Base
4
+
5
+ def self.component_name
6
+ :tooltip
7
+ end
8
+
9
+ def self.template_name
10
+ @template_name ||= :popover
11
+ end
12
+
13
+ private
14
+
15
+ def default_options
16
+ {class: 'tao-tooltip', auto_hide: true, with_arrow: true, trigger_action: :hover}
17
+ end
18
+
19
+ end
20
+ end
21
+ end
@@ -1,6 +1,7 @@
1
1
  require 'tao_ui/components/icon_component'
2
2
  require 'tao_ui/components/slide_box_component'
3
3
  require 'tao_ui/components/popover_component'
4
+ require 'tao_ui/components/tooltip_component'
4
5
  require 'tao_ui/components/confirm_popover_component'
5
6
  require 'tao_ui/components/dialog_component'
6
7
  require 'tao_ui/components/message_dialog_component'
@@ -1,3 +1,3 @@
1
1
  module TaoUi
2
- VERSION = '0.2.5'
2
+ VERSION = '0.2.6'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tao_ui
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - farthinker
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-22 00:00:00.000000000 Z
11
+ date: 2017-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: tao_on_rails
@@ -131,6 +131,7 @@ files:
131
131
  - lib/assets/javascripts/tao/ui/shared/ujs.coffee
132
132
  - lib/assets/javascripts/tao/ui/slide_box/element.coffee
133
133
  - lib/assets/javascripts/tao/ui/slide_box/index.coffee
134
+ - lib/assets/javascripts/tao/ui/tooltip.coffee
134
135
  - lib/assets/stylesheets/tao/ui/_custom.scss
135
136
  - lib/assets/stylesheets/tao/ui/_globals.scss
136
137
  - lib/assets/stylesheets/tao/ui/_mixins.scss
@@ -168,6 +169,7 @@ files:
168
169
  - lib/assets/stylesheets/tao/ui/shared/variables/_tables.scss
169
170
  - lib/assets/stylesheets/tao/ui/slide_box.scss
170
171
  - lib/assets/stylesheets/tao/ui/tables.scss
172
+ - lib/assets/stylesheets/tao/ui/tooltip.scss
171
173
  - lib/assets/stylesheets/tao/ui/variables/_base.scss
172
174
  - lib/generators/tao/icons/USAGE
173
175
  - lib/generators/tao/icons/icons_generator.rb
@@ -181,6 +183,7 @@ files:
181
183
  - lib/tao_ui/components/message_dialog_component.rb
182
184
  - lib/tao_ui/components/popover_component.rb
183
185
  - lib/tao_ui/components/slide_box_component.rb
186
+ - lib/tao_ui/components/tooltip_component.rb
184
187
  - lib/tao_ui/engine.rb
185
188
  - lib/tao_ui/version.rb
186
189
  - lib/views/components/tao_ui/components/_confirm_dialog.html.erb