Skip to content

Commit ea2753c

Browse files
committed
ヘッダー行の配色を調整し、正常終了時も注記を出す
- ヘッダー行・caption・ボタンがどれも似た薄い灰色で埋没していたため、 ヘッダー行をコード部分よりひと段暗く(#e6e6e6)し、caption タブは コード部分と同じ色(#f2f2f2)で「下とつながったタブ」に、RUN/COPY は 白背景+枠線(opacity 廃止)でボタンとして浮き上がらせる - 出力が空のサンプルだと実行が終わったのかわからないため、正常終了時も 「(正常終了しました)」を出力欄の末尾に追記する(DONE_NOTE)
1 parent fac9803 commit ea2753c

3 files changed

Lines changed: 28 additions & 18 deletions

File tree

test/js/test_run.mjs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
// importing either file here never touches a real DOM/Worker.
99
import {
1010
createOnceLoader, formatRunError, truncateOutput,
11-
accumulateOutput, STOPPED_NOTE, timeoutNote, editableText,
11+
accumulateOutput, STOPPED_NOTE, DONE_NOTE, timeoutNote, editableText,
1212
} from '../../theme/default/js/run.js'
1313
import { PRELUDE, formatRunError as formatWorkerRunError } from '../../theme/default/js/run-worker.js'
1414

@@ -115,8 +115,11 @@ assert(accumulateOutput('', 'first') === 'first',
115115
'accumulateOutput drops further chunks once truncated')
116116
}
117117

118-
// STOPPED_NOTE / timeoutNote: the notes appended to output on STOP / timeout
118+
// STOPPED_NOTE / DONE_NOTE / timeoutNote: the notes appended to the output
119+
// on STOP / normal completion / timeout
119120
assert(STOPPED_NOTE === '(停止しました)', 'STOPPED_NOTE is the stop notice')
121+
assert(DONE_NOTE === '(正常終了しました)',
122+
'DONE_NOTE marks a normal completion (visible even with empty output)')
120123
assert(timeoutNote(30) === '(30秒でタイムアウトしました)',
121124
'timeoutNote formats the configured timeout in seconds')
122125

theme/default/js/run.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,9 @@ export function accumulateOutput(current, chunk, limit = OUTPUT_LIMIT) {
6767
}
6868

6969
export const STOPPED_NOTE = '(停止しました)'
70+
// 出力が空のサンプルでも実行が終わったことがわかるように、
71+
// 正常終了時も必ずこの注記を出力欄の末尾に付ける
72+
export const DONE_NOTE = '(正常終了しました)'
7073
export function timeoutNote(seconds) {
7174
return `(${seconds}秒でタイムアウトしました)`
7275
}
@@ -303,6 +306,7 @@ function setupBlock(pre, runner) {
303306
if (message.type === 'output') {
304307
setOutputText(accumulateOutput(outputTextNode.data, message.text))
305308
} else if (message.type === 'done') {
309+
appendNote(DONE_NOTE)
306310
finish(out, 'RUN', false)
307311
} else if (message.type === 'error') {
308312
appendNote(message.message)

theme/default/style.css

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -138,15 +138,17 @@ pre {
138138
}
139139

140140

141-
/* pre の直前に密着するヘッダー行(script.js が生成)。pre と同じ背景色で
142-
コードブロックと一体に見せる(白い帯として浮くと、コードの上の隙間が
143-
広く見える)。左端に caption のタブ、右端に RUN/COPY のボタン群を置く */
141+
/* pre の直前に密着するヘッダー行(script.js が生成)。コード部分より
142+
ひと段暗い背景でコードブロックと一体に見せつつ(白い帯として浮くと、
143+
コードの上の隙間が広く見える)、コード部分と同色の caption タブや
144+
白背景のボタンが埋没しないようにする。左端に caption のタブ、右端に
145+
RUN/COPY のボタン群を置く */
144146
.highlight__toolbar {
145147
display: flex;
146148
align-items: flex-end;
147149
margin: 1em 0 0;
148150
padding: 0.25em 0.25em 0 0.25em;
149-
background-color: #f2f2f2;
151+
background-color: #e6e6e6;
150152
}
151153
.highlight__toolbar + pre {
152154
margin-top: 0;
@@ -173,25 +175,24 @@ pre {
173175
user-select: none;
174176
}
175177

176-
/* for RUN (js/run.js, statichtml --run-ruby-wasm) */
178+
/* for RUN (js/run.js, statichtml --run-ruby-wasm)。
179+
ヘッダー行の灰色に埋没しないよう、白背景+枠線でボタンらしくする */
177180
.highlight__run-button {
178181
margin: 0 0.5em 0.25em 0;
179182
padding: 0.25em 0.5em;
180-
background-color: #DDD;
181-
opacity: 0.75;
183+
background-color: #fff;
182184
cursor: pointer;
183-
border: 0;
185+
border: 1px solid #999;
184186
border-radius: 4px;
185187
font: inherit;
186188
}
187189
.highlight__run-button:hover {
188190
background-color: #EE8;
189-
opacity: 1;
190191
}
191192
.highlight__run-button[disabled] {
192193
background-color: #070;
194+
border-color: #070;
193195
color: white;
194-
opacity: 1;
195196
cursor: wait;
196197
}
197198
.highlight__run-output {
@@ -217,25 +218,25 @@ pre.highlight.ruby[data-editing="true"] > code:focus {
217218
outline: none;
218219
}
219220

220-
/* for COPY(highlight__button-group の中に入る) */
221+
/* for COPY(highlight__button-group の中に入る)。RUN と同じ見た目 */
221222
.highlight__copy-button {
222223
display: inline-block;
223224
margin-bottom: 0.25em;
224225
padding: 0.25em 0.5em;
225-
background: #DDD;
226-
opacity: 0.75;
226+
background: #fff;
227227
cursor: pointer;
228+
border: 1px solid #999;
228229
border-radius: 4px;
229230
}
230231
.highlight__copy-button:hover {
231232
background: #EE8;
232-
opacity: 1;
233233
}
234234
.highlight__copy-button::after {
235235
content: "COPY"
236236
}
237237
.highlight__copy-button.copied {
238238
background: #070;
239+
border-color: #070;
239240
color: white;
240241
}
241242
.highlight__copy-button.copied::after {
@@ -247,11 +248,13 @@ pre.highlight.ruby[data-editing="true"] > code:focus {
247248
}
248249

249250
/* サンプルコードのキャプション。pre の上に密着したタブとして表示する
250-
(上だけ角丸でタブらしく)。script.js がツールバー行の左端に取り込む */
251+
(上だけ角丸でタブらしく)。script.js がツールバー行の左端に取り込む。
252+
下のコード部分と同じ背景色にして「つながったタブ」に見せる(ヘッダー
253+
行のほうがひと段暗いので埋没しない) */
251254
.caption {
252255
display: inline-block;
253256
padding: 0.2em 0.5em;
254-
background: #ddd;
257+
background: #f2f2f2;
255258
margin: 1em 0 0;
256259
border-radius: 6px 6px 0 0;
257260
}

0 commit comments

Comments
 (0)