43
front/src/modules/ui/breadcrumb/components/Breadcrumb.tsx
Normal file
43
front/src/modules/ui/breadcrumb/components/Breadcrumb.tsx
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
import { Fragment } from 'react';
|
||||||
|
import { Link } from 'react-router-dom';
|
||||||
|
import styled from '@emotion/styled';
|
||||||
|
|
||||||
|
type BreadcrumbProps = {
|
||||||
|
className?: string;
|
||||||
|
links: { children: string; href?: string }[];
|
||||||
|
};
|
||||||
|
|
||||||
|
const StyledWrapper = styled.nav`
|
||||||
|
align-items: center;
|
||||||
|
color: ${({ theme }) => theme.font.color.extraLight};
|
||||||
|
display: flex;
|
||||||
|
font-size: ${({ theme }) => theme.font.size.lg};
|
||||||
|
font-weight: ${({ theme }) => theme.font.weight.semiBold};
|
||||||
|
gap: ${({ theme }) => theme.spacing(2)};
|
||||||
|
height: ${({ theme }) => theme.spacing(6)};
|
||||||
|
line-height: ${({ theme }) => theme.text.lineHeight.md};
|
||||||
|
`;
|
||||||
|
|
||||||
|
const StyledLink = styled(Link)`
|
||||||
|
color: inherit;
|
||||||
|
text-decoration: none;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const StyledText = styled.span`
|
||||||
|
color: ${({ theme }) => theme.font.color.tertiary};
|
||||||
|
`;
|
||||||
|
|
||||||
|
export const Breadcrumb = ({ className, links }: BreadcrumbProps) => (
|
||||||
|
<StyledWrapper className={className}>
|
||||||
|
{links.map((link, index) => (
|
||||||
|
<Fragment key={index}>
|
||||||
|
{link.href ? (
|
||||||
|
<StyledLink to={link.href}>{link.children}</StyledLink>
|
||||||
|
) : (
|
||||||
|
<StyledText>{link.children}</StyledText>
|
||||||
|
)}
|
||||||
|
{index < links.length - 1 && '/'}
|
||||||
|
</Fragment>
|
||||||
|
))}
|
||||||
|
</StyledWrapper>
|
||||||
|
);
|
||||||
@ -0,0 +1,24 @@
|
|||||||
|
import { Meta, StoryObj } from '@storybook/react';
|
||||||
|
|
||||||
|
import { ComponentDecorator } from '~/testing/decorators/ComponentDecorator';
|
||||||
|
import { ComponentWithRouterDecorator } from '~/testing/decorators/ComponentWithRouterDecorator';
|
||||||
|
|
||||||
|
import { Breadcrumb } from '../Breadcrumb';
|
||||||
|
|
||||||
|
const meta: Meta<typeof Breadcrumb> = {
|
||||||
|
title: 'UI/Breadcrumb/Breadcrumb',
|
||||||
|
component: Breadcrumb,
|
||||||
|
decorators: [ComponentDecorator, ComponentWithRouterDecorator],
|
||||||
|
args: {
|
||||||
|
links: [
|
||||||
|
{ children: 'Objects', href: '/link-1' },
|
||||||
|
{ children: 'Companies', href: '/link-2' },
|
||||||
|
{ children: 'New' },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
export default meta;
|
||||||
|
type Story = StoryObj<typeof Breadcrumb>;
|
||||||
|
|
||||||
|
export const Default: Story = {};
|
||||||
@ -1,8 +1,13 @@
|
|||||||
|
import { useEffect } from 'react';
|
||||||
|
import { useNavigate, useParams } from 'react-router-dom';
|
||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
|
|
||||||
|
import { AppPath } from '@/types/AppPath';
|
||||||
|
import { Breadcrumb } from '@/ui/breadcrumb/components/Breadcrumb';
|
||||||
import { IconSettings } from '@/ui/icon';
|
import { IconSettings } from '@/ui/icon';
|
||||||
import { SubMenuTopBarContainer } from '@/ui/layout/components/SubMenuTopBarContainer';
|
import { SubMenuTopBarContainer } from '@/ui/layout/components/SubMenuTopBarContainer';
|
||||||
|
|
||||||
|
import { activeObjectItems } from './constants/mockObjects';
|
||||||
import { objectSettingsWidth } from './constants/objectSettings';
|
import { objectSettingsWidth } from './constants/objectSettings';
|
||||||
|
|
||||||
const StyledContainer = styled.div`
|
const StyledContainer = styled.div`
|
||||||
@ -10,8 +15,27 @@ const StyledContainer = styled.div`
|
|||||||
width: ${objectSettingsWidth};
|
width: ${objectSettingsWidth};
|
||||||
`;
|
`;
|
||||||
|
|
||||||
export const SettingsObjectDetail = () => (
|
export const SettingsObjectDetail = () => {
|
||||||
<SubMenuTopBarContainer Icon={IconSettings} title="Settings">
|
const navigate = useNavigate();
|
||||||
<StyledContainer />
|
const { pluralObjectName = '' } = useParams();
|
||||||
</SubMenuTopBarContainer>
|
const activeObject = activeObjectItems.find(
|
||||||
);
|
(activeObject) => activeObject.name.toLowerCase() === pluralObjectName,
|
||||||
|
);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (!activeObject) navigate(AppPath.NotFound);
|
||||||
|
}, [activeObject, navigate]);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<SubMenuTopBarContainer Icon={IconSettings} title="Settings">
|
||||||
|
<StyledContainer>
|
||||||
|
<Breadcrumb
|
||||||
|
links={[
|
||||||
|
{ children: 'Objects', href: '/settings/objects' },
|
||||||
|
{ children: activeObject?.name ?? '' },
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</StyledContainer>
|
||||||
|
</SubMenuTopBarContainer>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|||||||
@ -4,14 +4,10 @@ import styled from '@emotion/styled';
|
|||||||
|
|
||||||
import { Button } from '@/ui/button/components/Button';
|
import { Button } from '@/ui/button/components/Button';
|
||||||
import {
|
import {
|
||||||
IconBuildingSkyscraper,
|
|
||||||
IconChevronRight,
|
IconChevronRight,
|
||||||
IconDotsVertical,
|
IconDotsVertical,
|
||||||
IconLuggage,
|
|
||||||
IconPlane,
|
|
||||||
IconPlus,
|
IconPlus,
|
||||||
IconSettings,
|
IconSettings,
|
||||||
IconUser,
|
|
||||||
} from '@/ui/icon';
|
} from '@/ui/icon';
|
||||||
import { SubMenuTopBarContainer } from '@/ui/layout/components/SubMenuTopBarContainer';
|
import { SubMenuTopBarContainer } from '@/ui/layout/components/SubMenuTopBarContainer';
|
||||||
import { Table } from '@/ui/table/components/Table';
|
import { Table } from '@/ui/table/components/Table';
|
||||||
@ -23,6 +19,10 @@ import { Tag } from '@/ui/tag/components/Tag';
|
|||||||
import { H1Title } from '@/ui/typography/components/H1Title';
|
import { H1Title } from '@/ui/typography/components/H1Title';
|
||||||
import { H2Title } from '@/ui/typography/components/H2Title';
|
import { H2Title } from '@/ui/typography/components/H2Title';
|
||||||
|
|
||||||
|
import {
|
||||||
|
activeObjectItems,
|
||||||
|
disabledObjectItems,
|
||||||
|
} from './constants/mockObjects';
|
||||||
import { objectSettingsWidth } from './constants/objectSettings';
|
import { objectSettingsWidth } from './constants/objectSettings';
|
||||||
|
|
||||||
const StyledContainer = styled.div`
|
const StyledContainer = styled.div`
|
||||||
@ -68,40 +68,6 @@ const StyledH1Title = styled(H1Title)`
|
|||||||
margin-bottom: 0;
|
margin-bottom: 0;
|
||||||
`;
|
`;
|
||||||
|
|
||||||
const activeObjectItems = [
|
|
||||||
{
|
|
||||||
name: 'Companies',
|
|
||||||
Icon: IconBuildingSkyscraper,
|
|
||||||
type: 'standard',
|
|
||||||
fields: 23,
|
|
||||||
instances: 165,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'People',
|
|
||||||
Icon: IconUser,
|
|
||||||
type: 'standard',
|
|
||||||
fields: 16,
|
|
||||||
instances: 462,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const disabledObjectItems = [
|
|
||||||
{
|
|
||||||
name: 'Travels',
|
|
||||||
Icon: IconLuggage,
|
|
||||||
type: 'custom',
|
|
||||||
fields: 23,
|
|
||||||
instances: 165,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
name: 'Flights',
|
|
||||||
Icon: IconPlane,
|
|
||||||
type: 'custom',
|
|
||||||
fields: 23,
|
|
||||||
instances: 165,
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
export const SettingsObjects = () => {
|
export const SettingsObjects = () => {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|||||||
@ -12,7 +12,10 @@ const meta: Meta<PageDecoratorArgs> = {
|
|||||||
title: 'Pages/Settings/SettingsObjectDetail',
|
title: 'Pages/Settings/SettingsObjectDetail',
|
||||||
component: SettingsObjectDetail,
|
component: SettingsObjectDetail,
|
||||||
decorators: [PageDecorator],
|
decorators: [PageDecorator],
|
||||||
args: { routePath: '/settings/objects/companies' },
|
args: {
|
||||||
|
routePath: '/settings/objects/:pluralObjectName',
|
||||||
|
routeParams: { ':pluralObjectName': 'companies' },
|
||||||
|
},
|
||||||
parameters: {
|
parameters: {
|
||||||
docs: { story: 'inline', iframeHeight: '500px' },
|
docs: { story: 'inline', iframeHeight: '500px' },
|
||||||
msw: graphqlMocks,
|
msw: graphqlMocks,
|
||||||
|
|||||||
40
front/src/pages/settings/constants/mockObjects.ts
Normal file
40
front/src/pages/settings/constants/mockObjects.ts
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
import {
|
||||||
|
IconBuildingSkyscraper,
|
||||||
|
IconLuggage,
|
||||||
|
IconPlane,
|
||||||
|
IconUser,
|
||||||
|
} from '@/ui/icon';
|
||||||
|
|
||||||
|
export const activeObjectItems = [
|
||||||
|
{
|
||||||
|
name: 'Companies',
|
||||||
|
Icon: IconBuildingSkyscraper,
|
||||||
|
type: 'standard',
|
||||||
|
fields: 23,
|
||||||
|
instances: 165,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'People',
|
||||||
|
Icon: IconUser,
|
||||||
|
type: 'standard',
|
||||||
|
fields: 16,
|
||||||
|
instances: 462,
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
export const disabledObjectItems = [
|
||||||
|
{
|
||||||
|
name: 'Travels',
|
||||||
|
Icon: IconLuggage,
|
||||||
|
type: 'custom',
|
||||||
|
fields: 23,
|
||||||
|
instances: 165,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: 'Flights',
|
||||||
|
Icon: IconPlane,
|
||||||
|
type: 'custom',
|
||||||
|
fields: 23,
|
||||||
|
instances: 165,
|
||||||
|
},
|
||||||
|
];
|
||||||
Reference in New Issue
Block a user