chore: improve number display and other comsmetic fixes
This commit is contained in:
parent
f48d78d03b
commit
d04f806c57
5 changed files with 66 additions and 39 deletions
|
|
@ -10,6 +10,12 @@ rustup target add wasm32-unknown-unknown
|
||||||
|
|
||||||
We will also use the [Trunk] tool to run and build our project.
|
We will also use the [Trunk] tool to run and build our project.
|
||||||
|
|
||||||
|
Finally, it's recommended to install the `leptosfmt` tool, since plain `rustfmt`
|
||||||
|
can't dealt with `view!` macros very well.
|
||||||
|
```sh
|
||||||
|
cargo install leptosfmt
|
||||||
|
```
|
||||||
|
|
||||||
## Developing
|
## Developing
|
||||||
|
|
||||||
To develop the project, run
|
To develop the project, run
|
||||||
|
|
@ -18,7 +24,6 @@ trunk serve --port 3000 --open
|
||||||
```
|
```
|
||||||
which, will open the app in your default browser at `http://localhost:3000`.
|
which, will open the app in your default browser at `http://localhost:3000`.
|
||||||
|
|
||||||
|
|
||||||
## Deploying
|
## Deploying
|
||||||
|
|
||||||
To build the project for release, use the command
|
To build the project for release, use the command
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,16 @@ body {
|
||||||
align-items: center;
|
align-items: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
header {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: end;
|
||||||
|
}
|
||||||
|
|
||||||
|
header > select {
|
||||||
|
margin: 0 1em;
|
||||||
|
}
|
||||||
|
|
||||||
h1,
|
h1,
|
||||||
h2,
|
h2,
|
||||||
h3,
|
h3,
|
||||||
|
|
@ -35,6 +45,7 @@ h6 {
|
||||||
h1.title {
|
h1.title {
|
||||||
width: 80vw;
|
width: 80vw;
|
||||||
max-inline-size: 80vw;
|
max-inline-size: 80vw;
|
||||||
|
padding-top: 1rem;
|
||||||
}
|
}
|
||||||
|
|
||||||
p {
|
p {
|
||||||
|
|
@ -62,21 +73,22 @@ form input {
|
||||||
width: 4em;
|
width: 4em;
|
||||||
}
|
}
|
||||||
|
|
||||||
form > div.results {
|
div.results {
|
||||||
display: grid;
|
display: grid;
|
||||||
grid-template-columns: 1fr 8em 5em 1fr;
|
grid-template-columns: 1fr 7em 1rem 5em 1fr;
|
||||||
|
padding-top: 1em;
|
||||||
min-width: 20em;
|
min-width: 20em;
|
||||||
max-width: 30em;
|
max-width: 30em;
|
||||||
width: 30vw;
|
width: 30vw;
|
||||||
font-size: 1.2em;
|
font-size: 1.2em;
|
||||||
}
|
}
|
||||||
|
|
||||||
form > div.results > span.left {
|
div.results > span.left {
|
||||||
grid-column: 2 / 3;
|
grid-column: 2 / 3;
|
||||||
text-align: right;
|
text-align: right;
|
||||||
padding-right: 1em;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
form > div.results > span.right {
|
div.results > span.right {
|
||||||
grid-column: 3 / 4;
|
grid-column: 4 / 5;
|
||||||
|
text-align: left;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
2
rust-analyzer.toml
Normal file
2
rust-analyzer.toml
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
[rustfmt]
|
||||||
|
overrideCommand = ["leptosfmt", "--stdin", "--rustfmt"]
|
||||||
1
rustfmt.toml
Normal file
1
rustfmt.toml
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
edition = "2024"
|
||||||
|
|
@ -77,38 +77,45 @@ pub fn Calculator() -> impl IntoView {
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</p>
|
</p>
|
||||||
<div class="results">
|
|
||||||
<span class="left">
|
|
||||||
<span>"P(X = "</span>
|
|
||||||
<span>{sample_successes}</span>
|
|
||||||
<span>"): "</span>
|
|
||||||
</span>
|
|
||||||
<span class="right">{move || result().exactly}</span>
|
|
||||||
<span class="left">
|
|
||||||
<span>"P(X < "</span>
|
|
||||||
<span>{sample_successes}</span>
|
|
||||||
<span>"): "</span>
|
|
||||||
</span>
|
|
||||||
<span class="right">{move || result().less_than}</span>
|
|
||||||
<span class="left">
|
|
||||||
<span>"P(X ≤ "</span>
|
|
||||||
<span>{sample_successes}</span>
|
|
||||||
<span>"): "</span>
|
|
||||||
</span>
|
|
||||||
<span class="right">{move || result().less_or_equal}</span>
|
|
||||||
<span class="left">
|
|
||||||
<span>"P(X > "</span>
|
|
||||||
<span>{sample_successes}</span>
|
|
||||||
<span>"): "</span>
|
|
||||||
</span>
|
|
||||||
<span class="right">{move || result().greater_than}</span>
|
|
||||||
<span class="left">
|
|
||||||
<span>"P(X ≥ "</span>
|
|
||||||
<span>{sample_successes}</span>
|
|
||||||
<span>"): "</span>
|
|
||||||
</span>
|
|
||||||
<span class="right">{move || result().greater_or_equal}</span>
|
|
||||||
</div>
|
|
||||||
</form>
|
</form>
|
||||||
|
<div class="results">
|
||||||
|
<span class="left">
|
||||||
|
<span>"P(X = "</span>
|
||||||
|
<span>{sample_successes}</span>
|
||||||
|
<span>"): "</span>
|
||||||
|
</span>
|
||||||
|
<span class="right">{move || display_rounded(result().exactly)}</span>
|
||||||
|
<span class="left">
|
||||||
|
<span>"P(X < "</span>
|
||||||
|
<span>{sample_successes}</span>
|
||||||
|
<span>"): "</span>
|
||||||
|
</span>
|
||||||
|
<span class="right">{move || display_rounded(result().less_than)}</span>
|
||||||
|
<span class="left">
|
||||||
|
<span>"P(X ≤ "</span>
|
||||||
|
<span>{sample_successes}</span>
|
||||||
|
<span>"): "</span>
|
||||||
|
</span>
|
||||||
|
<span class="right">{move || display_rounded(result().less_or_equal)}</span>
|
||||||
|
<span class="left">
|
||||||
|
<span>"P(X > "</span>
|
||||||
|
<span>{sample_successes}</span>
|
||||||
|
<span>"): "</span>
|
||||||
|
</span>
|
||||||
|
<span class="right">{move || display_rounded(result().greater_than)}</span>
|
||||||
|
<span class="left">
|
||||||
|
<span>"P(X ≥ "</span>
|
||||||
|
<span>{sample_successes}</span>
|
||||||
|
<span>"): "</span>
|
||||||
|
</span>
|
||||||
|
<span class="right">{move || display_rounded(result().greater_or_equal)}</span>
|
||||||
|
</div>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn display_rounded(x: f64) -> String {
|
||||||
|
format!("{x:.5}")
|
||||||
|
.trim_end_matches("0")
|
||||||
|
.trim_end_matches(".")
|
||||||
|
.to_string()
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue