Skip to content

Commit

Permalink
[docs-infra] Support interfaces for X docs (mui#41069)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexfauquette authored and mnajdova committed Mar 8, 2024
1 parent b1161c4 commit 067cba1
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ type ExpandableApiItemProps = {
isExtendable?: boolean;
note?: string;
sx?: SxProps;
title: string;
title: string | React.ReactNode;
type?: DescriptionType;
};

Expand Down
20 changes: 19 additions & 1 deletion docs/src/modules/components/ApiPage/list/PropertiesList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ export interface Properties {
isDeprecated?: boolean;
isOptional?: boolean;
isRequired?: boolean;
isProPlan?: boolean;
isPremiumPlan?: boolean;
propDefault?: string;
propName: string;
requiresRef?: string;
Expand Down Expand Up @@ -169,6 +171,8 @@ export default function PropertiesList(props: PropertiesListProps) {
isOptional,
isRequired,
isDeprecated,
isProPlan,
isPremiumPlan,
hooksParameters,
hooksReturnValue,
deprecationInfo,
Expand All @@ -191,7 +195,21 @@ export default function PropertiesList(props: PropertiesListProps) {
<StyledApiItem
key={propName}
id={getHash({ componentName, propName, hooksParameters, hooksReturnValue })}
title={propName}
title={
<React.Fragment>
{propName}
{isProPlan && (
<a href="/x/introduction/licensing/#pro-plan">
<span className="plan-pro" />
</a>
)}
{isPremiumPlan && (
<a href="/x/introduction/licensing/#premium-plan">
<span className="plan-premium" />
</a>
)}
</React.Fragment>
}
note={note}
type="props"
displayOption={displayOption}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@ export default function PropertiesSection(props) {
requiresRef: propDescription?.requiresRef,
isOptional,
isRequired,
isProPlan: propData.isProPlan,
isPremiumPlan: propData.isPremiumPlan,
isDeprecated,
hooksParameters,
hooksReturnValue,
Expand Down
33 changes: 25 additions & 8 deletions docs/src/modules/components/ApiPage/table/PropertiesTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ interface PropertiesTableProps {

export default function PropertiesTable(props: PropertiesTableProps) {
const { properties } = props;

const hasDefaultColumn = properties.some((item) => item.propDefault !== undefined);

const t = useTranslate();
return (
<StyledTableContainer>
Expand All @@ -130,7 +133,7 @@ export default function PropertiesTable(props: PropertiesTableProps) {
<tr>
<th>Name</th>
<th>Type</th>
<th>Default</th>
{hasDefaultColumn && <th>Default</th>}
<th>Description</th>
</tr>
</thead>
Expand All @@ -144,6 +147,8 @@ export default function PropertiesTable(props: PropertiesTableProps) {
requiresRef,
isOptional,
isRequired,
isProPlan,
isPremiumPlan,
isDeprecated,
hooksParameters,
hooksReturnValue,
Expand All @@ -165,6 +170,16 @@ export default function PropertiesTable(props: PropertiesTableProps) {
{propName}
{isRequired ? '*' : ''}
{isOptional ? '?' : ''}
{isProPlan && (
<a href="/x/introduction/licensing/#pro-plan">
<span className="plan-pro" />
</a>
)}
{isPremiumPlan && (
<a href="/x/introduction/licensing/#premium-plan">
<span className="plan-premium" />
</a>
)}
</td>
<td className="type-column">
{
Expand All @@ -176,13 +191,15 @@ export default function PropertiesTable(props: PropertiesTableProps) {
/>
}
</td>
<td className="default-column">
{propDefault ? (
<span className="MuiApi-table-item-default">{propDefault}</span>
) : (
'-'
)}
</td>
{hasDefaultColumn && (
<td className="default-column">
{propDefault ? (
<span className="MuiApi-table-item-default">{propDefault}</span>
) : (
'-'
)}
</td>
)}
<td className="MuiPropTable-description-column">
{description && <PropDescription description={description} />}
{seeMoreDescription && (
Expand Down
1 change: 1 addition & 0 deletions docs/translations/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
"overrideStylesStyledComponent": "<ul>\n<li>With a <a href=\"/material-ui/integrations/interoperability/#global-css\">global class name</a>.</li>\n<li>With a rule name as part of the component's <a href=\"{{styleOverridesLink}}\"><code>styleOverrides</code> property</a> in a custom theme.</li>\n</ul>",
"pageDescription": "API reference docs for the React {{name}} component. Learn about the props, CSS, and other APIs of this exported module.",
"props": "Props",
"properties": "Properties",
"parameters": "Parameters",
"requires-ref": "This <a href=\"/material-ui/guides/composition/#caveat-with-refs\">needs to be able to hold a ref</a>.",
"returns": "Returns: ",
Expand Down

0 comments on commit 067cba1

Please sign in to comment.