Design Systems & Component Libraries · درس

تطبيق رموز التصميم

تعلّم أساليب عملية لتعريف رموز التصميم وإدارتها وتوزيعها عبر منصات وتقنيات مختلفة

الدرس 2 من 412 خطوة

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

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

Tokens: Bringing Designs to Code

Welcome to Implementing Design Tokens! In the previous lesson, we learned what design tokens are. Now, let's get practical!

This lesson will show you how to define, manage, and distribute tokens so they can be used across different platforms like web and mobile apps.

Defining Your Core Tokens

Design tokens are typically defined in a structured, human-readable format, most commonly JSON or YAML. This central source acts as the single truth for all design values.

Here's a simple example of how you might define core color tokens:

{  "color": {    "brand": {      "primary": "#007bff",      "secondary": "#6c757d"    },    "text": {      "default": "#333333",      "subtle": "#666666"    }  }}

Categorizing Tokens: Primitives & Semantics

Tokens are often categorized to improve organization and maintainability:

  • Primitive Tokens: Low-level, abstract values (e.g., color-blue-500, spacing-16px).
  • Semantic Tokens (Alias): Contextual values that refer to primitive tokens (e.g., color-brand-primary maps to color-blue-500).

Using semantic tokens makes it easier to update themes or respond to brand changes.

Example: Primitive to Semantic Mapping

See how a semantic token like color-background-default uses a primitive token color-neutral-0. This creates a flexible system.

{  "color": {    "neutral": {      "0": "#ffffff",      "100": "#f8f9fa"    },    "background": {      "default": {        "value": "{color.neutral.0}"      },      "subtle": {        "value": "{color.neutral.100}"      }    }  }}

Managing Your Token Source

Once defined, these source files need a home. Common practices include:

  • Version Control: Storing tokens in a Git repository alongside your design system code.
  • Dedicated Tools: Using specialized token management platforms that offer UIs for designers and API access for developers.

This ensures a single source of truth and clear versioning.

Distributing to Web: CSS Variables

For web applications, design tokens are commonly transformed into CSS Custom Properties (also known as CSS Variables). These can then be directly used in your stylesheets.

This allows for dynamic theming and easy updates across your web components.

Web Token Usage Example

Here's how generated CSS variables might look and how they'd be used:

:root {
  --color-brand-primary: #007bff;
  --color-text-default: #333333;
}

.button {
  background-color: var(--color-brand-primary);
  color: var(--color-text-default);
  padding: 8px 16px;
}

Distributing to Native: Platform-Specific Files

For native mobile apps (iOS, Android), tokens are transformed into platform-specific files. This could be:

  • Android: XML resources (colors.xml, dimens.xml).
  • iOS: Swift files (structs, enums) or Objective-C headers.

These files are then imported and used in the native codebase.

Native Token Usage Example (Android)

An Android colors.xml file generated from tokens:

<!-- res/values/colors.xml -->
<resources>
    <color name="brand_primary">#007bff</color>
    <color name="text_default">#333333</color>
</resources>

<!-- In Kotlin/Java code: -->
// textView.setTextColor(ContextCompat.getColor(context, R.color.text_default))

Token Transformation Tools

Manually converting tokens for every platform is tedious. This is where token transformation tools shine!

Tools like Style Dictionary or Theo automate this process. They take your single source JSON/YAML, apply transformations, and generate platform-specific code (CSS, XML, Swift, JS, etc.).

This ensures consistency and saves a lot of development time.

Check Your Understanding

You've learned how design tokens are defined, categorized, and distributed across different platforms. Let's test your knowledge.

Recap: Your Token Toolkit

Great job! You now understand the practical steps of implementing design tokens:

  • Tokens are defined in structured formats like JSON.
  • Categorize tokens into primitive and semantic types.
  • Manage tokens in version control or dedicated tools.
  • Distribute tokens to web (CSS variables) and native platforms (XML, Swift).
  • Use transformation tools to automate generation.

This process ensures design consistency and efficiency across all your products!

البدء مجانًا

تعلم Design Systems & Component Libraries مع معلم ذكاء اصطناعي — مجانًا

اكتب وقم بتشغيل أكوادك الفعلية في المتصفح، واحصل على مساعدة فورية من معلم ذكاء اصطناعي متاح 24/7، واستمر من حيث توقفت على الويب أو في التطبيق.

الدورات
12
الدروس
48

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

هل درس «تطبيق رموز التصميم» مجاني؟

نعم — نص درس «تطبيق رموز التصميم» كامل متاح مجاناً هنا على الويب. لتمرينه بشكل تفاعلي (محرر أكواد مدمج ومدرس ذكاء اصطناعي متاح 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 منظم للمبتدئين حتى المتقدمين، لذا يمكنك البدء من هنا أو من البداية والتقدم بسرعتك الخاصة. هذا هو الدرس 2 من أصل 4.

كم من الوقت يستغرق درس «تطبيق رموز التصميم»؟

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

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

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

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

  1. ما هي رموز التصميم؟
  2. تطبيق رموز التصميم
  3. أتمتة سير العمل من التصميم إلى الشيفرة
  4. تسمية الرموز وبنية الرموز متعددة المستويات
← العودة إلى Design Systems & Component Libraries