Skip to content

Commit 3837303

Browse files
committed
done translate portals.md to ar ..
1 parent 5052244 commit 3837303

File tree

1 file changed

+42
-39
lines changed

1 file changed

+42
-39
lines changed

content/docs/portals.md

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,23 @@ id: portals
33
title: Portals
44
permalink: docs/portals.html
55
---
6+
7+
تُزوّدنا Portals بطريقة ممتازة لتصيير المكونات الأبناء إلى عقدة DOM موجودة خارج تسلسل DOM للمكونات الآباء.
68

7-
Portals provide a first-class way to render children into a DOM node that exists outside the DOM hierarchy of the parent component.
89

910
```js
1011
ReactDOM.createPortal(child, container)
1112
```
1213

13-
The first argument (`child`) is any [renderable React child](/docs/react-component.html#render), such as an element, string, or fragment. The second argument (`container`) is a DOM element.
14+
الوسيط الأول (`child`) هو عبارة عن أي [مكوّن ابن قابل للتصيير في React](/docs/react-component.html#render)، مثل العناصر، والسلاسل النصية، والأجزاء (fragments). الوسيط الثاني (`container`) هو عنصر DOM.
1415

15-
## Usage {#usage}
16+
## الاستخدام {#usage}
1617

17-
Normally, when you return an element from a component's render method, it's mounted into the DOM as a child of the nearest parent node:
18+
عندما تُعيد عنصر من تابع تصيير المكوّن فبشكل اعتيادي يُوصَل إلى DOM كمكوّن ابن لأقرب عقدة أب:
1819

1920
```js{4,6}
2021
render() {
21-
// React mounts a new div and renders the children into it
22+
// تصل React عنصر div جديد وتصير الأبناء إليه
2223
return (
2324
<div>
2425
{this.props.children}
@@ -27,34 +28,35 @@ render() {
2728
}
2829
```
2930

30-
However, sometimes it's useful to insert a child into a different location in the DOM:
31+
ولكن من المفيد أحيانًا إدخال الابن في مواقع متعددة من DOM:
3132

3233
```js{6}
3334
render() {
34-
// React does *not* create a new div. It renders the children into `domNode`.
35-
// `domNode` is any valid DOM node, regardless of its location in the DOM.
35+
// لا تنشئ React عنصر div جديد، فهي تصير الأبناء إلى `domNode`
36+
// `domNode` هي اي عقدة DOM صحيحة بغض النظر عن موقعها في DOM
3637
return ReactDOM.createPortal(
3738
this.props.children,
3839
domNode
3940
);
4041
}
4142
```
4243

43-
A typical use case for portals is when a parent component has an `overflow: hidden` or `z-index` style, but you need the child to visually "break out" of its container. For example, dialogs, hovercards, and tooltips.
44+
الحالة النموذجية لاستخدام portals هي عندما يمتلك المكوّن الأب التنسيق `overflow: hidden` أو `z-index` ولكنك تريد من المكوّن الابن أن يظهر خارج حاويته، على سبيل المثال مربعات الحوار (dialogs) وتلميحات الأدوات (tooltips).
4445

45-
> Note:
46+
> ملاحظة:
4647
>
47-
> When working with portals, remember that [managing keyboard focus](/docs/accessibility.html#programmatically-managing-focus) becomes very important.
48+
> تذكر عند التعامل مع Portals أنّ [إدارة تركيز لوحة المفاتيح](/docs/accessibility.html#programmatically-managing-focus) تصبح أمرًا هامًّا.
4849
>
49-
> For modal dialogs, ensure that everyone can interact with them by following the [WAI-ARIA Modal Authoring Practices](https://www.w3.org/TR/wai-aria-practices-1.1/#dialog_modal).
50+
>من أجل مربعات الحوار تأكد من قدرة جميع المستخدمين على التعامل معها عن طريق اتباع [هذه الإرشادات](https://www.w3.org/TR/wai-aria-practices-1.1/#dialog_modal).
5051
51-
[**Try it on CodePen**](https://codepen.io/gaearon/pen/yzMaBd)
52+
[**جرب المثال على CodePen.**](https://codepen.io/gaearon/pen/yzMaBd)
5253

53-
## Event Bubbling Through Portals {#event-bubbling-through-portals}
54+
## انتشار الأحداث عن طريق Portals {#event-bubbling-through-portals}
5455

55-
Even though a portal can be anywhere in the DOM tree, it behaves like a normal React child in every other way. Features like context work exactly the same regardless of whether the child is a portal, as the portal still exists in the *React tree* regardless of position in the *DOM tree*.
56+
بالرغم من أن portals يُمكِن لها أن تكون في أي مكان من شجرة DOM، فهي تتصرف مثل عناصر React الأبناء في كل طريقة أخرى. تعمل ميزات مثل السياق بنفس الطريقة بالضبط بغض النظر إن كان العنصر الابن portal أم لا، لأنّ portal يبقى موجودًا في *شجرة React* بغض النظر عن موقعه في *شجرة DOM*.
57+
58+
يتضمّن ذلك انتشار الأحداث (event bubbling)، حيث أنّ الحدث الذي أُطلِق بداخل portal سيتصاعد إلى العناصر الأسلاف في *شجرة React* حتى ولو لم تكن هذه العناصر أسلافًا في *شجرة DOM*. بافتراض بنية HTML التالية:
5659

57-
This includes event bubbling. An event fired from inside a portal will propagate to ancestors in the containing *React tree*, even if those elements are not ancestors in the *DOM tree*. Assuming the following HTML structure:
5860

5961
```html
6062
<html>
@@ -65,10 +67,10 @@ This includes event bubbling. An event fired from inside a portal will propagate
6567
</html>
6668
```
6769

68-
A `Parent` component in `#app-root` would be able to catch an uncaught, bubbling event from the sibling node `#modal-root`.
70+
سيكون المكوّن الأب `Parent` في `#app-root` قادرًا على الإمساك بالحدث المُضاعَف من العقدة الشقيقة له وهي ‎`#modal-root`.
6971

7072
```js{28-31,42-49,53,61-63,70-71,74}
71-
// These two containers are siblings in the DOM
73+
// الحاويتان التاليتان هما أشقاء في DOM
7274
const appRoot = document.getElementById('app-root');
7375
const modalRoot = document.getElementById('modal-root');
7476
@@ -79,14 +81,14 @@ class Modal extends React.Component {
7981
}
8082
8183
componentDidMount() {
82-
// The portal element is inserted in the DOM tree after
83-
// the Modal's children are mounted, meaning that children
84-
// will be mounted on a detached DOM node. If a child
85-
// component requires to be attached to the DOM tree
86-
// immediately when mounted, for example to measure a
87-
// DOM node, or uses 'autoFocus' in a descendant, add
88-
// state to Modal and only render the children when Modal
89-
// is inserted in the DOM tree.
84+
// يُدخَل عنصر portal في شجرة DOM
85+
// بعد وصل أبناء الـ modal
86+
// مما يعني وصل الأبناء إلى عقدة DOM منفصلة
87+
// إن احتاج المكون الابن وصله إلى عقدة DOM مباشرة عند الوصل
88+
// مثلا لقياس عقدة DOM
89+
// أو استخدام التركيز التلقائي
90+
// فأضف حالة إلى الـ Modal وصير فقط الابن
91+
// عند إدخال الـ Modal في شجرة DOM
9092
modalRoot.appendChild(this.el);
9193
}
9294
@@ -110,9 +112,9 @@ class Parent extends React.Component {
110112
}
111113
112114
handleClick() {
113-
// This will fire when the button in Child is clicked,
114-
// updating Parent's state, even though button
115-
// is not direct descendant in the DOM.
115+
// سيطلَق هذا عند الضغط على الزر في المكون الابن
116+
// مما يحدث حالة المكون الأب
117+
// حتى ولو لم يكن الزر منحدرًا بشكل مباشر في DOM.
116118
this.setState(state => ({
117119
clicks: state.clicks + 1
118120
}));
@@ -121,12 +123,11 @@ class Parent extends React.Component {
121123
render() {
122124
return (
123125
<div onClick={this.handleClick}>
124-
<p>Number of clicks: {this.state.clicks}</p>
126+
<p>عدد النقرات : {this.state.clicks}</p>
125127
<p>
126-
Open up the browser DevTools
127-
to observe that the button
128-
is not a child of the div
129-
with the onClick handler.
128+
افتح أدوات تطوير المتصفح لتلاحظ أن الزر ليس ابنًا
129+
للعنصر div
130+
الذي يمتلك معالج الأحداث onClick.
130131
</p>
131132
<Modal>
132133
<Child />
@@ -137,18 +138,20 @@ class Parent extends React.Component {
137138
}
138139
139140
function Child() {
140-
// The click event on this button will bubble up to parent,
141-
// because there is no 'onClick' attribute defined
141+
// سيتضاعف حدث النقر على هذا الزر إلى المكون الأب
142+
// بسبب عدم وجود خاصية onClick معرفة
143+
142144
return (
143145
<div className="modal">
144-
<button>Click</button>
146+
<button>انقر هنا</button>
145147
</div>
146148
);
147149
}
148150
149151
ReactDOM.render(<Parent />, appRoot);
150152
```
151153

152-
[**Try it on CodePen**](https://codepen.io/gaearon/pen/jGBWpE)
154+
[**جرب المثال على موقع CodePen.**](https://codepen.io/gaearon/pen/jGBWpE)
155+
156+
يسمح الإمساك بالحدث المُضاعَف من protal في المكوّن الأب بتطوير تجريدات مرنة والتي لا تعتمد على protals. على سبيل المثال إن صيرنا المكوّن `<Modal />`‎، فبإمكان المكوّن الأب له التقاط أحداثه بغض النظر عمّا إذا كان يعتمد protals.
153157

154-
Catching an event bubbling up from a portal in a parent component allows the development of more flexible abstractions that are not inherently reliant on portals. For example, if you render a `<Modal />` component, the parent can capture its events regardless of whether it's implemented using portals.

0 commit comments

Comments
 (0)