Skip to content

Commit

Permalink
feat(menu-footer): improved menu footer
Browse files Browse the repository at this point in the history
  • Loading branch information
mrviniciux committed Nov 7, 2024
1 parent 304bdf9 commit de878ed
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/app/[locale]/ClientLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import { DashboardLayout } from '@toolpad/core/DashboardLayout';
import { PageContainer } from '@toolpad/core/PageContainer';
import { useTranslations } from 'next-intl';
import LanguageSelector from '@/components/LanguageSelector';
import FooterMenu from '@/components/FooterMenu';

type ClientLayoutProps = {
locale: string;
Expand All @@ -35,7 +36,7 @@ export default function ClientLayout({ locale, children }: ClientLayoutProps) {
<SessionProvider>
<QueryClientProvider client={queryClient}>
<Auth>
<DashboardLayout slots={{ sidebarFooter: LanguageSelector }}>
<DashboardLayout slots={{ sidebarFooter: FooterMenu }}>
<PageContainer maxWidth={false}>{children}</PageContainer>
</DashboardLayout>
</Auth>
Expand Down
18 changes: 18 additions & 0 deletions src/components/FooterMenu/FooterMenu.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { Box, Typography } from '@mui/material';
import LanguageSelector from '../LanguageSelector';
import Link from 'next/link';

function FooterMenu() {
return (
<Box>
<LanguageSelector labeled />

<Typography variant="caption" paddingLeft={2}>
Developed by:{' '}
<Link href={'https://github.com/mrviniciux'}>@mrviniciux</Link> - 2024
</Typography>
</Box>
);
}

export default FooterMenu;
1 change: 1 addition & 0 deletions src/components/FooterMenu/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { default } from './FooterMenu';
25 changes: 21 additions & 4 deletions src/components/LanguageSelector/LanguageSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,23 @@ import {
MenuItem,
FormControl,
SelectChangeEvent,
Container,
Typography,
Box,
} from '@mui/material';
import Flag from 'react-world-flags';
import { useRouter } from 'next/navigation';
import { useLocale } from 'next-intl';
import { useLocale, useTranslations } from 'next-intl';
import { SidebarFooterProps } from '@toolpad/core';

interface LanguageSelectProps {}
type LanguageSelectProps = {
labeled?: boolean;
};

const LanguageSelector: React.FC<LanguageSelectProps> = () => {
const LanguageSelector: React.FC<LanguageSelectProps> = ({ labeled }) => {
const router = useRouter();
const locale = useLocale();
const translate = useTranslations();

const handleChange = (event: SelectChangeEvent<string>) => {
const selectedLocale = event.target.value as string;
Expand All @@ -35,7 +42,7 @@ const LanguageSelector: React.FC<LanguageSelectProps> = () => {
},
];

return (
const InputLanguage = () => (
<FormControl variant="outlined" size="small">
<Select
value={locale} // Idioma atual
Expand All @@ -52,6 +59,16 @@ const LanguageSelector: React.FC<LanguageSelectProps> = () => {
</Select>
</FormControl>
);

if (!labeled) return <InputLanguage />;

return (
<Box padding={2}>
<Typography variant="caption">{translate('menu.languages')}</Typography>{' '}
<br />
<InputLanguage />
</Box>
);
};

export default LanguageSelector;
3 changes: 3 additions & 0 deletions src/i18n/messages/en-US.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@
},
"orders": {
"title": "Orders"
},
"menu": {
"languages": "Languages:"
}
}
3 changes: 3 additions & 0 deletions src/i18n/messages/pt-BR.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,8 @@
},
"orders": {
"title": "Pedidos"
},
"menu": {
"languages": "Idiomas:"
}
}

0 comments on commit de878ed

Please sign in to comment.