Skip to content

Commit

Permalink
[ci] lint
Browse files Browse the repository at this point in the history
  • Loading branch information
studiocms-no-reply committed Dec 22, 2024
1 parent 58e223c commit a8e0387
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions packages/studiocms_ui/src/components/Tabs/Tabs.astro
Original file line number Diff line number Diff line change
Expand Up @@ -77,20 +77,23 @@ const extractTabInfoWithRegex = (input: string) => {
const markTabAsActive = (tabId: string, html: string): string => {
if (!tabId) return html;
const updatedHtml = html.replace(/<sui-tab-item[^>]*data-tab-id="([^"]*)"[^>]*>/g, (match, tabIdValue) => {
// Check if the tabId matches
if (tabIdValue === tabId) {
// Check if the element already has a class attribute
if (match.includes('class="')) {
// If class attribute exists, add 'active' to the class attribute
return match.replace(/(class="[^"]*)"/, '$1 active"');
}
// If class attribute does not exist, add it
return match.replace(/(<sui-tab-item[^>]*data-tab-id="[^"]*")/, '$1 class="active"');
}
return match; // Return original if the tabId does not match
});
const updatedHtml = html.replace(
/<sui-tab-item[^>]*data-tab-id="([^"]*)"[^>]*>/g,
(match, tabIdValue) => {
// Check if the tabId matches
if (tabIdValue === tabId) {
// Check if the element already has a class attribute
if (match.includes('class="')) {
// If class attribute exists, add 'active' to the class attribute
return match.replace(/(class="[^"]*)"/, '$1 active"');
}
// If class attribute does not exist, add it
return match.replace(/(<sui-tab-item[^>]*data-tab-id="[^"]*")/, '$1 class="active"');
}
return match; // Return original if the tabId does not match
}
);
return updatedHtml;
};
Expand Down

0 comments on commit a8e0387

Please sign in to comment.