@autobusal/common 1.1.1 → 1.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Breadcrumbs/Breadcrumbs.tsx +42 -0
- package/Breadcrumbs/styles.ts +31 -0
- package/index.ts +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { TFunction } from 'i18next';
|
|
2
|
+
import { GoHomeFill } from 'react-icons/go';
|
|
3
|
+
import { RxCaretRight } from 'react-icons/rx';
|
|
4
|
+
import { Container, Crumb, Current } from './styles';
|
|
5
|
+
import useBreadcrumbsStore from '@autobusal/providers/stores/breadcrumbs';
|
|
6
|
+
|
|
7
|
+
interface Props {
|
|
8
|
+
t: TFunction<'common'>
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const Breadcrumbs = ({ t }: Props): JSX.Element => {
|
|
12
|
+
const { current, data } = useBreadcrumbsStore();
|
|
13
|
+
|
|
14
|
+
const final: JSX.Element[] = [];
|
|
15
|
+
|
|
16
|
+
data?.forEach((item, index) => {
|
|
17
|
+
final.push(
|
|
18
|
+
<RxCaretRight key={ `caret-${ index }` } />
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
final.push(
|
|
22
|
+
<Crumb key={ `crumb-${ index }` } to={ item.url }>{ item.name }</Crumb>
|
|
23
|
+
);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
return (
|
|
27
|
+
<Container>
|
|
28
|
+
<Crumb to="/account"><GoHomeFill /> { t('breadcrumbs.account', { ns: 'common' }) }</Crumb>
|
|
29
|
+
|
|
30
|
+
{ final }
|
|
31
|
+
|
|
32
|
+
{ current && (
|
|
33
|
+
<>
|
|
34
|
+
<RxCaretRight key="last" />
|
|
35
|
+
<Current>{ current }</Current>
|
|
36
|
+
</>
|
|
37
|
+
) }
|
|
38
|
+
</Container>
|
|
39
|
+
);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export default Breadcrumbs;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Link } from 'react-router-dom';
|
|
2
|
+
import styled, { css } from 'styled-components';
|
|
3
|
+
|
|
4
|
+
const CrumbStyles = css`
|
|
5
|
+
display: flex;
|
|
6
|
+
align-items: center;
|
|
7
|
+
gap: 4px;
|
|
8
|
+
font-size: ${ props => props.theme.size.xs };
|
|
9
|
+
color: ${ props => props.theme.submenu.font };
|
|
10
|
+
`;
|
|
11
|
+
|
|
12
|
+
export const Container = styled.div`
|
|
13
|
+
display: flex;
|
|
14
|
+
flex-wrap: wrap;
|
|
15
|
+
align-items: center;
|
|
16
|
+
gap: 4px;
|
|
17
|
+
margin-bottom: 30px;
|
|
18
|
+
`;
|
|
19
|
+
|
|
20
|
+
export const Crumb = styled(Link)`
|
|
21
|
+
${ CrumbStyles }
|
|
22
|
+
|
|
23
|
+
font-weight: 700;
|
|
24
|
+
transition: opacity 0.3s ease;
|
|
25
|
+
`;
|
|
26
|
+
|
|
27
|
+
export const Current = styled.div`
|
|
28
|
+
${ CrumbStyles }
|
|
29
|
+
|
|
30
|
+
font-weight: 500;
|
|
31
|
+
`;
|
package/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ import Avatar from './Avatar';
|
|
|
4
4
|
import BackTo from './Back/BackTo';
|
|
5
5
|
import BackWithTitle from './Back/BackWithTitle';
|
|
6
6
|
import BlogItem from './BlogItem/BlogItem';
|
|
7
|
+
import Breadcrumbs from './Breadcrumbs/Breadcrumbs';
|
|
7
8
|
import Button from './Button/Button';
|
|
8
9
|
import Calendar from './Calendar/Calendar';
|
|
9
10
|
import ChangeLanguage from './ChangeLanguage/ChangeLanguage';
|
|
@@ -39,6 +40,7 @@ export {
|
|
|
39
40
|
BlogItem,
|
|
40
41
|
Box,
|
|
41
42
|
BoxMiddle,
|
|
43
|
+
Breadcrumbs,
|
|
42
44
|
Button,
|
|
43
45
|
Calendar,
|
|
44
46
|
ChangeLanguage,
|