Skip to content
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
21 changes: 17 additions & 4 deletions dist/index.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -7888,7 +7888,9 @@ var SidebarElements = ({ slugPrefix, items, subItemLevel }) => {
return false;
};
const getHref = (slugPrefix2, pathSuffix, slug) => {
const href = slugPrefix2 === "docs/api-reference" ? `/${slugPrefix2}/${slug}/${pathSuffix}` : `/${slugPrefix2}/${slug}`;
const validLocales = ["pt", "es"];
const localePrefix = locale && validLocales.includes(locale) ? `/${locale}` : "";
const href = slugPrefix2 === "docs/api-reference" ? `/${slugPrefix2}/${slug}/${pathSuffix}` : `${localePrefix}/${slugPrefix2}/${slug}`;
return href.replaceAll("//", "/");
};
const ElementRoot = ({
Expand Down Expand Up @@ -7921,7 +7923,11 @@ var SidebarElements = ({ slugPrefix, items, subItemLevel }) => {
onClick: () => toggleSidebarElementStatus(localizedSlug)
}
),
!checkDocumentationType(sidebarDataMaster, localizedSlug, "category") && !checkDocumentationType(sidebarDataMaster, localizedSlug, "link") ? /* @__PURE__ */ jsxs12(
!checkDocumentationType(
sidebarDataMaster,
localizedSlug,
"category"
) && !checkDocumentationType(sidebarDataMaster, localizedSlug, "link") ? /* @__PURE__ */ jsxs12(
Link4,
{
sx: textStyle(activeSidebarElement === activeItem, isExpandable),
Expand All @@ -7946,13 +7952,20 @@ var SidebarElements = ({ slugPrefix, items, subItemLevel }) => {
localizedName
]
}
) : checkDocumentationType(sidebarDataMaster, localizedSlug, "link") ? /* @__PURE__ */ jsxs12(Link4, { href: localizedSlug, target: "_blank", sx: styles_default12.elementText, children: [
) : checkDocumentationType(
sidebarDataMaster,
localizedSlug,
"link"
) ? /* @__PURE__ */ jsxs12(Link4, { href: localizedSlug, target: "_blank", sx: styles_default12.elementText, children: [
/* @__PURE__ */ jsx17(IconExternalLink, { size: 16, sx: { marginRight: "10px" } }),
localizedName
] }) : /* @__PURE__ */ jsxs12(
Box10,
{
sx: textStyle(activeSidebarElement === localizedSlug, isExpandable),
sx: textStyle(
activeSidebarElement === localizedSlug,
isExpandable
),
onClick: () => {
toggleSidebarElementStatus(localizedSlug);
},
Expand Down
2 changes: 1 addition & 1 deletion dist/index.mjs.map

Large diffs are not rendered by default.

42 changes: 32 additions & 10 deletions src/components/sidebar-elements/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,13 @@ const SidebarElements = ({ slugPrefix, items, subItemLevel }: SidebarProps) => {
}

const getHref = (slugPrefix: string, pathSuffix: string, slug: string) => {
const validLocales = ['pt', 'es']
const localePrefix =
locale && validLocales.includes(locale) ? `/${locale}` : ''
const href =
slugPrefix === 'docs/api-reference'
? `/${slugPrefix}/${slug}/${pathSuffix}`
: `/${slugPrefix}/${slug}`
: `${localePrefix}/${slugPrefix}/${slug}`
return href.replaceAll('//', '/')
}

Expand All @@ -119,14 +122,16 @@ const SidebarElements = ({ slugPrefix, items, subItemLevel }: SidebarProps) => {
{isExpandable && (
<Button
aria-label={
sidebarElementStatus.has(localizedSlug) && sidebarElementStatus.get(localizedSlug)
sidebarElementStatus.has(localizedSlug) &&
sidebarElementStatus.get(localizedSlug)
? 'Collapse category'
: 'Expand category'
}
size="regular"
variant="tertiary"
sx={
sidebarElementStatus.has(localizedSlug) && sidebarElementStatus.get(localizedSlug)
sidebarElementStatus.has(localizedSlug) &&
sidebarElementStatus.get(localizedSlug)
? styles.arrowIconActive
: styles.arrowIcon
}
Expand All @@ -144,7 +149,11 @@ const SidebarElements = ({ slugPrefix, items, subItemLevel }: SidebarProps) => {
onClick={() => toggleSidebarElementStatus(localizedSlug)}
/>
)}
{!checkDocumentationType(sidebarDataMaster, localizedSlug, 'category') &&
{!checkDocumentationType(
sidebarDataMaster,
localizedSlug,
'category'
) &&
!checkDocumentationType(sidebarDataMaster, localizedSlug, 'link') ? (
<Link
sx={textStyle(activeSidebarElement === activeItem, isExpandable)}
Expand All @@ -167,14 +176,21 @@ const SidebarElements = ({ slugPrefix, items, subItemLevel }: SidebarProps) => {
)}
{localizedName}
</Link>
) : checkDocumentationType(sidebarDataMaster, localizedSlug, 'link') ? (
) : checkDocumentationType(
sidebarDataMaster,
localizedSlug,
'link'
) ? (
<Link href={localizedSlug} target="_blank" sx={styles.elementText}>
<IconExternalLink size={16} sx={{ marginRight: '10px' }} />
{localizedName}
</Link>
) : (
<Box
sx={textStyle(activeSidebarElement === localizedSlug, isExpandable)}
sx={textStyle(
activeSidebarElement === localizedSlug,
isExpandable
)}
onClick={() => {
toggleSidebarElementStatus(localizedSlug)
}}
Expand All @@ -194,7 +210,7 @@ const SidebarElements = ({ slugPrefix, items, subItemLevel }: SidebarProps) => {
</Box>
)
}

const ElementChildren = ({ slug, children }: SidebarElement) => {
const isExpandable = children.length > 0
// const newPathPrefix =
Expand All @@ -218,9 +234,15 @@ const SidebarElements = ({ slugPrefix, items, subItemLevel }: SidebarProps) => {
return (
<Box className="sidebar-component">
{items?.map((item, index) => {
const key = typeof item.slug === 'string' ? String(item.slug) + String(index) : String(item.slug[locale]) + String(index)
const slug = typeof item.slug === 'string' ? `${item.slug}` : `${item.slug[locale]}`

const key =
typeof item.slug === 'string'
? String(item.slug) + String(index)
: String(item.slug[locale]) + String(index)
const slug =
typeof item.slug === 'string'
? `${item.slug}`
: `${item.slug[locale]}`

return (
<Fragment key={String(key)}>
<ElementRoot {...item} slug={slug} />
Expand Down
Loading