Skip to content

Commit

Permalink
feat: implement bordered variant for tabs component
Browse files Browse the repository at this point in the history
  • Loading branch information
Ikari-Shinji-re authored and nikaaru committed Sep 9, 2024
1 parent 0f65ab1 commit 1de8888
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 1 deletion.
33 changes: 33 additions & 0 deletions widget/ui/src/components/Tabs/Tabs.styles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export const Tabs = styled('div', {
borderStyle: 'solid',
backgroundColor: '$$color',
},
bordered: { backgroundColor: 'inherit' },
},
borderRadius: {
small: {
Expand All @@ -34,12 +35,16 @@ export const Tabs = styled('div', {
full: {
borderRadius: '$xm',
},
none: {
borderRadius: 'unset',
},
},
},
});

export const Tab = styled(Button, {
color: '$neutral700',
flex: 1,
backgroundColor: 'transparent',
height: '100%',
zIndex: 10,
Expand All @@ -60,13 +65,17 @@ export const Tab = styled(Button, {
full: {
borderRadius: '$xm',
},
none: {
borderRadius: 'unset',
},
},
type: {
primary: {
padding: '$5 $10',
height: '100%',
},
secondary: {},
bordered: {},
},
isActive: {
true: {
Expand Down Expand Up @@ -122,6 +131,24 @@ export const Tab = styled(Button, {
},
},
},
{
type: 'bordered',
isActive: true,
css: {
color: '$secondary500',
},
},
{
type: 'bordered',
isActive: false,
css: {
color: '$neutral600',
fontWeight: '$regular',
'&:hover': {
color: '$secondary550',
},
},
},
],
});

Expand All @@ -141,6 +168,9 @@ export const BackdropTab = styled('div', {
primary: {
backgroundColor: '$background',
},
bordered: {
borderBottom: '$secondary500 solid 2px',
},
},
borderRadius: {
small: {
Expand All @@ -152,6 +182,9 @@ export const BackdropTab = styled('div', {
full: {
borderRadius: '$xm',
},
none: {
borderRadius: 'unset',
},
},
},
});
7 changes: 6 additions & 1 deletion widget/ui/src/components/Tabs/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export function TabsComponent(props: TabsPropTypes) {
container = document.body,
value,
type,
borderRadius = 'medium',
className,
} = props;
const [tabWidth, setTabWidth] = useState(0);
Expand All @@ -25,6 +24,12 @@ export function TabsComponent(props: TabsPropTypes) {
// State variable to track the initial render
const [initialRender, setInitialRender] = useState(true);
const transformPosition = currentIndex * tabWidth;
let borderRadius: TabsPropTypes['borderRadius'] = 'medium';
if (type === 'bordered') {
borderRadius = 'none';
} else if (props.borderRadius) {
borderRadius = props.borderRadius;
}

useEffect(() => {
const updateTabWidth = () => {
Expand Down

0 comments on commit 1de8888

Please sign in to comment.