Skip to content
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

[GEN-2057]: make onClick optional for Tab component and adjust styling #2030

Merged
merged 11 commits into from
Dec 19, 2024
Merged
18 changes: 7 additions & 11 deletions frontend/webapp/reuseable-components/tab-list/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ interface TabProps {
icon: SVG;
selected: boolean;
disabled?: boolean;
onClick: () => void;
onClick?: () => void;
}

// Define types for the TabList component props
Expand All @@ -21,18 +21,18 @@ interface TabListProps {
}

// Styled-components for Tab and TabList
const TabContainer = styled.div<{ $selected: TabProps['selected']; $disabled: TabProps['disabled'] }>`
const TabContainer = styled.div<{ $selected: TabProps['selected']; $disabled: TabProps['disabled']; $noClick: boolean }>`
display: flex;
align-items: center;
padding: 10px 12px;
border-radius: 32px;
cursor: ${({ $disabled }) => ($disabled ? 'not-allowed' : 'pointer')};
background-color: ${({ $selected, theme }) => ($selected ? theme.colors.majestic_blue + hexPercentValues['024'] : theme.colors.card)};
cursor: ${({ $noClick, $disabled }) => ($noClick ? 'unset' : $disabled ? 'not-allowed' : 'pointer')};
background-color: ${({ $noClick, $selected, theme }) => ($noClick ? 'transparent' : $selected ? theme.colors.majestic_blue + hexPercentValues['024'] : theme.colors.card)};
opacity: ${({ $disabled }) => ($disabled ? 0.5 : 1)};
transition: background-color 0.3s, color 0.3s;

&:hover {
background-color: ${({ $disabled, theme }) => ($disabled ? 'none' : theme.colors.majestic_blue + hexPercentValues['024'])};
background-color: ${({ $noClick, $disabled, theme }) => ($noClick || $disabled ? 'none' : theme.colors.majestic_blue + hexPercentValues['024'])};
}

svg {
Expand All @@ -45,11 +45,10 @@ const TabListContainer = styled.div`
gap: 8px;
`;

// Tab component
const Tab: React.FC<TabProps> = ({ title, tooltip, icon: Icon, selected, disabled, onClick }) => {
return (
<Tooltip text={tooltip}>
<TabContainer $selected={selected} $disabled={disabled} onClick={onClick}>
<TabContainer $selected={selected} $disabled={disabled} $noClick={!onClick} onClick={onClick}>
<Icon size={14} />
<Text size={14}>{title}</Text>
</TabContainer>
Expand All @@ -62,7 +61,6 @@ const TABS = [
title: 'Overview',
icon: OverviewIcon,
selected: true,
onClick: () => {},
},
// {
// title: 'Service Map',
Expand All @@ -82,7 +80,7 @@ const TABS = [
// },
];

const TabList: React.FC<TabListProps> = ({ tabs = TABS }) => {
export const TabList: React.FC<TabListProps> = ({ tabs = TABS }) => {
return (
<TabListContainer>
{tabs.map((tab) => (
Expand All @@ -91,5 +89,3 @@ const TabList: React.FC<TabListProps> = ({ tabs = TABS }) => {
</TabListContainer>
);
};

export { TabList };
Loading