Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions .claude/rules/scratch-gui/e2e-test.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,7 @@ expect(await isActiveByTestId(driver, 'ruby-toolbar-mode-furigana')).toBe(true);
| `ruby-toolbar-menu-insert-class` | div | クラス挿入(ルビータブのみ) |
| `ruby-toolbar-menu-preview` | div | プレビュー(日本語タブでは「ルビーに直したものを確認」) |
| `ruby-toolbar-menu-download-japanese` | div | 日本語のプログラムを保存(.txt)。日本語タブのときだけ |
| `ruby-toolbar-menu-settings-heading` | div | 見出し「問題の約束」。日本語タブのときだけ |
| `ruby-toolbar-menu-auto-correct-settings` | div | 自動置換設定 |
| `ruby-toolbar-menu-settings-pattern-example` | div | 例示の形(添字は 0 から)。日本語タブのときだけ |
| `ruby-toolbar-menu-settings-pattern-index-from-one` | div | 添字が 1 から始まる問題。日本語タブのときだけ |

日本語モードは、ルビータブのボタンではなく**日本語タブ**(`gui-tab-japanese`)で開く(URL は `?tab=japanese`)。ルビータブのツールバーは、ふりがな・Ruby の 2 つ。

Expand All @@ -76,6 +73,18 @@ expect(await isActiveByTestId(driver, 'ruby-toolbar-mode-furigana')).toBe(true);
| `gui-tab-ruby` | li | ルビータブ(いつも Ruby で開く) |
| `gui-tab-japanese` | li | 日本語タブ(日本語の表示のときだけ。レッスンの `allowDnclMode` が false なら押せない) |
| `ruby-tab-language-band` | div | 日本語タブのエディタの上の帯 |
| `ruby-tab-problem-settings` | span | 帯の「問題の約束: 添字は 0 から」(いまの約束) |
| `ruby-tab-problem-settings-change` | button | 帯の「変える」。「問題の約束」のポップアップを開く |

### 問題の約束のポップアップ (`problem-settings-modal.jsx`)

| data-testid | 要素 | 説明 |
|------------|------|------|
| `problem-settings-modal-pattern-example` | label | カード「例示の形(添字は 0 から)」(中に radio) |
| `problem-settings-modal-pattern-index-from-one` | label | カード「添字が 1 から始まる問題」(中に radio) |
| `problem-settings-modal-sentences` | div | 選んだパターンでプログラムの先頭に入る文 |
| `problem-settings-modal-cancel` | button | キャンセル(何も変えない) |
| `problem-settings-modal-ok` | button | 決定(選んだパターンで書く。何も選んでいないときは押せない) |

### コンソール拡張機能 (`smalruby-console`)

Expand Down
29 changes: 16 additions & 13 deletions docs/dncl/README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion docs/dncl/design.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@
**実装の前に、この往復を確かめる。**
- 説明文が無いプログラムは、既定(例示の形)とみなす。
- 決まった文だけを設定として読む。それ以外の文は普通のコメント。
- 設定を変えるのは、ツールバーのメニュー(パターンを選ぶ)。選ぶと冒頭の説明文を書きかえ、プログラムをその設定で表し直す。
- 設定を変えるのは、エディタの上の緑の帯の「問題の約束」の「変える」で開くポップアップ(パターンを選ぶ)。選ぶと冒頭の説明文を書きかえ、プログラムをその設定で表し直す。
説明文を手で書きかえてもよい。

### よくある設定のパターン
Expand Down
2 changes: 1 addition & 1 deletion docs/smalruby-dncl-spec.ja.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ Data = [3, 1, 2]
表示する(Data[1])
```

エディタのその他メニュー(⋯)の見出し「問題の約束」の下の項目で、よくある設定のパターンを選んで書くこともできます([`docs/dncl/README.md`](dncl/README.md)「設定(冒頭の説明文)」)。
エディタの上の緑の帯の「問題の約束」の「変える」で開くポップアップで、よくある設定のパターンを選んで書くこともできます([`docs/dncl/README.md`](dncl/README.md)「設定(冒頭の説明文)」)。

### コメント

Expand Down
2 changes: 2 additions & 0 deletions packages/scratch-gui/.prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ src/components/*
# Smalruby-only directories (all contents included)
!src/components/auto-correct-modal/
!src/components/auto-correct-modal/**
!src/components/problem-settings-modal/
!src/components/problem-settings-modal/**
!src/components/block-display-modal/
!src/components/block-display-modal/**
!src/components/bug-report-consent/
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/* The rules of the problem stay whole in a narrow band; the name of the language gives way. */
.item {
display: inline-flex;
align-items: center;
gap: 0.375rem;
align-self: stretch;
flex-shrink: 0;
margin-left: 0.375rem;
}

.separator {
opacity: 0.7;
}

.change {
/* The whole height of the band can be pressed, not only the letters. */
align-self: stretch;
padding: 0 0.375rem;
border: none;
background: none;
color: inherit;
font: inherit;
text-decoration: underline;
cursor: pointer;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
// === Smalruby: This file is Smalruby-specific (the rules of the problem in the green band of the Japanese tab) ===
import PropTypes from 'prop-types';
import React from 'react';
import { defineMessages, injectIntl } from 'react-intl';
import intlShape from '../../lib/intlShape.js';
import styles from './problem-settings-band-item.css';

const messages = defineMessages({
label: {
defaultMessage: 'Rules of the problem: {rules}',
description: 'The rules of the problem the program is written by, in the green band of the Japanese tab',
id: 'gui.problemSettingsBand.label',
},
example: {
defaultMessage: 'indices from 0',
description: 'The rules of the problem in the green band: the form of the examples',
id: 'gui.problemSettingsBand.example',
},
indexFromOne: {
defaultMessage: 'indices from 1',
description: 'The rules of the problem in the green band: the indices start at 1',
id: 'gui.problemSettingsBand.indexFromOne',
},
other: {
defaultMessage: 'other',
description: 'The rules of the problem in the green band: the settings are no pattern',
id: 'gui.problemSettingsBand.other',
},
change: {
defaultMessage: 'Change',
description: 'Link in the green band of the Japanese tab to open the popup of the rules of the problem',
id: 'gui.problemSettingsBand.change',
},
});

const ProblemSettingsBandItem = ({ intl, patternId, onChange }) => (
<span className={styles.item}>
<span className={styles.separator} aria-hidden="true">
{'|'}
</span>
<span data-testid="ruby-tab-problem-settings">
{intl.formatMessage(messages.label, {
rules: intl.formatMessage(messages[patternId] || messages.other),
})}
</span>
<button className={styles.change} data-testid="ruby-tab-problem-settings-change" onClick={onChange}>
{intl.formatMessage(messages.change)}
</button>
</span>
);

ProblemSettingsBandItem.propTypes = {
intl: intlShape.isRequired,
patternId: PropTypes.string,
onChange: PropTypes.func.isRequired,
};

export default injectIntl(ProblemSettingsBandItem);
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
@import '../../css/colors.css';
@import '../../css/units.css';

/* The space over the popup: the 100px of the shared modal, smaller on a short screen. */
$top-space: 100px;
$top-space-short: 0.5rem;
/* What is not the body: the header and the 4px border on both sides. */
$frame-height: calc($library-header-height + 8px);

.modal-content {
width: 360px;
max-width: calc(100vw - 1rem);
}

/* On a short screen (the class PC of 1300×600, a phone held sideways) the popup
comes up to the top, so that 「決定」 stays on the screen. */
@media (max-height: 760px) {
.modal-content {
margin-top: $top-space-short;
}
}

.header {
background-color: $ui-green-2;
}

.body {
background: $ui-white; /* the overlay must not show through (.claude/rules/scratch-gui/modals.md) */
padding: 1.25rem;
display: flex;
flex-direction: column;
gap: 0.75rem;
font-size: 0.875rem;
color: hsla(0, 0%, 0%, 0.85);
/* The overlay does not scroll, so the body scrolls when the popup is taller than the screen. */
max-height: calc(100vh - $top-space - $top-space-short - $frame-height);
overflow-y: auto;
}

@media (max-height: 760px) {
.body {
max-height: calc(100vh - $top-space-short * 2 - $frame-height);
}
}

.explanation {
margin: 0;
line-height: 1.6;
}

.cards {
display: flex;
flex-direction: column;
gap: 0.5rem;
}

.card {
display: grid;
grid-template-columns: auto 1fr;
gap: 0.125rem 0.5rem;
align-items: center;
padding: 0.5rem 0.625rem;
border: 2px solid hsla(0, 0%, 0%, 0.15);
border-radius: 0.5rem;
cursor: pointer;
user-select: none;
}

.card-checked {
border-color: $ui-green-2;
background-color: hsla(163, 85%, 40%, 0.1);
}

.radio {
margin: 0;
accent-color: $ui-green-2;
cursor: pointer;
}

.card-name {
font-weight: bold;
}

.card-example {
grid-column: 2;
font-size: 0.8rem;
color: hsla(0, 0%, 0%, 0.6);
}

.card-example code {
font-family: Monaco, Menlo, Consolas, monospace;
color: hsla(0, 0%, 0%, 0.85);
}

.note {
font-size: 0.78rem;
color: hsla(0, 0%, 0%, 0.6);
}

.sentences {
font-family: Monaco, Menlo, Consolas, monospace;
font-size: 0.75rem;
padding: 0.375rem 0.5rem;
border: 1px dashed hsla(0, 0%, 0%, 0.2);
border-radius: 0.375rem;
background-color: hsla(0, 0%, 0%, 0.02);
white-space: pre-wrap;
word-break: break-all;
}

.button-row {
display: flex;
justify-content: flex-end;
gap: 0.5rem;
}

.cancel-button,
.ok-button {
padding: 0.5rem 1rem;
border-radius: 0.25rem;
font-weight: bold;
cursor: pointer;
}

.cancel-button {
border: 1px solid hsla(0, 0%, 0%, 0.15);
background-color: $ui-white;
color: hsla(0, 0%, 0%, 0.85);
}

.ok-button {
border: none;
background-color: $ui-green-2;
color: $ui-white;
}

.ok-button:disabled {
opacity: 0.5;
cursor: default;
}
Loading
Loading