imba-localization 0.3.5 → 0.3.7

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.
Files changed (2) hide show
  1. package/localization.imba +20 -3
  2. package/package.json +1 -1
package/localization.imba CHANGED
@@ -58,20 +58,37 @@ tag language-selector
58
58
  icons = "https://kapowaz.github.io/square-flags/flags/##.svg"
59
59
  #dropdown = false
60
60
  arrow = path-arrow-down
61
+ passive = false
62
+
63
+ def setup
64
+ if data
65
+ state.active = data
66
+ else
67
+ data = state.active
61
68
 
62
69
  def onselect key
63
70
  #dropdown = false
64
- state.active = key
71
+ data = key
72
+ state.active = key
65
73
 
66
74
  def icon country
67
75
  return icons.replace('##',country)
68
76
 
69
77
  def mouseleave e
78
+ return if passive
70
79
  const rect = self.getBoundingClientRect!
71
80
  const menu = $menu.getBoundingClientRect!
72
81
  const inside = e.clientY >= menu.bottom || e.clientY <= rect.top || (e.clientX <= rect.left and e.clientY <= rect.bottom) || (e.clientX <= menu.left and e.clientY >= menu.top) || (e.clientX >= rect.right and e.clientY <= rect.bottom) || (e.clientX >= menu.right and e.clientY >= menu.top)
73
82
  #dropdown = !inside
74
83
 
84
+ def mouseenter
85
+ return if passive
86
+ #dropdown = true
87
+
88
+ def click
89
+ return if !passive
90
+ #dropdown = !#dropdown
91
+
75
92
  css
76
93
  $ease: 0.5s
77
94
  .container rd:8px px:15px py:8px cursor:pointer bgc:light-dark(#000000/10, #FFFFFF/20) fw:500 fs:13px ead:$ease bd:1px solid transparent
@@ -85,7 +102,7 @@ tag language-selector
85
102
  .icon h:20px w:20px mr:10px rd:50% bd:1px solid transparent
86
103
  .text fs:13px bd:1px solid transparent
87
104
 
88
- <self [pos:rel] @mouseenter=(#dropdown = true) @mouseleave=mouseleave>
105
+ <self [pos:rel] @mouseenter=mouseenter @mouseleave=mouseleave @click=click>
89
106
  <div.container [pos:rel d:hcc] .active=#dropdown>
90
107
  <img.flag src=icon(state[state.active].$.flag)>
91
108
  <div.name> state.$.name
@@ -95,6 +112,6 @@ tag language-selector
95
112
  if #dropdown
96
113
  <div$menu.menu [pos:abs w:100% > max-content o@off:0] ease>
97
114
  for own key, value of state.languages
98
- <div.item @click=onselect(key) [d:none]=(key == state.active)>
115
+ <div.item @click.trap=onselect(key) [d:none]=(key == state.active)>
99
116
  <img.icon src=icon(value.$.flag)>
100
117
  <span.text> value.$.name
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "imba-localization",
3
- "version": "0.3.5",
3
+ "version": "0.3.7",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/HeapVoid/imba-localization.git"