imba-localization 0.2.5 → 0.2.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.
package/README.md CHANGED
@@ -11,7 +11,7 @@ A lightweight Imba module for loading and handling JSON-based localization files
11
11
  - 🧠 **Intuitive access** - Proxy-based access to translation strings
12
12
  - 📡 **Event handling** - Support for `onready`, `onchange`, and `onerror` events
13
13
  - 🚀 **Simple integration** - Easy to use in any Imba-based web application
14
- - 🧩 **`<LanguageSelector>`** - Plug and play component for switching languages
14
+ - 🧩 **`<LocalizationSelector>`** - Plug and play component for switching languages
15
15
 
16
16
  ## 📘 Notes
17
17
 
@@ -143,18 +143,18 @@ new LocalizationState(url, default = 'en')
143
143
 
144
144
  ## 🧩 Components
145
145
 
146
- ### LanguageSelector
146
+ ### LocalizationSelector
147
147
 
148
148
  A customizable dropdown component that allows users to select from available in the JSON localization file languages.
149
149
 
150
150
  ```imba
151
- import { LocalizationState, LanguageSelector } from 'imba-localization'
151
+ import { LocalizationState, LocalizationSelector } from 'imba-localization'
152
152
  const loc = new LocalizationState("path/to/lang.json", "en")
153
153
 
154
154
  # In your UI component
155
155
  tag AppHeader
156
156
  <self>
157
- <LanguageSelector state=loc> # state attribute is mandatory
157
+ <LocalizationSelector state=loc> # state attribute is mandatory
158
158
  ```
159
159
 
160
160
  To make this component work as intended, your JSON file will need some adjustments. For each supported language you will need to define the display name for the language and also the country code for the flag to show (for example `en` language is used in `gb` and `us` countries):
@@ -175,45 +175,45 @@ Here are CSS classes (and one variable) you can redefine:
175
175
  css
176
176
  $ease: 0.5s
177
177
  .main
178
- cursor:pointer
179
- rd:8px px:15px py:8px
180
- bgc:light-dark(#000000/10, #FFFFFF/20)
181
- fw:500 fs:13px
182
- ead:$ease
183
- .main-active
184
- bgc:light-dark(#000000/20, #FFFFFF/30)
185
- .main-flag
186
- mr:10px rd:50% w:20px h:20px
187
- .main-name
188
- mr:10px
189
- .main-arrow
190
- w:16px h:16px ml:auto
191
- fill:light-dark(#000000,#FFFFFF)
192
- scale-y:-1
193
- ead:$ease
194
- .menu
195
- t:100% l:50% x:-50% mt:2px rd:8px rd:8px py:5px zi:999
196
- fw:500 fs:13px
197
- backdrop-filter:blur(20px)
198
- bgc:light-dark(#000000/5, #FFFFFF/10)
199
- ead:$ease
200
- .menu-item
201
- cursor:pointer
202
- d:hflex px:10px py:5px rd:8px m:5px
203
- bg@hover:light-dark(#000000/10, #FFFFFF/20)
204
- .menu-item-icon
205
- h:20px w:20px mr:10px rd:50%
206
- .menu-item-text
207
- fs:13px
178
+ cursor:pointer
179
+ rd:8px px:15px py:8px
180
+ bgc:light-dark(#000000/10, #FFFFFF/20)
181
+ fw:500 fs:13px
182
+ ead:$ease
183
+ .main-active
184
+ bgc:light-dark(#000000/20, #FFFFFF/30)
185
+ .main-flag
186
+ mr:10px rd:50% w:20px h:20px
187
+ .main-name
188
+ mr:10px
189
+ .main-arrow
190
+ w:16px h:16px ml:auto
191
+ fill:light-dark(#000000,#FFFFFF)
192
+ scale-y:-1
193
+ ead:$ease
194
+ .menu
195
+ t:100% l:50% x:-50% mt:2px rd:8px rd:8px py:5px zi:999
196
+ fw:500 fs:13px
197
+ backdrop-filter:blur(20px)
198
+ bgc:light-dark(#000000/5, #FFFFFF/10)
199
+ ead:$ease
200
+ .menu-item
201
+ cursor:pointer
202
+ d:hflex px:10px py:5px rd:8px m:5px
203
+ bg@hover:light-dark(#000000/10, #FFFFFF/20)
204
+ .menu-item-icon
205
+ h:20px w:20px mr:10px rd:50%
206
+ .menu-item-text
207
+ fs:13px
208
208
  ```
209
209
  LanguageSelector can be easily customized through CSS and Imba tag (class) inheritance. Here how the above classes can be adjusted via the inheritance:
210
210
 
211
211
  ```imba
212
- import { LocalizationState, LanguageSelector } from 'imba-localization'
212
+ import { LocalizationState, LocalizationSelector } from 'imba-localization'
213
213
  const loc = new LocalizationState("path/to/lang.json", "en")
214
214
 
215
215
  # Create an inheritent class
216
- tag Languages < LanguageSelector
216
+ tag Languages < LocalizationSelector
217
217
  css
218
218
  $ease: 1s
219
219
  .menu-item rd:2px
@@ -230,7 +230,7 @@ tag MyApp
230
230
  You can redefine the collection of flag icons through the `icons` attribute:
231
231
 
232
232
  ```imba
233
- <LanguageSelector icons='https://flagicons.lipis.dev/flags/4x3/##.svg'>
233
+ <LocalizationSelector icons='https://flagicons.lipis.dev/flags/4x3/##.svg'>
234
234
  ```
235
235
  There are many flag collections out there:
236
236
  - https://kapowaz.github.io/square-flags/flags/##.svg (default one)
@@ -253,12 +253,12 @@ tag SomeIcon
253
253
  <path d="...">
254
254
 
255
255
 
256
- <LanguageSelector arrow=SomeIcon>
256
+ <LocalizationSelector arrow=SomeIcon>
257
257
  ```
258
258
 
259
259
  ### ArrowIcon
260
260
 
261
- The default arrow icon used in the LanguageSelector component is available as a separate icon (in case for some reason you don't want to use [imba-phosphor-icons](https://www.npmjs.com/package/imba-phosphor-icons) package by Sindre).
261
+ The default arrow icon used in the LocalizationSelector component is available as a separate icon (in case for some reason you don't want to use [imba-phosphor-icons](https://www.npmjs.com/package/imba-phosphor-icons) package by Sindre).
262
262
 
263
263
  ```imba
264
264
  import {ArrowIcon} from 'imba-localization'
package/localization.imba CHANGED
@@ -56,7 +56,7 @@ export tag ArrowIcon
56
56
  <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 256 256">
57
57
  <path d="M213.66,165.66a8,8,0,0,1-11.32,0L128,91.31,53.66,165.66a8,8,0,0,1-11.32-11.32l80-80a8,8,0,0,1,11.32,0l80,80A8,8,0,0,1,213.66,165.66Z">
58
58
 
59
- export tag LanguageSelector
59
+ export tag LocalizationSelector
60
60
  state
61
61
  icons = "https://kapowaz.github.io/square-flags/flags/##.svg"
62
62
  #dropdown = false
@@ -74,7 +74,7 @@ export tag LanguageSelector
74
74
  .main-name mr:10px
75
75
  .main-arrow w:16px h:16px fill:light-dark(#000000,#FFFFFF) ml:auto scale-y:-1 ead:$ease
76
76
  .menu t:100% l:50% x:-50% zi:999 backdrop-filter:blur(20px) mt:2px rd:8px rd:8px py:5px bgc:light-dark(#000000/5, #FFFFFF/10) fw:500 fs:13px ead:$ease
77
- .menu-item d:hflex px:10px py:5px rd:8px cursor:pointer bg@hover:light-dark(#000000/10, #FFFFFF/20) m:5px
77
+ .menu-item d:hflex ai:center px:10px py:5px rd:8px cursor:pointer bg@hover:light-dark(#000000/10, #FFFFFF/20) m:5px
78
78
  .menu-item-icon h:20px w:20px mr:10px rd:50%
79
79
  .menu-item-text fs:13px
80
80
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "imba-localization",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/HeapVoid/imba-localization.git"