|
61 | 61 | } |
62 | 62 |
|
63 | 63 | let section = $state<HTMLElement | null>(null) |
| 64 | +
|
| 65 | + let hide_form = $state(true) |
| 66 | +
|
| 67 | + async function show_form() { |
| 68 | + hide_form = false |
| 69 | + await tick() |
| 70 | + section?.scrollIntoView({ |
| 71 | + block: 'start', |
| 72 | + behavior: 'smooth', |
| 73 | + }) |
| 74 | + } |
64 | 75 | </script> |
65 | 76 |
|
66 | 77 | <section bind:this={section}> |
67 | | - <h2>Suggestion Form</h2> |
68 | | - |
69 | | - <p class="hint"> |
70 | | - Use the form below to report missing data, submit an issue, or make a suggestion. |
71 | | - </p> |
72 | | - |
73 | | - <form onsubmit={create_issue}> |
74 | | - <div class="form-group"> |
75 | | - <label for="title"> |
76 | | - <span>Short summary</span> |
77 | | - <span class="description">max. {TITLE_MAX_LENGTH} characters</span> |
78 | | - </label> |
79 | | - <input |
80 | | - type="text" |
81 | | - id="title" |
82 | | - class="full-width" |
83 | | - bind:value={title} |
84 | | - required |
85 | | - aria-invalid={title.length > TITLE_MAX_LENGTH} |
86 | | - /> |
87 | | - </div> |
88 | | - |
89 | | - <div class="form-group"> |
90 | | - <label for="body"> |
91 | | - <span>Details</span> |
92 | | - <span class="description">max. {BODY_MAX_LENGTH} characters</span> |
93 | | - </label> |
94 | | - <textarea |
95 | | - id="body" |
96 | | - {@attach resize_textarea} |
97 | | - bind:value={body} |
98 | | - required |
99 | | - class="full-width" |
100 | | - aria-invalid={body.length > BODY_MAX_LENGTH} |
101 | | - ></textarea> |
102 | | - </div> |
103 | | - |
104 | | - <div class="form-group"> |
105 | | - <label for="name"> |
106 | | - <span>Your name</span> |
107 | | - <span class="description">optional</span> |
108 | | - </label> |
109 | | - <input |
110 | | - type="text" |
111 | | - id="name" |
112 | | - class="full-width" |
113 | | - bind:value={name} |
114 | | - aria-invalid={name.length > NAME_MAX_LENGTH} |
115 | | - /> |
116 | | - </div> |
117 | | - |
118 | | - <button class="button" disabled={sending}> |
119 | | - {#if sending} |
120 | | - Submitting... |
121 | | - {:else} |
122 | | - Submit |
123 | | - {/if} |
124 | | - </button> |
125 | | - </form> |
126 | | - |
127 | | - {#if error} |
128 | | - <p class="error"> |
129 | | - <Fa icon={faWarning} /> |
130 | | - Error: {error} |
| 78 | + {#if hide_form} |
| 79 | + <button class="button" onclick={show_form}>Make a suggestion</button> |
| 80 | + {:else} |
| 81 | + <h2>Suggestion Form</h2> |
| 82 | + |
| 83 | + <p class="hint"> |
| 84 | + Use the form below to report missing data, submit an issue, or make a |
| 85 | + suggestion. |
131 | 86 | </p> |
132 | | - {/if} |
133 | 87 |
|
134 | | - {#if url} |
135 | | - <p> |
136 | | - <Fa icon={faCheckCircle} /> |
137 | | - Your suggestion has been created as a |
138 | | - <a href={url} target="_blank">GitHub issue</a>. We will review it shortly. |
139 | | - </p> |
| 88 | + <form onsubmit={create_issue}> |
| 89 | + <div class="form-group"> |
| 90 | + <label for="title"> |
| 91 | + <span>Short summary</span> |
| 92 | + <span class="description">max. {TITLE_MAX_LENGTH} characters</span> |
| 93 | + </label> |
| 94 | + <input |
| 95 | + type="text" |
| 96 | + id="title" |
| 97 | + class="full-width" |
| 98 | + bind:value={title} |
| 99 | + required |
| 100 | + aria-invalid={title.length > TITLE_MAX_LENGTH} |
| 101 | + /> |
| 102 | + </div> |
| 103 | + |
| 104 | + <div class="form-group"> |
| 105 | + <label for="body"> |
| 106 | + <span>Details</span> |
| 107 | + <span class="description">max. {BODY_MAX_LENGTH} characters</span> |
| 108 | + </label> |
| 109 | + <textarea |
| 110 | + id="body" |
| 111 | + {@attach resize_textarea} |
| 112 | + bind:value={body} |
| 113 | + required |
| 114 | + class="full-width" |
| 115 | + aria-invalid={body.length > BODY_MAX_LENGTH} |
| 116 | + ></textarea> |
| 117 | + </div> |
| 118 | + |
| 119 | + <div class="form-group"> |
| 120 | + <label for="name"> |
| 121 | + <span>Your name</span> |
| 122 | + <span class="description">optional</span> |
| 123 | + </label> |
| 124 | + <input |
| 125 | + type="text" |
| 126 | + id="name" |
| 127 | + class="full-width" |
| 128 | + bind:value={name} |
| 129 | + aria-invalid={name.length > NAME_MAX_LENGTH} |
| 130 | + /> |
| 131 | + </div> |
| 132 | + |
| 133 | + <button class="button" disabled={sending}> |
| 134 | + {#if sending} |
| 135 | + Submitting... |
| 136 | + {:else} |
| 137 | + Submit |
| 138 | + {/if} |
| 139 | + </button> |
| 140 | + </form> |
| 141 | + |
| 142 | + {#if error} |
| 143 | + <p class="error"> |
| 144 | + <Fa icon={faWarning} /> |
| 145 | + Error: {error} |
| 146 | + </p> |
| 147 | + {/if} |
| 148 | + |
| 149 | + {#if url} |
| 150 | + <p> |
| 151 | + <Fa icon={faCheckCircle} /> |
| 152 | + Your suggestion has been created as a |
| 153 | + <a href={url} target="_blank">GitHub issue</a>. We will review it shortly. |
| 154 | + </p> |
| 155 | + {/if} |
140 | 156 | {/if} |
141 | 157 | </section> |
142 | 158 |
|
143 | 159 | <style> |
144 | 160 | section { |
145 | | - margin-top: 4rem; |
| 161 | + margin-top: 2rem; |
146 | 162 | padding-bottom: 1rem; |
147 | 163 | margin-bottom: -1rem; |
148 | 164 | } |
|
0 commit comments