Skip to content

Commit

Permalink
[ci] format
Browse files Browse the repository at this point in the history
  • Loading branch information
ElianCodes authored and astrobot-houston committed Aug 23, 2023
1 parent eabc4e0 commit 7f13952
Showing 1 changed file with 16 additions and 7 deletions.
23 changes: 16 additions & 7 deletions src/components/tabs/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,17 @@ type Props = {

export default function Tabs({ sharedStore, ...slots }: Props) {
const tabId = genTabId();
const panels = Object.entries(slots).filter(isPanelSlotEntry).filter(panel => !isPanelEmpty(panel));
const tabs = Object.entries(slots).filter(isTabSlotEntry).filter(([key]) => !isPanelEmpty(panels.find(
([panelKey]) => panelKey === `${panelSlotKey}${getBaseKeyFromTab(key)}`
)!));
const panels = Object.entries(slots)
.filter(isPanelSlotEntry)
.filter((panel) => !isPanelEmpty(panel));
const tabs = Object.entries(slots)
.filter(isTabSlotEntry)
.filter(
([key]) =>
!isPanelEmpty(
panels.find(([panelKey]) => panelKey === `${panelSlotKey}${getBaseKeyFromTab(key)}`)!
)
);
/** Used to focus next and previous tab on arrow key press */
const tabButtonRefs = useRef<Record<TabSlot, HTMLButtonElement | null>>({});
const scrollToTabRef = useRef<HTMLButtonElement | null>(null);
Expand All @@ -62,9 +69,11 @@ export default function Tabs({ sharedStore, ...slots }: Props) {

function isPanelEmpty(panel: [`panel.${string}`, ComponentChildren]): boolean {
if (
!panel ||
(typeof panel[1] !== 'object' ? panel[1] : (panel[1] as VNode<Record<string, string>>).props.value.toString()) === ''
) {
!panel ||
(typeof panel[1] !== 'object'
? panel[1]
: (panel[1] as VNode<Record<string, string>>).props.value.toString()) === ''
) {
return true;
}
return false;
Expand Down

0 comments on commit 7f13952

Please sign in to comment.