Skip to content

Commit

Permalink
done translate web-components.md to ar ..
Browse files Browse the repository at this point in the history
  • Loading branch information
3imed-jaberi committed Jun 3, 2019
1 parent 03784ae commit 08bb09d
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions content/docs/web-components.md
@@ -1,46 +1,47 @@
---
id: web-components
title: Web Components
title: ู…ูƒูˆู†ุงุช ุงู„ูˆูŠุจ
permalink: docs/web-components.html
redirect_from:
- "docs/webcomponents.html"
---

React and [Web Components](https://developer.mozilla.org/en-US/docs/Web/Web_Components) are built to solve different problems. Web Components provide strong encapsulation for reusable components, while React provides a declarative library that keeps the DOM in sync with your data. The two goals are complementary. As a developer, you are free to use React in your Web Components, or to use Web Components in React, or both.
ุฅู†ู‘ ู…ูƒูˆู‘ู†ุงุช React ูˆ[ู…ูƒูˆู‘ู†ุงุช ุงู„ูˆูŠุจ](https://developer.mozilla.org/en-US/docs/Web/Web_Components) ู…ุจู†ูŠุฉ ู„ุญู„ ู…ุดุงูƒู„ ู…ุฎุชู„ูุฉ. ุญูŠุซ ุชูุฒูˆูู‘ุฏู†ุง ู…ูƒูˆู‘ู†ุงุช ุงู„ูˆูŠุจ ุจุชุบู„ูŠู ู‚ูˆูŠ ู„ู…ูƒูˆู‘ู†ุงุช ู‚ุงุจู„ุฉ ู„ุฅุนุงุฏุฉ ุงู„ุงุณุชุฎุฏุงู…ุŒ ุจูŠู†ู…ุง ุชูุฒูˆูู‘ุฏู†ุง ู…ูƒูˆู‘ู†ุงุช React ุจู…ูƒุชุจุฉ ุชุตุฑูŠุญุงุช ุชูุจู‚ูŠ DOM ุนู„ู‰ ุชุฒุงู…ู† ู…ุน ุจูŠุงู†ุงุชู†ุง. ูŠูƒูˆู† ู‡ุฐุง ุงู„ู‡ุฏูุงู† ู…ุชูƒุงู…ู„ูŠู†ุŒ ูˆูƒู…ูุทูˆู‘ุฑ ู„ูƒ ุญุฑูŠุฉ ุงุณุชุฎุฏุงู… React ููŠ ู…ูƒูˆู‘ู†ุงุช ุงู„ูˆูŠุจ ู„ุฏูŠูƒุŒ ุฃูˆ ุงุณุชุฎุฏุงู… ู…ูƒูˆู‘ู†ุงุช ุงู„ูˆูŠุจ ููŠ React ุฃูˆ ูƒู„ูŠู‡ู…ุง ู…ุนู‹ุง.

Most people who use React don't use Web Components, but you may want to, especially if you are using third-party UI components that are written using Web Components.
ู…ุนุธู… ู…ู† ูŠุณุชุฎุฏู… React ู„ุง ูŠุณุชุฎุฏู… ู…ูƒูˆู‘ู†ุงุช ุงู„ูˆูŠุจุŒ ูˆู„ูƒู† ู‚ุฏ ุชุฑุบุจ ููŠ ุฐู„ูƒ ุฎุงุตุฉ ุฅุฐุง ูƒู†ุช ุชุณุชุฎุฏู… ู…ูƒูˆู‘ู†ุงุช ู„ูˆุงุฌู‡ุฉ ุงู„ู…ุณุชุฎุฏู… ู…ู† ุทุฑู ุซุงู„ุซ ูˆุงู„ุชูŠ ุชูƒูˆู† ู…ูƒุชูˆุจุฉ ุจุงุณุชุฎุฏุงู… ู…ูƒูˆู‘ู†ุงุช ุงู„ูˆูŠุจ.

## Using Web Components in React {#using-web-components-in-react}

## ุงุณุชุฎุฏุงู… ู…ูƒูˆู‘ู†ุงุช ุงู„ูˆูŠุจ ููŠ React {#using-web-components-in-react}

```javascript
class HelloMessage extends React.Component {
render() {
return <div>Hello <x-search>{this.props.name}</x-search>!</div>;
return <div>ุฃู‡ู„ู‹ุง <x-search>{this.props.name}</x-search>!</div>;
}
}
```

> Note:
> ู…ู„ุงุญุธุฉ:
>
> Web Components often expose an imperative API. For instance, a `video` Web Component might expose `play()` and `pause()` functions. To access the imperative APIs of a Web Component, you will need to use a ref to interact with the DOM node directly. If you are using third-party Web Components, the best solution is to write a React component that behaves as a wrapper for your Web Component.
>ุชุนุฑุถ ู…ูƒูˆู‘ู†ุงุช ุงู„ูˆูŠุจ ุนุงุฏุฉ ูˆุงุฌู‡ุฉ ุจุฑู…ุฌุฉ ุชุทุจูŠู‚ุงุช (API) ุฅู„ุฒุงู…ูŠู‘ุฉ. ุนู„ู‰ ุณุจูŠู„ ุงู„ู…ุซุงู„ ู‚ุฏ ูŠูุนุฑูู‘ุถ ู…ูƒูˆู‘ู† ุงู„ูˆูŠุจ `video` ุงู„ุฏุงู„ุชูŠู† `play()`โ€Ž ูˆ `pause()`ุŒ ูˆู„ู„ูˆุตูˆู„ ุฅู„ู‰ ูˆุงุฌู‡ุฉ ุจุฑู…ุฌุฉ ุงู„ุชุทุจูŠู‚ุงุช ุงู„ุฅู„ุฒุงู…ูŠุฉ ู„ู…ูƒูˆู‘ู†ุงุช ุงู„ูˆูŠุจ ุณุชุญุชุงุฌ ุฅู„ู‰ ุงุณุชุฎุฏุงู… ู…ุฑุฌุน ู„ู„ุชูุงุนู„ ู…ุน ุนู‚ุฏุฉ DOM ู…ุจุงุดุฑุฉู‹. ุฅู† ูƒู†ุช ุชุณุชุฎุฏู… ู…ูƒูˆู‘ู†ุงุช ูˆูŠุจ ู…ู† ุทุฑู ุซุงู„ุซ ูุงู„ุญู„ ุงู„ุฃู…ุซู„ ู‡ูˆ ูƒุชุงุจุฉ ู…ูƒูˆู‘ู† React ูŠุณู„ูƒ ุณู„ูˆูƒ ุบู„ุงู ู„ู…ูƒูˆู‘ู†ุงุช ุงู„ูˆูŠุจ ู„ุฏูŠูƒ.
>
> Events emitted by a Web Component may not properly propagate through a React render tree.
> You will need to manually attach event handlers to handle these events within your React components.
> ุงู„ุฃุญุฏุงุซ ุงู„ุตุงุฏุฑุฉ ู…ู† ู‚ุจู„ ู…ูƒูˆู‘ู† ุงู„ูˆูŠุจ ู‚ุฏ ู„ุง ุชู†ุชุดุฑ ุจุดูƒู„ ุตุญูŠุญ ุนุจุฑ ุดุฌุฑุฉ ุชุตูŠูŠุฑ React.
> ุณุชุญุชุงุฌ ุฅู„ู‰ ุฅุฑูุงู‚ ู…ุนุงู„ุฌ ุฃุญุฏุงุซ ูŠุฏูˆูŠู‹ู‘ุง ู„ู„ุชุนุงู…ู„ ู…ุน ู‡ุฐู‡ ุงู„ุฃุญุฏุงุซ ุถู…ู† ู…ูƒูˆู‘ู†ุงุช React ู„ุฏูŠูƒ.
One common confusion is that Web Components use "class" instead of "className".
ุฅุญุฏู‰ ุงู„ุฃู…ูˆุฑ ุงู„ุชูŠ ู…ู† ุงู„ุดุงุฆุน ุงู„ุฎุทุฃ ุจู‡ุง ู‡ูŠ ุงุณุชุฎุฏุงู… ู…ูƒูˆู‘ู†ุงุช ุงู„ูˆูŠุจ ู„ู„ุฎุงุตูŠู‘ุฉ "class" ุจุฏู„ู‹ุง ู…ู† "className":

```javascript
function BrickFlipbox() {
return (
<brick-flipbox class="demo">
<div>front</div>
<div>back</div>
<div>ุงู„ูˆุงุฌู‡ุฉ ุงู„ุฃู…ุงู…ูŠุฉ</div>
<div>ุงู„ูˆุงุฌู‡ุฉ ุงู„ุฎู„ููŠุฉ</div>
</brick-flipbox>
);
}
```

## Using React in your Web Components {#using-react-in-your-web-components}
## ุงุณุชุฎุฏุงู… React ููŠ ู…ูƒูˆู‘ู†ุงุช ุงู„ูˆูŠุจ ู„ุฏูŠูƒ {#using-react-in-your-web-components}

```javascript
class XSearch extends HTMLElement {
Expand All @@ -56,7 +57,7 @@ class XSearch extends HTMLElement {
customElements.define('x-search', XSearch);
```

>Note:
>ู…ู„ุงุญุธุฉ:
>
>This code **will not** work if you transform classes with Babel. See [this issue](https://github.com/w3c/webcomponents/issues/587) for the discussion.
>Include the [custom-elements-es5-adapter](https://github.com/webcomponents/webcomponentsjs#custom-elements-es5-adapterjs) before you load your web components to fix this issue.
> **ู„ู†** ุชุนู…ู„ ู‡ุฐู‡ ุงู„ุดูŠูุฑุฉ ุฅู† ู†ู‚ู„ุช ุงู„ุฃุตู†ุงู ุจุงุณุชุฎุฏุงู… Babel. ุงู†ุธุฑ ุฅู„ู‰ ู‡ุฐู‡ ุงู„ู…ุดูƒู„ุฉ [ู…ู† ู‡ู†ุง](https://github.com/w3c/webcomponents/issues/587).
> ูŠุฌุจ ุนู„ูŠูƒ ุชุถู…ูŠู† [custom-elements-es5-adapter](https://github.com/webcomponents/webcomponentsjs#custom-elements-es5-adapterjs) ู‚ุจู„ ุชุญู…ูŠู„ ู…ูƒูˆู‘ู†ุงุช ุงู„ูˆูŠุจ ู„ุฅุตู„ุงุญ ู‡ุฐู‡ ุงู„ู…ุดูƒู„ุฉ.

0 comments on commit 08bb09d

Please sign in to comment.