|
36 | 36 | frameworks.find((framework) => framework.key === site.framework) |
37 | 37 | ); |
38 | 38 | let showFallback = $derived(adapter === Adapter.Static); |
39 | | - let hasChanges = $derived( |
| 39 | +
|
| 40 | + let isUntouched = $derived( |
40 | 41 | installCommand === site?.installCommand && |
41 | 42 | buildCommand === site?.buildCommand && |
42 | 43 | outputDirectory === site?.outputDirectory && |
43 | 44 | selectedFramework?.key === site?.framework && |
44 | | - fallback === (site?.fallbackFile || undefined) && |
45 | | - adapter === site?.adapter |
| 45 | + (fallback ?? '') === (site?.fallbackFile ?? '') && |
| 46 | + (adapter ?? '') === (site?.adapter ?? '') |
46 | 47 | ); |
47 | 48 | let frameworkAdapterData = $derived( |
48 | 49 | selectedFramework.adapters.find((a) => a.key === adapter) ?? selectedFramework.adapters[0] |
49 | 50 | ); |
50 | 51 |
|
| 52 | + $effect(() => { |
| 53 | + if (adapter) { |
| 54 | + const data = selectedFramework.adapters.find((a) => a.key === adapter); |
| 55 | + if (data) { |
| 56 | + installCommand = data.installCommand; |
| 57 | + buildCommand = data.buildCommand; |
| 58 | + outputDirectory = data.outputDirectory; |
| 59 | + fallback = data.fallbackFile; |
| 60 | + } |
| 61 | + } |
| 62 | + }); |
| 63 | +
|
51 | 64 | $effect(() => { |
52 | 65 | if (selectedFramework?.key !== site.framework) { |
53 | | - //Update adapter |
| 66 | + // Update adapter |
54 | 67 | const singleAdapter = selectedFramework?.adapters?.length <= 1; |
55 | 68 | if (singleAdapter) { |
56 | 69 | const hasSSR = selectedFramework?.adapters?.some((a) => a?.key === Adapter.Ssr); |
|
65 | 78 | } |
66 | 79 |
|
67 | 80 | //Update values |
68 | | - const data = selectedFramework.adapters.find((a) => a.key === adapter); |
| 81 | + const data = |
| 82 | + selectedFramework.adapters.find((a) => a.key === adapter) ?? |
| 83 | + selectedFramework.adapters[0]; |
69 | 84 | installCommand = data.installCommand; |
70 | 85 | buildCommand = data.buildCommand; |
71 | 86 | outputDirectory = data.outputDirectory; |
72 | | - adapter = selectedFramework.adapters[0].key as Adapter; |
| 87 | + adapter = data.key as Adapter; |
73 | 88 | fallback = data.fallbackFile; |
74 | 89 | } else { |
75 | 90 | adapter = site.adapter as Adapter; |
|
157 | 172 | const data = selectedFramework.adapters.find((a) => a.key === adapter); |
158 | 173 |
|
159 | 174 | if (type === 'installCommand') { |
160 | | - installCommand = site?.installCommand ?? data.installCommand; |
| 175 | + installCommand = data.installCommand; |
161 | 176 | } else if (type === 'buildCommand') { |
162 | | - buildCommand = site?.buildCommand ?? data.buildCommand; |
| 177 | + buildCommand = data.buildCommand; |
163 | 178 | } else if (type === 'outputDirectory') { |
164 | | - outputDirectory = site?.outputDirectory ?? data.outputDirectory; |
| 179 | + outputDirectory = data.outputDirectory; |
165 | 180 | } |
166 | 181 | } |
167 | 182 | </script> |
|
216 | 231 | {adapterData.ssr.desc} |
217 | 232 | {/if} |
218 | 233 | {#if adapterData?.ssr?.url} |
219 | | - <Link external href={adapterData.ssr.url}>Learn more</Link> |
| 234 | + <Link variant="muted" size="m" external href={adapterData.ssr.url} |
| 235 | + >Learn more</Link> |
220 | 236 | {/if} |
221 | 237 | </Card.Selector> |
222 | 238 | <Card.Selector |
|
243 | 259 | {adapterData.static.desc} |
244 | 260 | {/if} |
245 | 261 | {#if adapterData?.static?.url} |
246 | | - <Link external href={adapterData.static.url}>Learn more</Link> |
| 262 | + <Link |
| 263 | + variant="muted" |
| 264 | + size="m" |
| 265 | + external |
| 266 | + href={adapterData.static.url}>Learn more</Link> |
247 | 267 | {/if} |
248 | 268 | </Card.Selector> |
249 | 269 | </Layout.Grid> |
|
258 | 278 | placeholder={frameworkAdapterData?.installCommand || |
259 | 279 | 'Enter install command'} /> |
260 | 280 |
|
261 | | - <Button secondary size="s" on:click={() => reset('installCommand')}> |
| 281 | + <Button |
| 282 | + secondary |
| 283 | + size="s" |
| 284 | + on:click={() => reset('installCommand')} |
| 285 | + disabled={installCommand === frameworkAdapterData?.installCommand}> |
262 | 286 | Reset |
263 | 287 | </Button> |
264 | 288 | </Layout.Stack> |
|
269 | 293 | bind:value={buildCommand} |
270 | 294 | placeholder={frameworkAdapterData?.buildCommand || |
271 | 295 | 'Enter build command'} /> |
272 | | - <Button secondary size="s" on:click={() => reset('buildCommand')}> |
| 296 | + <Button |
| 297 | + secondary |
| 298 | + size="s" |
| 299 | + disabled={buildCommand === frameworkAdapterData?.buildCommand} |
| 300 | + on:click={() => reset('buildCommand')}> |
273 | 301 | Reset |
274 | 302 | </Button> |
275 | 303 | </Layout.Stack> |
|
280 | 308 | bind:value={outputDirectory} |
281 | 309 | placeholder={frameworkAdapterData?.outputDirectory || |
282 | 310 | 'Enter output directory'} /> |
283 | | - <Button secondary size="s" on:click={() => reset('outputDirectory')}> |
| 311 | + <Button |
| 312 | + secondary |
| 313 | + size="s" |
| 314 | + disabled={(outputDirectory ?? '') === |
| 315 | + (frameworkAdapterData?.outputDirectory ?? '')} |
| 316 | + on:click={() => reset('outputDirectory')}> |
284 | 317 | Reset |
285 | 318 | </Button> |
286 | 319 | </Layout.Stack> |
|
305 | 338 | </svelte:fragment> |
306 | 339 |
|
307 | 340 | <svelte:fragment slot="actions"> |
308 | | - <Button disabled={hasChanges} submit>Update</Button> |
| 341 | + <Button disabled={isUntouched} submit>Update</Button> |
309 | 342 | </svelte:fragment> |
310 | 343 | </CardGrid> |
311 | 344 | </Form> |
0 commit comments