()
| 63 | } |
| 64 | |
| 65 | function App() { |
| 66 | const [ids, setIds] = createSignal<Array<number>>([]) |
| 67 | const [idsToLoad, setIdsToLoad] = createSignal<Array<number>>([]) |
| 68 | const [error, setError] = createSignal('') |
| 69 | |
| 70 | return ( |
| 71 | <div class="App"> |
| 72 | <h2>Character fetcher</h2> |
| 73 | <div> |
| 74 | <label style={{ display: 'block' }}> |
| 75 | Character ids (numeric, comma separated) |
| 76 | </label> |
| 77 | <input |
| 78 | style={{ display: 'inline-block' }} |
| 79 | placeholder="ids" |
| 80 | onInput={(event) => { |
| 81 | const parsedIds = event.currentTarget.value |
| 82 | .split(',') |
| 83 | .map((id) => id.trim()) |
| 84 | |
| 85 | if (parsedIds.every((id) => /^\d+$/.test(id))) { |
| 86 | setIds(parsedIds.map(Number)) |
| 87 | setError('') |
| 88 | } else { |
| 89 | setError('Invalid.. only use numbers and comma') |
| 90 | } |
| 91 | }} |
| 92 | /> |
| 93 | </div> |
| 94 | |
| 95 | <Show when={error()}> |
| 96 | <h3 style={{ color: 'red' }}>{error()}</h3> |
| 97 | </Show> |
| 98 | |
| 99 | <button |
| 100 | type="button" |
| 101 | disabled={!!error()} |
| 102 | onClick={() => { |
| 103 | setIdsToLoad(ids()) |
| 104 | }} |
| 105 | > |
| 106 | Load characters |
| 107 | </button> |
| 108 | <div> |
| 109 | <h4 style={{ 'text-align': 'left' }}>Characters:</h4> |
| 110 | <Characters ids={idsToLoad()} /> |
| 111 | </div> |
| 112 | </div> |
| 113 | ) |
| 114 | } |
| 115 | |
| 116 | function Root() { |
| 117 | return ( |
nothing calls this directly
no outgoing calls
no test coverage detected