דלג לתוכן הראשי
עיון בתיעוד

CSS מותאם אישית

פתח המילוט: עצבו מחדש כל משטח של הווידג'ט עם CSS גולמי כשפקדי הטוקנים של הסטודיו אינם מספיקים.

פקדי הטוקנים של Widget Design Studio מכסים את רוב צורכי המיתוג — הם נשארים בטוחים לפי AA ושורדים עדכוני ווידג'ט. כשהם אינם מספיקים, כל עיצוב נושא שדה CSS מותאם אישית (שלב «כללי»): CSS גולמי המוזרק ל-Shadow DOM של הווידג'ט, המכוון לסלקטורים היציבים ולמאפייני --syncanix-* המתועדים בעמוד זה.

איך זה חל

ה-CSS מאומת בזמן ההקלדה ומאומת שוב בצד השרת בעת השמירה. הוא נכנס לתוקף כששומרים את העיצוב; אם העיצוב הזה הוא שבשימוש, ווידג'טים מוטמעים קולטים את השינוי בטעינת התצורה הבאה — בתוך דקות ספורות.

מחרוזת CSS אחת לכל עיצוב: היא חלה על כל גודלי הווידג'ט ועל שני ערכות הצבע (תחמו כללי מצב כהה עם הסלקטור שלמטה), וכללי ערכת נושא לפי עמוד לעולם אינם נושאים CSS מותאם אישית משלהם.

ה-CSS שלכם מנצח בקסקדה

הווידג'ט מזריק את ה-CSS שלכם כגיליון הסגנונות האחרון ב-Shadow DOM שלו, אחרי כל הסגנונות המובנים. לכן כלל בעל ספציפיות שווה גובר על זה של הווידג'ט — אין צורך ב-!important לעיצוב מחדש רגיל.

/* Does NOT work — tokens are applied inline on the host element,
   which beats any :host rule: */
:host { --syncanix-primary: #0f766e; }

/* Works — re-declare the variable on a descendant instead: */
.syncanix-panel { --syncanix-primary: #0f766e; }

סלקטורים יציבים

הסלקטורים האלה הם חוזה מתועד ויציב — מקובע בבדיקות, כך שגרסת ווידג'ט אינה יכולה לשנות את שמם בשקט.

/* Launcher (the closed floating button — an attribute, not a class) */
[data-syncanix='launcher']
.syncanix-launcher-avatar
.syncanix-launcher-brand

/* Panel chrome */
.syncanix-panel
.syncanix-panel-header

/* Messages */
.syncanix-panel-item-user
.syncanix-panel-item-assistant
.syncanix-msg-body

/* Composer */
.syncanix-panel-composer
.syncanix-panel-composer-form
.syncanix-panel-composer-input
.syncanix-panel-composer-submit
.syncanix-panel-composer-stop
.syncanix-panel-composer-limit

/* Rich primitives — each renders with its type on the root */
.syncanix-card
.syncanix-confirm-card
[data-syncanix-primitive='list' | 'table' | 'card' | 'markdown' | 'button'
  | 'detail' | 'form' | 'status' | 'empty-state' | 'confirm-card' | 'navigate'
  | 'component' | 'iframe' | 'action-plan' | 'action-in-progress'
  | 'action-result' | 'chart' | 'embed' | 'metric' | 'funnel' | 'flow'
  | 'sign-in-card' | 'onboarding-checklist']

מאפיינים מותאמים אישית

כל משטח בווידג'ט נצבע ממאפייני --syncanix-* מותאמים אישית עם מרחב שמות, כך שהצהרה מחדש על אחד מהם בתת-עץ מעצבת מחדש רק את אותו תת-עץ. אותם שמות טוקנים מתקבלים גם במאפיין ההטמעה data-theme — ראו עיצוב ערכת הנושא של הווידג'ט להרכבת שכבות ערכת הנושא.

/* Colour */
--syncanix-primary            --syncanix-primary-foreground
--syncanix-background         --syncanix-foreground
--syncanix-muted              --syncanix-muted-foreground
--syncanix-border             --syncanix-ring
--syncanix-destructive        --syncanix-destructive-foreground
--syncanix-link

/* Typography */
--syncanix-font-family        --syncanix-font-family-heading
--syncanix-line-height-base   --syncanix-letter-spacing-base
--syncanix-measure

/* Shape */
--syncanix-radius             --syncanix-radius-sm
--syncanix-radius-md          --syncanix-radius-lg
--syncanix-radius-full        --syncanix-avatar-radius

/* Elevation, spacing, motion, icons */
--syncanix-shadow-lg          --syncanix-shadow-xl
--syncanix-spacing            --syncanix-spacing-sm
--syncanix-motion-duration    --syncanix-motion-easing
--syncanix-icon-stroke-width

/* Per-element studio overrides (set on a descendant to override locally) */
--syncanix-launcher-bg        --syncanix-launcher-fg
--syncanix-header-bg          --syncanix-header-fg
--syncanix-user-bubble-bg     --syncanix-user-bubble-fg
--syncanix-assistant-bubble-bg  --syncanix-assistant-bubble-fg
--syncanix-composer-bg        --syncanix-pane-bg
--syncanix-ai-font-family     --syncanix-user-font-family

בהיר וכהה

ערכת הצבע שנקבעה מוטבעת על מארח הווידג'ט כ-data-color-scheme. ה-CSS שלכם חל בשתי הערכות — תחמו כללים לכהה בלבד עם :host([data-color-scheme='dark']).

.syncanix-panel-header { background: #f8fafc; }

:host([data-color-scheme='dark']) .syncanix-panel-header {
  background: #1e293b;
}

מה חסום

ה-CSS המותאם אישית מאומת בעורך, בשמירה, ושוב בווידג'ט לפני ההזרקה. המאמת דוחה:

  • @import — שליפה או דליפה של CSS חיצוני.
  • expression()‎, כתובות javascript: ו-data:text/html, behavior:, ‏-moz-binding — וקטורים ישנים של הזרקת סקריפטים.
  • הפניות url()‎ חיצוניות — וקטור משואת רשת / דליפת נתונים. הטמיעו משאבים (כולל קובצי גופנים) ככתובות data: URI במקום זאת.
  • תג סגירה ‎</style> — בריחה מה-Shadow DOM.
  • הסתרה או עיצוב מחדש של ההצהרה «נוצר עם בינה מלאכותית» (סלקטורים syncanix-ai-* / syncanix-first-message-*) — משטח רגולטורי נעול.
  • יותר מ-64 KB של CSS לכל עיצוב.

דוגמאות

/* A gradient panel header with a hairline divider */
.syncanix-panel-header {
  background: linear-gradient(135deg, #0f766e, #134e4a);
  border-block-end: 1px solid rgba(255, 255, 255, 0.12);
}
עיצוב מחדש של כותרת הפאנל
/* Round only the cards, and give tables a tighter radius */
[data-syncanix-primitive='card'] { --syncanix-radius: 1rem; }
[data-syncanix-primitive='table'] { --syncanix-radius: 0.25rem; }
דריסת טוקן לפרימיטיב אחד בלבד
/* Slow the widget's motion down, and switch it off for
   reduced-motion visitors */
.syncanix-panel { --syncanix-motion-duration: 300ms; }

@media (prefers-reduced-motion: reduce) {
  .syncanix-panel { --syncanix-motion-duration: 0ms; }
}
כוונון תנועה תוך כיבוד reduced-motion

השלבים הבאים