Skip to content

Dev tab - Don't render empty sections or the tab #3600

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

Merged
merged 2 commits into from
Mar 12, 2025
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: 4 additions & 2 deletions docuilib/src/components/ComponentPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,12 @@ export default function ComponentPage({component}) {

const buildTabs = () => {
const tabs = component.docs?.tabs;

const api = component.props;
const tabsArray = api ? [...tabs, devTab] : tabs;

// TODO: align Tabs bottom border with TabItem's selected indication line
if (tabs) {
return <Tabs className="main-tabs">{getTabItems([...tabs, devTab])}</Tabs>;
return <Tabs className="main-tabs">{getTabItems(tabsArray)}</Tabs>;
Comment on lines +63 to +68
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we remove Dev tab based on props, it won't render things like notes and tips, no?
Which component/page has this issue (has no api)?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's why I based it on the props - that the most important feature that without it I don't think we need the tab.
Can you think of a case where we don't have props but need to display the extend/modifiers/snippet?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really, approving, worse case we'll change it

}
};

Expand Down
4 changes: 4 additions & 0 deletions docuilib/src/components/pageComponents/Banner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ export const Banner = ({section, component}) => {
const _title = title || getTitle(type);
const _description = description || getDescription(type);

if (!_description) {
return null;
}

return (
<div
className="row"
Expand Down
34 changes: 20 additions & 14 deletions docuilib/src/components/pageComponents/SectionHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,25 @@ export const SectionHeader = ({section, component}) => {
return type === 'item' ? '#6E7881' : '#495059';
};

const getUsageTitle = () => {
if (component.snippet) {
return (
<div
style={{
display: 'flex',
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
marginBottom: 12
}}
>
{getTitle(type, title)}
{getCodeExampleLink()}
</div>
);
}
};

const getCodeExampleLink = () => {
return (
<a
Expand Down Expand Up @@ -66,20 +85,7 @@ export const SectionHeader = ({section, component}) => {

switch (type) {
case 'usage':
return (
<div
style={{
display: 'flex',
flexDirection: 'row',
alignItems: 'center',
justifyContent: 'space-between',
marginBottom: 12
}}
>
{getTitle(type, title)}
{getCodeExampleLink()}
</div>
);
return getUsageTitle();
default:
return (
<div
Expand Down
32 changes: 0 additions & 32 deletions src/components/test.api.json
Original file line number Diff line number Diff line change
Expand Up @@ -285,38 +285,6 @@
"description": "html:<h2>Title</h2><p>This is a html content</p><ul><li>item 1</li><li>item 2</li></ul>"
}
]
},
{
"title": "Code",
"sections": [
{
"title": "Usage",
"type": "usage"
},
{
"type": "info"
},
{
"type": "tip"
},
{
"type": "banner",
"title": "NOTE",
"description": "This is an interesting information"
},
{
"type": "banner",
"title": "Banner",
"description": "This is some massage to the user",
"color": "pink",
"icon": ""
},
{
"type": "props",
"title": "API",
"description": "This is the list of additional props for the Text component"
}
]
}
]
}
Expand Down