+page.svelte 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  1. <script>
  2. import "$lib/global.css";
  3. import {PUBLIC_API_URL} from "$env/static/public";
  4. import {goto} from "$app/navigation";
  5. import {toast} from "$lib/toast.svelte.js";
  6. import favicon from "$lib/assets/favicon.png";
  7. let name = $state("");
  8. let email = $state("");
  9. let password = $state("");
  10. let confirmPassword = $state("");
  11. let url = $state("");
  12. const submit = async ()=>{
  13. const body = {
  14. name: name,
  15. email: email,
  16. password: password,
  17. confirm_password: confirmPassword,
  18. url: url
  19. };
  20. const response = await fetch(`${PUBLIC_API_URL}/user`, {
  21. method: "POST",
  22. headers: {"Content-Type": "application/json"},
  23. body: JSON.stringify(body)
  24. });
  25. const responseBody = await response.json();
  26. if(!response.ok){
  27. toast(responseBody.error.message, "error")
  28. console.log(responseBody.error.message);
  29. }else{
  30. goto("/login");
  31. }
  32. }
  33. </script>
  34. <main>
  35. <a href="/" class="logo">
  36. <span class="logo-icon">
  37. <img src={favicon} alt="ChatRPG logo" width="35" height="35" />
  38. </span>
  39. <span class="logo-text">ChatRPG</span>
  40. </a>
  41. <div class="form-glow">
  42. <form class="standardForm" onsubmit={submit}>
  43. <h2>Join The Adventure</h2>
  44. <label>Name
  45. <input bind:value={name} type="text" required>
  46. </label>
  47. <label>Email
  48. <input bind:value={email} type="email" required>
  49. </label>
  50. <label>Password
  51. <input bind:value={password} type="password" required>
  52. </label>
  53. <label>Confirm Password
  54. <input bind:value={confirmPassword} type="password" required>
  55. </label>
  56. <input bind:value={url} type="hidden" required>
  57. <button type="submit">Register</button>
  58. <p>Already have an account? <a href="/login">Log in</a></p>
  59. </form>
  60. </div>
  61. </main>
  62. <style>
  63. main {
  64. min-height: 100vh;
  65. display: flex;
  66. flex-direction: column;
  67. align-items: center;
  68. justify-content: center;
  69. gap: 1.75rem;
  70. padding: 2rem 1rem;
  71. }
  72. a.logo {
  73. display: flex;
  74. align-items: center;
  75. gap: 14px;
  76. text-decoration: none;
  77. color: #e5e5ea;
  78. font-weight: 700;
  79. font-size: 32px;
  80. letter-spacing: -0.5px;
  81. }
  82. a.logo img {
  83. width: 48px;
  84. height: 48px;
  85. }
  86. a.logo .logo-icon {
  87. color: #c084fc;
  88. display: flex;
  89. align-items: center;
  90. justify-content: center;
  91. }
  92. h2{
  93. text-align: center;
  94. }
  95. .form-glow {
  96. position: relative;
  97. border-radius: 14px;
  98. width: min(660px, 100%);
  99. }
  100. .form-glow::before {
  101. content: "";
  102. position: absolute;
  103. inset: -2px;
  104. border-radius: 14px;
  105. background: conic-gradient(
  106. from var(--angle, 0deg),
  107. transparent 0%,
  108. #c084fc 20%,
  109. #5a5aff 40%,
  110. transparent 60%
  111. );
  112. animation: spin-border 10s linear infinite;
  113. z-index: 0;
  114. }
  115. .form-glow::after {
  116. content: "";
  117. position: absolute;
  118. inset: 1px;
  119. border-radius: 13px;
  120. background: #1a1a2e;
  121. z-index: 1;
  122. }
  123. .form-glow .standardForm {
  124. position: relative;
  125. z-index: 2;
  126. border-color: transparent;
  127. max-width: 660px;
  128. }
  129. @property --angle {
  130. syntax: "<angle>";
  131. inherits: false;
  132. initial-value: 0deg;
  133. }
  134. @keyframes spin-border {
  135. to { --angle: 360deg; }
  136. }
  137. </style>