feat(ui): complete redesign with modern Tailwind styling and enhanced UX
Comprehensive UI overhaul implementing a modern design system with: - New gradient backgrounds and improved color palette - Redesigned navigation with logo and better user state handling - Combined auth page with tab-based login/register flow - Enhanced dashboard with event cards and empty states - Improved event creation and join forms with better validation - Responsive layouts with proper spacing and typography - Added loading states and error handling throughout - Modern button styles with hover effects and transitions
This commit is contained in:
parent
a5e221cbad
commit
2642fd2d24
@ -7,24 +7,69 @@
|
||||
'Noto Color Emoji';
|
||||
--font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, 'Liberation Mono', 'Courier New',
|
||||
monospace;
|
||||
--color-red-50: oklch(97.1% 0.013 17.38);
|
||||
--color-red-100: oklch(93.6% 0.032 17.717);
|
||||
--color-red-200: oklch(88.5% 0.062 18.334);
|
||||
--color-red-400: oklch(70.4% 0.191 22.216);
|
||||
--color-red-500: oklch(63.7% 0.237 25.331);
|
||||
--color-red-600: oklch(57.7% 0.245 27.325);
|
||||
--color-red-700: oklch(50.5% 0.213 27.518);
|
||||
--color-red-800: oklch(44.4% 0.177 26.899);
|
||||
--color-green-500: oklch(72.3% 0.219 149.579);
|
||||
--color-green-600: oklch(62.7% 0.194 149.214);
|
||||
--color-green-700: oklch(52.7% 0.154 150.069);
|
||||
--color-cyan-50: oklch(98.4% 0.019 200.873);
|
||||
--color-blue-500: oklch(62.3% 0.214 259.815);
|
||||
--color-blue-600: oklch(54.6% 0.245 262.881);
|
||||
--color-indigo-50: oklch(96.2% 0.018 272.314);
|
||||
--color-indigo-100: oklch(93% 0.034 272.788);
|
||||
--color-indigo-500: oklch(58.5% 0.233 277.117);
|
||||
--color-indigo-600: oklch(51.1% 0.262 276.966);
|
||||
--color-indigo-700: oklch(45.7% 0.24 277.023);
|
||||
--color-indigo-800: oklch(39.8% 0.195 277.366);
|
||||
--color-purple-500: oklch(62.7% 0.265 303.9);
|
||||
--color-purple-600: oklch(55.8% 0.288 302.321);
|
||||
--color-gray-50: oklch(98.5% 0.002 247.839);
|
||||
--color-gray-100: oklch(96.7% 0.003 264.542);
|
||||
--color-gray-200: oklch(92.8% 0.006 264.531);
|
||||
--color-gray-300: oklch(87.2% 0.01 258.338);
|
||||
--color-gray-400: oklch(70.7% 0.022 261.325);
|
||||
--color-gray-500: oklch(55.1% 0.027 264.364);
|
||||
--color-gray-600: oklch(44.6% 0.03 256.802);
|
||||
--color-gray-700: oklch(37.3% 0.034 259.733);
|
||||
--color-gray-800: oklch(27.8% 0.033 256.848);
|
||||
--color-gray-900: oklch(21% 0.034 264.665);
|
||||
--color-white: #fff;
|
||||
--spacing: 0.25rem;
|
||||
--container-md: 28rem;
|
||||
--container-2xl: 42rem;
|
||||
--container-4xl: 56rem;
|
||||
--container-5xl: 64rem;
|
||||
--container-7xl: 80rem;
|
||||
--text-xs: 0.75rem;
|
||||
--text-xs--line-height: calc(1 / 0.75);
|
||||
--text-sm: 0.875rem;
|
||||
--text-sm--line-height: calc(1.25 / 0.875);
|
||||
--text-lg: 1.125rem;
|
||||
--text-lg--line-height: calc(1.75 / 1.125);
|
||||
--text-xl: 1.25rem;
|
||||
--text-xl--line-height: calc(1.75 / 1.25);
|
||||
--text-2xl: 1.5rem;
|
||||
--text-2xl--line-height: calc(2 / 1.5);
|
||||
--text-3xl: 1.875rem;
|
||||
--text-3xl--line-height: calc(2.25 / 1.875);
|
||||
--text-5xl: 3rem;
|
||||
--text-5xl--line-height: 1;
|
||||
--text-6xl: 3.75rem;
|
||||
--text-6xl--line-height: 1;
|
||||
--font-weight-medium: 500;
|
||||
--font-weight-semibold: 600;
|
||||
--font-weight-bold: 700;
|
||||
--radius-md: 0.375rem;
|
||||
--radius-lg: 0.5rem;
|
||||
--animate-spin: spin 1s linear infinite;
|
||||
--default-transition-duration: 150ms;
|
||||
--default-transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
||||
--default-font-family: var(--font-sans);
|
||||
--default-mono-font-family: var(--font-mono);
|
||||
}
|
||||
@ -178,9 +223,15 @@
|
||||
.visible {
|
||||
visibility: visible;
|
||||
}
|
||||
.absolute {
|
||||
position: absolute;
|
||||
}
|
||||
.relative {
|
||||
position: relative;
|
||||
}
|
||||
.inset-0 {
|
||||
inset: calc(var(--spacing) * 0);
|
||||
}
|
||||
.container {
|
||||
width: 100%;
|
||||
@media (width >= 40rem) {
|
||||
@ -199,35 +250,134 @@
|
||||
max-width: 96rem;
|
||||
}
|
||||
}
|
||||
.mx-auto {
|
||||
margin-inline: auto;
|
||||
}
|
||||
.mt-1 {
|
||||
margin-top: calc(var(--spacing) * 1);
|
||||
}
|
||||
.mt-2 {
|
||||
margin-top: calc(var(--spacing) * 2);
|
||||
}
|
||||
.mt-4 {
|
||||
margin-top: calc(var(--spacing) * 4);
|
||||
}
|
||||
.mt-6 {
|
||||
margin-top: calc(var(--spacing) * 6);
|
||||
}
|
||||
.mt-20 {
|
||||
margin-top: calc(var(--spacing) * 20);
|
||||
}
|
||||
.mr-2 {
|
||||
margin-right: calc(var(--spacing) * 2);
|
||||
}
|
||||
.mr-3 {
|
||||
margin-right: calc(var(--spacing) * 3);
|
||||
}
|
||||
.mb-2 {
|
||||
margin-bottom: calc(var(--spacing) * 2);
|
||||
}
|
||||
.mb-3 {
|
||||
margin-bottom: calc(var(--spacing) * 3);
|
||||
}
|
||||
.mb-4 {
|
||||
margin-bottom: calc(var(--spacing) * 4);
|
||||
}
|
||||
.mb-6 {
|
||||
margin-bottom: calc(var(--spacing) * 6);
|
||||
}
|
||||
.mb-8 {
|
||||
margin-bottom: calc(var(--spacing) * 8);
|
||||
}
|
||||
.ml-3 {
|
||||
margin-left: calc(var(--spacing) * 3);
|
||||
}
|
||||
.block {
|
||||
display: block;
|
||||
}
|
||||
.flex {
|
||||
display: flex;
|
||||
}
|
||||
.table {
|
||||
display: table;
|
||||
.grid {
|
||||
display: grid;
|
||||
}
|
||||
.hidden {
|
||||
display: none;
|
||||
}
|
||||
.inline {
|
||||
display: inline;
|
||||
}
|
||||
.inline-flex {
|
||||
display: inline-flex;
|
||||
}
|
||||
.h-5 {
|
||||
height: calc(var(--spacing) * 5);
|
||||
}
|
||||
.h-8 {
|
||||
height: calc(var(--spacing) * 8);
|
||||
}
|
||||
.h-12 {
|
||||
height: calc(var(--spacing) * 12);
|
||||
}
|
||||
.h-16 {
|
||||
height: calc(var(--spacing) * 16);
|
||||
}
|
||||
.min-h-screen {
|
||||
min-height: 100vh;
|
||||
}
|
||||
.w-5 {
|
||||
width: calc(var(--spacing) * 5);
|
||||
}
|
||||
.w-8 {
|
||||
width: calc(var(--spacing) * 8);
|
||||
}
|
||||
.w-12 {
|
||||
width: calc(var(--spacing) * 12);
|
||||
}
|
||||
.w-16 {
|
||||
width: calc(var(--spacing) * 16);
|
||||
}
|
||||
.w-64 {
|
||||
width: calc(var(--spacing) * 64);
|
||||
}
|
||||
.w-80 {
|
||||
width: calc(var(--spacing) * 80);
|
||||
}
|
||||
.w-96 {
|
||||
width: calc(var(--spacing) * 96);
|
||||
}
|
||||
.border-collapse {
|
||||
border-collapse: collapse;
|
||||
.w-full {
|
||||
width: 100%;
|
||||
}
|
||||
.max-w-2xl {
|
||||
max-width: var(--container-2xl);
|
||||
}
|
||||
.max-w-4xl {
|
||||
max-width: var(--container-4xl);
|
||||
}
|
||||
.max-w-5xl {
|
||||
max-width: var(--container-5xl);
|
||||
}
|
||||
.max-w-7xl {
|
||||
max-width: var(--container-7xl);
|
||||
}
|
||||
.max-w-md {
|
||||
max-width: var(--container-md);
|
||||
}
|
||||
.flex-1 {
|
||||
flex: 1;
|
||||
}
|
||||
.flex-shrink-0 {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.transform {
|
||||
transform: var(--tw-rotate-x,) var(--tw-rotate-y,) var(--tw-rotate-z,) var(--tw-skew-x,) var(--tw-skew-y,);
|
||||
}
|
||||
.resize {
|
||||
resize: both;
|
||||
.animate-spin {
|
||||
animation: var(--animate-spin);
|
||||
}
|
||||
.appearance-none {
|
||||
appearance: none;
|
||||
}
|
||||
.flex-col {
|
||||
flex-direction: column;
|
||||
@ -247,20 +397,103 @@
|
||||
.gap-4 {
|
||||
gap: calc(var(--spacing) * 4);
|
||||
}
|
||||
.gap-6 {
|
||||
gap: calc(var(--spacing) * 6);
|
||||
}
|
||||
.gap-8 {
|
||||
gap: calc(var(--spacing) * 8);
|
||||
}
|
||||
.space-y-3 {
|
||||
:where(& > :not(:last-child)) {
|
||||
--tw-space-y-reverse: 0;
|
||||
margin-block-start: calc(calc(var(--spacing) * 3) * var(--tw-space-y-reverse));
|
||||
margin-block-end: calc(calc(var(--spacing) * 3) * calc(1 - var(--tw-space-y-reverse)));
|
||||
}
|
||||
}
|
||||
.space-y-4 {
|
||||
:where(& > :not(:last-child)) {
|
||||
--tw-space-y-reverse: 0;
|
||||
margin-block-start: calc(calc(var(--spacing) * 4) * var(--tw-space-y-reverse));
|
||||
margin-block-end: calc(calc(var(--spacing) * 4) * calc(1 - var(--tw-space-y-reverse)));
|
||||
}
|
||||
}
|
||||
.space-y-6 {
|
||||
:where(& > :not(:last-child)) {
|
||||
--tw-space-y-reverse: 0;
|
||||
margin-block-start: calc(calc(var(--spacing) * 6) * var(--tw-space-y-reverse));
|
||||
margin-block-end: calc(calc(var(--spacing) * 6) * calc(1 - var(--tw-space-y-reverse)));
|
||||
}
|
||||
}
|
||||
.space-y-8 {
|
||||
:where(& > :not(:last-child)) {
|
||||
--tw-space-y-reverse: 0;
|
||||
margin-block-start: calc(calc(var(--spacing) * 8) * var(--tw-space-y-reverse));
|
||||
margin-block-end: calc(calc(var(--spacing) * 8) * calc(1 - var(--tw-space-y-reverse)));
|
||||
}
|
||||
}
|
||||
.space-x-4 {
|
||||
:where(& > :not(:last-child)) {
|
||||
--tw-space-x-reverse: 0;
|
||||
margin-inline-start: calc(calc(var(--spacing) * 4) * var(--tw-space-x-reverse));
|
||||
margin-inline-end: calc(calc(var(--spacing) * 4) * calc(1 - var(--tw-space-x-reverse)));
|
||||
}
|
||||
}
|
||||
.rounded {
|
||||
border-radius: 0.25rem;
|
||||
}
|
||||
.rounded-full {
|
||||
border-radius: calc(infinity * 1px);
|
||||
}
|
||||
.rounded-lg {
|
||||
border-radius: var(--radius-lg);
|
||||
}
|
||||
.rounded-md {
|
||||
border-radius: var(--radius-md);
|
||||
}
|
||||
.border {
|
||||
border-style: var(--tw-border-style);
|
||||
border-width: 1px;
|
||||
}
|
||||
.border-2 {
|
||||
border-style: var(--tw-border-style);
|
||||
border-width: 2px;
|
||||
}
|
||||
.border-t {
|
||||
border-top-style: var(--tw-border-style);
|
||||
border-top-width: 1px;
|
||||
}
|
||||
.border-b {
|
||||
border-bottom-style: var(--tw-border-style);
|
||||
border-bottom-width: 1px;
|
||||
}
|
||||
.border-b-2 {
|
||||
border-bottom-style: var(--tw-border-style);
|
||||
border-bottom-width: 2px;
|
||||
}
|
||||
.border-blue-600 {
|
||||
border-color: var(--color-blue-600);
|
||||
}
|
||||
.border-gray-200 {
|
||||
border-color: var(--color-gray-200);
|
||||
}
|
||||
.border-gray-300 {
|
||||
border-color: var(--color-gray-300);
|
||||
}
|
||||
.border-indigo-600 {
|
||||
border-color: var(--color-indigo-600);
|
||||
}
|
||||
.border-red-200 {
|
||||
border-color: var(--color-red-200);
|
||||
}
|
||||
.border-transparent {
|
||||
border-color: transparent;
|
||||
}
|
||||
.bg-blue-500 {
|
||||
background-color: var(--color-blue-500);
|
||||
}
|
||||
.bg-gray-50 {
|
||||
background-color: var(--color-gray-50);
|
||||
}
|
||||
.bg-gray-100 {
|
||||
background-color: var(--color-gray-100);
|
||||
}
|
||||
@ -270,48 +503,212 @@
|
||||
.bg-green-500 {
|
||||
background-color: var(--color-green-500);
|
||||
}
|
||||
.bg-green-600 {
|
||||
background-color: var(--color-green-600);
|
||||
}
|
||||
.bg-indigo-100 {
|
||||
background-color: var(--color-indigo-100);
|
||||
}
|
||||
.bg-indigo-600 {
|
||||
background-color: var(--color-indigo-600);
|
||||
}
|
||||
.bg-purple-500 {
|
||||
background-color: var(--color-purple-500);
|
||||
}
|
||||
.bg-red-50 {
|
||||
background-color: var(--color-red-50);
|
||||
}
|
||||
.bg-red-100 {
|
||||
background-color: var(--color-red-100);
|
||||
}
|
||||
.bg-white {
|
||||
background-color: var(--color-white);
|
||||
}
|
||||
.bg-gradient-to-br {
|
||||
--tw-gradient-position: to bottom right in oklab;
|
||||
background-image: linear-gradient(var(--tw-gradient-stops));
|
||||
}
|
||||
.from-indigo-50 {
|
||||
--tw-gradient-from: var(--color-indigo-50);
|
||||
--tw-gradient-stops: var(--tw-gradient-via-stops, var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position));
|
||||
}
|
||||
.via-white {
|
||||
--tw-gradient-via: var(--color-white);
|
||||
--tw-gradient-via-stops: var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-via) var(--tw-gradient-via-position), var(--tw-gradient-to) var(--tw-gradient-to-position);
|
||||
--tw-gradient-stops: var(--tw-gradient-via-stops);
|
||||
}
|
||||
.to-cyan-50 {
|
||||
--tw-gradient-to: var(--color-cyan-50);
|
||||
--tw-gradient-stops: var(--tw-gradient-via-stops, var(--tw-gradient-position), var(--tw-gradient-from) var(--tw-gradient-from-position), var(--tw-gradient-to) var(--tw-gradient-to-position));
|
||||
}
|
||||
.p-2 {
|
||||
padding: calc(var(--spacing) * 2);
|
||||
}
|
||||
.p-3 {
|
||||
padding: calc(var(--spacing) * 3);
|
||||
}
|
||||
.p-4 {
|
||||
padding: calc(var(--spacing) * 4);
|
||||
}
|
||||
.p-6 {
|
||||
padding: calc(var(--spacing) * 6);
|
||||
}
|
||||
.p-8 {
|
||||
padding: calc(var(--spacing) * 8);
|
||||
}
|
||||
.px-2 {
|
||||
padding-inline: calc(var(--spacing) * 2);
|
||||
}
|
||||
.px-2\.5 {
|
||||
padding-inline: calc(var(--spacing) * 2.5);
|
||||
}
|
||||
.px-3 {
|
||||
padding-inline: calc(var(--spacing) * 3);
|
||||
}
|
||||
.px-4 {
|
||||
padding-inline: calc(var(--spacing) * 4);
|
||||
}
|
||||
.px-6 {
|
||||
padding-inline: calc(var(--spacing) * 6);
|
||||
}
|
||||
.px-8 {
|
||||
padding-inline: calc(var(--spacing) * 8);
|
||||
}
|
||||
.py-0\.5 {
|
||||
padding-block: calc(var(--spacing) * 0.5);
|
||||
}
|
||||
.py-2 {
|
||||
padding-block: calc(var(--spacing) * 2);
|
||||
}
|
||||
.py-3 {
|
||||
padding-block: calc(var(--spacing) * 3);
|
||||
}
|
||||
.py-8 {
|
||||
padding-block: calc(var(--spacing) * 8);
|
||||
}
|
||||
.py-12 {
|
||||
padding-block: calc(var(--spacing) * 12);
|
||||
}
|
||||
.py-16 {
|
||||
padding-block: calc(var(--spacing) * 16);
|
||||
}
|
||||
.text-center {
|
||||
text-align: center;
|
||||
}
|
||||
.text-2xl {
|
||||
font-size: var(--text-2xl);
|
||||
line-height: var(--tw-leading, var(--text-2xl--line-height));
|
||||
}
|
||||
.text-3xl {
|
||||
font-size: var(--text-3xl);
|
||||
line-height: var(--tw-leading, var(--text-3xl--line-height));
|
||||
}
|
||||
.text-5xl {
|
||||
font-size: var(--text-5xl);
|
||||
line-height: var(--tw-leading, var(--text-5xl--line-height));
|
||||
}
|
||||
.text-lg {
|
||||
font-size: var(--text-lg);
|
||||
line-height: var(--tw-leading, var(--text-lg--line-height));
|
||||
}
|
||||
.text-sm {
|
||||
font-size: var(--text-sm);
|
||||
line-height: var(--tw-leading, var(--text-sm--line-height));
|
||||
}
|
||||
.text-xl {
|
||||
font-size: var(--text-xl);
|
||||
line-height: var(--tw-leading, var(--text-xl--line-height));
|
||||
}
|
||||
.text-xs {
|
||||
font-size: var(--text-xs);
|
||||
line-height: var(--tw-leading, var(--text-xs--line-height));
|
||||
}
|
||||
.font-bold {
|
||||
--tw-font-weight: var(--font-weight-bold);
|
||||
font-weight: var(--font-weight-bold);
|
||||
}
|
||||
.font-medium {
|
||||
--tw-font-weight: var(--font-weight-medium);
|
||||
font-weight: var(--font-weight-medium);
|
||||
}
|
||||
.font-semibold {
|
||||
--tw-font-weight: var(--font-weight-semibold);
|
||||
font-weight: var(--font-weight-semibold);
|
||||
}
|
||||
.text-blue-600 {
|
||||
color: var(--color-blue-600);
|
||||
}
|
||||
.text-gray-400 {
|
||||
color: var(--color-gray-400);
|
||||
}
|
||||
.text-gray-500 {
|
||||
color: var(--color-gray-500);
|
||||
}
|
||||
.text-gray-600 {
|
||||
color: var(--color-gray-600);
|
||||
}
|
||||
.text-gray-700 {
|
||||
color: var(--color-gray-700);
|
||||
}
|
||||
.text-gray-900 {
|
||||
color: var(--color-gray-900);
|
||||
}
|
||||
.text-green-500 {
|
||||
color: var(--color-green-500);
|
||||
}
|
||||
.text-green-600 {
|
||||
color: var(--color-green-600);
|
||||
}
|
||||
.text-indigo-600 {
|
||||
color: var(--color-indigo-600);
|
||||
}
|
||||
.text-indigo-800 {
|
||||
color: var(--color-indigo-800);
|
||||
}
|
||||
.text-red-400 {
|
||||
color: var(--color-red-400);
|
||||
}
|
||||
.text-red-500 {
|
||||
color: var(--color-red-500);
|
||||
}
|
||||
.text-red-600 {
|
||||
color: var(--color-red-600);
|
||||
}
|
||||
.text-red-700 {
|
||||
color: var(--color-red-700);
|
||||
}
|
||||
.text-red-800 {
|
||||
color: var(--color-red-800);
|
||||
}
|
||||
.text-white {
|
||||
color: var(--color-white);
|
||||
}
|
||||
.underline {
|
||||
text-decoration-line: underline;
|
||||
.placeholder-gray-500 {
|
||||
&::placeholder {
|
||||
color: var(--color-gray-500);
|
||||
}
|
||||
.outline {
|
||||
outline-style: var(--tw-outline-style);
|
||||
outline-width: 1px;
|
||||
}
|
||||
.shadow {
|
||||
--tw-shadow: 0 1px 3px 0 var(--tw-shadow-color, rgb(0 0 0 / 0.1)), 0 1px 2px -1px var(--tw-shadow-color, rgb(0 0 0 / 0.1));
|
||||
box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
|
||||
}
|
||||
.shadow-lg {
|
||||
--tw-shadow: 0 10px 15px -3px var(--tw-shadow-color, rgb(0 0 0 / 0.1)), 0 4px 6px -4px var(--tw-shadow-color, rgb(0 0 0 / 0.1));
|
||||
box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
|
||||
}
|
||||
.shadow-sm {
|
||||
--tw-shadow: 0 1px 3px 0 var(--tw-shadow-color, rgb(0 0 0 / 0.1)), 0 1px 2px -1px var(--tw-shadow-color, rgb(0 0 0 / 0.1));
|
||||
box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
|
||||
}
|
||||
.transition-colors {
|
||||
transition-property: color, background-color, border-color, outline-color, text-decoration-color, fill, stroke, --tw-gradient-from, --tw-gradient-via, --tw-gradient-to;
|
||||
transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
|
||||
transition-duration: var(--tw-duration, var(--default-transition-duration));
|
||||
}
|
||||
.transition-shadow {
|
||||
transition-property: box-shadow;
|
||||
transition-timing-function: var(--tw-ease, var(--default-transition-timing-function));
|
||||
transition-duration: var(--tw-duration, var(--default-transition-duration));
|
||||
}
|
||||
.hover\:bg-blue-600 {
|
||||
&:hover {
|
||||
@ -334,6 +731,27 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
.hover\:bg-green-700 {
|
||||
&:hover {
|
||||
@media (hover: hover) {
|
||||
background-color: var(--color-green-700);
|
||||
}
|
||||
}
|
||||
}
|
||||
.hover\:bg-indigo-50 {
|
||||
&:hover {
|
||||
@media (hover: hover) {
|
||||
background-color: var(--color-indigo-50);
|
||||
}
|
||||
}
|
||||
}
|
||||
.hover\:bg-indigo-700 {
|
||||
&:hover {
|
||||
@media (hover: hover) {
|
||||
background-color: var(--color-indigo-700);
|
||||
}
|
||||
}
|
||||
}
|
||||
.hover\:bg-purple-600 {
|
||||
&:hover {
|
||||
@media (hover: hover) {
|
||||
@ -348,6 +766,155 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
.hover\:text-gray-600 {
|
||||
&:hover {
|
||||
@media (hover: hover) {
|
||||
color: var(--color-gray-600);
|
||||
}
|
||||
}
|
||||
}
|
||||
.hover\:text-gray-700 {
|
||||
&:hover {
|
||||
@media (hover: hover) {
|
||||
color: var(--color-gray-700);
|
||||
}
|
||||
}
|
||||
}
|
||||
.hover\:text-gray-800 {
|
||||
&:hover {
|
||||
@media (hover: hover) {
|
||||
color: var(--color-gray-800);
|
||||
}
|
||||
}
|
||||
}
|
||||
.hover\:text-gray-900 {
|
||||
&:hover {
|
||||
@media (hover: hover) {
|
||||
color: var(--color-gray-900);
|
||||
}
|
||||
}
|
||||
}
|
||||
.hover\:text-indigo-500 {
|
||||
&:hover {
|
||||
@media (hover: hover) {
|
||||
color: var(--color-indigo-500);
|
||||
}
|
||||
}
|
||||
}
|
||||
.hover\:text-indigo-600 {
|
||||
&:hover {
|
||||
@media (hover: hover) {
|
||||
color: var(--color-indigo-600);
|
||||
}
|
||||
}
|
||||
}
|
||||
.hover\:shadow-lg {
|
||||
&:hover {
|
||||
@media (hover: hover) {
|
||||
--tw-shadow: 0 10px 15px -3px var(--tw-shadow-color, rgb(0 0 0 / 0.1)), 0 4px 6px -4px var(--tw-shadow-color, rgb(0 0 0 / 0.1));
|
||||
box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
|
||||
}
|
||||
}
|
||||
}
|
||||
.focus\:z-10 {
|
||||
&:focus {
|
||||
z-index: 10;
|
||||
}
|
||||
}
|
||||
.focus\:border-indigo-500 {
|
||||
&:focus {
|
||||
border-color: var(--color-indigo-500);
|
||||
}
|
||||
}
|
||||
.focus\:ring-2 {
|
||||
&:focus {
|
||||
--tw-ring-shadow: var(--tw-ring-inset,) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color, currentcolor);
|
||||
box-shadow: var(--tw-inset-shadow), var(--tw-inset-ring-shadow), var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow);
|
||||
}
|
||||
}
|
||||
.focus\:ring-green-500 {
|
||||
&:focus {
|
||||
--tw-ring-color: var(--color-green-500);
|
||||
}
|
||||
}
|
||||
.focus\:ring-indigo-500 {
|
||||
&:focus {
|
||||
--tw-ring-color: var(--color-indigo-500);
|
||||
}
|
||||
}
|
||||
.focus\:ring-offset-2 {
|
||||
&:focus {
|
||||
--tw-ring-offset-width: 2px;
|
||||
--tw-ring-offset-shadow: var(--tw-ring-inset,) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
|
||||
}
|
||||
}
|
||||
.focus\:outline-none {
|
||||
&:focus {
|
||||
--tw-outline-style: none;
|
||||
outline-style: none;
|
||||
}
|
||||
}
|
||||
.sm\:ml-6 {
|
||||
@media (width >= 40rem) {
|
||||
margin-left: calc(var(--spacing) * 6);
|
||||
}
|
||||
}
|
||||
.sm\:flex {
|
||||
@media (width >= 40rem) {
|
||||
display: flex;
|
||||
}
|
||||
}
|
||||
.sm\:flex-row {
|
||||
@media (width >= 40rem) {
|
||||
flex-direction: row;
|
||||
}
|
||||
}
|
||||
.sm\:space-x-8 {
|
||||
@media (width >= 40rem) {
|
||||
:where(& > :not(:last-child)) {
|
||||
--tw-space-x-reverse: 0;
|
||||
margin-inline-start: calc(calc(var(--spacing) * 8) * var(--tw-space-x-reverse));
|
||||
margin-inline-end: calc(calc(var(--spacing) * 8) * calc(1 - var(--tw-space-x-reverse)));
|
||||
}
|
||||
}
|
||||
}
|
||||
.sm\:px-6 {
|
||||
@media (width >= 40rem) {
|
||||
padding-inline: calc(var(--spacing) * 6);
|
||||
}
|
||||
}
|
||||
.sm\:text-sm {
|
||||
@media (width >= 40rem) {
|
||||
font-size: var(--text-sm);
|
||||
line-height: var(--tw-leading, var(--text-sm--line-height));
|
||||
}
|
||||
}
|
||||
.md\:grid-cols-2 {
|
||||
@media (width >= 48rem) {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
.md\:grid-cols-3 {
|
||||
@media (width >= 48rem) {
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
.md\:text-6xl {
|
||||
@media (width >= 48rem) {
|
||||
font-size: var(--text-6xl);
|
||||
line-height: var(--tw-leading, var(--text-6xl--line-height));
|
||||
}
|
||||
}
|
||||
.lg\:grid-cols-3 {
|
||||
@media (width >= 64rem) {
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
}
|
||||
}
|
||||
.lg\:px-8 {
|
||||
@media (width >= 64rem) {
|
||||
padding-inline: calc(var(--spacing) * 8);
|
||||
}
|
||||
}
|
||||
}
|
||||
@property --tw-rotate-x {
|
||||
syntax: "*";
|
||||
@ -369,19 +936,136 @@
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
}
|
||||
@property --tw-space-y-reverse {
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
initial-value: 0;
|
||||
}
|
||||
@property --tw-space-x-reverse {
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
initial-value: 0;
|
||||
}
|
||||
@property --tw-border-style {
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
initial-value: solid;
|
||||
}
|
||||
@property --tw-gradient-position {
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
}
|
||||
@property --tw-gradient-from {
|
||||
syntax: "<color>";
|
||||
inherits: false;
|
||||
initial-value: #0000;
|
||||
}
|
||||
@property --tw-gradient-via {
|
||||
syntax: "<color>";
|
||||
inherits: false;
|
||||
initial-value: #0000;
|
||||
}
|
||||
@property --tw-gradient-to {
|
||||
syntax: "<color>";
|
||||
inherits: false;
|
||||
initial-value: #0000;
|
||||
}
|
||||
@property --tw-gradient-stops {
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
}
|
||||
@property --tw-gradient-via-stops {
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
}
|
||||
@property --tw-gradient-from-position {
|
||||
syntax: "<length-percentage>";
|
||||
inherits: false;
|
||||
initial-value: 0%;
|
||||
}
|
||||
@property --tw-gradient-via-position {
|
||||
syntax: "<length-percentage>";
|
||||
inherits: false;
|
||||
initial-value: 50%;
|
||||
}
|
||||
@property --tw-gradient-to-position {
|
||||
syntax: "<length-percentage>";
|
||||
inherits: false;
|
||||
initial-value: 100%;
|
||||
}
|
||||
@property --tw-font-weight {
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
}
|
||||
@property --tw-outline-style {
|
||||
@property --tw-shadow {
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
initial-value: solid;
|
||||
initial-value: 0 0 #0000;
|
||||
}
|
||||
@property --tw-shadow-color {
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
}
|
||||
@property --tw-shadow-alpha {
|
||||
syntax: "<percentage>";
|
||||
inherits: false;
|
||||
initial-value: 100%;
|
||||
}
|
||||
@property --tw-inset-shadow {
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
initial-value: 0 0 #0000;
|
||||
}
|
||||
@property --tw-inset-shadow-color {
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
}
|
||||
@property --tw-inset-shadow-alpha {
|
||||
syntax: "<percentage>";
|
||||
inherits: false;
|
||||
initial-value: 100%;
|
||||
}
|
||||
@property --tw-ring-color {
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
}
|
||||
@property --tw-ring-shadow {
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
initial-value: 0 0 #0000;
|
||||
}
|
||||
@property --tw-inset-ring-color {
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
}
|
||||
@property --tw-inset-ring-shadow {
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
initial-value: 0 0 #0000;
|
||||
}
|
||||
@property --tw-ring-inset {
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
}
|
||||
@property --tw-ring-offset-width {
|
||||
syntax: "<length>";
|
||||
inherits: false;
|
||||
initial-value: 0px;
|
||||
}
|
||||
@property --tw-ring-offset-color {
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
initial-value: #fff;
|
||||
}
|
||||
@property --tw-ring-offset-shadow {
|
||||
syntax: "*";
|
||||
inherits: false;
|
||||
initial-value: 0 0 #0000;
|
||||
}
|
||||
@keyframes spin {
|
||||
to {
|
||||
transform: rotate(360deg);
|
||||
}
|
||||
}
|
||||
@layer properties {
|
||||
@supports ((-webkit-hyphens: none) and (not (margin-trim: inline))) or ((-moz-orient: inline) and (not (color:rgb(from red r g b)))) {
|
||||
@ -391,9 +1075,33 @@
|
||||
--tw-rotate-z: initial;
|
||||
--tw-skew-x: initial;
|
||||
--tw-skew-y: initial;
|
||||
--tw-space-y-reverse: 0;
|
||||
--tw-space-x-reverse: 0;
|
||||
--tw-border-style: solid;
|
||||
--tw-gradient-position: initial;
|
||||
--tw-gradient-from: #0000;
|
||||
--tw-gradient-via: #0000;
|
||||
--tw-gradient-to: #0000;
|
||||
--tw-gradient-stops: initial;
|
||||
--tw-gradient-via-stops: initial;
|
||||
--tw-gradient-from-position: 0%;
|
||||
--tw-gradient-via-position: 50%;
|
||||
--tw-gradient-to-position: 100%;
|
||||
--tw-font-weight: initial;
|
||||
--tw-outline-style: solid;
|
||||
--tw-shadow: 0 0 #0000;
|
||||
--tw-shadow-color: initial;
|
||||
--tw-shadow-alpha: 100%;
|
||||
--tw-inset-shadow: 0 0 #0000;
|
||||
--tw-inset-shadow-color: initial;
|
||||
--tw-inset-shadow-alpha: 100%;
|
||||
--tw-ring-color: initial;
|
||||
--tw-ring-shadow: 0 0 #0000;
|
||||
--tw-inset-ring-color: initial;
|
||||
--tw-inset-ring-shadow: 0 0 #0000;
|
||||
--tw-ring-inset: initial;
|
||||
--tw-ring-offset-width: 0px;
|
||||
--tw-ring-offset-color: #fff;
|
||||
--tw-ring-offset-shadow: 0 0 #0000;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
796
src/main.rs
796
src/main.rs
@ -10,10 +10,8 @@ enum Route {
|
||||
#[layout(Navbar)]
|
||||
#[route("/")]
|
||||
Home {},
|
||||
#[route("/login")]
|
||||
Login {},
|
||||
#[route("/register")]
|
||||
Register {},
|
||||
#[route("/auth")]
|
||||
Auth {},
|
||||
#[route("/dashboard")]
|
||||
Dashboard {},
|
||||
#[route("/create-event")]
|
||||
@ -63,7 +61,7 @@ fn App() -> Element {
|
||||
use_effect(move || {
|
||||
spawn(async move {
|
||||
if let Ok(res) = auth::get_current_user().await {
|
||||
user_state.set(res);
|
||||
&user_state.set(res);
|
||||
}
|
||||
});
|
||||
});
|
||||
@ -78,10 +76,130 @@ fn App() -> Element {
|
||||
/// Home page
|
||||
#[component]
|
||||
fn Home() -> Element {
|
||||
let user_state = use_context::<Signal<Option<auth::UserSafe>>>();
|
||||
let navigator = use_navigator();
|
||||
|
||||
rsx! {
|
||||
div {
|
||||
class: "flex flex-col items-center justify-center min-h-screen py-2",
|
||||
h1 { "Welcome to Wichtl" }
|
||||
class: "min-h-screen bg-gradient-to-br from-indigo-50 via-white to-cyan-50",
|
||||
div {
|
||||
class: "container mx-auto px-6 py-16",
|
||||
div {
|
||||
class: "max-w-4xl mx-auto text-center",
|
||||
h1 {
|
||||
class: "text-5xl md:text-6xl font-bold text-gray-900 mb-6",
|
||||
"Welcome to ",
|
||||
span { class: "text-indigo-600", "Wichtl" }
|
||||
}
|
||||
p {
|
||||
class: "text-xl text-gray-600 mb-8 max-w-2xl mx-auto",
|
||||
"The modern way to organize Secret Santa gift exchanges. Create events, invite friends, and draw names seamlessly."
|
||||
}
|
||||
|
||||
if let Some(user) = user_state() {
|
||||
div {
|
||||
class: "space-y-4",
|
||||
p { class: "text-lg text-gray-700", "Welcome back, {user.username}!" }
|
||||
div {
|
||||
class: "flex flex-col sm:flex-row gap-4 justify-center",
|
||||
Link {
|
||||
to: Route::Dashboard {},
|
||||
class: "bg-indigo-600 text-white px-8 py-3 rounded-lg font-semibold hover:bg-indigo-700 transition-colors",
|
||||
"Go to Dashboard"
|
||||
}
|
||||
Link {
|
||||
to: Route::CreateEvent {},
|
||||
class: "bg-white text-indigo-600 border-2 border-indigo-600 px-8 py-3 rounded-lg font-semibold hover:bg-indigo-50 transition-colors",
|
||||
"Create New Event"
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
div {
|
||||
class: "space-y-4",
|
||||
div {
|
||||
class: "flex flex-col sm:flex-row gap-4 justify-center",
|
||||
Link {
|
||||
to: Route::Auth {},
|
||||
class: "bg-indigo-600 text-white px-8 py-3 rounded-lg font-semibold hover:bg-indigo-700 transition-colors",
|
||||
"Get Started"
|
||||
}
|
||||
Link {
|
||||
to: Route::Auth {},
|
||||
class: "bg-white text-indigo-600 border-2 border-indigo-600 px-8 py-3 rounded-lg font-semibold hover:bg-indigo-50 transition-colors",
|
||||
"Sign In"
|
||||
}
|
||||
}
|
||||
p { class: "text-sm text-gray-500", "No account? Sign up takes 30 seconds." }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Features section
|
||||
div {
|
||||
class: "mt-20 grid md:grid-cols-3 gap-8 max-w-5xl mx-auto",
|
||||
div {
|
||||
class: "text-center p-6",
|
||||
div {
|
||||
class: "w-16 h-16 bg-indigo-100 rounded-full flex items-center justify-center mx-auto mb-4",
|
||||
svg {
|
||||
class: "w-8 h-8 text-indigo-600",
|
||||
fill: "none",
|
||||
stroke: "currentColor",
|
||||
view_box: "0 0 24 24",
|
||||
path {
|
||||
stroke_linecap: "round",
|
||||
stroke_linejoin: "round",
|
||||
stroke_width: "2",
|
||||
d: "M12 6v6m0 0v6m0-6h6m-6 0H6"
|
||||
}
|
||||
}
|
||||
}
|
||||
h3 { class: "text-lg font-semibold text-gray-900 mb-2", "Easy Event Creation" }
|
||||
p { class: "text-gray-600", "Set up your Secret Santa event in seconds with our intuitive interface." }
|
||||
}
|
||||
div {
|
||||
class: "text-center p-6",
|
||||
div {
|
||||
class: "w-16 h-16 bg-indigo-100 rounded-full flex items-center justify-center mx-auto mb-4",
|
||||
svg {
|
||||
class: "w-8 h-8 text-indigo-600",
|
||||
fill: "none",
|
||||
stroke: "currentColor",
|
||||
view_box: "0 0 24 24",
|
||||
path {
|
||||
stroke_linecap: "round",
|
||||
stroke_linejoin: "round",
|
||||
stroke_width: "2",
|
||||
d: "M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z"
|
||||
}
|
||||
}
|
||||
}
|
||||
h3 { class: "text-lg font-semibold text-gray-900 mb-2", "Smart Name Drawing" }
|
||||
p { class: "text-gray-600", "Our algorithm ensures fair and random gift assignments with optional exclusions." }
|
||||
}
|
||||
div {
|
||||
class: "text-center p-6",
|
||||
div {
|
||||
class: "w-16 h-16 bg-indigo-100 rounded-full flex items-center justify-center mx-auto mb-4",
|
||||
svg {
|
||||
class: "w-8 h-8 text-indigo-600",
|
||||
fill: "none",
|
||||
stroke: "currentColor",
|
||||
view_box: "0 0 24 24",
|
||||
path {
|
||||
stroke_linecap: "round",
|
||||
stroke_linejoin: "round",
|
||||
stroke_width: "2",
|
||||
d: "M8.684 13.342C8.886 12.938 9 12.482 9 12c0-.482-.114-.938-.316-1.342m0 2.684a3 3 0 110-2.684m0 2.684l6.632 3.316m-6.632-6l6.632-3.316m0 0a3 3 0 105.367-2.684 3 3 0 00-5.367 2.684zm0 9.316a3 3 0 105.367 2.684 3 3 0 00-5.367-2.684z"
|
||||
}
|
||||
}
|
||||
}
|
||||
h3 { class: "text-lg font-semibold text-gray-900 mb-2", "Share & Invite" }
|
||||
p { class: "text-gray-600", "Generate shareable links to invite participants to your gift exchange." }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -95,21 +213,47 @@ fn Navbar() -> Element {
|
||||
let navigator = use_navigator();
|
||||
|
||||
rsx! {
|
||||
nav {
|
||||
class: "bg-white shadow-lg border-b border-gray-200",
|
||||
div {
|
||||
id: "navbar",
|
||||
class: "flex gap-4 p-4 bg-gray-800 text-white items-center",
|
||||
class: "max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",
|
||||
div {
|
||||
class: "flex justify-between h-16",
|
||||
div {
|
||||
class: "flex items-center",
|
||||
Link {
|
||||
to: Route::Home {},
|
||||
class: "flex-shrink-0 flex items-center",
|
||||
div {
|
||||
class: "w-8 h-8 bg-indigo-600 rounded-lg flex items-center justify-center mr-3",
|
||||
span { class: "text-white font-bold text-lg", "W" }
|
||||
}
|
||||
span { class: "text-xl font-bold text-gray-900", "Wichtl" }
|
||||
}
|
||||
div {
|
||||
class: "hidden sm:ml-6 sm:flex sm:space-x-8",
|
||||
Link {
|
||||
to: Route::Home {},
|
||||
class: "text-gray-500 hover:text-gray-900 px-3 py-2 rounded-md text-sm font-medium transition-colors",
|
||||
"Home"
|
||||
}
|
||||
if let Some(user) = user_state() {
|
||||
if let Some(_user) = user_state() {
|
||||
Link {
|
||||
to: Route::Dashboard {},
|
||||
class: "text-gray-500 hover:text-gray-900 px-3 py-2 rounded-md text-sm font-medium transition-colors",
|
||||
"Dashboard"
|
||||
}
|
||||
span { "Welcome, {user.username}!" }
|
||||
}
|
||||
}
|
||||
}
|
||||
div {
|
||||
class: "flex items-center",
|
||||
if let Some(user) = user_state() {
|
||||
div {
|
||||
class: "flex items-center space-x-4",
|
||||
span { class: "text-gray-700 text-sm", "Welcome, {user.username}!" }
|
||||
button {
|
||||
class: "hover:text-gray-300",
|
||||
class: "text-gray-500 hover:text-gray-700 px-3 py-2 rounded-md text-sm font-medium transition-colors",
|
||||
onclick: move |_| async move {
|
||||
if auth::logout().await.is_ok() {
|
||||
user_state.set(None);
|
||||
@ -118,14 +262,15 @@ fn Navbar() -> Element {
|
||||
},
|
||||
"Logout"
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Link {
|
||||
to: Route::Login {},
|
||||
"Login"
|
||||
to: Route::Auth {},
|
||||
class: "bg-indigo-600 text-white px-4 py-2 rounded-md text-sm font-medium hover:bg-indigo-700 transition-colors",
|
||||
"Sign In"
|
||||
}
|
||||
}
|
||||
}
|
||||
Link {
|
||||
to: Route::Register {},
|
||||
"Register"
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -135,7 +280,8 @@ fn Navbar() -> Element {
|
||||
}
|
||||
|
||||
#[component]
|
||||
fn Login() -> Element {
|
||||
fn Auth() -> Element {
|
||||
let mut active_tab = use_signal(|| "login".to_string());
|
||||
let mut username = use_signal(|| String::new());
|
||||
let mut password = use_signal(|| String::new());
|
||||
let mut error = use_signal(|| String::new());
|
||||
@ -144,96 +290,144 @@ fn Login() -> Element {
|
||||
|
||||
rsx! {
|
||||
div {
|
||||
class: "flex flex-col items-center justify-center min-h-screen py-2",
|
||||
h1 { class: "text-2xl font-bold mb-4", "Login" }
|
||||
class: "min-h-screen bg-gradient-to-br from-indigo-50 via-white to-cyan-50 flex items-center justify-center py-12 px-4 sm:px-6 lg:px-8",
|
||||
div {
|
||||
class: "flex flex-col gap-4 w-64",
|
||||
class: "max-w-md w-full space-y-8",
|
||||
div {
|
||||
class: "text-center",
|
||||
div {
|
||||
class: "w-16 h-16 bg-indigo-600 rounded-lg flex items-center justify-center mx-auto mb-4",
|
||||
span { class: "text-white font-bold text-2xl", "W" }
|
||||
}
|
||||
h2 { class: "text-3xl font-bold text-gray-900", if active_tab() == "login" { "Sign in to your account" } else { "Create your account" } }
|
||||
p { class: "mt-2 text-sm text-gray-600", if active_tab() == "login" { "Don't have an account? " } else { "Already have an account? " }
|
||||
button {
|
||||
class: "font-medium text-indigo-600 hover:text-indigo-500",
|
||||
onclick: move |_| active_tab.set(if active_tab() == "login" { "register".to_string() } else { "login".to_string() }),
|
||||
if active_tab() == "login" { "Sign up" } else { "Sign in" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
div {
|
||||
class: "bg-white rounded-lg shadow-lg p-8",
|
||||
|
||||
// Tab buttons (hidden, using the link above instead)
|
||||
|
||||
// Login Form
|
||||
if active_tab() == "login" {
|
||||
div {
|
||||
class: "space-y-6",
|
||||
div {
|
||||
label { class: "block text-sm font-medium text-gray-700", "for": "username", "Username" }
|
||||
input {
|
||||
class: "border p-2 rounded",
|
||||
placeholder: "Username",
|
||||
id: "username",
|
||||
class: "appearance-none rounded-md relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm",
|
||||
placeholder: "Enter your username",
|
||||
value: "{username}",
|
||||
oninput: move |e| username.set(e.value())
|
||||
}
|
||||
}
|
||||
div {
|
||||
label { class: "block text-sm font-medium text-gray-700", "for": "password", "Password" }
|
||||
input {
|
||||
class: "border p-2 rounded",
|
||||
id: "password",
|
||||
class: "appearance-none rounded-md relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm",
|
||||
type: "password",
|
||||
placeholder: "Password",
|
||||
placeholder: "Enter your password",
|
||||
value: "{password}",
|
||||
oninput: move |e| password.set(e.value())
|
||||
}
|
||||
}
|
||||
button {
|
||||
class: "bg-blue-500 text-white p-2 rounded hover:bg-blue-600",
|
||||
onclick: move |_| async move {
|
||||
class: "group relative w-full flex justify-center py-2 px-4 border border-transparent text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 transition-colors",
|
||||
onclick: move |_| {
|
||||
let mut user_state = use_context::<Signal<Option<auth::UserSafe>>>();
|
||||
async move {
|
||||
error.set("".to_string());
|
||||
success.set("".to_string());
|
||||
match auth::login(username(), password()).await {
|
||||
Ok(_msg) => {
|
||||
success.set("Login successful".to_string());
|
||||
if let Ok(Some(user)) = auth::get_current_user().await {
|
||||
let mut user_state = use_context::<Signal<Option<auth::UserSafe>>>();
|
||||
user_state.set(Some(user));
|
||||
navigator.push(Route::Home {});
|
||||
}
|
||||
},
|
||||
Err(e) => error.set(e.to_string()),
|
||||
}
|
||||
}
|
||||
},
|
||||
"Login"
|
||||
}
|
||||
if !error().is_empty() {
|
||||
p { class: "text-red-500", "{error}" }
|
||||
}
|
||||
if !success().is_empty() {
|
||||
p { class: "text-green-500", "{success}" }
|
||||
"Sign in"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[component]
|
||||
fn Register() -> Element {
|
||||
let mut username = use_signal(|| String::new());
|
||||
let mut password = use_signal(|| String::new());
|
||||
let mut error = use_signal(|| String::new());
|
||||
let mut success = use_signal(|| String::new());
|
||||
|
||||
rsx! {
|
||||
// Register Form
|
||||
if active_tab() == "register" {
|
||||
div {
|
||||
class: "flex flex-col items-center justify-center min-h-screen py-2",
|
||||
h1 { class: "text-2xl font-bold mb-4", "Register" }
|
||||
class: "space-y-6",
|
||||
div {
|
||||
class: "flex flex-col gap-4 w-64",
|
||||
label { class: "block text-sm font-medium text-gray-700", "for": "reg-username", "Username" }
|
||||
input {
|
||||
class: "border p-2 rounded",
|
||||
placeholder: "Username",
|
||||
id: "reg-username",
|
||||
class: "appearance-none rounded-md relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm",
|
||||
placeholder: "Choose a username",
|
||||
value: "{username}",
|
||||
oninput: move |e| username.set(e.value())
|
||||
}
|
||||
}
|
||||
div {
|
||||
label { class: "block text-sm font-medium text-gray-700", "for": "reg-password", "Password" }
|
||||
input {
|
||||
class: "border p-2 rounded",
|
||||
id: "reg-password",
|
||||
class: "appearance-none rounded-md relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm",
|
||||
type: "password",
|
||||
placeholder: "Password",
|
||||
placeholder: "Choose a password",
|
||||
value: "{password}",
|
||||
oninput: move |e| password.set(e.value())
|
||||
}
|
||||
}
|
||||
button {
|
||||
class: "bg-green-500 text-white p-2 rounded hover:bg-green-600",
|
||||
onclick: move |_| async move {
|
||||
class: "group relative w-full flex justify-center py-2 px-4 border border-transparent text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 transition-colors",
|
||||
onclick: move |_| {
|
||||
let mut user_state = use_context::<Signal<Option<auth::UserSafe>>>();
|
||||
async move {
|
||||
error.set("".to_string());
|
||||
success.set("".to_string());
|
||||
match auth::register(username(), password()).await {
|
||||
Ok(msg) => success.set(msg),
|
||||
Err(e) => error.set(e.to_string()),
|
||||
Ok(_msg) => {
|
||||
// Auto-login after successful registration
|
||||
match auth::login(username(), password()).await {
|
||||
Ok(_login_msg) => {
|
||||
if let Ok(Some(user)) = auth::get_current_user().await {
|
||||
user_state.set(Some(user));
|
||||
navigator.push(Route::Home {});
|
||||
} else {
|
||||
success.set("Registration successful. Please log in.".to_string());
|
||||
}
|
||||
},
|
||||
"Register"
|
||||
Err(login_err) => {
|
||||
error.set(format!("Registration successful but auto-login failed: {}", login_err));
|
||||
}
|
||||
}
|
||||
},
|
||||
Err(e) => error.set(e.to_string()),
|
||||
}
|
||||
}
|
||||
},
|
||||
"Create Account"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Messages
|
||||
if !error().is_empty() {
|
||||
p { class: "text-red-500", "{error}" }
|
||||
p { class: "text-red-500 mt-4 text-center text-sm", "{error}" }
|
||||
}
|
||||
if !success().is_empty() {
|
||||
p { class: "text-green-500", "{success}" }
|
||||
p { class: "text-green-500 mt-4 text-center text-sm", "{success}" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -246,29 +440,150 @@ fn Dashboard() -> Element {
|
||||
|
||||
rsx! {
|
||||
div {
|
||||
class: "flex flex-col items-center min-h-screen py-2",
|
||||
h1 { class: "text-2xl font-bold mb-4", "My Events" }
|
||||
class: "min-h-screen bg-gradient-to-br from-indigo-50 via-white to-cyan-50 py-8",
|
||||
div {
|
||||
class: "max-w-7xl mx-auto px-4 sm:px-6 lg:px-8",
|
||||
div {
|
||||
class: "mb-8",
|
||||
h1 { class: "text-3xl font-bold text-gray-900", "My Events" }
|
||||
p { class: "mt-1 text-sm text-gray-600", "Manage your Secret Santa gift exchanges" }
|
||||
}
|
||||
|
||||
div {
|
||||
class: "mb-8",
|
||||
Link {
|
||||
to: Route::CreateEvent {},
|
||||
class: "bg-blue-500 text-white p-2 rounded hover:bg-blue-600 mb-4",
|
||||
class: "inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 transition-colors",
|
||||
svg {
|
||||
class: "w-5 h-5 mr-2",
|
||||
fill: "none",
|
||||
stroke: "currentColor",
|
||||
view_box: "0 0 24 24",
|
||||
path {
|
||||
stroke_linecap: "round",
|
||||
stroke_linejoin: "round",
|
||||
stroke_width: "2",
|
||||
d: "M12 6v6m0 0v6m0-6h6m-6 0H6"
|
||||
}
|
||||
}
|
||||
"Create New Event"
|
||||
}
|
||||
}
|
||||
|
||||
match &*events.read_unchecked() {
|
||||
Some(Ok(list)) => rsx! {
|
||||
if list.is_empty() {
|
||||
div {
|
||||
class: "flex flex-col gap-4 w-96",
|
||||
class: "text-center py-12",
|
||||
svg {
|
||||
class: "mx-auto h-12 w-12 text-gray-400",
|
||||
fill: "none",
|
||||
stroke: "currentColor",
|
||||
view_box: "0 0 24 24",
|
||||
path {
|
||||
stroke_linecap: "round",
|
||||
stroke_linejoin: "round",
|
||||
stroke_width: "2",
|
||||
d: "M19 11H5m14 0a2 2 0 012 2v6a2 2 0 01-2 2H5a2 2 0 01-2-2v-6a2 2 0 012-2m14 0V9a2 2 0 00-2-2M5 11V9a2 2 0 012-2m0 0V5a2 2 0 012-2h6a2 2 0 012 2v2M7 7h10"
|
||||
}
|
||||
}
|
||||
h3 { class: "mt-2 text-sm font-medium text-gray-900", "No events" }
|
||||
p { class: "mt-1 text-sm text-gray-500", "Get started by creating a new Secret Santa event." }
|
||||
div {
|
||||
class: "mt-6",
|
||||
Link {
|
||||
to: Route::CreateEvent {},
|
||||
class: "inline-flex items-center px-4 py-2 border border-transparent shadow-sm text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500",
|
||||
"Create Event"
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
div {
|
||||
class: "grid gap-6 md:grid-cols-2 lg:grid-cols-3",
|
||||
for event in list {
|
||||
div {
|
||||
class: "bg-white rounded-lg shadow hover:shadow-lg transition-shadow p-6 border border-gray-200",
|
||||
div {
|
||||
class: "flex items-center justify-between mb-4",
|
||||
h3 {
|
||||
class: "text-lg font-semibold text-gray-900",
|
||||
Link {
|
||||
to: Route::EventPage { id: event.id },
|
||||
class: "border p-4 rounded hover:bg-gray-100 flex justify-between items-center",
|
||||
span { class: "font-bold", "{event.name}" }
|
||||
span { class: "text-gray-500", "{event.date}" }
|
||||
class: "hover:text-indigo-600 transition-colors",
|
||||
"{event.name}"
|
||||
}
|
||||
}
|
||||
span {
|
||||
class: "inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-indigo-100 text-indigo-800",
|
||||
"{event.date}"
|
||||
}
|
||||
}
|
||||
p { class: "text-sm text-gray-600 mb-4", "Budget: {event.budget}" }
|
||||
div {
|
||||
class: "flex justify-between items-center",
|
||||
Link {
|
||||
to: Route::EventPage { id: event.id },
|
||||
class: "text-indigo-600 hover:text-indigo-500 text-sm font-medium",
|
||||
"View Event →"
|
||||
}
|
||||
Link {
|
||||
to: Route::EventPage { id: event.id },
|
||||
class: "text-gray-400 hover:text-gray-600",
|
||||
svg {
|
||||
class: "w-5 h-5",
|
||||
fill: "none",
|
||||
stroke: "currentColor",
|
||||
view_box: "0 0 24 24",
|
||||
path {
|
||||
stroke_linecap: "round",
|
||||
stroke_linejoin: "round",
|
||||
stroke_width: "2",
|
||||
d: "M9 5l7 7-7 7"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
Some(Err(e)) => rsx! { p { class: "text-red-500", "Error: {e}" } },
|
||||
None => rsx! { p { "Loading..." } },
|
||||
Some(Err(e)) => rsx! {
|
||||
div {
|
||||
class: "bg-red-50 border border-red-200 rounded-md p-4",
|
||||
div {
|
||||
class: "flex",
|
||||
div {
|
||||
class: "flex-shrink-0",
|
||||
svg {
|
||||
class: "h-5 w-5 text-red-400",
|
||||
fill: "currentColor",
|
||||
view_box: "0 0 20 20",
|
||||
path {
|
||||
fill_rule: "evenodd",
|
||||
d: "M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",
|
||||
clip_rule: "evenodd"
|
||||
}
|
||||
}
|
||||
}
|
||||
div {
|
||||
class: "ml-3",
|
||||
h3 { class: "text-sm font-medium text-red-800", "Error loading events" }
|
||||
p { class: "mt-2 text-sm text-red-700", "{e}" }
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
None => rsx! {
|
||||
div {
|
||||
class: "flex justify-center items-center py-12",
|
||||
div {
|
||||
class: "animate-spin rounded-full h-12 w-12 border-b-2 border-indigo-600"
|
||||
}
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -284,40 +599,74 @@ fn CreateEvent() -> Element {
|
||||
|
||||
rsx! {
|
||||
div {
|
||||
class: "flex flex-col items-center justify-center min-h-screen py-2",
|
||||
h1 { class: "text-2xl font-bold mb-4", "Create Event" }
|
||||
class: "min-h-screen bg-gradient-to-br from-indigo-50 via-white to-cyan-50 py-12 px-4 sm:px-6 lg:px-8",
|
||||
div {
|
||||
class: "flex flex-col gap-4 w-64",
|
||||
input {
|
||||
class: "border p-2 rounded",
|
||||
placeholder: "Event Name",
|
||||
value: "{name}",
|
||||
oninput: move |e| name.set(e.value())
|
||||
class: "max-w-md mx-auto",
|
||||
div {
|
||||
class: "text-center mb-8",
|
||||
h2 { class: "text-3xl font-bold text-gray-900", "Create New Event" }
|
||||
p { class: "mt-2 text-sm text-gray-600", "Set up your Secret Santa gift exchange" }
|
||||
}
|
||||
input {
|
||||
class: "border p-2 rounded",
|
||||
type: "date",
|
||||
value: "{date}",
|
||||
oninput: move |e| date.set(e.value())
|
||||
}
|
||||
input {
|
||||
class: "border p-2 rounded",
|
||||
placeholder: "Budget (e.g. 20 EUR)",
|
||||
value: "{budget}",
|
||||
oninput: move |e| budget.set(e.value())
|
||||
}
|
||||
button {
|
||||
class: "bg-green-500 text-white p-2 rounded hover:bg-green-600",
|
||||
onclick: move |_| async move {
|
||||
div {
|
||||
class: "bg-white rounded-lg shadow-lg p-8",
|
||||
form {
|
||||
class: "space-y-6",
|
||||
onsubmit: move |e| {
|
||||
e.prevent_default();
|
||||
spawn(async move {
|
||||
match server_fns::create_event(name(), date(), budget()).await {
|
||||
Ok(_) => { navigator.push(Route::Dashboard {}); },
|
||||
Err(e) => error.set(e.to_string()),
|
||||
}
|
||||
});
|
||||
},
|
||||
"Create"
|
||||
div {
|
||||
label { class: "block text-sm font-medium text-gray-700", "for": "event-name", "Event Name" }
|
||||
input {
|
||||
id: "event-name",
|
||||
class: "appearance-none rounded-md relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm",
|
||||
placeholder: "e.g., Family Christmas 2024",
|
||||
value: "{name}",
|
||||
oninput: move |e| name.set(e.value()),
|
||||
required: true
|
||||
}
|
||||
}
|
||||
div {
|
||||
label { class: "block text-sm font-medium text-gray-700", "for": "event-date", "Event Date" }
|
||||
input {
|
||||
id: "event-date",
|
||||
class: "appearance-none rounded-md relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm",
|
||||
type: "date",
|
||||
value: "{date}",
|
||||
oninput: move |e| date.set(e.value()),
|
||||
required: true
|
||||
}
|
||||
}
|
||||
div {
|
||||
label { class: "block text-sm font-medium text-gray-700", "for": "event-budget", "Budget" }
|
||||
input {
|
||||
id: "event-budget",
|
||||
class: "appearance-none rounded-md relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm",
|
||||
placeholder: "e.g., 20 EUR",
|
||||
value: "{budget}",
|
||||
oninput: move |e| budget.set(e.value()),
|
||||
required: true
|
||||
}
|
||||
}
|
||||
div {
|
||||
button {
|
||||
type: "submit",
|
||||
class: "group relative w-full flex justify-center py-2 px-4 border border-transparent text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 transition-colors",
|
||||
"Create Event"
|
||||
}
|
||||
}
|
||||
if !error().is_empty() {
|
||||
p { class: "text-red-500", "{error}" }
|
||||
div {
|
||||
class: "bg-red-50 border border-red-200 rounded-md p-4",
|
||||
p { class: "text-sm text-red-700", "{error}" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -433,45 +782,264 @@ fn JoinEvent(token: String) -> Element {
|
||||
let mut name = use_signal(|| String::new());
|
||||
let mut error = use_signal(|| String::new());
|
||||
let navigator = use_navigator();
|
||||
let mut user_state = use_context::<Signal<Option<auth::UserSafe>>>();
|
||||
|
||||
// Login form state (for inline login)
|
||||
let mut login_username = use_signal(|| String::new());
|
||||
let mut login_password = use_signal(|| String::new());
|
||||
let mut login_error = use_signal(|| String::new());
|
||||
|
||||
// Registration form state (for inline registration)
|
||||
let mut register_username = use_signal(|| String::new());
|
||||
let mut register_password = use_signal(|| String::new());
|
||||
let mut register_error = use_signal(|| String::new());
|
||||
let mut register_success = use_signal(|| String::new());
|
||||
|
||||
rsx! {
|
||||
div {
|
||||
class: "flex flex-col items-center justify-center min-h-screen py-2",
|
||||
class: "min-h-screen bg-gradient-to-br from-indigo-50 via-white to-cyan-50 py-12 px-4 sm:px-6 lg:px-8",
|
||||
div {
|
||||
class: "max-w-md mx-auto",
|
||||
div {
|
||||
class: "bg-white rounded-lg shadow-lg p-8",
|
||||
match &*event.read() {
|
||||
Some(Ok(e)) => rsx! {
|
||||
h1 { class: "text-2xl font-bold mb-4", "Join {e.name}" }
|
||||
p { class: "mb-4", "Date: {e.date}" }
|
||||
p { class: "mb-4", "Budget: {e.budget}" }
|
||||
div {
|
||||
class: "flex flex-col gap-4 w-64",
|
||||
input {
|
||||
class: "border p-2 rounded",
|
||||
placeholder: "Your Name",
|
||||
value: "{name}",
|
||||
oninput: move |e| name.set(e.value())
|
||||
class: "text-center mb-6",
|
||||
div {
|
||||
class: "w-16 h-16 bg-indigo-100 rounded-full flex items-center justify-center mx-auto mb-4",
|
||||
svg {
|
||||
class: "w-8 h-8 text-indigo-600",
|
||||
fill: "none",
|
||||
stroke: "currentColor",
|
||||
view_box: "0 0 24 24",
|
||||
path {
|
||||
stroke_linecap: "round",
|
||||
stroke_linejoin: "round",
|
||||
stroke_width: "2",
|
||||
d: "M17 20h5v-2a3 3 0 00-5.356-1.857M17 20H7m10 0v-2c0-.656-.126-1.283-.356-1.857M7 20H2v-2a3 3 0 015.356-1.857M7 20v-2c0-.656.126-1.283.356-1.857m0 0a5.002 5.002 0 019.288 0M15 7a3 3 0 11-6 0 3 3 0 016 0zm6 3a2 2 0 11-4 0 2 2 0 014 0zM7 10a2 2 0 11-4 0 2 2 0 014 0z"
|
||||
}
|
||||
button {
|
||||
class: "bg-green-500 text-white p-2 rounded hover:bg-green-600",
|
||||
onclick: move |_| {
|
||||
let token = token.clone();
|
||||
async move {
|
||||
match server_fns::join_event(token, name()).await {
|
||||
}
|
||||
}
|
||||
h1 { class: "text-2xl font-bold text-gray-900 mb-2", "Join {e.name}" }
|
||||
p { class: "text-sm text-gray-600", "You're invited to join this Secret Santa event!" }
|
||||
}
|
||||
|
||||
div {
|
||||
class: "bg-gray-50 rounded-lg p-4 mb-6",
|
||||
div {
|
||||
class: "flex justify-between items-center mb-2",
|
||||
span { class: "text-sm font-medium text-gray-700", "Event Date:" }
|
||||
span { class: "text-sm text-gray-900", "{e.date}" }
|
||||
}
|
||||
div {
|
||||
class: "flex justify-between items-center",
|
||||
span { class: "text-sm font-medium text-gray-700", "Gift Budget:" }
|
||||
span { class: "text-sm text-gray-900", "{e.budget}" }
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(user) = user_state() {
|
||||
// User is logged in - show join form
|
||||
form {
|
||||
class: "space-y-4",
|
||||
onsubmit: move |evt| {
|
||||
evt.prevent_default();
|
||||
let token_clone = token.clone();
|
||||
spawn(async move {
|
||||
match server_fns::join_event(token_clone, name()).await {
|
||||
Ok(_) => {
|
||||
navigator.push(Route::Dashboard {});
|
||||
}
|
||||
Err(e) => error.set(e.to_string()),
|
||||
}
|
||||
Err(err) => error.set(err.to_string()),
|
||||
}
|
||||
});
|
||||
},
|
||||
div {
|
||||
label { class: "block text-sm font-medium text-gray-700", "for": "participant-name", "Your Name" }
|
||||
input {
|
||||
id: "participant-name",
|
||||
class: "appearance-none rounded-md relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm",
|
||||
placeholder: "Enter your name",
|
||||
value: "{name}",
|
||||
oninput: move |evt| name.set(evt.value()),
|
||||
required: true
|
||||
}
|
||||
}
|
||||
button {
|
||||
type: "submit",
|
||||
class: "group relative w-full flex justify-center py-2 px-4 border border-transparent text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 transition-colors",
|
||||
"Join Event"
|
||||
}
|
||||
if !error().is_empty() {
|
||||
p { class: "text-red-500", "{error}" }
|
||||
div {
|
||||
class: "bg-red-50 border border-red-200 rounded-md p-3",
|
||||
p { class: "text-sm text-red-700", "{error}" }
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// User is not logged in - show login/register options
|
||||
div {
|
||||
class: "space-y-6",
|
||||
|
||||
// Login form
|
||||
div {
|
||||
class: "border border-gray-200 rounded-lg p-4",
|
||||
h3 { class: "text-lg font-semibold text-gray-900 mb-3", "Login to Join" }
|
||||
div {
|
||||
class: "space-y-3",
|
||||
input {
|
||||
class: "appearance-none rounded-md relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm",
|
||||
placeholder: "Username",
|
||||
value: "{login_username}",
|
||||
oninput: move |e| login_username.set(e.value())
|
||||
}
|
||||
input {
|
||||
class: "appearance-none rounded-md relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm",
|
||||
type: "password",
|
||||
placeholder: "Password",
|
||||
value: "{login_password}",
|
||||
oninput: move |e| login_password.set(e.value())
|
||||
}
|
||||
button {
|
||||
class: "group relative w-full flex justify-center py-2 px-4 border border-transparent text-sm font-medium rounded-md text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 transition-colors",
|
||||
onclick: move |_| {
|
||||
let mut user_state_clone = user_state.clone();
|
||||
async move {
|
||||
login_error.set("".to_string());
|
||||
match auth::login(login_username(), login_password()).await {
|
||||
Ok(_msg) => {
|
||||
if let Ok(Some(user)) = auth::get_current_user().await {
|
||||
user_state_clone.set(Some(user));
|
||||
}
|
||||
},
|
||||
Err(e) => login_error.set(e.to_string()),
|
||||
}
|
||||
}
|
||||
},
|
||||
Some(Err(e)) => rsx! { p { class: "text-red-500", "Error: {e}" } },
|
||||
None => rsx! { p { "Loading..." } },
|
||||
"Login"
|
||||
}
|
||||
if !login_error().is_empty() {
|
||||
p { class: "text-sm text-red-600", "{login_error}" }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// OR divider
|
||||
div {
|
||||
class: "relative",
|
||||
div {
|
||||
class: "absolute inset-0 flex items-center",
|
||||
div { class: "w-full border-t border-gray-300" }
|
||||
}
|
||||
div {
|
||||
class: "relative flex justify-center text-sm",
|
||||
span { class: "px-2 bg-white text-gray-500", "or" }
|
||||
}
|
||||
}
|
||||
|
||||
// Registration form
|
||||
div {
|
||||
class: "border border-gray-200 rounded-lg p-4",
|
||||
h3 { class: "text-lg font-semibold text-gray-900 mb-3", "Register to Join" }
|
||||
div {
|
||||
class: "space-y-3",
|
||||
input {
|
||||
class: "appearance-none rounded-md relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm",
|
||||
placeholder: "Username",
|
||||
value: "{register_username}",
|
||||
oninput: move |e| register_username.set(e.value())
|
||||
}
|
||||
input {
|
||||
class: "appearance-none rounded-md relative block w-full px-3 py-2 border border-gray-300 placeholder-gray-500 text-gray-900 focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm",
|
||||
type: "password",
|
||||
placeholder: "Password",
|
||||
value: "{register_password}",
|
||||
oninput: move |e| register_password.set(e.value())
|
||||
}
|
||||
button {
|
||||
class: "group relative w-full flex justify-center py-2 px-4 border border-transparent text-sm font-medium rounded-md text-white bg-green-600 hover:bg-green-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-500 transition-colors",
|
||||
onclick: move |_| {
|
||||
let mut user_state_clone = user_state.clone();
|
||||
async move {
|
||||
register_error.set("".to_string());
|
||||
register_success.set("".to_string());
|
||||
match auth::register(register_username(), register_password()).await {
|
||||
Ok(_msg) => {
|
||||
// Auto-login after registration
|
||||
match auth::login(register_username(), register_password()).await {
|
||||
Ok(_login_msg) => {
|
||||
if let Ok(Some(user)) = auth::get_current_user().await {
|
||||
user_state_clone.set(Some(user));
|
||||
} else {
|
||||
register_success.set("Registration successful. Please log in above.".to_string());
|
||||
}
|
||||
},
|
||||
Err(login_err) => {
|
||||
register_error.set(format!("Registration successful but auto-login failed: {}", login_err));
|
||||
}
|
||||
}
|
||||
},
|
||||
Err(e) => register_error.set(e.to_string()),
|
||||
}
|
||||
}
|
||||
},
|
||||
"Register"
|
||||
}
|
||||
if !register_error().is_empty() {
|
||||
p { class: "text-sm text-red-600", "{register_error}" }
|
||||
}
|
||||
if !register_success().is_empty() {
|
||||
p { class: "text-sm text-green-600", "{register_success}" }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
Some(Err(e)) => rsx! {
|
||||
div {
|
||||
class: "text-center",
|
||||
div {
|
||||
class: "w-16 h-16 bg-red-100 rounded-full flex items-center justify-center mx-auto mb-4",
|
||||
svg {
|
||||
class: "w-8 h-8 text-red-600",
|
||||
fill: "none",
|
||||
stroke: "currentColor",
|
||||
view_box: "0 0 24 24",
|
||||
path {
|
||||
stroke_linecap: "round",
|
||||
stroke_linejoin: "round",
|
||||
stroke_width: "2",
|
||||
d: "M12 8v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"
|
||||
}
|
||||
}
|
||||
}
|
||||
h2 { class: "text-lg font-semibold text-gray-900 mb-2", "Invalid Invitation" }
|
||||
p { class: "text-sm text-gray-600 mb-4", "This invitation link appears to be invalid or has expired." }
|
||||
p { class: "text-red-600 font-medium", "{e}" }
|
||||
div {
|
||||
class: "mt-6",
|
||||
Link {
|
||||
to: Route::Home {},
|
||||
class: "inline-flex items-center px-4 py-2 border border-transparent text-sm font-medium rounded-md shadow-sm text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500",
|
||||
"Go Home"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
None => rsx! {
|
||||
div {
|
||||
class: "text-center",
|
||||
div {
|
||||
class: "animate-spin rounded-full h-12 w-12 border-b-2 border-indigo-600 mx-auto mb-4"
|
||||
}
|
||||
p { class: "text-sm text-gray-600", "Loading invitation..." }
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user