diff --git a/grid_form.scss b/grid_form.scss new file mode 100644 index 0000000..ec48f79 --- /dev/null +++ b/grid_form.scss @@ -0,0 +1,108 @@ +// form component as a grid +.form_grid { + display: grid; + grid-template-columns: repeat(6, minmax(0, 1fr)); + row-gap: 1.5rem; + column-gap: 1rem; +} + +// size up to 12 columns on small or bigger devices +@media (min-width: 640px) { + .form_grid { + grid-template-columns: repeat(12, minmax(0, 1fr)); + } +} + +.form_heading { + font-size: 1.875rem; + padding-top: 0.5rem; + padding-bottom: 0.5rem; + text-align: center; + font-weight: bold; + color: #374151; + border-bottom: 2px solid #374151; + margin-bottom: 2rem; + grid-column: span 12; +} + +.form_label { + font-family: ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Noto Sans,Ubuntu,Cantarell,Helvetica Neue,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji; + text-transform: uppercase; + letter-spacing: 0.05em; + text-align: left; + color: #4a5568; + font-size: 1rem; + font-weight: bold; + margin-left: 0.5rem; + margin-bottom: 0.25rem; + display: inline; +} + +.form_input { + display: block; + width: 100%; + background-color: #f7fafc; + border-width: 2px; + border-color: #e2e8f0; + border-style: solid; + color: #4a5568; + padding-top: 0.5rem; + padding-bottom: 0.5rem; + padding-left: 1rem; + padding-right: 1rem; + border-radius: 0.375rem; + line-height: 1.25; + outline: none; +} +.form_input:focus { + background-color: #ffffff; + border-color: #90cdf4; +} +.form_input_invalid { + border: 2px solid #EF4444; + background-color: #ffd4d4; +} + +.form_submit { + display: block; + outline: none; + border: none; + /* width: 100%; */ + border-radius: 1rem; + background-color: #0477d6; + color: #fff; + font-weight: bold; + cursor: pointer; + margin: 0 auto; + padding: 0.75rem 1.25rem; + font-size: 1rem; + appearance: none; + min-height: 40px; +} +.form_submit:hover { + background-color: #005fb3; +} + + +// column widths +.w-full { + grid-column: 1 / -1; +} +.w-12 { + grid-column: span 12 / span 12; +} +.w-6 { + grid-column: span 6 / span 6; +} +.w-4 { + grid-column: span 4 / span 4; +} +.w-3 { + grid-column: span 3 / span 3; +} +.w-2 { + grid-column: span 2 / span 2; +} +.w-1 { + grid-column: span 1 / span 1; +} diff --git a/src/styles/tw_grid.rs b/src/styles/grid_form.rs similarity index 76% rename from src/styles/tw_grid.rs rename to src/styles/grid_form.rs index afadf76..5f6a747 100644 --- a/src/styles/tw_grid.rs +++ b/src/styles/grid_form.rs @@ -6,20 +6,20 @@ use crate::controls::{ use leptos::*; use leptos_router::Form; -pub enum TailwindGridStylingAttributes { +pub enum GridFormStylingAttributes { Width(u32), } #[derive(Clone, Copy, Debug, Default, Hash, PartialEq, Eq, PartialOrd, Ord)] -pub struct TailwindGridFormStyle; +pub struct GridFormStyle; -impl FormStyle for TailwindGridFormStyle { - type StylingAttributes = TailwindGridStylingAttributes; +impl FormStyle for GridFormStyle { + type StylingAttributes = GridFormStylingAttributes; // TODO: something about an on-submit thing fn form_frame(&self, children: View) -> View { view! { -
} @@ -28,7 +28,7 @@ impl FormStyle for TailwindGridFormStyle { fn heading(&self, control: ControlRenderData