Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
Binary file added assets/svg/Loading.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 26 additions & 0 deletions components/segmentedButton.withdraw/SegmentPanel.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import React from 'react';

import Box from '@mui/material/Box';

interface SegmentPanelProps {
children?: React.ReactNode;
index: number;
value: number;
}

export const SegmentPanel = (props: SegmentPanelProps) => {
const { children, value, index, ...other } = props;

return (
<div
role="tabpanel"
hidden={value !== index}
id={`simple-tabpanel-${index}`}
aria-labelledby={`simple-tab-${index}`}
{...other}
className="w-full"
>
{value === index && <Box sx={{ p: 0 }}>{children}</Box>}
</div>
);
};
71 changes: 71 additions & 0 deletions components/segmentedButton.withdraw/SegmentedButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import React, { useState, SyntheticEvent } from 'react';
import { styled } from '@mui/material/styles';
import Box from '@mui/material/Box';
import Tab from '@mui/material/Tab';
import Tabs from '@mui/material/Tabs';


interface SegmentProps {
label: string;
children?: React.ReactNode;
}


interface Props {
tabs: SegmentProps[];
className?: string;
position?: 'vertical' | 'horizontal';
onTabChange?: (event: SyntheticEvent, newValue: number) => void; // Optional callback for handling tab changes
}


const SegmentedButton = ({ tabs, className, position = 'vertical', onTabChange }: Props) => {
const [value, setValue] = useState(0);

const handleChange = (event: SyntheticEvent<Element, Event>, newValue: number) => {
setValue(newValue);
if (onTabChange) {
onTabChange(event, newValue);
}
};


const StyledTab = styled(Tab)(({ theme }) => ({
"&.MuiTab-root": {
color: theme.palette.onSurface.main,
padding: "0.625rem 0",
textTransform: "none",
margin: 0,
width: "50%",
minHeight: "2.5rem",
},
"&.Mui-selected": {
color: theme.palette.onSecondaryContainer.main,
backgroundColor: theme.palette.onSecondaryFixedVariant.main,
}
}));

return (
<Box className={className}>
<Box sx={{ width: position === 'vertical' ? '100%' : 'auto' }}>
<Tabs
className={`${position === 'vertical' && 'mb-6'} min-h-10 rounded-full border border-outline-dark`}
value={value}
onChange={handleChange}
centered
sx={{
".MuiTabs-indicator": {
backgroundColor: 'transparent',
},
}}
>
{tabs.map((tab, index) => (
<StyledTab label={tab.label} key={index} />
))}
</Tabs>
</Box>
</Box>
);
};

export default SegmentedButton;
Loading