feat(ui): unified tab-switch animation - enter-only fade in TabPanel

One 0.2s enter-only fade (opacity + 6px rise) in the kit TabPanel covers
every tab switch (M3 clean-fade pattern; CSS animation so the global
reduced-motion kill switch applies). Orders and Invoices view switchers
now render through TabPanel (also fixes their dangling aria-controls).
Removed the inconsistent bespoke framer entrances inside tab content
(CompanySettings cascade, ReceivedInvoices card). Filter-style status
tabs (Projects/Offers/Invoices) deliberately keep the refetch dim only.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
BOHA
2026-06-12 18:04:32 +02:00
parent bf33d0a543
commit b9103c59f0
5 changed files with 878 additions and 919 deletions

View File

@@ -8,7 +8,6 @@ import {
type CompanySettingsData, type CompanySettingsData,
} from "../lib/queries/settings"; } from "../lib/queries/settings";
import { bankAccountsOptions, type BankAccount } from "../lib/queries/common"; import { bankAccountsOptions, type BankAccount } from "../lib/queries/common";
import { motion } from "framer-motion";
import Box from "@mui/material/Box"; import Box from "@mui/material/Box";
import Typography from "@mui/material/Typography"; import Typography from "@mui/material/Typography";
import IconButton from "@mui/material/IconButton"; import IconButton from "@mui/material/IconButton";
@@ -633,11 +632,6 @@ export default function CompanySettings({
return ( return (
<Box> <Box>
{!embedded && ( {!embedded && (
<motion.div
initial={{ opacity: 0, y: 12 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.25 }}
>
<Box <Box
sx={{ sx={{
display: "flex", display: "flex",
@@ -650,11 +644,7 @@ export default function CompanySettings({
> >
<Box> <Box>
<Typography variant="h4">Nastavení firmy</Typography> <Typography variant="h4">Nastavení firmy</Typography>
<Typography <Typography variant="body2" color="text.secondary" sx={{ mt: 0.5 }}>
variant="body2"
color="text.secondary"
sx={{ mt: 0.5 }}
>
Firemní údaje a bankovní účty Firemní údaje a bankovní účty
</Typography> </Typography>
</Box> </Box>
@@ -662,7 +652,6 @@ export default function CompanySettings({
{saving ? "Ukládání..." : "Uložit nastavení"} {saving ? "Ukládání..." : "Uložit nastavení"}
</Button> </Button>
</Box> </Box>
</motion.div>
)} )}
<Box <Box
@@ -674,11 +663,6 @@ export default function CompanySettings({
> >
{/* Company Info */} {/* Company Info */}
{(canEditCompany || !embedded) && ( {(canEditCompany || !embedded) && (
<motion.div
initial={{ opacity: 0, y: 12 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.25, delay: 0.06 }}
>
<Card> <Card>
<Typography variant="h6" sx={{ mb: 2 }}> <Typography variant="h6" sx={{ mb: 2 }}>
Firemní údaje Firemní údaje
@@ -834,10 +818,7 @@ export default function CompanySettings({
<Box sx={{ mt: 0.5 }}> <Box sx={{ mt: 0.5 }}>
<CheckboxField <CheckboxField
label={ label={
<Typography <Typography variant="body2" sx={{ fontSize: "0.8rem" }}>
variant="body2"
sx={{ fontSize: "0.8rem" }}
>
Zobrazit název v PDF Zobrazit název v PDF
</Typography> </Typography>
} }
@@ -876,16 +857,10 @@ export default function CompanySettings({
</Button> </Button>
</Box> </Box>
</Card> </Card>
</motion.div>
)} )}
{/* Bank Accounts */} {/* Bank Accounts */}
{(canManageBanking || !embedded) && ( {(canManageBanking || !embedded) && (
<motion.div
initial={{ opacity: 0, y: 12 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.25, delay: 0.08 }}
>
<Card> <Card>
<Typography variant="h6" sx={{ mb: 2 }}> <Typography variant="h6" sx={{ mb: 2 }}>
Bankovní účty Bankovní účty
@@ -921,9 +896,7 @@ export default function CompanySettings({
color="text.secondary" color="text.secondary"
sx={{ mb: 1.5 }} sx={{ mb: 1.5 }}
> >
{editingBank !== null {editingBank !== null ? "Upravit účet" : "Přidat nový účet"}
? "Upravit účet"
: "Přidat nový účet"}
</Typography> </Typography>
<Box <Box
sx={{ sx={{
@@ -1046,16 +1019,10 @@ export default function CompanySettings({
</> </>
)} )}
</Card> </Card>
</motion.div>
)} )}
{/* PDF Field Order */} {/* PDF Field Order */}
{(canEditCompany || !embedded) && ( {(canEditCompany || !embedded) && (
<motion.div
initial={{ opacity: 0, y: 12 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.25, delay: 0.08 }}
>
<Card> <Card>
<Typography variant="h6" sx={{ mb: 2 }}> <Typography variant="h6" sx={{ mb: 2 }}>
Pořadí polí dodavatele v PDF Pořadí polí dodavatele v PDF
@@ -1119,16 +1086,10 @@ export default function CompanySettings({
))} ))}
</Box> </Box>
</Card> </Card>
</motion.div>
)} )}
{/* Document Numbering */} {/* Document Numbering */}
{(canEditCompany || !embedded) && ( {(canEditCompany || !embedded) && (
<motion.div
initial={{ opacity: 0, y: 12 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.25, delay: 0.1 }}
>
<Card> <Card>
<Typography variant="h6" sx={{ mb: 2 }}> <Typography variant="h6" sx={{ mb: 2 }}>
Číslování dokladů Číslování dokladů
@@ -1143,11 +1104,11 @@ export default function CompanySettings({
mb: 2, mb: 2,
}} }}
> >
<strong>Dostupné zástupné znaky:</strong>{" "} <strong>Dostupné zástupné znaky:</strong> <code>{"{YYYY}"}</code>{" "}
<code>{"{YYYY}"}</code> rok, <code>{"{YY}"}</code> rok (2 rok, <code>{"{YY}"}</code> rok (2 číslice),{" "}
číslice), <code>{"{PREFIX}"}</code> prefix (nabídky / sklad),{" "} <code>{"{PREFIX}"}</code> prefix (nabídky / sklad),{" "}
<code>{"{CODE}"}</code> typový kód, <code>{"{NNN}"}</code>{" "} <code>{"{CODE}"}</code> typový kód, <code>{"{NNN}"}</code> pořadí
pořadí (3 číslice), <code>{"{NNNN}"}</code> pořadí (4 číslice),{" "} (3 číslice), <code>{"{NNNN}"}</code> pořadí (4 číslice),{" "}
<code>{"{NNNNN}"}</code> pořadí (5 číslic) <code>{"{NNNNN}"}</code> pořadí (5 číslic)
</Box> </Box>
{[ {[
@@ -1310,16 +1271,10 @@ export default function CompanySettings({
); );
})} })}
</Card> </Card>
</motion.div>
)} )}
{/* Currency & VAT */} {/* Currency & VAT */}
{(canEditCompany || !embedded) && ( {(canEditCompany || !embedded) && (
<motion.div
initial={{ opacity: 0, y: 12 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.25, delay: 0.12 }}
>
<Card> <Card>
<Typography variant="h6" sx={{ mb: 2 }}> <Typography variant="h6" sx={{ mb: 2 }}>
Měna a DPH Měna a DPH
@@ -1383,16 +1338,10 @@ export default function CompanySettings({
</Field> </Field>
</Box> </Box>
</Card> </Card>
</motion.div>
)} )}
{/* Logo */} {/* Logo */}
{(canEditCompany || !embedded) && ( {(canEditCompany || !embedded) && (
<motion.div
initial={{ opacity: 0, y: 12 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.25, delay: 0.14 }}
>
<Card> <Card>
<Typography variant="h6" sx={{ mb: 2 }}> <Typography variant="h6" sx={{ mb: 2 }}>
Logo Logo
@@ -1506,25 +1455,13 @@ export default function CompanySettings({
</Box> </Box>
</Box> </Box>
</Card> </Card>
</motion.div>
)} )}
</Box> </Box>
{embedded && canEditCompany && ( {embedded && canEditCompany && (
<motion.div <Button onClick={handleSave} fullWidth sx={{ mt: 2 }} disabled={saving}>
initial={{ opacity: 0, y: 12 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.25, delay: 0.2 }}
>
<Button
onClick={handleSave}
fullWidth
sx={{ mt: 2 }}
disabled={saving}
>
{saving ? "Ukládání..." : "Uložit nastavení firmy"} {saving ? "Ukládání..." : "Uložit nastavení firmy"}
</Button> </Button>
</motion.div>
)} )}
<ConfirmDialog <ConfirmDialog

View File

@@ -40,6 +40,7 @@ import {
LoadingState, LoadingState,
FilterBar, FilterBar,
Tabs, Tabs,
TabPanel,
PageHeader, PageHeader,
PageEnter, PageEnter,
type DataColumn, type DataColumn,
@@ -706,7 +707,7 @@ export default function Invoices() {
</Box> </Box>
</Box> </Box>
{activeTab === "received" ? ( <TabPanel value="received" current={activeTab} sx={{ pt: 0 }}>
<Suspense fallback={<LoadingState />}> <Suspense fallback={<LoadingState />}>
<ReceivedInvoices <ReceivedInvoices
statsMonth={statsMonth} statsMonth={statsMonth}
@@ -715,7 +716,8 @@ export default function Invoices() {
setUploadOpen={setReceivedUploadOpen} setUploadOpen={setReceivedUploadOpen}
/> />
</Suspense> </Suspense>
) : ( </TabPanel>
<TabPanel value="issued" current={activeTab} sx={{ pt: 0 }}>
<> <>
{renderKpi()} {renderKpi()}
@@ -808,7 +810,7 @@ export default function Invoices() {
loading={deleting} loading={deleting}
/> />
</> </>
)} </TabPanel>
</PageEnter> </PageEnter>
); );
} }

View File

@@ -5,7 +5,14 @@ import Typography from "@mui/material/Typography";
import IconButton from "@mui/material/IconButton"; import IconButton from "@mui/material/IconButton";
import { useAuth } from "../context/AuthContext"; import { useAuth } from "../context/AuthContext";
import Forbidden from "../components/Forbidden"; import Forbidden from "../components/Forbidden";
import { Button, Tabs, PageHeader, PageEnter, LoadingState } from "../ui"; import {
Button,
Tabs,
TabPanel,
PageHeader,
PageEnter,
LoadingState,
} from "../ui";
import OrdersReceived from "./ReceivedOrders"; import OrdersReceived from "./ReceivedOrders";
const IssuedOrders = lazy(() => import("./IssuedOrders")); const IssuedOrders = lazy(() => import("./IssuedOrders"));
@@ -170,18 +177,19 @@ export default function Orders() {
</Box> </Box>
</Box> </Box>
{activeTab === "vydane" ? ( <TabPanel value="vydane" current={activeTab} sx={{ pt: 0 }}>
<Suspense fallback={<LoadingState />}> <Suspense fallback={<LoadingState />}>
<IssuedOrders month={statsMonth} year={statsYear} /> <IssuedOrders month={statsMonth} year={statsYear} />
</Suspense> </Suspense>
) : ( </TabPanel>
<TabPanel value="prijate" current={activeTab} sx={{ pt: 0 }}>
<OrdersReceived <OrdersReceived
month={statsMonth} month={statsMonth}
year={statsYear} year={statsYear}
createOpen={createOpen} createOpen={createOpen}
setCreateOpen={setCreateOpen} setCreateOpen={setCreateOpen}
/> />
)} </TabPanel>
</PageEnter> </PageEnter>
); );
} }

View File

@@ -1,6 +1,5 @@
import { useState, useEffect, useRef } from "react"; import { useState, useEffect, useRef } from "react";
import { useQuery, useQueryClient } from "@tanstack/react-query"; import { useQuery, useQueryClient } from "@tanstack/react-query";
import { motion } from "framer-motion";
import Box from "@mui/material/Box"; import Box from "@mui/material/Box";
import Typography from "@mui/material/Typography"; import Typography from "@mui/material/Typography";
import IconButton from "@mui/material/IconButton"; import IconButton from "@mui/material/IconButton";
@@ -810,11 +809,6 @@ export default function ReceivedInvoices({
<> <>
{renderKpi()} {renderKpi()}
<motion.div
initial={{ opacity: 0, y: 12 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.25, delay: 0.08 }}
>
<Card> <Card>
<FilterBar> <FilterBar>
<Box sx={{ flex: "1 1 320px" }}> <Box sx={{ flex: "1 1 320px" }}>
@@ -876,7 +870,6 @@ export default function ReceivedInvoices({
</Box> </Box>
)} )}
</Card> </Card>
</motion.div>
{/* Upload Modal */} {/* Upload Modal */}
<Modal <Modal

View File

@@ -2,6 +2,8 @@ import type { ReactNode } from "react";
import MuiTabs from "@mui/material/Tabs"; import MuiTabs from "@mui/material/Tabs";
import Tab from "@mui/material/Tab"; import Tab from "@mui/material/Tab";
import Box from "@mui/material/Box"; import Box from "@mui/material/Box";
import { keyframes } from "@mui/system";
import type { SxProps, Theme } from "@mui/material/styles";
export interface TabDef { export interface TabDef {
value: string; value: string;
@@ -47,15 +49,26 @@ export function Tabs({
); );
} }
// The ONE tab-switch animation, app-wide: enter-only fade of the incoming
// panel (M3 "clean fade" — old content drops instantly, no exit/slide; tabs
// are too high-frequency for anything longer). Kept as a CSS animation so the
// global prefers-reduced-motion kill switch in GlobalStyles neutralizes it.
const panelEnter = keyframes({
from: { opacity: 0, transform: "translateY(6px)" },
to: { opacity: 1, transform: "none" },
});
/** Renders children only when its value matches the current tab. */ /** Renders children only when its value matches the current tab. */
export function TabPanel({ export function TabPanel({
value, value,
current, current,
children, children,
sx,
}: { }: {
value: string; value: string;
current: string; current: string;
children: ReactNode; children: ReactNode;
sx?: SxProps<Theme>;
}) { }) {
if (value !== current) return null; if (value !== current) return null;
return ( return (
@@ -63,7 +76,13 @@ export function TabPanel({
role="tabpanel" role="tabpanel"
id={panelId(value)} id={panelId(value)}
aria-labelledby={tabId(value)} aria-labelledby={tabId(value)}
sx={{ pt: 2.5 }} sx={[
{
pt: 2.5,
animation: `${panelEnter} 0.2s cubic-bezier(0.16, 1, 0.3, 1)`,
},
...(Array.isArray(sx) ? sx : [sx]),
]}
> >
{children} {children}
</Box> </Box>