An open source design system that's fully customizable and agent ready
TypeScript
docs(Section): center a Section with the inline-margin longhands in xstyle (#10207)
Cindy Zhangc942796a15ec
diff --git a/.changeset/section-docs-centering.md b/.changeset/section-docs-centering.mdnew file mode 100644index 0000000000..3d0caede07--- /dev/null+++ b/.changeset/section-docs-centering.md@@ -0,0 +1,7 @@+---+'@astryxdesign/core': patch+---++[docs] Section's docs show how to center it: set `marginInlineStart` and `marginInlineEnd` to `'auto'` in `xstyle`.++@cixzhangdiff --git a/packages/core/src/Section/Section.doc.mjs b/packages/core/src/Section/Section.doc.mjsindex 6dbe41f534..65e7c5886e 100644--- a/packages/core/src/Section/Section.doc.mjs+++ b/packages/core/src/Section/Section.doc.mjs@@ -122,8 +122,28 @@ export const docs = {{ guidance: true, description: 'Add dividers between same-background sections that need separation.' },{ guidance: true, description: 'Combine with a heading + Stack for a typical page section pattern.' },{ guidance: false, description: 'Use Card when you mean Section. Cards are for discrete items (one notification, one profile). Sections are for page regions.' },+ { guidance: true, description: "To center a Section, set marginInlineStart and marginInlineEnd to 'auto' in xstyle. If Astryx source is compiled in your app's own StyleX pass, the marginInline shorthand loses to Section's own inline margins." },],},+ examples: [+ {+ label: 'Center a Section with a maximum width',+ code: `import * as stylex from '@stylexjs/stylex';+import {Section} from '@astryxdesign/core/Section';++const styles = stylex.create({+ centered: {marginInlineStart: 'auto', marginInlineEnd: 'auto'},+});++function Page({children}: {children: React.ReactNode}) {+ return (+ <Section maxWidth={1280} xstyle={styles.centered}>+ {children}+ </Section>+ );+}`,+ },+ ],};/** @type {import('@astryxdesign/cli/authoring').ComponentDoc} */@@ -230,6 +250,7 @@ export const docsZh = {{ guidance: true, description: 'Add dividers between same-background sections that need separation.' },{ guidance: true, description: 'Combine with a heading + Stack for a typical page section pattern.' },{ guidance: false, description: 'Use Card when you mean Section. Cards are for discrete items (one notification, one profile). Sections are for page regions.' },+ { guidance: true, description: '要让 Section 居中,在 xstyle 中把 marginInlineStart 和 marginInlineEnd 设为 \'auto\'。如果 Astryx 源码在你的应用自己的 StyleX 编译中处理,marginInline 简写会输给 Section 自身的行内外边距。' },],},};@@ -248,6 +269,7 @@ export const docsDense = {{ guidance: true, description: 'Add dividers between same-background sections that need separation.' },{ guidance: true, description: 'Combine w/ heading + Stack for typical page section pattern.' },{ guidance: false, description: 'Use Card when you mean Section. Cards = discrete items (one notification, one profile). Sections = page regions.' },+ { guidance: true, description: "Center: xstyle marginInlineStart + marginInlineEnd 'auto'. If Astryx source goes through your app's StyleX pass, marginInline shorthand loses to Section's inline margins." },],},propDescriptions: {