You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/learn/your-first-component.md
+29-32Lines changed: 29 additions & 32 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,47 +1,47 @@
1
1
---
2
-
title: Your First Component
2
+
title: مكوّنك الأول
3
3
---
4
4
5
5
<Intro>
6
6
7
-
*Components* are one of the core concepts of React. They are the foundation upon which you build user interfaces (UI), which makes them the perfect place to start your React journey!
7
+
*المكونات* هي إحدى المفاهيم الرئيسية في React. هي الأساس الذي تبني عليها واجهات المستخدم. مما يجعلها المكان الصحيح لبدأ رحلتك مع React.
8
8
9
9
</Intro>
10
10
11
11
<YouWillLearn>
12
12
13
-
*What a component is
14
-
*What role components play in a React application
15
-
*How to write your first React component
13
+
*ما هو المكوّن
14
+
*ما الدور الذي تلعبه المكوّنات في تطبيق React
15
+
*كيف تكتب أول مكوّن React
16
16
17
17
</YouWillLearn>
18
18
19
-
## Components: UI building blocks {/*components-ui-building-blocks*/}
19
+
## المكونات: حجر بناء واجهة المستخدم {/*components-ui-building-blocks*/}
20
20
21
-
On the Web, HTML lets us create rich structured documents with its built-in set of tags like `<h1>`and`<li>`:
21
+
في الويب، تمكننا HTML من إنشاء وثائق مهيكلة غنية باستخدام مجموعة الوسوم المدمجة مثل `<h1>`و`<li>`:
22
22
23
23
```html
24
24
<article>
25
-
<h1>My First Component</h1>
25
+
<h1>مكوّني الأول</h1>
26
26
<ol>
27
-
<li>Components: UI Building Blocks</li>
28
-
<li>Defining a Component</li>
29
-
<li>Using a Component</li>
27
+
<li>المكوّنات: حجر بناء واجهة المستخدم</li>
28
+
<li>تعريف مكوّن</li>
29
+
<li>إستخدام مكوّن</li>
30
30
</ol>
31
31
</article>
32
32
```
33
33
34
-
This markup represents this article `<article>`, its heading `<h1>`, and an (abbreviated) table of contents as an ordered list `<ol>`. Markup like this, combined with CSS for style, and JavaScript for interactivity, lies behind every sidebar, avatar, modal, dropdown—every piece of UI you see on the Web.
34
+
يمثل هذا الترميز المرئي هذه المقالة `<article>`, عنوانها `<h1>`, وفهرس محتويات مختصر في شكل قائمة مرتبة `<ol>`. ترميز مرئي كهذا, مدمج مع CSS من أجل الأنماط التصميمية, و JavaScript من أجل التفاعلية, يكمن وراء كل شريط جانبي, صورة رمزية, نافذة, قائمة منسدلة - كل قطعة من واجهة مستخدم تراها في الويب.
35
35
36
-
React lets you combine your markup, CSS, and JavaScript into custom "components", **reusable UI elements for your app.** The table of contents code you saw above could be turned into a `<TableOfContents />`component you could render on every page. Under the hood, it still uses the same HTML tags like `<article>`, `<h1>`, etc.
36
+
تمكنك React من دمج الترميز المرئي, وCSS, وJavaScript في "مكونات" مخصصة, **عناصر واجهة المستخدم قابلة لإعادة الاستخدام لتطبيقك**. يمكن تحويل كود فهرس المحتوى الذي رأيته أعلاه الى مكوّن `<TableOfContents />`الذي يمكن تصييره في كل صفحة. لا يزال يستخدم هذا المكوّن تحت الخطاء وسوم مثل `<article>`, `<h1>`, إلخ.
37
37
38
-
Just like with HTML tags, you can compose, order and nest components to design whole pages. For example, the documentation page you're reading is made out of React components:
38
+
تمامًا مثل الوسوم HTML، يمكنك تجميع وترتيب وتضمين المكوّنات لتصميم صفحات كاملة. على سبيل المثال، صفحة المستندات التي تقرأها مصنوعة من مكوّنات React.
39
39
40
40
```js
41
41
<PageLayout>
42
42
<NavigationHeader>
43
43
<SearchBar />
44
-
<Link to="/docs">Docs</Link>
44
+
<Link to="/docs">المستندات</Link>
45
45
</NavigationHeader>
46
46
<Sidebar />
47
47
<PageContent>
@@ -51,11 +51,11 @@ Just like with HTML tags, you can compose, order and nest components to design w
51
51
</PageLayout>
52
52
```
53
53
54
-
As your project grows, you will notice that many of your designs can be composed by reusing components you already wrote, speeding up your development. Our table of contents above could be added to any screen with `<TableOfContents />`! You can even jumpstart your project with the thousands of components shared by the React open source community like [Chakra UI](https://chakra-ui.com/)and[Material UI.](https://material-ui.com/)
54
+
مع نمو مشروعك, ستلاحظ انه يمكن تجميع العديد من تصاميمك بواسطة إعادة استخدام مكوّنات كتبتها مسبقا, مما يسرع عملية التطوير. يمكن إضافة فهرس المحتويات أعلاه الى أي شاشة عن طريق `<TableOfContents />`! يمكنك أيضا الإنطلاق بسرعة في مشروعك باستخدام آلاف المكوّنات المشتركة من قبل مجتمع React مفتوحة المصدر مثل [Chakra UI](https://chakra-ui.com/)و[Material UI.](https://material-ui.com/).
55
55
56
-
## Defining a component {/*defining-a-component*/}
56
+
## تعريف مكوّن {/*defining-a-component*/}
57
57
58
-
Traditionally when creating web pages, web developers marked up their content and then added interaction by sprinkling on some JavaScript. This worked great when interaction was a nice-to-have on the web. Now it is expected for many sites and all apps. React puts interactivity first while still using the same technology: **a React component is a JavaScript function that you can _sprinkle with markup_.**Here's what that looks like (you can edit the example below):
58
+
تقليديًا، عند إنشاء صفحات الويب، يقوم مطورو الويب بترميز المحتوى الخاص بهم ومن ثم يضيفون التفاعل عن طريق إضافة بعض JavaScript. نجح هذا بشكل رائع عندما كان التفاعل مجرد ميزة اضافية جيدة على الويب. الآن يُتوقع وجود التفاعل في العديد من المواقع وجميع التطبيقات. تضع React التفاعلية في المقام الأول مع الاستمرار في استخدام نفس التقنية: **مكوّن React هو دالة JavaScript يمكنك أن تُضف إليها ترميز مرئي.**هنا مثال لذلك (يمكنك تحرير المثال أدناه):
59
59
60
60
<Sandpack>
61
61
@@ -64,7 +64,7 @@ export default function Profile() {
64
64
return (
65
65
<img
66
66
src="https://i.imgur.com/MK3eW3Am.jpg"
67
-
alt="Katherine Johnson"
67
+
alt="كاثرين جونسون"
68
68
/>
69
69
)
70
70
}
@@ -76,30 +76,30 @@ img { height: 200px; }
76
76
77
77
</Sandpack>
78
78
79
-
And here's how to build a component:
79
+
وهنا كيفية بناء مكوّن::
80
80
81
-
### Step 1: Export the component {/*step-1-export-the-component*/}
The`export default`prefix is a [standard JavaScript syntax](https://developer.mozilla.org/docs/web/javascript/reference/statements/export) (not specific to React). It lets you mark the main function in a file so that you can later import it from other files. (More on importing in [Importing and Exporting Components](/learn/importing-and-exporting-components)!)
83
+
البادئة`export default`هي جزء من [صيغة JavaScript القياسية](https://developer.mozilla.org/docs/web/javascript/reference/statements/export) (ليست محددة لـ React). تتيح لك وضع علامة على الدالة الرئيسية في ملف بحيث يمكنك استيرادها لاحقًا من ملفات أخرى. (للمزيد عن الاستيراد، راجع موضوع [استيراد وتصدير المكوّنات](/learn/importing-and-exporting-components)!)
84
84
85
-
### Step 2: Define the function {/*step-2-define-the-function*/}
85
+
### خطوة 2: تعريف الدالة {/*step-2-define-the-function*/}
86
86
87
-
With `function Profile() { }`you define a JavaScript function with the name `Profile`.
87
+
باستخدام الدالة `Profile() { }`، تقوم بتعريف دالة JavaScript بإسم "Profile".
88
88
89
89
<Pitfall>
90
90
91
-
React components are regular JavaScript functions, but **their names must start with a capital letter** or they won't work!
91
+
مكوّنات React هي عبارة عن دوال JavaScript عادية، ولكن يجب أن يبدأ اسماءها بحرف كبير، وإلا فلن تعمل بشكل صحيح!
The component returns an`<img />`tag with`src`and`alt` attributes. `<img />`is written like HTML, but it is actually JavaScript under the hood! This syntax is called[JSX](/learn/writing-markup-with-jsx), and it lets you embed markup inside JavaScript.
97
+
يقوم المكوّن بإرجاع عنصر`<img />`مع خواص`src`و`alt`. يتم كتابة `<img />`بنفس طريقة كتابة HTML، ولكنه في الواقع JavaScript تحت الغطاء! يُطلق على هذه الصيغة[JSX](/learn/writing-markup-with-jsx)، وتتيح لك تضمين ترميز مرئي داخل JavaScript.
98
98
99
-
Return statements can be written all on one line, as in this component:
99
+
يمكن كتابة عبارات الإرجاع في سطر واحد، كما في هذا المكوّن:
0 commit comments