refactor: update Tabs component structure and theme colors (#6638)

- Replaced the div wrapper in the Tabs component with StyledWrapper for improved styling.
- Simplified TabsList and TabsTrigger components by removing theme dependency and using classnames for styling.
- Updated inactive background colors in multiple theme files to enhance visual consistency across themes.
This commit is contained in:
Abhishek S Lal
2026-01-02 22:01:35 +05:30
committed by GitHub
parent 1e3a0d9af3
commit 33361ba659
15 changed files with 61 additions and 37 deletions

View File

@@ -0,0 +1,37 @@
import styled from 'styled-components';
const StyledWrapper = styled.div`
.tabs-list {
display: inline-flex;
height: 2rem;
width: fit-content;
justify-content: center;
gap: 0.25rem;
}
.tab-trigger {
display: inline-flex;
align-items: center;
justify-content: center;
border-radius: 4px;
padding: 8px;
font-size: 0.75rem;
white-space: nowrap;
cursor: pointer;
border: 1px solid transparent;
background: transparent;
color: ${(props) => props.theme.tabs.secondary.inactive.color};
transition: all 0.15s ease;
&:hover {
background: ${(props) => props.theme.tabs.secondary.inactive.bg};
}
&.active {
background: ${(props) => props.theme.tabs.secondary.active.bg};
color: ${(props) => props.theme.tabs.secondary.active.color};
}
}
`;
export default StyledWrapper;

View File

@@ -1,42 +1,29 @@
import React, { createContext, useContext } from 'react';
import { useTheme } from 'providers/Theme';
import classnames from 'classnames';
import StyledWrapper from './StyledWrapper';
const TabsContext = createContext();
export const Tabs = ({ value, onValueChange, children, className = '' }) => {
return (
<TabsContext.Provider value={{ value, onValueChange }}>
<div className={`flex flex-col h-full flex-1 ${className}`}>{children}</div>
<StyledWrapper className={`flex flex-col h-full flex-1 ${className}`}>{children}</StyledWrapper>
</TabsContext.Provider>
);
};
export const TabsList = ({ children, className = '' }) => {
const { theme } = useTheme();
return (
<div
className={`inline-flex h-8 w-fit justify-center rounded-md p-0.5 gap-[2px] ${className}`}
style={{ background: theme.tabs.secondary.inactive.bg }}
>
{children}
</div>
);
return <div className={`tabs-list ${className}`}>{children}</div>;
};
export const TabsTrigger = ({ value: triggerValue, children, className = '' }) => {
const { value, onValueChange } = useContext(TabsContext);
const { theme } = useTheme();
const isActive = value === triggerValue;
return (
<button
onClick={() => onValueChange(triggerValue)}
className={`inline-flex items-center justify-center rounded-[4px] p-[8px] text-xs whitespace-nowrap transition-all cursor-pointer border border-transparent hover:opacity-90 ${className}`}
style={{
background: isActive ? theme.tabs.secondary.active.bg : 'transparent',
color: isActive ? theme.tabs.secondary.active.color : theme.tabs.secondary.inactive.color
}}
className={classnames('tab-trigger', className, { active: isActive })}
>
{children}
</button>

View File

@@ -370,7 +370,7 @@ const catppuccinFrappeTheme = {
color: colors.TEXT
},
inactive: {
bg: colors.SURFACE1,
bg: colors.SURFACE0,
color: colors.SUBTEXT0
}
}

View File

@@ -370,7 +370,7 @@ const catppuccinMacchiatoTheme = {
color: colors.TEXT
},
inactive: {
bg: colors.SURFACE1,
bg: colors.SURFACE0,
color: colors.SUBTEXT0
}
}

View File

@@ -370,7 +370,7 @@ const catppuccinMochaTheme = {
color: colors.TEXT
},
inactive: {
bg: colors.SURFACE1,
bg: colors.SURFACE0,
color: colors.SUBTEXT0
}
}

View File

@@ -353,12 +353,12 @@ const darkMonochromeTheme = {
},
secondary: {
active: {
bg: '#2D2D2D',
bg: '#3F3F3F',
color: '#CCCCCC'
},
inactive: {
bg: '#3F3F3F',
color: '#CCCCCC'
color: '#999999'
}
}
},

View File

@@ -374,7 +374,7 @@ const darkPastelTheme = {
color: colors.TEXT
},
inactive: {
bg: colors.GRAY_4,
bg: colors.GRAY_3,
color: colors.TEXT_MUTED
}
}

View File

@@ -398,12 +398,12 @@ const darkTheme = {
},
secondary: {
active: {
bg: '#2D2D2D',
color: '#CCCCCC'
bg: palette.background.SURFACE0,
color: palette.text.BASE
},
inactive: {
bg: '#3F3F3F',
color: '#CCCCCC'
bg: palette.background.SURFACE0,
color: palette.text.SUBTEXT1
}
}
},

View File

@@ -373,7 +373,7 @@ const nordTheme = {
color: colors.NORD4
},
inactive: {
bg: colors.NORD3,
bg: colors.NORD2,
color: colors.NORD4
}
}

View File

@@ -376,7 +376,7 @@ const vscodeDarkTheme = {
color: colors.TEXT
},
inactive: {
bg: colors.GRAY_4,
bg: colors.GRAY_3,
color: colors.TEXT_MUTED
}
}

View File

@@ -363,7 +363,7 @@ const catppuccinLatteTheme = {
},
secondary: {
active: {
bg: colors.BASE,
bg: colors.SURFACE0,
color: colors.TEXT
},
inactive: {

View File

@@ -351,7 +351,7 @@ const lightMonochromeTheme = {
},
secondary: {
active: {
bg: '#FFFFFF',
bg: '#ECECEE',
color: '#343434'
},
inactive: {

View File

@@ -367,7 +367,7 @@ const lightPastelTheme = {
},
secondary: {
active: {
bg: colors.WHITE,
bg: colors.GRAY_2,
color: colors.TEXT
},
inactive: {

View File

@@ -387,12 +387,12 @@ const lightTheme = {
},
secondary: {
active: {
bg: palette.background.BASE,
bg: palette.background.SURFACE1,
color: palette.text.BASE
},
inactive: {
bg: palette.background.SURFACE1,
color: palette.text.BASE
bg: palette.background.SURFACE0,
color: palette.text.SUBTEXT1
}
}
},

View File

@@ -371,7 +371,7 @@ const vscodeLightTheme = {
},
secondary: {
active: {
bg: colors.WHITE,
bg: colors.GRAY_2,
color: colors.TEXT
},
inactive: {