Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reorganized grouping of props to follow RAC #534

Merged
merged 4 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions apps/docs/components/tag/tag.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
@property --font-size {
syntax: '<length>';
inherits: false;
initial-value: 1rem;
}

:root {
--hd-tag-font-family: var(--hd-default-font-family);
--hd-tag-font-size: 0.875rem;
Expand Down
87 changes: 75 additions & 12 deletions apps/docs/scripts/generateComponentData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ interface Groups {
}

interface GroupsConfig {
[key: string]: string | string[];
[key: string]: (string | RegExp)[];
}

export interface ComponentDocWithGroups extends ComponentDoc {
Expand Down Expand Up @@ -102,10 +102,59 @@ function getFormattedData(data: ComponentDoc[]): ComponentDocWithGroups[] {
// Define the groups and their corresponding terms

const groupsConfig: GroupsConfig = {
events: ["Events", "DOMAttributes"],
accessibility: ["Aria", "Focusable"],
layout: "Slot"
// Add more groups here as needed
Events: [
/^on[A-Z]/
],
Layout: [
"flex", "flexGrow", "flexShrink", "flexBasis", "alignSelf", "justifySelf", "order", "flexOrder",
"gridArea", "gridColumn", "gridRow", "gridColumnStart", "gridColumnEnd", "gridRowStart", "gridRowEnd", "slot",
"overflow"
],
Spacing: [
"margin", "marginTop", "marginLeft", "marginRight", "marginBottom", "marginStart", "marginEnd", "marginX", "marginY",
"padding", "paddingTop", "paddingLeft", "paddingRight", "paddingBottom", "paddingStart", "paddingEnd", "paddingX", "paddingY"
],
Sizing: [
"width", "minWidth", "maxWidth", "height", "minHeight", "maxHeight", "defaultWidth"
],
Background: [
"background", "backgroundColor", "backgroundImage", "backgroundSize", "backgroundPosition", "backgroundRepeat",
"opacity"
],
Borders: [
"border",
"borderX",
"borderY",
"borderStyle",
"borderTop",
"borderLeft",
"borderRight",
"borderTop",
"borderBottom",
"borderWidth", "borderStartWidth", "borderEndWidth", "borderLeftWidth", "borderRightWidth", "borderTopWidth", "borderBottomWidth", "borderXWidth", "borderYWidth",
"borderColor", "borderStartColor", "borderEndColor", "borderLeftColor", "borderRightColor", "borderTopColor", "borderBottomColor", "borderXColor", "borderYColor",
"borderRadius", "borderTopStartRadius", "borderTopEndRadius", "borderBottomStartRadius", "borderBottomEndRadius", "borderTopLeftRadius", "borderTopRightRadius", "borderBottomLeftRadius", "borderBottomRightRadius"
],
Shadows: [
"boxShadow",
"textShadow"
],
Positioning: [
"position", "top", "bottom", "left", "right", "start", "end", "zIndex", "isHidden", "hidden", "display"
],
Typography: [
"font",
"fontFamily",
"fontSize",
"fontStyle",
"textAlign",
"verticalAlign",
"lineHeight",
"letterSpacing"
],
Accessibility: [
"role", "id", "tabIndex", "excludeFromTabOrder", "preventFocusOnPress", /^aria-/
]
};

// Define the exceptions that should be added to a specific group
Expand Down Expand Up @@ -136,18 +185,32 @@ function getFormattedData(data: ComponentDoc[]): ComponentDocWithGroups[] {
Object.entries(props).forEach(([key, prop]) => {
let added = false;

// Special handling for the "id" prop
if (key === "id") {
if (prop.type?.name === "string") {
groups.Accessibility[key] = prop;
added = true;
} else {
groups.default[key] = prop;
added = true;
}
delete props[key];

return;
}

// Check each group to see if the prop should be added to it
Object.entries(groupsConfig).forEach(([group, term]) => {
if (Array.isArray(term)) {
term.forEach(t => {
if (prop.parent?.name.includes(t)) {
Object.entries(groupsConfig).forEach(([group, terms]) => {
if (Array.isArray(terms)) {
terms.forEach(term => {
if (
(typeof term === "string" && prop.name === term) ||
(term instanceof RegExp && term.test(prop.name))
) {
groups[group][key] = prop;
added = true;
}
});
} else if (prop.parent?.name.includes(term)) {
groups[group][key] = prop;
added = true;
}
});

Expand Down