Shannon Sterz [Mon, 13 Jan 2025 14:55:27 +0000 (15:55 +0100)]
macros: fix build for tests
it seems adapting the test case in pwt-macros was forgotten at some
point. this makes the test cases build-able again. please note that
this does not make all test cases here work, as some of them seem to
expect the output of specific rustc versions. this should probably be
addressed in a separate commit.
Shannon Sterz [Fri, 3 Jan 2025 13:58:46 +0000 (14:58 +0100)]
menu: remove MenuBar struct
this only had one use, create a Menu where `menubar` was already set to
`true`. use a new constructor instead called `new_menubar()` that does
the same without creating a superfluous type. it's also more idiomatic
to it this way. this fixes the clippy lint `new_ret_no_self` [1].
Shannon Sterz [Fri, 3 Jan 2025 13:37:10 +0000 (14:37 +0100)]
dom: use `into()` when converting JSValue to HtmlElement
this cannot fail, so just use `into()` and then wrap with `Some()` to
conform to function signature. this removes the clippy lint
`unnecessary_fallible_conversions` [1].
Shannon Sterz [Fri, 3 Jan 2025 13:29:22 +0000 (14:29 +0100)]
selection/store/tree_store: use `where` for generics in hooks
instead of in-lining them in the function definition. the `hook!` macro
will add a `'hook` liftime via a `where` clause to them when expanded,
which triggers the clippy lint `multiple_bound_locations` [1] as the
generics would then be bound in the function signature and the `where`
clause. so just define them in the `where` clause right away to avoid
that.
Shannon Sterz [Fri, 3 Jan 2025 13:15:20 +0000 (14:15 +0100)]
snack_bar_manager: use a box for `Show` message
the `Show` message takes a whole `SnackBar` struct that is
significantlly larger than the other enum variants here. use a `Box` to
improve performance and remove the clippy lint `large_enum_variant` [1].
Shannon Sterz [Fri, 3 Jan 2025 12:45:31 +0000 (13:45 +0100)]
form context: allow register_field with too many arguments
this is a publically facing api so allow the clippy lint
`too_many_arguments` [1] here for now and add a to-do to possible
refactor this to use it's own parameter types.
Shannon Sterz [Fri, 3 Jan 2025 12:33:33 +0000 (13:33 +0100)]
form module: allow module inception as we only public re-expose `Form`
allowing the clippy lint `module_inception` [1] here makes some sense as
no one should every really need to import anything but `pwt::form::Form`
or `pwt::form::PwtForm`.
Shannon Sterz [Fri, 3 Jan 2025 12:11:40 +0000 (13:11 +0100)]
split_pane: take ownership of `self` in `PaneSize` `to_*` functions
this breaks the self convention for types that are `Copy` such as
`PaneSize`. this should improve readability and fixes the
`wrong_self_convention` clippy lint [1].
Shannon Sterz [Fri, 3 Jan 2025 12:03:14 +0000 (13:03 +0100)]
loader/data_table: refactor match statements that return booleans
this can usually be more succinctly expressed with the `matches!` macro
or other methods to deal with `Result`s or `Option`s. this also fixed
the clippy lint `match_like_matches_macro` [1].
Shannon Sterz [Fri, 3 Jan 2025 10:46:04 +0000 (11:46 +0100)]
theme_mode_selector: `_`-prefix ctx as it's only used in recursion
since we olny pass through the `ctx` parameter and don't use it here
ourselves mark it with a `-`-prefix. this fixes the clippy lint
`only_used_in_recursion` [1].
Shannon Sterz [Fri, 3 Jan 2025 10:26:25 +0000 (11:26 +0100)]
tree wide: apply auto-appliable clippy fix-ups
this mostly includes:
- switching from `Into` to `From` implementations as that also provides
an `Into` implementation for "free"
- adding `Default` implementations where possible (e.g. if a `new`
function without parameters exists)
- removing unnecessary reference and dereference operations (e.g. if the
compiler would do that automatically anyway)
- using more idiomatic syntax (e.g. using `contains` instead of `<` and
`>=` operators)
- removing closures where they aren't necessary
- removing `format!` macros where `to_string()` would do to improve
performance
- remove unnecessary convertions and into calls
these should not change the semantics of the exists code itself, so
there are no breaking changes. however, adding `Default` implementations
and such, does add new public APIs for some types.
Dominik Csapak [Fri, 20 Dec 2024 10:31:39 +0000 (11:31 +0100)]
widget: dropdown: update picker placement after showing
It seems that under certain circumstances (e.g. a dropdown in a
dialog) updating the position of the picker before it's opened (it's a
popover) does not work properly in safari/webkit/epiphany.
When trying to open such a dropdown, it (or some parts of it) would be
rendered with a height of 0px, even though the elements have a height
set explicitly.
To fix this, update the picker placement after opening it. What
exactly is the cause (e.g. if it's a browser bug or our css/aligning)
is yet to be determined.
This fixes an issue on webkit (tested with epiphany) that opening
dropdowns in a dialog did not show the dropdown properly.
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com> Tested-by: Maximiliano Sandoval <m.sandoval@proxmox.com>
[ TL: extend comment to mention webkit explicitly ] Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Thomas Lamprecht [Thu, 19 Dec 2024 11:13:16 +0000 (12:13 +0100)]
whitepaper: re-flow text to 80 cc width
Wrap at a consistent text-width of 80 character columns, that is
a relatively standard width for prose and a good balance for having
more context visible at the same time while not requiring to much neck
moving.
Also fix a unclosed code-block by adding the third backtick
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
Dominik Csapak [Wed, 18 Dec 2024 14:25:08 +0000 (15:25 +0100)]
widget: display: don't set inital value
when doing that, a new value that is set via `new` won't get used as a
value anymore, which is undesired. only use the value for the default,
which was the original intenion.
This fixes an issue where the value of a display field changes after the
first creation and would not update it's displayed value.
Shannon Sterz [Tue, 17 Dec 2024 15:09:46 +0000 (16:09 +0100)]
catalog_loader: don't try to load the catalog if the language is empty
this means that the Language value in the local storage is not set. by
default this would try to load `catalog-.mo` as language is an empty
string, so just skip trying to load something here and simply initialize
with an empty catalog instead, avoiding a failed load.
Dominik Csapak [Mon, 16 Dec 2024 13:18:38 +0000 (14:18 +0100)]
widget: data table: beter handle navigation input
when inside a cell, we generally want to navigate with arrow keys,
except if we're inside an input element. In that case, use tab/shift+tab
to navigate out and don't catch arrows/space to allow navigation within
the input field (and input a space).
Thomas Lamprecht [Sat, 14 Dec 2024 12:58:52 +0000 (13:58 +0100)]
theme density: rework naming to more telling variants
Rework the naming and doc comments of the theme density type but
include backward compatibility for the old variants when parsing the
density from a string. There's nothing to adapt on the actual UI
examples or products.
The bigger improvement is avoiding "Auto" for the default theme
spacing/density, as "auto" is widely used for something that
dynamically adapts on some environment aspects. But all our themes do
not have any such queries for high/low dpi or screen width to choose a
fitting spacing dynamically. Use `Preset` to avoid clashing with the
widely used `Default` trait from the rust std lib, albeit we could use
that if we really want.
The smaller fine tuning is renaming "High" to "Compact" and "Touch" to
"Relaxed".
The reasoning for the first is that most people, including our user
base, does not work with density a lot in their every day life, be it
physical density or screen density, so "higher density", while
definitively correct for what it does, is not that intuitive, i.e.
when "higher" makes things "smaller" we have a sort of double-negation
that is almost never good to have for UX.
The reasoning for the second (Touch -> Relaxed) is that this is not
doing anything with touch directly, it just might correlate with that
use case, and coupling a setting name with one specific use case is a
bit confusing for peoples coming from other use cases, like simply
having a higher DPI but not doing desktop wide scaling.
Note the naming was initially suggested by me with Thunderbird as
example, so this is really just improving on my own short comings from
the past. It also seems that newer Thunderbird Versions (e.g., latest
134.0b4) changed the wording to something similar than we now have
after this commit.
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>