Temp
This commit is contained in:
parent
d9988fbf6c
commit
8b11832c22
|
@ -1,10 +1,11 @@
|
||||||
mod api;
|
mod api;
|
||||||
|
|
||||||
use rocket::fs::FileServer;
|
use std::path::{Path, PathBuf};
|
||||||
|
|
||||||
|
use rocket::fs::{FileServer, NamedFile, Options};
|
||||||
use rocket_cors::CorsOptions;
|
use rocket_cors::CorsOptions;
|
||||||
use rocket_db_pools::{mongodb, Database};
|
use rocket_db_pools::{mongodb, Database};
|
||||||
use rocket_okapi::{
|
use rocket_okapi::{
|
||||||
openapi,
|
|
||||||
rapidoc::*,
|
rapidoc::*,
|
||||||
settings::{OpenApiSettings, UrlObject},
|
settings::{OpenApiSettings, UrlObject},
|
||||||
swagger_ui::{make_swagger_ui, SwaggerUIConfig},
|
swagger_ui::{make_swagger_ui, SwaggerUIConfig},
|
||||||
|
@ -17,12 +18,6 @@ extern crate rocket;
|
||||||
#[database("party")]
|
#[database("party")]
|
||||||
pub struct Db(mongodb::Client);
|
pub struct Db(mongodb::Client);
|
||||||
|
|
||||||
#[openapi]
|
|
||||||
#[get("/")]
|
|
||||||
fn index() -> String {
|
|
||||||
format!("Hello, world!")
|
|
||||||
}
|
|
||||||
|
|
||||||
#[launch]
|
#[launch]
|
||||||
fn rocket() -> _ {
|
fn rocket() -> _ {
|
||||||
let cors = CorsOptions::default()
|
let cors = CorsOptions::default()
|
||||||
|
@ -33,7 +28,9 @@ fn rocket() -> _ {
|
||||||
let building_rocket = rocket::build()
|
let building_rocket = rocket::build()
|
||||||
.attach(Db::init())
|
.attach(Db::init())
|
||||||
.attach(cors)
|
.attach(cors)
|
||||||
.mount("/", FileServer::from("./web/dist"))
|
.mount("/", FileServer::from("./web/dist").rank(5))
|
||||||
|
.mount("/users", FileServer::from("./web/dist"))
|
||||||
|
.mount("/events", FileServer::from("./web/dist"))
|
||||||
.mount(
|
.mount(
|
||||||
"/swagger",
|
"/swagger",
|
||||||
make_swagger_ui(&SwaggerUIConfig {
|
make_swagger_ui(&SwaggerUIConfig {
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
<!DOCTYPE html><html><head>
|
<!DOCTYPE html><html><head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<link rel="stylesheet" href="/tailwind-9741b801a155bf5f.css">
|
<!--<link data-trunk href="tailwind.css" rel="css">-->
|
||||||
|
<link rel="stylesheet" href="/simple.min-d15f5ff500b4c62a.css">
|
||||||
|
<link rel="stylesheet" href="/style-13bbcf1f99e2f75c.css">
|
||||||
<link href="https://cdn.jsdelivr.net/npm/@mdi/font@6.9.96/css/materialdesignicons.min.css" rel="stylesheet">
|
<link href="https://cdn.jsdelivr.net/npm/@mdi/font@6.9.96/css/materialdesignicons.min.css" rel="stylesheet">
|
||||||
<title>Yew App</title>
|
<title>LAN Party</title>
|
||||||
|
|
||||||
<link rel="preload" href="/index-15f6ea5300c4a038_bg.wasm" as="fetch" type="application/wasm" crossorigin="">
|
<link rel="preload" href="/index-fd3fb1b7ad6689f9_bg.wasm" as="fetch" type="application/wasm" crossorigin="">
|
||||||
<link rel="modulepreload" href="/index-15f6ea5300c4a038.js"></head>
|
<link rel="modulepreload" href="/index-fd3fb1b7ad6689f9.js"></head>
|
||||||
<body class="base theme-dark bg-gray-900 text-gray-400">
|
<body>
|
||||||
|
<script type="module">import init from '/index-fd3fb1b7ad6689f9.js';init('/index-fd3fb1b7ad6689f9_bg.wasm');</script></body></html>
|
||||||
|
|
||||||
<script type="module">import init from '/index-15f6ea5300c4a038.js';init('/index-15f6ea5300c4a038_bg.wasm');</script></body></html>
|
|
File diff suppressed because it is too large
Load Diff
|
@ -2,10 +2,10 @@
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<link data-trunk href="tailwind.css" rel="css">
|
<!--<link data-trunk href="tailwind.css" rel="css">-->
|
||||||
|
<link data-trunk href="simple.min.css" rel="css">
|
||||||
|
<link data-trunk href="style.css" rel="css">
|
||||||
<link href="https://cdn.jsdelivr.net/npm/@mdi/font@6.9.96/css/materialdesignicons.min.css" rel="stylesheet">
|
<link href="https://cdn.jsdelivr.net/npm/@mdi/font@6.9.96/css/materialdesignicons.min.css" rel="stylesheet">
|
||||||
<title>Yew App</title>
|
<title>LAN Party</title>
|
||||||
</head>
|
</head>
|
||||||
<body class="base theme-dark bg-gray-900 text-gray-400">
|
|
||||||
</body>
|
|
||||||
</html>
|
</html>
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1,60 +0,0 @@
|
||||||
use yew::{function_component, html, Callback, Classes, Component, Properties};
|
|
||||||
|
|
||||||
/*
|
|
||||||
pub enum Msg {
|
|
||||||
Click,
|
|
||||||
}
|
|
||||||
|
|
||||||
pub struct Button;
|
|
||||||
|
|
||||||
impl Component for Button {
|
|
||||||
type Message = Msg;
|
|
||||||
type Properties = Props;
|
|
||||||
|
|
||||||
fn create(ctx: &yew::Context<Self>) -> Self {
|
|
||||||
Self
|
|
||||||
}
|
|
||||||
|
|
||||||
fn update(&mut self, ctx: &yew::Context<Self>, msg: Self::Message) -> bool {
|
|
||||||
match msg {
|
|
||||||
Msg::Click => ctx.props().onclick.emit(()),
|
|
||||||
};
|
|
||||||
|
|
||||||
false
|
|
||||||
}
|
|
||||||
|
|
||||||
fn view(&self, ctx: &yew::Context<Self>) -> yew::Html {
|
|
||||||
let link = ctx.link().clone();
|
|
||||||
|
|
||||||
html! {
|
|
||||||
<button class="bg-gray-700 hover:bg-gray-800 text-gray-400 font-bold py-2 px-2 rounded inline-flex items-center" onclick={link.callback(|_| Msg::Click)}>{ "+1" }</button>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
#[derive(Properties, PartialEq, Default)]
|
|
||||||
pub struct Props {
|
|
||||||
pub onclick: Callback<()>,
|
|
||||||
#[prop_or_default]
|
|
||||||
pub text: String,
|
|
||||||
#[prop_or_default]
|
|
||||||
pub icon: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[function_component(Button)]
|
|
||||||
pub fn button(props: &Props) -> Html {
|
|
||||||
let mut icon_class = Classes::from("mdi");
|
|
||||||
icon_class.push("text-lg");
|
|
||||||
|
|
||||||
if !props.icon.is_empty() {
|
|
||||||
icon_class.push(&props.icon);
|
|
||||||
}
|
|
||||||
|
|
||||||
html! {
|
|
||||||
<button class="bg-gray-700 hover:bg-gray-800 text-gray-400 font-bold py-2 px-2 rounded inline-flex items-center" onclick={props.onclick.reform(move |_| ())}>
|
|
||||||
<span class={icon_class}></span>
|
|
||||||
<span>{ &props.text }</span>
|
|
||||||
</button>
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -5,11 +5,10 @@ use lan_party_core::event::{
|
||||||
free_for_all_game::FreeForAllGameSpec, team_game::TeamGameSpec, test::TestSpec, EventSpec,
|
free_for_all_game::FreeForAllGameSpec, team_game::TeamGameSpec, test::TestSpec, EventSpec,
|
||||||
EventTypeSpec,
|
EventTypeSpec,
|
||||||
};
|
};
|
||||||
|
use log::debug;
|
||||||
use paste::paste;
|
use paste::paste;
|
||||||
use sycamore::prelude::*;
|
use sycamore::prelude::*;
|
||||||
|
|
||||||
use super::input_classes;
|
|
||||||
|
|
||||||
macro_rules! editable {
|
macro_rules! editable {
|
||||||
($type:ty => $editor:ty) => {
|
($type:ty => $editor:ty) => {
|
||||||
impl<'a, G: Html> Editable<'a, G> for $type {
|
impl<'a, G: Html> Editable<'a, G> for $type {
|
||||||
|
@ -23,7 +22,8 @@ macro_rules! edit_fields {
|
||||||
view! { $cx,
|
view! { $cx,
|
||||||
$(
|
$(
|
||||||
p {
|
p {
|
||||||
($name) ": " ($prop.edit($cx))
|
label { ($name) }
|
||||||
|
($prop.edit($cx))
|
||||||
}
|
}
|
||||||
)*
|
)*
|
||||||
}
|
}
|
||||||
|
@ -65,6 +65,58 @@ macro_rules! edit_struct {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
macro_rules! link_variants {
|
||||||
|
($cx:ident, $selected:ident => $($index:literal: $var_name:ident = $variant:ident: $var_type:ty),* $(,)? => $state:ident as $t:ident) => {
|
||||||
|
let $selected = create_signal($cx, String::from("0"));
|
||||||
|
|
||||||
|
$(let $var_name = if let $t::$variant(v) = $state.get().as_ref().clone() {
|
||||||
|
create_signal($cx, v.clone())
|
||||||
|
} else {
|
||||||
|
create_signal($cx, <$var_type>::default())
|
||||||
|
};)*
|
||||||
|
|
||||||
|
create_effect($cx, || {
|
||||||
|
debug!("{:#?}", $selected.get());
|
||||||
|
match $selected.get().as_str() {
|
||||||
|
$(stringify!($index) => $state.set($t::$variant($var_name.get().as_ref().clone())),)*
|
||||||
|
_ => unreachable!()
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! edit_enum {
|
||||||
|
($enum:ident => $selected:ident => $($index:literal: $var_name:ident = $variant:ident: $var_type:ty),* $(,)?) => {
|
||||||
|
paste! {
|
||||||
|
pub struct [<$enum Edit>];
|
||||||
|
|
||||||
|
impl<'a, G: Html> Editor<'a, G, $enum> for [<$enum Edit>] {
|
||||||
|
fn edit(cx: Scope<'a>, props: EditProps<'a, $enum>) -> View<G> {
|
||||||
|
let state = props.state;
|
||||||
|
|
||||||
|
link_variants!(cx, $selected =>
|
||||||
|
$($index: $var_name = $variant: $var_type,)*
|
||||||
|
=> state as $enum
|
||||||
|
);
|
||||||
|
|
||||||
|
view! { cx,
|
||||||
|
Block(title=stringify!($enum).to_string()) {
|
||||||
|
select(bind:value=$selected) {
|
||||||
|
$(option(value={stringify!($index)}, selected=$index==0) { (stringify!($variant)) })*
|
||||||
|
}
|
||||||
|
(match state.get().as_ref().clone() {
|
||||||
|
$($enum::$variant(_) => $var_name.edit(cx),)*
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
editable!($enum => [<$enum Edit>]);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Prop)]
|
#[derive(Prop)]
|
||||||
pub struct EditProps<'a, T> {
|
pub struct EditProps<'a, T> {
|
||||||
pub state: &'a Signal<T>,
|
pub state: &'a Signal<T>,
|
||||||
|
@ -108,6 +160,13 @@ pub trait Editable<'a, G: Html>: Sized {
|
||||||
}
|
}
|
||||||
|
|
||||||
edit_struct!(EventSpec => ("Name", name), ("Description", description), ("Event type", event_type));
|
edit_struct!(EventSpec => ("Name", name), ("Description", description), ("Event type", event_type));
|
||||||
|
|
||||||
|
edit_enum!(EventTypeSpec => selected =>
|
||||||
|
0: test = Test: TestSpec,
|
||||||
|
1: team_game = TeamGame: TeamGameSpec,
|
||||||
|
2: free_for_all_game = FreeForAllGame: FreeForAllGameSpec
|
||||||
|
);
|
||||||
|
|
||||||
edit_struct!(TestSpec => ("Number of players", num_players));
|
edit_struct!(TestSpec => ("Number of players", num_players));
|
||||||
edit_struct!(TeamGameSpec => );
|
edit_struct!(TeamGameSpec => );
|
||||||
edit_struct!(FreeForAllGameSpec => );
|
edit_struct!(FreeForAllGameSpec => );
|
||||||
|
@ -117,7 +176,7 @@ pub struct StringEdit;
|
||||||
impl<'a, G: Html> Editor<'a, G, String> for StringEdit {
|
impl<'a, G: Html> Editor<'a, G, String> for StringEdit {
|
||||||
fn edit(cx: Scope<'a>, props: EditProps<'a, String>) -> View<G> {
|
fn edit(cx: Scope<'a>, props: EditProps<'a, String>) -> View<G> {
|
||||||
view! { cx,
|
view! { cx,
|
||||||
input(class=input_classes(), bind:value=props.state)
|
input(bind:value=props.state)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -132,12 +191,12 @@ where
|
||||||
{
|
{
|
||||||
fn edit(cx: Scope<'a>, _props: EditProps<'a, T>) -> View<G> {
|
fn edit(cx: Scope<'a>, _props: EditProps<'a, T>) -> View<G> {
|
||||||
view! { cx,
|
view! { cx,
|
||||||
"Unimplemented"
|
i { "Editor Unimplemented" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
editable!(EventTypeSpec => StubEdit);
|
//editable!(EventTypeSpec => StubEdit);
|
||||||
|
|
||||||
pub struct InputEdit;
|
pub struct InputEdit;
|
||||||
|
|
||||||
|
@ -148,14 +207,14 @@ where
|
||||||
fn edit(cx: Scope<'a>, props: EditProps<'a, T>) -> View<G> {
|
fn edit(cx: Scope<'a>, props: EditProps<'a, T>) -> View<G> {
|
||||||
let value = create_signal(cx, props.state.get().to_string());
|
let value = create_signal(cx, props.state.get().to_string());
|
||||||
|
|
||||||
create_memo(cx, || {
|
create_effect(cx, || {
|
||||||
props
|
props
|
||||||
.state
|
.state
|
||||||
.set((*value.get()).parse().unwrap_or(T::default()))
|
.set((*value.get()).parse().unwrap_or(T::default()))
|
||||||
});
|
});
|
||||||
|
|
||||||
view! { cx,
|
view! { cx,
|
||||||
input(class=input_classes(), bind:value=value)
|
input(bind:value=value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -182,3 +241,19 @@ impl<'a, G: Html> Editor<'a, G, bool> for BoolEdit {
|
||||||
}
|
}
|
||||||
|
|
||||||
editable!(bool => BoolEdit);
|
editable!(bool => BoolEdit);
|
||||||
|
|
||||||
|
#[derive(Default, Clone)]
|
||||||
|
pub struct Test {
|
||||||
|
inner: TestInner,
|
||||||
|
inner2: TestInner,
|
||||||
|
}
|
||||||
|
|
||||||
|
edit_struct!(Test => ("Inner", inner), ("Inner 2", inner2));
|
||||||
|
|
||||||
|
#[derive(Default, Clone)]
|
||||||
|
pub struct TestInner {
|
||||||
|
some_text: String,
|
||||||
|
some_number: usize,
|
||||||
|
}
|
||||||
|
|
||||||
|
edit_struct!(TestInner => ("Text", some_text), ("Number", some_number));
|
||||||
|
|
|
@ -3,20 +3,6 @@ pub mod event;
|
||||||
use sycamore::prelude::*;
|
use sycamore::prelude::*;
|
||||||
use web_sys::Event;
|
use web_sys::Event;
|
||||||
|
|
||||||
#[derive(Prop)]
|
|
||||||
pub struct PageProps<'a, G: Html> {
|
|
||||||
pub children: Children<'a, G>,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[component]
|
|
||||||
pub fn Page<'a, G: Html>(cx: Scope<'a>, props: PageProps<'a, G>) -> View<G> {
|
|
||||||
let children = props.children.call(cx);
|
|
||||||
|
|
||||||
view! { cx,
|
|
||||||
div(class="max-w-7xl mx-auto") { (children) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Prop)]
|
#[derive(Prop)]
|
||||||
pub struct Props<F: FnMut(Event)> {
|
pub struct Props<F: FnMut(Event)> {
|
||||||
pub onclick: F,
|
pub onclick: F,
|
||||||
|
@ -28,14 +14,14 @@ pub struct Props<F: FnMut(Event)> {
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn Button<'a, G: Html, F: 'a + FnMut(Event)>(cx: Scope<'a>, props: Props<F>) -> View<G> {
|
pub fn Button<'a, G: Html, F: 'a + FnMut(Event)>(cx: Scope<'a>, props: Props<F>) -> View<G> {
|
||||||
let mut icon_class = String::from("mdi text-lg ");
|
let mut icon_class = String::from("mdi ");
|
||||||
|
|
||||||
if !props.icon.is_empty() {
|
if !props.icon.is_empty() {
|
||||||
icon_class.push_str(&props.icon);
|
icon_class.push_str(&props.icon);
|
||||||
}
|
}
|
||||||
|
|
||||||
view! { cx,
|
view! { cx,
|
||||||
button(class="bg-gray-700 hover:bg-gray-800 text-gray-400 font-bold py-2 px-2 rounded inline-flex items-center",on:click=props.onclick) {
|
button(on:click=props.onclick) {
|
||||||
span(class=icon_class)
|
span(class=icon_class)
|
||||||
span { (props.text) }
|
span { (props.text) }
|
||||||
}
|
}
|
||||||
|
@ -54,30 +40,22 @@ pub fn Table<'a, G: Html>(cx: Scope<'a>, props: TableProps<'a, G>) -> View<G> {
|
||||||
let children = props.children.call(cx);
|
let children = props.children.call(cx);
|
||||||
|
|
||||||
view! { cx,
|
view! { cx,
|
||||||
div(class="inline-block min-w-full py-2 align-middle") {
|
table {
|
||||||
div(class="overflow-hidden shadow ring-1 ring-black ring-opacity-5 md:rounded-lg") {
|
thead {
|
||||||
table(class="min-w-full divide-y divide-gray-600") {
|
|
||||||
thead(class="bg-gray-800") {
|
|
||||||
tr {
|
tr {
|
||||||
(View::new_fragment(props.headers.iter().cloned().map(|header| view! { cx,
|
(View::new_fragment(props.headers.iter().cloned().map(|header| view! { cx,
|
||||||
th(
|
th(scope="col") {
|
||||||
scope="col",
|
|
||||||
class="px-3 py-3.5 text-left
|
|
||||||
text-sm font-semibold text-gray-400"
|
|
||||||
) {
|
|
||||||
(header)
|
(header)
|
||||||
}
|
}
|
||||||
}).collect()))
|
}).collect()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
tbody(class="divide-y divide-gray-600 bg-gray-700") {
|
tbody {
|
||||||
(children)
|
(children)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Prop)]
|
#[derive(Prop)]
|
||||||
pub struct BlockProps<'a, G: Html> {
|
pub struct BlockProps<'a, G: Html> {
|
||||||
|
@ -88,46 +66,11 @@ pub struct BlockProps<'a, G: Html> {
|
||||||
#[component]
|
#[component]
|
||||||
pub fn Block<'a, G: Html>(cx: Scope<'a>, props: BlockProps<'a, G>) -> View<G> {
|
pub fn Block<'a, G: Html>(cx: Scope<'a>, props: BlockProps<'a, G>) -> View<G> {
|
||||||
let children = props.children.call(cx);
|
let children = props.children.call(cx);
|
||||||
let open = create_signal(cx, false);
|
|
||||||
|
|
||||||
let class = create_memo(cx, || {
|
|
||||||
if *open.get() {
|
|
||||||
"overflow-hidden"
|
|
||||||
} else {
|
|
||||||
"overflow-hidden max-h-1"
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
view! { cx,
|
view! { cx,
|
||||||
div(class="px-3 py-3 rounded-lg border-solid border-gray-800 border-2 my-3") {
|
details {
|
||||||
p(class="cursor-pointer text-lg",on:click=move |_| open.set(!*open.get())) { (props.title) }
|
summary { (props.title) }
|
||||||
div(class=class) {
|
p { (children) }
|
||||||
br {}
|
|
||||||
div {
|
|
||||||
(children)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn input_classes() -> &'static str {
|
|
||||||
"mx-2 appearance-none block bg-gray-700 text-slate-400 border border-gray-600 rounded py-2 px-2 w-50 leading-tight focus:outline-none focus:ring-1 focus:ring-gray-500 focus:border-gray-500"
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
#[function_component(Loading)]
|
|
||||||
pub fn loading() -> Html {
|
|
||||||
html! {
|
|
||||||
<svg role="status" class="inline h-8 w-8 animate-spin mr-2 text-gray-200 dark:text-gray-600 fill-gray-400"
|
|
||||||
viewBox="0 0 100 101" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
||||||
<path
|
|
||||||
d="M100 50.5908C100 78.2051 77.6142 100.591 50 100.591C22.3858 100.591 0 78.2051 0 50.5908C0 22.9766 22.3858 0.59082 50 0.59082C77.6142 0.59082 100 22.9766 100 50.5908ZM9.08144 50.5908C9.08144 73.1895 27.4013 91.5094 50 91.5094C72.5987 91.5094 90.9186 73.1895 90.9186 50.5908C90.9186 27.9921 72.5987 9.67226 50 9.67226C27.4013 9.67226 9.08144 27.9921 9.08144 50.5908Z"
|
|
||||||
fill="currentColor" />
|
|
||||||
<path
|
|
||||||
d="M93.9676 39.0409C96.393 38.4038 97.8624 35.9116 97.0079 33.5539C95.2932 28.8227 92.871 24.3692 89.8167 20.348C85.8452 15.1192 80.8826 10.7238 75.2124 7.41289C69.5422 4.10194 63.2754 1.94025 56.7698 1.05124C51.7666 0.367541 46.6976 0.446843 41.7345 1.27873C39.2613 1.69328 37.813 4.19778 38.4501 6.62326C39.0873 9.04874 41.5694 10.4717 44.0505 10.1071C47.8511 9.54855 51.7191 9.52689 55.5402 10.0491C60.8642 10.7766 65.9928 12.5457 70.6331 15.2552C75.2735 17.9648 79.3347 21.5619 82.5849 25.841C84.9175 28.9121 86.7997 32.2913 88.1811 35.8758C89.083 38.2158 91.5421 39.6781 93.9676 39.0409Z"
|
|
||||||
fill="currentFill" />
|
|
||||||
</svg>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
|
@ -1,49 +0,0 @@
|
||||||
use yew::{function_component, html, Children, Html, Properties};
|
|
||||||
|
|
||||||
#[derive(Properties, PartialEq, Default)]
|
|
||||||
pub struct Props {
|
|
||||||
pub headers: Vec<String>,
|
|
||||||
pub rows: Vec<Vec<String>>,
|
|
||||||
pub loading: bool,
|
|
||||||
|
|
||||||
#[prop_or_default]
|
|
||||||
pub children: Children,
|
|
||||||
}
|
|
||||||
|
|
||||||
#[function_component(Table)]
|
|
||||||
pub fn table(props: &Props) -> Html {
|
|
||||||
html! {
|
|
||||||
<div class="inline-block min-w-full py-2 align-middle">
|
|
||||||
<div class="overflow-hidden shadow ring-1 ring-black ring-opacity-5 md:rounded-lg">
|
|
||||||
<table class="min-w-full divide-y divide-gray-600">
|
|
||||||
<thead class="bg-gray-800">
|
|
||||||
<tr>
|
|
||||||
{props.headers.iter().map(|header| html! {
|
|
||||||
<th scope="col" class="px-3 py-3.5 text-left text-sm font-semibold text-gray-400">{header}</th>
|
|
||||||
}).collect::<Html>()}
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody class="divide-y divide-gray-600 bg-gray-700">
|
|
||||||
{props.rows.iter().map(|row| html! {
|
|
||||||
<tr>
|
|
||||||
{row.iter().map(|value| html! {
|
|
||||||
<td class="whitespace-nowrap px-3 py-4 text-sm text-gray-400">{value}</td>
|
|
||||||
}).collect::<Html>()}
|
|
||||||
</tr>
|
|
||||||
}).collect::<Html>()}
|
|
||||||
{ for props.children.iter() }
|
|
||||||
{if props.loading == true { html! {
|
|
||||||
<tr>
|
|
||||||
<td colspan={(props.headers.len() + 1).to_string()} class="py-3">
|
|
||||||
<div class="grid place-items-center">
|
|
||||||
{ "Loading ..." }
|
|
||||||
</div>
|
|
||||||
</td>
|
|
||||||
</tr>
|
|
||||||
}} else { html! {} }}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -34,25 +34,14 @@ pub struct NavbarProps<'a, G: Html> {
|
||||||
pub fn Navbar<'a, G: Html>(cx: Scope<'a>, props: NavbarProps<'a, G>) -> View<G> {
|
pub fn Navbar<'a, G: Html>(cx: Scope<'a>, props: NavbarProps<'a, G>) -> View<G> {
|
||||||
let children = props.children.call(cx);
|
let children = props.children.call(cx);
|
||||||
view! { cx,
|
view! { cx,
|
||||||
nav(class="bg-gray-800") {
|
nav {
|
||||||
div(class="mx-auto max-w-7xl px-2 sm:px-6 lg:px-8") {
|
|
||||||
div(class="relative flex h-16 items-center justify-between") {
|
|
||||||
div(class="flex flex-1 items-center justify-center sm:items-stretch sm:justify-start") {
|
|
||||||
div(class="hidden sm:ml-6 sm:block") {
|
|
||||||
div(class="flex space-x-4") {
|
|
||||||
(View::new_fragment(props.pages.iter().cloned().enumerate().map(|(_i, page)| {
|
(View::new_fragment(props.pages.iter().cloned().enumerate().map(|(_i, page)| {
|
||||||
view! { cx, a(href=page.target) { (page.name) } }
|
view! { cx, a(href=page.target) { (page.name) } }
|
||||||
}).collect()))
|
}).collect()))
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
(children)
|
(children)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
console_log::init_with_level(log::Level::Debug).unwrap();
|
console_log::init_with_level(log::Level::Debug).unwrap();
|
||||||
|
@ -78,10 +67,12 @@ fn main() {
|
||||||
integration=HistoryIntegration::new(),
|
integration=HistoryIntegration::new(),
|
||||||
view=|cx, route: &ReadSignal<AppRoutes>| {
|
view=|cx, route: &ReadSignal<AppRoutes>| {
|
||||||
view! { cx,
|
view! { cx,
|
||||||
|
header {
|
||||||
Navbar(pages=pages) {
|
Navbar(pages=pages) {
|
||||||
|
|
||||||
}
|
}
|
||||||
div(class="app") {
|
}
|
||||||
|
main {
|
||||||
(match route.get().as_ref() {
|
(match route.get().as_ref() {
|
||||||
AppRoutes::Home => view! { cx,
|
AppRoutes::Home => view! { cx,
|
||||||
"This is the home page"
|
"This is the home page"
|
||||||
|
|
|
@ -1,22 +1,23 @@
|
||||||
|
use crate::components::event::{IntoEdit, Test};
|
||||||
use lan_party_core::event::EventSpec;
|
use lan_party_core::event::EventSpec;
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use sycamore::prelude::*;
|
use sycamore::prelude::*;
|
||||||
|
|
||||||
use crate::components::{
|
use crate::components::{
|
||||||
event::{Edit, EditProps},
|
event::{Edit, EditProps},
|
||||||
Block, Button, Page,
|
Block, Button,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[component]
|
#[component]
|
||||||
pub fn EventsPage<'a, G: Html>(cx: Scope<'a>) -> View<G> {
|
pub fn EventsPage<'a, G: Html>(cx: Scope<'a>) -> View<G> {
|
||||||
let event_spec = create_signal(cx, EventSpec::default());
|
let event_spec = create_signal(cx, EventSpec::default());
|
||||||
|
let test = create_signal(cx, Test::default());
|
||||||
|
|
||||||
view! { cx,
|
view! { cx,
|
||||||
Page {
|
|
||||||
Block(title="Create new event".into()) {
|
Block(title="Create new event".into()) {
|
||||||
EventSpec::edit(EditProps { state: event_spec })
|
EventSpec::edit(EditProps { state: event_spec })
|
||||||
Button(icon="mdi-check".into(), onclick=move |_| debug!("{:#?}", event_spec.get()))
|
Button(icon="mdi-check".into(), onclick=move |_| debug!("{:#?}", event_spec.get()))
|
||||||
}
|
(test.edit(cx))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
use crate::components::{input_classes, Button, Page, Table};
|
use crate::components::{Button, Table};
|
||||||
use lan_party_core::user::User;
|
use lan_party_core::user::User;
|
||||||
use log::debug;
|
use log::debug;
|
||||||
use reqwasm::http::Method;
|
use reqwasm::http::Method;
|
||||||
|
@ -100,7 +100,6 @@ pub fn UsersPage<'a, G: Html>(cx: Scope<'a>) -> View<G> {
|
||||||
};
|
};
|
||||||
|
|
||||||
view! { cx,
|
view! { cx,
|
||||||
Page {
|
|
||||||
Table(headers=headers) {
|
Table(headers=headers) {
|
||||||
Keyed(
|
Keyed(
|
||||||
iterable=users,
|
iterable=users,
|
||||||
|
@ -108,15 +107,15 @@ pub fn UsersPage<'a, G: Html>(cx: Scope<'a>) -> View<G> {
|
||||||
let user = create_ref(cx, user);
|
let user = create_ref(cx, user);
|
||||||
view! { cx,
|
view! { cx,
|
||||||
tr {
|
tr {
|
||||||
td(class="whatespace-nowrap px-3 py-4 text-sm") { (user.name) }
|
td { (user.name) }
|
||||||
td(class="whatespace-nowrap px-3 text-sm") {
|
td {
|
||||||
(if Some(&user.name) == (*score_edit.get()).as_ref() { view! { cx,
|
(if Some(&user.name) == (*score_edit.get()).as_ref() { view! { cx,
|
||||||
span(class="inline-block") {
|
span(class="user-score") {
|
||||||
input(bind:value=new_score, class=input_classes())
|
input(bind:value=new_score)
|
||||||
}
|
}
|
||||||
Button(icon="mdi-check".into(), onclick=oncheck)
|
Button(icon="mdi-check".into(), onclick=oncheck)
|
||||||
}} else { view! { cx,
|
}} else { view! { cx,
|
||||||
span(class="my-3,w-20") {
|
span(class="user-score") {
|
||||||
(user.score)
|
(user.score)
|
||||||
}
|
}
|
||||||
Button(
|
Button(
|
||||||
|
@ -128,7 +127,7 @@ pub fn UsersPage<'a, G: Html>(cx: Scope<'a>) -> View<G> {
|
||||||
)
|
)
|
||||||
}})
|
}})
|
||||||
}
|
}
|
||||||
td(class="whatespace-nowrap px-3 py-4 text-sm") {
|
td {
|
||||||
Button(icon="mdi-delete".into(),onclick=ondelete(user.name.clone()))
|
Button(icon="mdi-delete".into(),onclick=ondelete(user.name.clone()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,17 +136,16 @@ pub fn UsersPage<'a, G: Html>(cx: Scope<'a>) -> View<G> {
|
||||||
key=|user| (user.name.clone(), user.score.clone()),
|
key=|user| (user.name.clone(), user.score.clone()),
|
||||||
)
|
)
|
||||||
tr {
|
tr {
|
||||||
td(class="whatespace-nowrap px-3 text-sm") {
|
td {
|
||||||
span(class="inline-block") {
|
span {
|
||||||
input(bind:value=new_username, class=input_classes())
|
input(bind:value=new_username)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
td(class="whatespace-nowrap px-3 py-4 text-sm") {}
|
td {}
|
||||||
td(class="whatespace-nowrap py-4 px-3 text-sm") {
|
td {
|
||||||
Button(icon="mdi-plus".into(),onclick=onadd)
|
Button(icon="mdi-plus".into(),onclick=onadd)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
:root {
|
||||||
|
--accent: #1769c1;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (prefers-color-scheme: dark) {
|
||||||
|
:root {
|
||||||
|
--accent: #1769c1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.user-score {
|
||||||
|
display: inline-block;
|
||||||
|
margin-right: 1em;
|
||||||
|
width: 100px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.block-title {
|
||||||
|
margin: 0px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.block {
|
||||||
|
padding: 1em;
|
||||||
|
border: 1px solid var(--border);
|
||||||
|
border-radius: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.collapse {
|
||||||
|
overflow: hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.collapse.closed {
|
||||||
|
max-height: 0em;
|
||||||
|
}
|
||||||
|
|
||||||
|
details {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
details[open] summary {
|
||||||
|
margin-bottom: -0.7rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
details[open] > summary {
|
||||||
|
margin-bottom: .5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
textarea,
|
||||||
|
select,
|
||||||
|
input,
|
||||||
|
progress {
|
||||||
|
appearance: none;
|
||||||
|
-webkit-appearance: none;
|
||||||
|
-moz-appearance: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
textarea:focus, input:focus{
|
||||||
|
outline: none;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue