openguessr-ui 0.1.0 → 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 +41 -36
- package/errorPopup.svelte.js +1 -1
- package/index.js +12 -1
- package/package.json +1 -2
package/README.md
CHANGED
|
@@ -13,17 +13,17 @@ These core concepts define how UI should be structured.
|
|
|
13
13
|
|
|
14
14
|
### Core concepts
|
|
15
15
|
|
|
16
|
-
- **Boxes:** Boxes house controls, text, or other boxes.
|
|
16
|
+
- **Boxes:** Boxes house controls, text, images, or other boxes.
|
|
17
17
|
|
|
18
|
-
- **Panels:** Panels are
|
|
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
|
|
|
24
24
|
### Hierarchy
|
|
25
25
|
|
|
26
|
-
1. Every element starts in layout space (level 1), where `--layout-margin` defines the spacing between grouped elements
|
|
26
|
+
1. Every element starts in layout space (level 1), where `--layout-margin` defines the spacing between grouped elements, the padding, and the border radii of children. For separating unrelated elements, `--layout-spacer` is used.
|
|
27
27
|
|
|
28
28
|
2. The second level is containers, where the spacing and padding is `--box-margin`, and the border radii of children are as well.
|
|
29
29
|
|
|
@@ -31,9 +31,9 @@ These core concepts define how UI should be structured.
|
|
|
31
31
|
|
|
32
32
|
4. On the fourth level there is either content or smaller boxes. Smaller boxes still use `--box-margin` for padding and spacing, but `--content-margin` for border radii.
|
|
33
33
|
|
|
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
|
|
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
|
|
|
@@ -64,25 +64,25 @@ These variables are used for colors:
|
|
|
64
64
|
| --overlay-color | Dark overlays |
|
|
65
65
|
| --overlay-color-dark | Full-screen menu overlays |
|
|
66
66
|
| --bright-green-color | Experience, perks |
|
|
67
|
-
| --bright-green-color-soft| Indicators
|
|
67
|
+
| --bright-green-color-soft| Indicators |
|
|
68
68
|
| --bright-green-color-dark | Experience, perk backgrounds |
|
|
69
69
|
| --background-color | Opaque background |
|
|
70
70
|
| --dark-shadow-color | Text or drop shadows |
|
|
71
71
|
|
|
72
72
|
> [!TIP]
|
|
73
|
-
> There should be at most one `--brand-color` element visible at a time (the primary action). Green colors should
|
|
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
|
| -------- | ------- |
|
|
79
79
|
| --button-shadow | Buttons |
|
|
80
|
-
| --button-shadow-dark |
|
|
80
|
+
| --button-shadow-dark | Dark buttons |
|
|
81
81
|
| --box-shadow-top | Boxes that fade out towards the bottom |
|
|
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
|
|
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
|
|
|
@@ -169,7 +169,7 @@ Layouts typically use this base styling:
|
|
|
169
169
|
|
|
170
170
|
### Buttons
|
|
171
171
|
|
|
172
|
-
Buttons should always be placed in a box or panel, not just on a blank page. Large buttons
|
|
172
|
+
Buttons should always be placed in a box or panel, not just on a blank page. Large buttons shouldn't be put into a box.
|
|
173
173
|
|
|
174
174
|
To create a button, apply the `standard-button` class. This will create a red primary button. To make it secondary, add `bright`.
|
|
175
175
|
|
|
@@ -181,7 +181,7 @@ Large buttons with short text inside often look unnaturally slim when placed as
|
|
|
181
181
|
|
|
182
182
|
Regular buttons typically have the icon placed on the left side.
|
|
183
183
|
|
|
184
|
-
Large buttons with text place the icon towards the right and use `space-between` to ensure that when multiple buttons are present, icons and text are perfectly aligned
|
|
184
|
+
Large buttons with text place the icon towards the right and use `space-between` to ensure that when multiple buttons are present in a stack, icons and text are perfectly horizontally aligned, making it easier to scan through them at a glance.
|
|
185
185
|
|
|
186
186
|
### Icons
|
|
187
187
|
|
|
@@ -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:
|
|
@@ -263,7 +265,7 @@ The chip component is used for small pieces of information, such as a "New" or "
|
|
|
263
265
|
- `italic`: Makes the text italic, typically combined with red
|
|
264
266
|
- `mutedOpacity`: Makes the text muted, red variant typically disables this
|
|
265
267
|
- `onclick`: Makes the chip clickable
|
|
266
|
-
- `class`, `style`: Class passthrough
|
|
268
|
+
- `class`, `style`: Class and style passthrough
|
|
267
269
|
|
|
268
270
|
### Collapsible
|
|
269
271
|
|
|
@@ -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`)
|
|
@@ -411,6 +414,8 @@ Usage example:
|
|
|
411
414
|
<button {@attach tooltip({ text: "Settings" })}><GearsIcon /></button>
|
|
412
415
|
```
|
|
413
416
|
|
|
417
|
+
Options:
|
|
418
|
+
|
|
414
419
|
- `text`: The tooltip text
|
|
415
420
|
- `imageSrc`: Image shown above the text
|
|
416
421
|
- `imageAspectRatio`: Aspect ratio of the image
|
|
@@ -423,10 +428,12 @@ Usage example:
|
|
|
423
428
|
|
|
424
429
|
## Sound effects
|
|
425
430
|
|
|
426
|
-
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:
|
|
427
432
|
|
|
428
433
|
```js
|
|
429
|
-
import
|
|
434
|
+
import { sounds } from "openguessr-ui";
|
|
435
|
+
|
|
436
|
+
new Audio(sounds.basic_button).play();
|
|
430
437
|
```
|
|
431
438
|
|
|
432
439
|
| Sound | Purpose |
|
|
@@ -434,20 +441,18 @@ import basicButtonSound from "openguessr-ui/sound-effects/basic_button.ogg";
|
|
|
434
441
|
| basic_button | Default sound for standard buttons and tabs |
|
|
435
442
|
| juicy_button | Selection-like choices (e.g. map selection) |
|
|
436
443
|
| start_button | Starting or joining a game |
|
|
437
|
-
| toggle_button | Anything that toggles
|
|
438
|
-
| change_value | Changing a value
|
|
439
|
-
| item_select | Selecting an item
|
|
444
|
+
| toggle_button | Anything that toggles (e.g. collapsibles) |
|
|
445
|
+
| change_value | Changing a value (e.g. through a ticker) |
|
|
446
|
+
| item_select | Selecting an item (e.g. a pin, badge, or flag) |
|
|
440
447
|
| item_locked | Trying to select a locked item |
|
|
441
448
|
|
|
442
|
-
The components don't play sounds themselves. Instead,
|
|
449
|
+
The components don't play sounds themselves. Instead, they should be played via callbacks:
|
|
443
450
|
|
|
444
451
|
- Collapsible `ontoggle`: `toggle_button`
|
|
445
452
|
- Ticker `onchange`: `change_value`
|
|
453
|
+
- Tabs `onchange`: `basic_button`
|
|
446
454
|
- Notification `onaccept`, `ondismiss`: `basic_button`
|
|
447
|
-
|
|
448
|
-
## Scroll bars
|
|
449
|
-
|
|
450
|
-
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`
|
|
451
456
|
|
|
452
457
|
## Text formatting guidelines
|
|
453
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": {
|