An open source design system that's fully customizable and agent ready
TypeScript
docs(Avatar): list supported numeric sizes (#6283)
zakelstormba804614817d
diff --git a/.changeset/avatar-numeric-size-docs.md b/.changeset/avatar-numeric-size-docs.mdnew file mode 100644index 0000000000..1f3b8dfbab--- /dev/null+++ b/.changeset/avatar-numeric-size-docs.md@@ -0,0 +1,7 @@+---+'@astryxdesign/core': patch+---++[docs] `Avatar` and `AvatarGroup` docs list the numeric sizes `size` accepts (16, 20, 24, 32, 36, 40, 48, 60, 64, 72, 96, 128, 144, 180) instead of implying any pixel value, and say that an `AvatarGroup`'s size always overrides a child `Avatar`'s size, including the group's default.++@korkt-kimdiff --git a/packages/core/src/Avatar/Avatar.doc.mjs b/packages/core/src/Avatar/Avatar.doc.mjsindex 04e2bf0430..04cc55e4e2 100644--- a/packages/core/src/Avatar/Avatar.doc.mjs+++ b/packages/core/src/Avatar/Avatar.doc.mjs@@ -67,8 +67,10 @@ export const docs = {},{name: 'size',- type: "'xsm' | 'sm' | 'md' | 'lg' | 'xl' | number",- description: "Avatar size. Use a named size ('xsm' 20px, 'sm' 24px, 'md' 36px, 'lg' 48px, 'xl' 128px) or a numeric pixel value. Avatar shares Icon's abbreviated scale, but its tiers are larger because avatars align with media rather than glyphs. Inside an AvatarGroup the group's size wins and this prop is ignored.",+ type:+ "'xsm' | 'sm' | 'md' | 'lg' | 'xl' | 16 | 20 | 24 | 32 | 36 | 40 | 48 | 60 | 64 | 72 | 96 | 128 | 144 | 180",+ description:+ "Avatar size: named sizes are 'xsm' (20px), 'sm' (24px), 'md' (36px), 'lg' (48px), and 'xl' (128px); numeric sizes must be one of the pixel values listed in the type. Inside an AvatarGroup, the group's size always overrides this prop, including when the group uses its default size.",default: "'md'",},{@@ -169,7 +171,7 @@ export const docsDense = {fallbackSrc: 'fallback image when primary fails',name: 'user name for initials and alt text',alt: 'alt text; falls back to name',- size: "avatar size. Named ('xsm' 20px, 'sm' 24px, 'md' 36px, 'lg' 48px, 'xl' 128px) or numeric px. An AvatarGroup's size overrides it.",+ size: "named sizes: 'xsm' 20px, 'sm' 24px, 'md' 36px, 'lg' 48px, 'xl' 128px; numeric px restricted to values listed in the type. AvatarGroup's size always wins, default included.",status:'corner content for status indicators; AvatarStatusDot reports its `label`, composed into the avatar accessible name ("Jane Doe, Online"), at any nesting depth',tooltip:diff --git a/packages/core/src/AvatarGroup/AvatarGroup.doc.mjs b/packages/core/src/AvatarGroup/AvatarGroup.doc.mjsindex 5605d90254..99c47530e3 100644--- a/packages/core/src/AvatarGroup/AvatarGroup.doc.mjs+++ b/packages/core/src/AvatarGroup/AvatarGroup.doc.mjs@@ -48,9 +48,10 @@ export const docs = {},{name: 'size',- type: 'AvatarSize',+ type:+ "'xsm' | 'sm' | 'md' | 'lg' | 'xl' | 16 | 20 | 24 | 32 | 36 | 40 | 48 | 60 | 64 | 72 | 96 | 128 | 144 | 180",description:- "Size applied to all avatars via context. This wins over each child Avatar's own size prop, including when it is left at the default, so set the size here rather than on the children.",+ "Size applied to all avatars: named sizes are 'xsm' (20px), 'sm' (24px), 'md' (36px), 'lg' (48px), and 'xl' (128px); numeric sizes must be one of the pixel values listed in the type. The group's size always overrides each child Avatar's size, including when the group uses its default size.",default: "'md'",},{diff --git a/packages/core/src/docPropLiterals.test.ts b/packages/core/src/docPropLiterals.test.tsindex af499f2ea3..3aa06b24c9 100644--- a/packages/core/src/docPropLiterals.test.ts+++ b/packages/core/src/docPropLiterals.test.ts@@ -3,7 +3,8 @@/* eslint-disable @typescript-eslint/no-require-imports *//*** @file Guards doc prop types against opaque named unions (#1645).- * @input Every {Name}.doc.mjs plus the TypeScript sources they describe.+ * @input Every {Name}.doc.mjs plus the TypeScript sources they describe,+ * including same-file private aliases used by exported literal unions.* @output Fails when a documented prop type hides its legal literal values.* @position Repo-wide doc-shape guard, sibling of docPropReferences.test.ts.*@@ -188,18 +189,34 @@ for (const file of findFiles(SRC_DIR, ['.ts', '.tsx'])) {// markers the comment-stripped `src` has already removed.const rawTypeRhs = new Map<string, string>();for (const m of raw.matchAll(- /export type ([A-Z][A-Za-z0-9]*)(?:<[^>]*>)?\s*=\s*([^;]+);/g,+ /\btype ([A-Z][A-Za-z0-9]*)(?:<[^>]*>)?\s*=\s*([^;]+);/g,)) {rawTypeRhs.set(m[1], m[2]);}- for (const m of src.matchAll(- /export type ([A-Z][A-Za-z0-9]*)(?:<[^>]*>)?\s*=\s*([^;]+);/g,- )) {- const [, name, rhsRaw] = m;- const rhs = rhsRaw.replace(/\s+/g, ' ').trim();- if (LITERAL_UNION.test(rhs)) {+ const declarations = [+ ...src.matchAll(+ /\b(export )?type ([A-Z][A-Za-z0-9]*)(?:<[^>]*>)?\s*=\s*([^;]+);/g,+ ),+ ];+ // Resolve same-file literal aliases before registering exported types.+ // Repeat until no new literal unions are found.+ const fileLiterals = new Map<string, string>();+ let previousSize: number;+ do {+ previousSize = fileLiterals.size;+ for (const [, , name, rhsRaw] of declarations) {+ const rhs = rhsRaw+ .replace(/\s+/g, ' ')+ .trim()+ .split('|')+ .map(part => fileLiterals.get(part.trim()) ?? part.trim())+ .join(' | ');++ if (!LITERAL_UNION.test(rhs)) {+ continue;+ }const deprecated = deprecatedLiteralMembers(rawTypeRhs.get(name) ?? '');- literalUnions.set(+ fileLiterals.set(name,rhs.replace(/^\|\s*/, '')@@ -209,8 +226,17 @@ for (const file of findFiles(SRC_DIR, ['.ts', '.tsx'])) {.filter(member => !deprecated.has(member)).join(' | '),);+ }+ } while (fileLiterals.size !== previousSize);+ for (const [, exported, name, rhsRaw] of declarations) {+ if (!exported) {+ continue;+ }+ const literals = fileLiterals.get(name);+ if (literals !== undefined) {+ literalUnions.set(name, literals);} else {- namedBodies.set(name, rhs);+ namedBodies.set(name, rhsRaw.replace(/\s+/g, ' ').trim());}}for (const m of src.matchAll(