Skip to content

Commit f7c09d6

Browse files
authored
Merge pull request #26 from ut-code/feature/updatesidepanel
リセットボタンとサイドパネルのUI改善
2 parents 7e45f4b + 882af14 commit f7c09d6

File tree

2 files changed

+53
-10
lines changed

2 files changed

+53
-10
lines changed

src/sidepanel/App.css

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,36 @@
4040
.read-the-docs {
4141
color: #888;
4242
}
43+
44+
.container {
45+
padding: 1rem;
46+
text-align: center;
47+
}
48+
49+
.reset-button {
50+
margin-top: 2rem;
51+
padding: 4px 8px;
52+
font-size: 0.8em;
53+
background-color: #666;
54+
color: white;
55+
border: none;
56+
border-radius: 4px;
57+
cursor: pointer;
58+
}
59+
60+
.reset-button:hover {
61+
background-color: #888;
62+
}
63+
64+
.problem {
65+
font-size: 1.2em;
66+
}
67+
.result-ok {
68+
font-weight: bold;
69+
font-size: 2rem;
70+
margin-top: 1rem;
71+
padding: 0.1rem;
72+
border: none;
73+
background-color: none;
74+
color: #ff0000;
75+
}

src/sidepanel/App.tsx

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ function App() {
2626
})
2727
const pageKeyRef = useRef<string | null>(null)
2828

29+
// リセット処理を行う関数
30+
const resetButton = () => {
31+
setStep(1)
32+
setResult(null)
33+
baselineRef.current = { p1: null, p2: null, p3Visible: null, p4: null }
34+
pageKeyRef.current = null
35+
chrome.storage.local.remove('currentStep')
36+
}
37+
2938
// 追加: ステップの永続化
3039
useEffect(() => {
3140
chrome.storage.local.get(['currentStep']).then(({ currentStep }) => {
@@ -159,26 +168,26 @@ function App() {
159168
{step === 1 && (
160169
<div>
161170
<h2>ミッション1</h2>
162-
<p>レビューの「とにかくひどい。」をほかの言葉に書き換えてみよう。</p>
163-
{result && <div className={result.ok ? "result-ok" : "result-ng"}><h3>判定: {result.ok ? '成功!' : '未達成'}</h3><p>{result.details}</p>{result.ok && <p>次の問題へ進みます...</p>}</div>}
171+
<p className="problem">レビューの「とにかくひどい。」をほかの言葉に書き換えてみよう。</p>
172+
{result && <div><h3 className={result.ok ? "result-ok" : "result-ng"}>{result.ok ? '成功!' : '未達成'}</h3><p>{result.details}</p>{result.ok && <p>次の問題へ進みます...</p>}</div>}
164173
{!result && <p className="hint">ヒント:開発者ツールを使って、レビューに当たる要素を探してみよう。</p>}
165174
</div>
166175
)}
167176

168177
{step === 2 && (
169178
<div>
170179
<h2>ミッション2</h2>
171-
<p>星1の画像(star1.png)の <code>src</code> を書き換えて、星5 (star5.png) にしてみよう!</p>
172-
{result && <div className={result.ok ? "result-ok" : "result-ng"}><h3>判定: {result.ok ? '成功!' : '未達成'}</h3><p>{result.details}</p>{result.ok && <p>次の問題へ進みます...</p>}</div>}
180+
<p className="problem">星1の画像(star1.png)の <code>src</code> を書き換えて、星5 (star5.png) にしてみよう!</p>
181+
{result && <div><h3 className={result.ok ? "result-ok" : "result-ng"}>{result.ok ? '成功!' : '未達成'}</h3><p>{result.details}</p>{result.ok && <p>次の問題へ進みます...</p>}</div>}
173182
{!result && <p className="hint">ヒント:imgタグの src 属性を探そう。</p>}
174183
</div>
175184
)}
176185

177186
{step === 3 && (
178187
<div>
179188
<h2>ミッション3</h2>
180-
<p>一つ目のレビューを、CSSを使って非表示にしてみよう!</p>
181-
{result && <div className={result.ok ? "result-ok" : "result-ng"}><h3>判定: {result.ok ? '成功!' : '未達成'}</h3><p>{result.details}</p>{result.ok && <p>次の問題へ進みます...</p>}</div>}
189+
<p className="problem">一つ目のレビューを、CSSを使って非表示にしてみよう!</p>
190+
{result && <div><h3 className={result.ok ? "result-ok" : "result-ng"}>{result.ok ? '成功!' : '未達成'}</h3><p>{result.details}</p>{result.ok && <p>次の問題へ進みます...</p>}</div>}
182191
{!result && <p className="hint">ヒント:DevToolsのスタイルパネルで <code>display: none;</code> を追加してみよう。</p>}
183192
</div>
184193
)}
@@ -187,10 +196,10 @@ function App() {
187196
{step === 4 && (
188197
<div>
189198
<h2>ミッション4</h2>
190-
<p>割引コードを盗んで、30%割引を適用させよう!</p>
199+
<p className="problem">割引コードを盗んで、30%割引を適用させよう!</p>
191200
{result && (
192-
<div className={result.ok ? "result-ok" : "result-ng"}>
193-
<h3>判定: {result.ok ? '成功!' : '未達成'}</h3>
201+
<div>
202+
<h3 className={result.ok ? "result-ok" : "result-ng"}>{result.ok ? '成功!' : '未達成'}</h3>
194203
<p>{result.details}</p>
195204
</div>
196205
)}
@@ -201,7 +210,7 @@ function App() {
201210
{step === 5 && (
202211
<div>
203212
<h2>最後のミッション</h2>
204-
<p>今までの知識を使って、予約サイトでチケットを先に予約しよう!</p>
213+
<p className="problem">今までの知識を使って、予約サイトでチケットを先に予約しよう!</p>
205214
<br></br>
206215
<button
207216
onClick={() => {
@@ -216,6 +225,7 @@ function App() {
216225
<p>上のリンクを押して、とあるイベントの予約サイトに侵入し、一足先にチケットを予約しよう。</p>
217226
</div>
218227
)}
228+
<button onClick={resetButton} className="reset-button">ミッションをリセット</button>
219229
</div>
220230
)
221231
}

0 commit comments

Comments
 (0)