auto tabs only on profile
This commit is contained in:
parent
0379e41f3b
commit
f590fd6081
@ -17,6 +17,7 @@ interface TabsProps {
|
||||
|
||||
interface TabElementProps extends Omit<TabsProps, "tabs"> {
|
||||
t: Tab;
|
||||
autoWidth?: boolean;
|
||||
}
|
||||
|
||||
function clamp(n: number, min: number, max: number) {
|
||||
@ -29,10 +30,10 @@ function clamp(n: number, min: number, max: number) {
|
||||
return n;
|
||||
}
|
||||
|
||||
export const TabElement = ({ t, tab, setTab }: TabElementProps) => {
|
||||
export const TabElement = ({ autoWidth, t, tab, setTab }: TabElementProps) => {
|
||||
const style = useMemo(() => {
|
||||
return { minWidth: `${clamp(t.text.length, 3, 8) * 14}px` } as CSSProperties;
|
||||
}, [t.text]);
|
||||
return autoWidth ? ({ minWidth: `${clamp(t.text.length, 3, 8) * 16}px` } as CSSProperties) : {};
|
||||
}, [t.text, autoWidth]);
|
||||
return (
|
||||
<div
|
||||
className={`tab ${tab.value === t.value ? "active" : ""} ${t.disabled ? "disabled" : ""}`}
|
||||
|
@ -301,7 +301,7 @@ export default function ProfilePage() {
|
||||
}
|
||||
|
||||
function renderTab(v: Tab) {
|
||||
return <TabElement key={v.value} t={v} tab={tab} setTab={setTab} />;
|
||||
return <TabElement autoWidth={true} key={v.value} t={v} tab={tab} setTab={setTab} />;
|
||||
}
|
||||
|
||||
const w = window.document.querySelector(".page")?.clientWidth;
|
||||
|
Loading…
x
Reference in New Issue
Block a user