Wizard.svelte 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <!-- Wizard.svelte -->
  2. <script>
  3. import { slide } from "svelte/transition";
  4. import ProgressBar from "./ProgressBar.svelte";
  5. import Step1_Founders from "./Step1_Founders.svelte";
  6. import Step2_Scale from "./Step2_Scale.svelte";
  7. import Step3_Activity from "./Step3_Activity.svelte";
  8. import Step4_Finance from "./Step4_Finance.svelte";
  9. import ResultCard from "./ResultCard.svelte";
  10. import { findRecommendation } from "../utils/matcher";
  11. import rules from "../data/rules.json";
  12. let step = $state(1);
  13. let form = $state({
  14. founders: 1,
  15. scale: "малый",
  16. activity: "услуги",
  17. investments: false,
  18. risk: true,
  19. });
  20. let result = $state(null);
  21. $inspect(result);
  22. $effect(() => {
  23. if (step === 5) {
  24. result = findRecommendation(form, rules);
  25. }
  26. });
  27. function next() {
  28. if (step < 5) step++;
  29. }
  30. function prev() {
  31. if (step > 1) step--;
  32. }
  33. function reset() {
  34. step = 1;
  35. result = null;
  36. form = {
  37. founders: 1,
  38. scale: "малый",
  39. activity: "услуги",
  40. investments: false,
  41. risk: true,
  42. };
  43. }
  44. const steps = [
  45. { num: 1, title: "Кто запускает?" },
  46. { num: 2, title: "Масштаб" },
  47. { num: 3, title: "Деятельность" },
  48. { num: 4, title: "Финансы и риски" },
  49. { num: 5, title: "Результат" },
  50. ];
  51. </script>
  52. <div class="wizard container">
  53. <h1 class="title">Выбор ОПФ для бизнеса</h1>
  54. <ProgressBar {step} total={5} />
  55. {#if step === 1}
  56. <div transition:slide>
  57. <Step1_Founders bind:value={form.founders} {next} />
  58. </div>
  59. {:else if step === 2}
  60. <div transition:slide>
  61. <Step2_Scale bind:value={form.scale} {next} {prev} />
  62. </div>
  63. {:else if step === 3}
  64. <div transition:slide>
  65. <Step3_Activity bind:value={form.activity} {next} {prev} />
  66. </div>
  67. {:else if step === 4}
  68. <div transition:slide>
  69. <Step4_Finance bind:form {next} {prev} />
  70. </div>
  71. {:else if step === 5}
  72. <div transition:slide>
  73. <ResultCard {result} {reset} />
  74. </div>
  75. {/if}
  76. </div>
  77. <style>
  78. .wizard {
  79. max-width: 600px;
  80. margin: 2rem auto;
  81. padding: 2rem;
  82. background-color: #ffffff;
  83. color: #1e293b;
  84. border-radius: 16px;
  85. box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  86. height: min-content;
  87. }
  88. .title {
  89. text-align: center;
  90. margin-bottom: 1rem;
  91. color: #0f172a;
  92. }
  93. /* Тёмная тема */
  94. @media (prefers-color-scheme: dark) {
  95. .wizard {
  96. background-color: #1e293b;
  97. color: #e2e8f0;
  98. box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
  99. }
  100. .title {
  101. color: #f1f5f9;
  102. }
  103. }
  104. </style>