Skip to content

Commit 7e9acff

Browse files
committed
translate teleport
1 parent d7bf363 commit 7e9acff

File tree

1 file changed

+48
-48
lines changed

1 file changed

+48
-48
lines changed

src/guide/built-ins/teleport.md

Lines changed: 48 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,27 @@
1-
# Teleport {#teleport}
1+
# المكون Teleport {#teleport}
22

3-
<VueSchoolLink href="https://vueschool.io/lessons/vue-3-teleport" title="Free Vue.js Teleport Lesson"/>
3+
<VueSchoolLink href="https://vueschool.io/lessons/vue-3-teleport" title="فيديو حول المكون Teleport"/>
44

5-
`<Teleport>` is a built-in component that allows us to "teleport" a part of a component's template into a DOM node that exists outside the DOM hierarchy of that component.
5+
`<Teleport>` هو مكون مدمج يسمح لنا بـ "نقل" جزء من قالب مكون معين إلى عنصر DOM موجودة خارج التسلسل المتداخل للـDOM لهذا المكون.
66

7-
## Basic Usage {#basic-usage}
7+
## الاستخدام الأساسي {#basic-usage}
88

9-
Sometimes we may run into the following scenario: a part of a component's template belongs to it logically, but from a visual standpoint, it should be displayed somewhere else in the DOM, outside of the Vue application.
9+
في بعض الأحيان ، قد نواجه السيناريو التالي: جزء من قالب مكون معين ينتمي من ناحية منطقية إلى المكون ، ولكن من ناحية مظهرية ، يجب عرضه في مكان آخر في DOM ، خارج تطبيق Vue.
1010

11-
The most common example of this is when building a full-screen modal. Ideally, we want the modal's button and the modal itself to live within the same component, since they are both related to the open / close state of the modal. But that means the modal will be rendered alongside the button, deeply nested in the application's DOM hierarchy. This can create some tricky issues when positioning the modal via CSS.
11+
المثال الأكثر شيوعا لهذا هو عند بناء نافذة منبثقة تغطي الشاشة. من المفضل أن نريد أن ينتمي زر النافذة المنبثقة والنافذة نفسها في نفس المكون، لأنهما يتعلقان بحالة الفتح / الإغلاق للنافذة المنبثقة. ولكن هذا يعني أن النافذة ستعرض مع زرها، وهي عميقة في تسلسل التداخل في DOM التطبيق. يمكن أن تنشأ بعض المشاكل الصعبة عند تحديد موضع للنافذة من خلال CSS.
1212

13-
Consider the following HTML structure.
13+
لنعتبر هيكل الـ HTML التالي:
1414

1515
```vue-html
1616
<div class="outer">
17-
<h3>Vue Teleport Example</h3>
17+
<h3>مثال للمكون Teleport في Vue</h3>
1818
<div>
1919
<MyModal />
2020
</div>
2121
</div>
2222
```
2323

24-
And here is the implementation of `<MyModal>`:
24+
وهنا الشيفرةالتنفيذية للمكون `<MyModal>`:
2525

2626
<div class="composition-api">
2727

@@ -33,11 +33,11 @@ const open = ref(false)
3333
</script>
3434
3535
<template>
36-
<button @click="open = true">Open Modal</button>
36+
<button @click="open = true">فتح النافذة المنبثقة</button>
3737
3838
<div v-if="open" class="modal">
39-
<p>Hello from the modal!</p>
40-
<button @click="open = false">Close</button>
39+
<p>مرحبا من داخل النافذة المنبثقة</p>
40+
<button @click="open = false">غلق</button>
4141
</div>
4242
</template>
4343
@@ -68,11 +68,11 @@ export default {
6868
</script>
6969
7070
<template>
71-
<button @click="open = true">Open Modal</button>
71+
<button @click="open = true"> افتح النافذة المنبثقة</button>
7272
7373
<div v-if="open" class="modal">
74-
<p>Hello from the modal!</p>
75-
<button @click="open = false">Close</button>
74+
<p>مرحبا من داخل النافذة المنبثقة</p>
75+
<button @click="open = false">غلق</button>
7676
</div>
7777
</template>
7878
@@ -90,42 +90,41 @@ export default {
9090

9191
</div>
9292

93-
The component contains a `<button>` to trigger the opening of the modal, and a `<div>` with a class of `.modal`, which will contain the modal's content and a button to self-close.
93+
المكون يحتوي على زر `<button>` لتشغيل فتح النافذة المنبثقة ، وعنصر `<div>` مع اسم الصنف `modal.` ، والذي سيحتوي على محتوى النافذة المنبثقة وزر لإغلاقها.
9494

95-
When using this component inside the initial HTML structure, there are a number of potential issues:
95+
عند استخدام هذا المكون داخل الهيكل الأولي للـ HTML ، فإنه يوجد عدد من المشاكل المحتملة:
9696

97-
- `position: fixed` only places the element relative to the viewport when no ancestor element has `transform`, `perspective` or `filter` property set. If, for example, we intend to animate the ancestor `<div class="outer">` with a CSS transform, it would break the modal layout!
97+
- `position: fixed` يحدد فقط وضعية العنصر بالنسبة لإطار الصفحة المعروض عندما لا يحتوي أي عنصر أب على خاصية `transform` ، `perspective` أو `filter`. إذا، مثلا، كنا ننوي تحريك العنصر الأصلي `<"div class="outer>` مع خاصية التحويل الخاصة بـCSS ، فسيؤدي ذلك إلى فشل تحديد نسق النافذة المنبثقة!
9898

99-
- The modal's `z-index` is constrained by its containing elements. If there is another element that overlaps with `<div class="outer">` and has a higher `z-index`, it would cover our modal.
10099

101-
`<Teleport>` provides a clean way to work around these, by allowing us to break out of the nested DOM structure. Let's modify `<MyModal>` to use `<Teleport>`:
100+
- `z-index` الخاص بالنافذة المنبثقة محدود بواسطة عناصرها الحاوية. إذا كان هناك عنصر آخر يتداخل مع `<"div class="outer>` وله `z-index` أعلى ، فسيغطي العنصر الآخر النافذة المنبثقة.
101+
102+
يوفر المكون `<Teleport>` طريقة نظيفة لحل هذه المشاكل ، حيث يسمح لنا بالخروج من الهيكل DOM المتداخل. دعونا نعدل `<MyModal>` لاستخدام `<Teleport>`:
102103

103104
```vue-html{3,8}
104-
<button @click="open = true">Open Modal</button>
105+
<button @click="open = true"> افتح النافذة المنبثقة</button>
105106
106-
<Teleport to="body">
107-
<div v-if="open" class="modal">
108-
<p>Hello from the modal!</p>
109-
<button @click="open = false">Close</button>
110-
</div>
111-
</Teleport>
107+
<div v-if="open" class="modal">
108+
<p>مرحبا من داخل النافذة المنبثقة</p>
109+
<button @click="open = false">غلق</button>
110+
</div>
112111
```
113112

114-
The `to` target of `<Teleport>` expects a CSS selector string or an actual DOM node. Here, we are essentially telling Vue to "**teleport** this template fragment **to** the **`body`** tag".
113+
قيمة الخاصية `to` للمكون Teleport هي عبارة عن سلسلة نصية تحتوي على محدد CSS أو عنصر HTML ، هنا نقول بشكل أساسي لـVue "**انقل** (teleport) هذا الجزء من القالب و قم بوصله بعنصر Body"
115114

116-
You can click the button below and inspect the `<body>` tag via your browser's devtools:
115+
يمكنك الضغط على الزر أدناه وفحص عنصر `<body>` عبر أدوات التطوير و التحكم في المتصفح:
117116

118117
<script setup>
119118
let open = $ref(false)
120119
</script>
121120

122121
<div class="demo">
123-
<button @click="open = true">Open Modal</button>
122+
<button @click="open = true"> افتح النافذة المنبثقة</button>
124123
<ClientOnly>
125124
<Teleport to="body">
126125
<div v-if="open" class="demo modal-demo">
127-
<p style="margin-bottom:20px">Hello from the modal!</p>
128-
<button @click="open = false">Close</button>
126+
<p style="margin-bottom:20px">مرحبا من داخل النافذة المنبثقة</p>
127+
<button @click="open = false">غلق</button>
129128
</div>
130129
</Teleport>
131130
</ClientOnly>
@@ -146,35 +145,35 @@ let open = $ref(false)
146145
}
147146
</style>
148147

149-
You can combine `<Teleport>` with [`<Transition>`](./transition) to create animated modals - see [Example here](/examples/#modal).
148+
يمكن دمج `<Teleport>` مع [`<Transition>`](./transition) لإنشاء نوافذ منبثقة متحركة - انظر [المثال هنا](/examples/#modal).
150149

151-
:::tip
152-
The teleport `to` target must be already in the DOM when the `<Teleport>` component is mounted. Ideally, this should be an element outside the entire Vue application. If targeting another element rendered by Vue, you need to make sure that element is mounted before the `<Teleport>`.
150+
:::tip ملاحظة
151+
قيمة الخاصية `to` للمكون Teleport يجب أن تكون موجودة بالفعل في DOM عند وصل المكون `<Teleport>` . من المفضل أن تكون عنصر HTML خارج تطبيق Vue بأكمله. إذا كنت تستهدف عنصر آخر مصير من قبل Vue ، فيجب عليك التأكد من أن العنصر موصول قبل وصل `<Teleport>`.
153152
:::
154153

155-
## Using with Components {#using-with-components}
154+
## الاستخدام مع المكونات {#using-with-components}
156155

157-
`<Teleport>` only alters the rendered DOM structure - it does not affect the logical hierarchy of the components. That is to say, if `<Teleport>` contains a component, that component will remain a logical child of the parent component containing the `<Teleport>`. Props passing and event emitting will continue to work the same way.
156+
`<Teleport>` تغير فقط الهيكل DOM المعروض - و لا يؤثر على الترتيب المنطقي للمكونات. و هذا يعني أنه إذا كان `<Teleport>` يحتوي على مكون ، فسيبقى هذا المكون ابنا منطقياً للمكون الأب الذي يحتوي على `<Teleport>`. سيظل تمرير الخصائص و إرسال الأحداث على نفس الطريقة.
158157

159-
This also means that injections from a parent component work as expected, and that the child component will be nested below the parent component in the Vue Devtools, instead of being placed where the actual content moved to.
158+
هذا يعني أيضاً أن عملية الحقن من المكون الأب تعمل كما هو متوقع، و أن المكون الابن سيكون مدرجا تحت المكون الأب مباشرة في أدوات التطوير و التحكم لـVue ، بدلاً من وضعه حيث يُنقل المحتوى الفعلي إليه.
160159

161-
## Disabling Teleport {#disabling-teleport}
160+
## تعطيل المكون Teleport {#disabling-teleport}
162161

163-
In some cases, we may want to conditionally disable `<Teleport>`. For example, we may want to render a component as an overlay for desktop, but inline on mobile. `<Teleport>` supports the `disabled` prop which can be dynamically toggled:
162+
في بعض الحالات ، قد نرغب في تعطيل `<Teleport>` بشكل شرطي. على سبيل المثال ، قد نرغب في تقديم مكون كطبقة تغطية لسطح المكتب ، ولكن مضمنًا على الهاتف المحمول. يدعم `<Teleport>` خاصية `disabled` التي يمكن تبديلها بشكل ديناميكي:
164163

165164
```vue-html
166165
<Teleport :disabled="isMobile">
167166
...
168167
</Teleport>
169168
```
170169

171-
Where the `isMobile` state can be dynamically updated by detecting media query changes.
170+
حيث يمكن تحديث حالة `isMobile` بشكل ديناميكي عن طريق تتبع تغييرات استعلامات الوسائط.
172171

173-
## Multiple Teleports on the Same Target {#multiple-teleports-on-the-same-target}
172+
## مكونات Teleport على نفس العنصر {#multiple-teleports-on-the-same-target}
174173

175-
A common use case would be a reusable `<Modal>` component, with the potential for multiple instances to be active at the same time. For this kind of scenario, multiple `<Teleport>` components can mount their content to the same target element. The order will be a simple append - later mounts will be located after earlier ones within the target element.
174+
حالة استخدام شائعة قد تكون عبارة عن مكون `<Modal>` قابل لإعادة الاستخدام، مع إمكانية وجود عدة نسخ نشطة منه في نفس الوقت. في هذا السيناريو، يمكن لعدة مكونات `<Teleport>` وصل محتوياتها على نفس العنصر الهدف. سيكون الترتيب ببساطة عبارة عن تذييل للمكونات داخله- ستكون الوصلات الأحدث موجودة بعد الوصلات الأقدم داخل العنصر الهدف.
176175

177-
Given the following usage:
176+
ليكن الاستخدام الموالي
178177

179178
```vue-html
180179
<Teleport to="#modals">
@@ -185,7 +184,8 @@ Given the following usage:
185184
</Teleport>
186185
```
187186

188-
The rendered result would be:
187+
188+
ستكون النتيجة المصيرة كالتالي:
189189

190190
```html
191191
<div id="modals">
@@ -196,7 +196,7 @@ The rendered result would be:
196196

197197
---
198198

199-
**Related**
199+
**ذات علاقة**
200200

201-
- [`<Teleport>` API reference](/api/built-in-components.html#teleport)
202-
- [Handling Teleports in SSR](/guide/scaling-up/ssr.html#teleports)
201+
- [`<Teleport>` مرجع الواجهة البرمجية للمكون](/api/built-in-components.html#teleport)
202+
- [معالجة Teleports  في حالة التصيير من جانب الخادم SSR](/guide/scaling-up/ssr.html#teleports)

0 commit comments

Comments
 (0)