openguessr-ui 0.1.1 → 0.2.0
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 +25 -22
- package/errorPopup.svelte.js +1 -1
- package/index.js +12 -1
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -17,7 +17,7 @@ These core concepts define how UI should be structured.
|
|
|
17
17
|
|
|
18
18
|
- **Panels:** Panels are used for floating UI. They typically include controls rather than loads of text or images, perfect for HUDs.
|
|
19
19
|
|
|
20
|
-
- **Containers:** Containers contain boxes. The popup acts as a layout/container
|
|
20
|
+
- **Containers:** Containers contain boxes. The popup acts as a layout/container hybrid that also contains boxes.
|
|
21
21
|
|
|
22
22
|
- **Layouts:** Layouts are typically full pages that containers or panels sit in.
|
|
23
23
|
|
|
@@ -33,7 +33,7 @@ These core concepts define how UI should be structured.
|
|
|
33
33
|
|
|
34
34
|
The content level (inside buttons, chips, tabs, or other controls) uses spacing of `--content-margin`. Placing content directly into layouts or containers is not allowed, it needs to sit inside a box or panel.
|
|
35
35
|
|
|
36
|
-
Popups take some properties from layouts and some from containers. They use `--layout-margin` for spacing, but content inside them is boxes (level 3) with `--box-margin` for border radii.
|
|
36
|
+
Popups take some properties from layouts and some from containers. They use `--layout-margin` for spacing, but content inside them is boxes (level 3) with `--box-margin` for border radii.
|
|
37
37
|
|
|
38
38
|
## Styling
|
|
39
39
|
|
|
@@ -72,7 +72,7 @@ These variables are used for colors:
|
|
|
72
72
|
> [!TIP]
|
|
73
73
|
> There should be at most one `--brand-color` element visible at a time (the primary action). Green colors should not be used for success, use bright styling instead (e.g. `rgba(255, 255, 255, 0.2)`).
|
|
74
74
|
|
|
75
|
-
These
|
|
75
|
+
These variables are used for box shadows:
|
|
76
76
|
|
|
77
77
|
| Variable | Used for |
|
|
78
78
|
| -------- | ------- |
|
|
@@ -82,7 +82,7 @@ These variabels are used for box shadows:
|
|
|
82
82
|
| --box-shadow-bottom | Boxes that fade out towards the top |
|
|
83
83
|
| --box-shadow | Boxes |
|
|
84
84
|
| --bulb-shadow | Pills, chips, badges |
|
|
85
|
-
| --panel-shadow | Floating elements (containers, panels
|
|
85
|
+
| --panel-shadow | Floating elements (containers, panels etc.) |
|
|
86
86
|
|
|
87
87
|
These variables are used for blur:
|
|
88
88
|
|
|
@@ -108,11 +108,11 @@ Boxes typically use this base styling:
|
|
|
108
108
|
}
|
|
109
109
|
```
|
|
110
110
|
|
|
111
|
-
Their width shouldn't grow to fit the container or
|
|
111
|
+
Their width shouldn't grow to fit the container or popup they are in.
|
|
112
112
|
|
|
113
113
|
#### Text inside boxes
|
|
114
114
|
|
|
115
|
-
Since boxes have rather tight padding and text naturally adds top and bottom spacing through the line-height, applying `padding-inline: var(--content-margin)` to text is recommended. If the entire box just contains text, raising the
|
|
115
|
+
Since boxes have rather tight padding and text naturally adds top and bottom spacing through the line-height, applying `padding-inline: var(--content-margin)` to text is recommended. If the entire box just contains text, raising the box's inline padding to `--layout-margin` has the same effect.
|
|
116
116
|
|
|
117
117
|
### Panels
|
|
118
118
|
|
|
@@ -131,7 +131,7 @@ Panels typically use this base styling:
|
|
|
131
131
|
|
|
132
132
|
Panels that house large buttons which are rounder than usual buttons should have a border radius of `--layout-margin` to avoid uneven corners. Don't mix them, panels should stick to only large or only small buttons.
|
|
133
133
|
|
|
134
|
-
When panels sit inside layouts with a strong background color (e.g. `--overlay-color-dark`), their
|
|
134
|
+
When panels sit inside layouts with a strong background color (e.g. `--overlay-color-dark`), their background color should be `--box-color` instead of `--panel-color` to avoid layering two blue-ish tones (which will produce a color that looks too vibrant).
|
|
135
135
|
|
|
136
136
|
The gap or margin between related panels should be `--box-margin` if they use `--box-margin` for the border radii, otherwise `--layout-margin`.
|
|
137
137
|
|
|
@@ -197,7 +197,7 @@ The spacing between text and an icon inside content should be `--content-margin`
|
|
|
197
197
|
|
|
198
198
|
### Scrollable areas
|
|
199
199
|
|
|
200
|
-
Overfade (`overfade`) is a library used for scrollable areas. It applies a dynamic mask-image
|
|
200
|
+
Overfade (`overfade`) is a library used for scrollable areas. It applies a dynamic mask-image to the scroll container, the element that holds the overflowing content.
|
|
201
201
|
|
|
202
202
|
For example, when an element, that contains overflowing text content and uses `of-top` and `of-bottom`, is scrolled all the way to the top, the top of the text is not faded out, only the bottom is.
|
|
203
203
|
|
|
@@ -213,6 +213,8 @@ These classes should not be applied directly on boxes or containers, since that
|
|
|
213
213
|
|
|
214
214
|
Scrollable content should be intentionally, visibly cut off when scrolling is allowed to communicate the fact that scrolling is possible.
|
|
215
215
|
|
|
216
|
+
Typically, scroll bars should be hidden via `scrollbar-width: none`. There can be exceptions, e.g. for text editors where a scroll bar brings utility.
|
|
217
|
+
|
|
216
218
|
### Opacity values
|
|
217
219
|
|
|
218
220
|
Opacity values used are typically `0.25`, `0.5`, `0.75` and `1`. Supportive text, such as the explanation for a feature, can be `0.75` or even `0.5`. Labels, e.g. for controls, should be full opacity.
|
|
@@ -240,7 +242,7 @@ The popup component is used for dialogs. It takes the following props:
|
|
|
240
242
|
- `open`: Whether the popup is open
|
|
241
243
|
- `slim`: Reduces the max width
|
|
242
244
|
- `verySlim`: Reduces the max width further
|
|
243
|
-
- `frameless`: Reduces the padding, e.g. for
|
|
245
|
+
- `frameless`: Reduces the padding, e.g. for iframes
|
|
244
246
|
- `onuserclose`: Called when the user closes the popup
|
|
245
247
|
|
|
246
248
|
A common design pattern is to include a heading at the top of a popup. For this, the built-in `popup-title` class can be used:
|
|
@@ -299,7 +301,7 @@ showConfirmPopup("Remove item?", "The item will be removed from your favorites."
|
|
|
299
301
|
|
|
300
302
|
The error popup component is used to inform the user about errors. It needs to be mounted.
|
|
301
303
|
|
|
302
|
-
Error popups are shown via `
|
|
304
|
+
Error popups are shown via `showErrorPopup(title, description, errorCode, reload, hideDontShowAgainOption)`:
|
|
303
305
|
|
|
304
306
|
- `title`: The popup title
|
|
305
307
|
- `description`: The description
|
|
@@ -310,7 +312,7 @@ Error popups are shown via `errorPopup(title, description, errorCode, reload, hi
|
|
|
310
312
|
Usage example:
|
|
311
313
|
|
|
312
314
|
```js
|
|
313
|
-
|
|
315
|
+
showErrorPopup("Failed to load map", "An error occurred loading this map.", "Code 404: Map not found");
|
|
314
316
|
```
|
|
315
317
|
|
|
316
318
|
### InfoBanner
|
|
@@ -361,7 +363,7 @@ The room code input component is used for entering 6-character room codes. It ta
|
|
|
361
363
|
|
|
362
364
|
- `segments`: The entered characters
|
|
363
365
|
- `inPage`: Set to false when used in panels, boxes etc.
|
|
364
|
-
- `onsubmit`: Called with the code when
|
|
366
|
+
- `onsubmit`: Called with the code when Enter or the submit button is pressed
|
|
365
367
|
|
|
366
368
|
### Tabs
|
|
367
369
|
|
|
@@ -382,16 +384,17 @@ The ticker component is used for fine-grained numeric inputs. It takes the follo
|
|
|
382
384
|
- `value`: Current value
|
|
383
385
|
- `initialValue`: Start value
|
|
384
386
|
- `step`: Step amount (how much the value changes per step)
|
|
385
|
-
- `minimum`:
|
|
386
|
-
- `
|
|
387
|
-
- `
|
|
387
|
+
- `minimum`: Minimum value
|
|
388
|
+
- `maximum`: Maximum value
|
|
389
|
+
- `minimumText`, `maximumText`: Text displayed when the min/max is reached
|
|
390
|
+
- `minimumValue`, `maximumValue`: Custom value to bind when the min/max is reached
|
|
388
391
|
- `note`: Unit of the value
|
|
389
392
|
- `minValueWidth`: Minimum width of value field to prevent the width from jumping
|
|
390
393
|
- `onchange`: Called when the value changes
|
|
391
394
|
|
|
392
395
|
### TitleSeparator
|
|
393
396
|
|
|
394
|
-
The title separator component is used to separate content inside
|
|
397
|
+
The title separator component is used to separate content inside popups or containers. It takes the following props:
|
|
395
398
|
|
|
396
399
|
- `text`: The title text
|
|
397
400
|
- `noMargin`: Removes the default top and bottom margin (`--layout-margin`)
|
|
@@ -425,10 +428,12 @@ Options:
|
|
|
425
428
|
|
|
426
429
|
## Sound effects
|
|
427
430
|
|
|
428
|
-
UI sound effects are available as `.ogg` files and can be played with any audio library:
|
|
431
|
+
UI sound effects are available as `.ogg` files and can be played with any audio library. The `sounds` export maps each name to its file URL:
|
|
429
432
|
|
|
430
433
|
```js
|
|
431
|
-
import
|
|
434
|
+
import { sounds } from "openguessr-ui";
|
|
435
|
+
|
|
436
|
+
new Audio(sounds.basic_button).play();
|
|
432
437
|
```
|
|
433
438
|
|
|
434
439
|
| Sound | Purpose |
|
|
@@ -445,11 +450,9 @@ The components don't play sounds themselves. Instead, they should be played via
|
|
|
445
450
|
|
|
446
451
|
- Collapsible `ontoggle`: `toggle_button`
|
|
447
452
|
- Ticker `onchange`: `change_value`
|
|
453
|
+
- Tabs `onchange`: `basic_button`
|
|
448
454
|
- Notification `onaccept`, `ondismiss`: `basic_button`
|
|
449
|
-
|
|
450
|
-
## Scroll bars
|
|
451
|
-
|
|
452
|
-
Typically, scroll bars should be hidden via `scrollbar-width: none`. There can be exceptions, e.g. for text editors where a scroll bar brings utility.
|
|
455
|
+
- ConfirmPopup `onconfirm`: `basic_button`
|
|
453
456
|
|
|
454
457
|
## Text formatting guidelines
|
|
455
458
|
|
package/errorPopup.svelte.js
CHANGED
|
@@ -8,7 +8,7 @@ export const errorPopupState = $state({
|
|
|
8
8
|
reload: false
|
|
9
9
|
});
|
|
10
10
|
|
|
11
|
-
export function
|
|
11
|
+
export function showErrorPopup(popupTitle, popupDescription, popupErrorCode, reloadPopup, hideDontShowAgainOption) {
|
|
12
12
|
errorPopupState.hideDisableOption = hideDontShowAgainOption;
|
|
13
13
|
|
|
14
14
|
// If errors should be shown or it is a critical error that needs a reload, show the popup
|
package/index.js
CHANGED
|
@@ -13,4 +13,15 @@ export { default as TitleSeparator } from "./components/TitleSeparator.svelte";
|
|
|
13
13
|
export { tooltip } from "./tooltip.svelte.js";
|
|
14
14
|
export { showNotification } from "./notifications.svelte.js";
|
|
15
15
|
export { showConfirmPopup } from "./confirmPopup.svelte.js";
|
|
16
|
-
export {
|
|
16
|
+
export { showErrorPopup } from "./errorPopup.svelte.js";
|
|
17
|
+
|
|
18
|
+
// Sounds
|
|
19
|
+
import basic_button from "./sound-effects/basic_button.ogg";
|
|
20
|
+
import juicy_button from "./sound-effects/juicy_button.ogg";
|
|
21
|
+
import start_button from "./sound-effects/start_button.ogg";
|
|
22
|
+
import toggle_button from "./sound-effects/toggle_button.ogg";
|
|
23
|
+
import change_value from "./sound-effects/change_value.ogg";
|
|
24
|
+
import item_select from "./sound-effects/item_select.ogg";
|
|
25
|
+
import item_locked from "./sound-effects/item_locked.ogg";
|
|
26
|
+
|
|
27
|
+
export const sounds = { basic_button, juicy_button, start_button, toggle_button, change_value, item_select, item_locked };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "openguessr-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"dev": "vite example"
|
|
@@ -28,7 +28,6 @@
|
|
|
28
28
|
"./variables.css": "./variables.css",
|
|
29
29
|
"./base.css": "./base.css",
|
|
30
30
|
"./classes.css": "./classes.css",
|
|
31
|
-
"./sound-effects/*": "./sound-effects/*",
|
|
32
31
|
"./fonts/*": "./fonts/*"
|
|
33
32
|
},
|
|
34
33
|
"peerDependencies": {
|