0Pricing
Design Systems & Component Libraries · درس

اتفاقيات تسمية المكونات

تعلّم كيف تجعل التسمية الواضحة والمتسقة للمكونات وخصائصها مكتبة المكونات سهلة الاكتشاف ومتوقعة وقابلة للصيانة.

اتفاقيات تسمية المكونات درس مجاني في Design Systems & Component Libraries على CoddyKit. هذا هو الدرس 4 من أصل 4. يمكنك قراءة الدرس كاملاً أدناه مجاناً — ثم تمرن عليه مباشرة في المتصفح باستخدام محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7. هذا الدرس جزء من مسار التعلم في Design Systems & Component Libraries، وتقدمك يتزامن عبر الويب وتطبيق CoddyKit. تتضمن دورة Design Systems & Component Libraries 4 دروس في المجموع.

بعض أجزاء هذا الدرس لم تُترجم بعد وتظهر باللغة الإنجليزية.

Why Names Matter

The hardest problems in component libraries are not technical - they are naming. A poorly named component is hard to find, easy to misuse, and painful to rename later.

Good names act as documentation and reduce the questions teammates ask.

Be Descriptive, Not Clever

Name components by what they are or do, not by clever metaphors.

  • Good: UserAvatar, PrimaryButton
  • Avoid: Blob, Sparkle, Thingy

A new teammate should guess the purpose from the name alone.

Consistent Casing

Pick one casing rule and never deviate. The web convention:

  • Components: PascalCase (CardHeader)
  • Props: camelCase (isDisabled)
  • CSS classes: kebab-case (card-header)

Mixing casing styles erodes trust in the library.

Boolean Props

Boolean props read best with an is, has, or should prefix. They sound like questions and default to false.

The snippet below shows the pattern.

function describe(props) {
  return 'disabled=' + props.isDisabled + ', loading=' + props.isLoading;
}

console.log(describe({ isDisabled: true, isLoading: false }));

Prop Naming Patterns

Establish predictable prop names across all components:

  • variant for visual style (primary, ghost)
  • size for scale (sm, md, lg)
  • onChange, onClick for event handlers

If every component uses the same names, learning one teaches you all.

Avoid Implementation Details

Do not bake fragile details into names. BlueButton becomes a lie the moment the brand color changes.

Prefer intent-based names like PrimaryButton. The intent is stable even when the styling evolves.

Namespacing and Prefixes

Many systems prefix components to avoid clashes and signal origin: DsButton, AcmeCard.

This helps when consuming apps already have their own components. Choose a short prefix and apply it everywhere or nowhere - consistency over preference.

Compound Component Naming

Related parts should share a family name: Card, CardHeader, CardBody, CardFooter.

The shared prefix groups them in autocomplete and signals they belong together. This is far clearer than Card, Heading, Content.

Renaming Is Expensive

Once a component name ships, every consuming app depends on it. Renaming becomes a breaking change requiring deprecation cycles.

Invest time in the name up front. A 10-minute naming discussion saves months of migration pain.

Document the Rules

Write your naming conventions down in the contribution guide. New contributors should not have to reverse-engineer your patterns.

A short, enforced naming doc keeps the library coherent as more people contribute.

Names as a Contract

Ultimately, a component's name and prop names form a public API contract. Treat them with the same care as any API.

Predictable names let developers compose your library confidently without reading the source.

Quick Check

Test your naming instincts.

Recap

You learned naming conventions that keep a component library usable:

  • Be descriptive and intent-based, not clever or color-bound.
  • Use consistent casing and predictable prop names.
  • Group compound components with shared prefixes.
  • Document the rules and remember renaming is costly.

Good names are quiet documentation.

الأسئلة الشائعة

هل درس «اتفاقيات تسمية المكونات» مجاني؟

نعم — نص درس «اتفاقيات تسمية المكونات» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 24/7) وفتح باقي دورة Design Systems & Component Libraries، انتقل إلى CoddyKit PRO. تتضمن دورة Design Systems & Component Libraries 4 دروس في المجموع.

ماذا ستتعلم في «اتفاقيات تسمية المكونات»؟

تعلّم كيف تجعل التسمية الواضحة والمتسقة للمكونات وخصائصها مكتبة المكونات سهلة الاكتشاف ومتوقعة وقابلة للصيانة. تتمرن على Design Systems & Component Libraries مع أكواد عملية تشغلها مباشرة في المتصفح، ومدرس ذكاء اصطناعي متاح 24/7 يجيب على أسئلتك أثناء عملك.

هل أحتاج إلى خبرة سابقة لأبدأ Design Systems & Component Libraries؟

لا تُشترط خبرة سابقة. Design Systems & Component Libraries على CoddyKit منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 4 من أصل 4.

كم من الوقت يستغرق درس «اتفاقيات تسمية المكونات»؟

معظم دروس CoddyKit تستغرق حوالي 5–10 دقائق. كل منها موجز وتفاعلي، لذا تحرز تقدماً مستمراً وتستأنف من حيث توقفت عبر الويب والتطبيق.

هل يمكنني كتابة وتشغيل أكواد في درس Design Systems & Component Libraries هذا؟

نعم. كل درس في Design Systems & Component Libraries يتضمن محرر أكواد مدمج، لذا تكتب وتشغل أكواداً حقيقية مباشرة في متصفحك وتحصل على تعليقات فورية من الذكاء الاصطناعي — بدون إعداد محلي.

جميع الدروس في هذه الدورة

  1. منهجية Atomic Design
  2. تشريح المكوّنات وبنيتها
  3. اختيار مكوّنات حزمة التقنيات
  4. اتفاقيات تسمية المكونات
← العودة إلى Design Systems & Component Libraries