File size: 2,278 Bytes
7ac86fa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<script lang="ts">
  import type { StoryChoice } from '$lib/types';

  export let choices: StoryChoice[];
  export let onChoiceSelected: ((choice: StoryChoice) => void) | undefined = undefined;
  export let disabled: boolean = false;

  function handleChoice(choice: StoryChoice) {
    if (!disabled) {
      onChoiceSelected?.(choice);
    }
  }
</script>

{#if choices && choices.length > 0}
  <div class="choice-interface">
    <h3>What do you do?</h3>
    <div class="choices">
      {#each choices as choice}
        <button
          class="choice-button"
          class:disabled={disabled}
          on:click={() => handleChoice(choice)}
          disabled={disabled}
        >
          <span class="choice-text">{choice.text}</span>
          {#if choice.description}
            <span class="choice-description">{choice.description}</span>
          {/if}
        </button>
      {/each}
    </div>
  </div>
{/if}

<style>
  .choice-interface {
    padding: 2rem;
    background: #f8f9fa;
    border-radius: 0.5rem;
    margin: 1.5rem 0;
  }

  h3 {
    margin: 0 0 1.5rem 0;
    color: #1a1a1a;
    font-size: 1.5rem;
    text-align: center;
  }

  .choices {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-width: 600px;
    margin: 0 auto;
  }

  .choice-button {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    padding: 1.25rem 1.5rem;
    background: white;
    border: 2px solid #dee2e6;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
  }

  .choice-button:hover:not(.disabled) {
    border-color: #007bff;
    background: #f0f8ff;
    transform: translateX(5px);
  }

  .choice-button.disabled {
    opacity: 0.5;
    cursor: not-allowed;
  }

  .choice-text {
    font-size: 1.1rem;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 0.5rem;
  }

  .choice-description {
    font-size: 0.9rem;
    color: #666;
    line-height: 1.4;
  }

  @media (max-width: 768px) {
    .choice-interface {
      padding: 1.5rem 1rem;
    }

    h3 {
      font-size: 1.25rem;
    }

    .choice-button {
      padding: 1rem 1.25rem;
    }

    .choice-text {
      font-size: 1rem;
    }

    .choice-description {
      font-size: 0.85rem;
    }
  }
</style>