-
Notifications
You must be signed in to change notification settings - Fork 187
translate Advanced Guides > Portals
#44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
020b62b
docs/portals 本文を試訳
fsubal 13b2718
コード内のコメントの残りも翻訳
fsubal f530cd6
誤字・改行を修正
fsubal e2aa1c5
気になる細かい表現を修正
fsubal 1bcf317
同じように〜、同じように のような重複を避ける
fsubal 6e33c35
fire は 発行 → 発火 で訳すように変更
fsubal c0fe009
数字の前後にスペースが抜けていたので修正
fsubal 739f565
first-class = 公式
smikitky 2d191d3
such as のニュアンスが抜けてしまっているので修正
smikitky e9eefc8
イベントのバブリング第1文を修正
smikitky ef14e46
Update content/docs/portals.md
koba04 e2653d1
コード内コメントの訳を修正
koba04 f5254de
** → *
fsubal bb0d86e
外部サイトの名前は一旦そのままにしておく
fsubal b04a71b
Revert "外部サイトの名前は一旦そのままにしておく"
fsubal 6646b6e
コメントの行数が変わると、コードのハイライトがずれるので、元の行数に収める
fsubal 7abeb9d
(portal) を追加
smikitky 374da2d
inherently のかかり方が変わってしまっている
smikitky 78d5111
行末のスペースは削っておく
fsubal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
気になる細かい表現を修正
- Loading branch information
commit e2aa1c52fcd124f0202c7302985d41dee56b3a63
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,7 +4,7 @@ title: ポータル | |
| permalink: docs/portals.html | ||
| --- | ||
|
|
||
| ポータルは、親コンポーネントの DOM 階層の外にある DOM ノードに対して、子コンポーネントを描画するための第一級の方法を提供します。 | ||
| ポータルは、親コンポーネントの DOM 階層外にある DOM ノードに対して、子コンポーネントを描画するための第一級の方法を提供します。 | ||
|
|
||
| ```js | ||
| ReactDOM.createPortal(child, container) | ||
|
|
@@ -14,7 +14,7 @@ ReactDOM.createPortal(child, container) | |
|
|
||
| ## 使い方 | ||
|
|
||
| 通常、コンポーネントの `render` メソッドから要素を返すと、最も近い親ノードの子要素として DOM にマウントされます。 | ||
| 通常、コンポーネントの `render` メソッドから要素を返すと、最も近い親ノードの子として DOM にマウントされます。 | ||
|
|
||
| ```js{4,6} | ||
| render() { | ||
|
|
@@ -40,7 +40,7 @@ render() { | |
| } | ||
| ``` | ||
|
|
||
| 典型的なポータルのユースケースは、親要素が `overflow: hidden` や `z-index` のスタイルを持っているものの、子要素がコンテナを「飛び出して」いるように見せたいようなものです。例えば、ダイアログ、ホバーカード、ツールチップがそれに当たります。 | ||
| 典型的なポータルのユースケースは、親要素が `overflow: hidden` や `z-index` のスタイルを持っていても、子要素にはコンテナを「飛び出して」いるように見えて欲しいようなものです。例えば、ダイアログ、ホバーカード、ツールチップがそれに当たります。 | ||
|
|
||
| > 補足 | ||
| > | ||
|
|
@@ -54,7 +54,7 @@ render() { | |
|
|
||
| ポータルは DOM ツリーのどこにでもありうるとはいえ、他の点では通常の React の子要素と同じように振る舞います。コンテクスト (context) のような機能は、たとえ子要素がポータルだろうと完全に同じように動きます。というのも、 **DOM ツリー**上の位置にかかわらず、ポータルは依然として **React のツリー**内にいるからです。 | ||
|
|
||
| これにはイベントのバブリングも含まれます。ポータルの内部から発行されたイベントは **React のツリー**内の祖先へと伝播します。たとえそれが **DOM ツリー** 上では祖先でなくともです。 | ||
| これにはイベントのバブリングも含まれます。ポータルの内部から発行されたイベントは **React のツリー**内の祖先へと伝播します。たとえそれが **DOM ツリー**上では祖先でなくともです。 | ||
|
|
||
| 次のような HTML 構造があったとして、 | ||
|
|
||
|
|
@@ -67,7 +67,7 @@ render() { | |
| </html> | ||
| ``` | ||
|
|
||
| `#app-root` 内にある `Parent` コンポーネントは、 `#modal-root` 内のコンポーネントから伝播したイベントがキャッチされなかった場合に、それをキャッチできます。 | ||
| `#app-root` 内にある `Parent` コンポーネントは、 `#modal-root` 内のコンポーネントから伝播したイベントが捕捉されなかった場合に、それを捕捉できます。 | ||
|
|
||
| ```js{28-31,42-49,53,61-63,70-71,74} | ||
fsubal marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| // この 2 つのコンテナは DOM 上の兄弟要素とします | ||
|
|
@@ -85,7 +85,7 @@ class Modal extends React.Component { | |
| // つまり、子要素は一旦どこにも結びつかない DOM ノードへとマウントされるということです。 | ||
| // もし子コンポーネントがマウント後すぐに DOM ツリーに結びついてほしい ―― | ||
| // たとえば DOM ノードの大きさを測りたい、子孫要素で `autoFocus` を使いたいなど | ||
| // ―― 場合は、 Modal に状態を持たせて子要素が DOM ツリーに入ったときだけ描画されるようにしましょう。 | ||
| // ―― 場合は、 Modal に状態を持たせて子要素が DOM ツリーに入ったときだけ描画されるようにします。 | ||
|
||
| modalRoot.appendChild(this.el); | ||
| } | ||
|
|
||
|
|
@@ -149,4 +149,4 @@ ReactDOM.render(<Parent />, appRoot); | |
|
|
||
| [**Try it on CodePen**](https://codepen.io/gaearon/pen/jGBWpE) | ||
|
|
||
| ポータルから浮上したイベントが親コンポーネントでキャッチできるということは、より柔軟な抽象を、本質的にポータルに依存しない形で開発できるということです。たとえば `<Modal />` コンポーネントをレンダーして、親コンポーネントがそこから来るイベントを捕捉するのは、`<Modal />` の実装がポータルを使っているかに関係なくできます。 | ||
| ポータルから伝播したイベントが親コンポーネントで捕捉できるということは、より柔軟な抽象を、本質的にポータルに依存しない形で開発できるということです。たとえば `<Modal />` コンポーネントをレンダーして、親コンポーネントがそこから来るイベントを捕捉するのは、`<Modal />` の実装がポータルを使っているかに関係なくできます。 | ||
fsubal marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.