@autobusal/common 0.0.7 → 0.0.9
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/ChangeLanguage/ChangeLanguage.tsx +3 -3
- package/ChangeLanguage/styles.ts +2 -9
- package/Loading/Loading.tsx +56 -0
- package/Loading/styles.ts +22 -0
- package/Modal/Modal.tsx +37 -0
- package/Modal/styles.ts +49 -0
- package/index.ts +4 -1
- package/package.json +1 -1
|
@@ -30,15 +30,15 @@ const ChangeLanguage = ({ type, t, i18n, onClose }: Props): JSX.Element => {
|
|
|
30
30
|
|
|
31
31
|
const available = data.preferences.languages.available;
|
|
32
32
|
|
|
33
|
-
const items = available.map(item => (
|
|
34
|
-
<ButtonChange onClick={ () => onChange(item) }>
|
|
33
|
+
const items = available.map((item, index) => (
|
|
34
|
+
<ButtonChange key={ index } onClick={ () => onChange(item) }>
|
|
35
35
|
<IoGlobeOutline />
|
|
36
36
|
{ `${ t('languages.change', { ns: 'common' }) } ${ t(`languages.${ item }`, { ns: 'common' }) }` }
|
|
37
37
|
</ButtonChange>
|
|
38
38
|
));
|
|
39
39
|
|
|
40
40
|
return (
|
|
41
|
-
<Container ref={ ref } $type={ type } $languages={ available.length }>
|
|
41
|
+
<Container ref={ ref } className="change-language" $type={ type } $languages={ available.length }>
|
|
42
42
|
<Title>{ t('languages.title', { ns: 'common' }) }</Title>
|
|
43
43
|
|
|
44
44
|
<ContainerButtons>
|
package/ChangeLanguage/styles.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import styled
|
|
1
|
+
import styled from 'styled-components';
|
|
2
2
|
|
|
3
3
|
export const Container = styled.div<{
|
|
4
4
|
$type: 'top' | 'bottom'
|
|
@@ -6,19 +6,12 @@ export const Container = styled.div<{
|
|
|
6
6
|
}>`
|
|
7
7
|
position: absolute;
|
|
8
8
|
bottom: calc((-1 * ${ props => props.$languages } * 27px) - 50px - 8px);
|
|
9
|
-
|
|
9
|
+
right: 0;
|
|
10
10
|
z-index: 101;
|
|
11
|
-
width: 200px;
|
|
12
11
|
padding: 10px;
|
|
13
12
|
background-color: ${ props => props.theme.background.normal };
|
|
14
13
|
box-shadow: ${ props => props.theme.boxShadow };
|
|
15
14
|
border-radius: ${ props => props.theme.borderRadius };
|
|
16
|
-
|
|
17
|
-
// // // @todo: de verificat in private
|
|
18
|
-
// // ${ props => props.$type === 'bottom' && css`
|
|
19
|
-
// // // top: auto;
|
|
20
|
-
// // // bottom: 30px;
|
|
21
|
-
// // ` }
|
|
22
15
|
`;
|
|
23
16
|
|
|
24
17
|
export const Title = styled.h5`
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { SpinnerRoundFilled, SpinnerCircularFixed } from 'spinners-react';
|
|
2
|
+
import { useSystemTheme } from '@autobusal/providers';
|
|
3
|
+
import Skeleton from 'react-loading-skeleton';
|
|
4
|
+
import { ContainerGeneral
|
|
5
|
+
// , ContainerInline
|
|
6
|
+
, ContainerParagraph } from './styles';
|
|
7
|
+
import 'react-loading-skeleton/dist/skeleton.css';
|
|
8
|
+
|
|
9
|
+
export const General = (): JSX.Element => {
|
|
10
|
+
const theme = useSystemTheme();
|
|
11
|
+
|
|
12
|
+
const options = {
|
|
13
|
+
speed: 75,
|
|
14
|
+
thickness: 120,
|
|
15
|
+
color: (theme === 'light' ? '#CECECE' : '#F2F2F2'),
|
|
16
|
+
size: '40px'
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
return (
|
|
20
|
+
<ContainerGeneral>
|
|
21
|
+
{ import.meta.env.VITE_APP_TYPE === 'normal'
|
|
22
|
+
? <SpinnerRoundFilled size={ options.size } color={ options.color } speed={ options.speed } thickness={ options.thickness } />
|
|
23
|
+
: <SpinnerCircularFixed size={ options.size } color={ options.color } speed={ options.speed } thickness={ options.thickness } />
|
|
24
|
+
}
|
|
25
|
+
</ContainerGeneral>
|
|
26
|
+
)
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
// interface InlineProps {
|
|
30
|
+
// text: string
|
|
31
|
+
// }
|
|
32
|
+
|
|
33
|
+
// export const Inline = ({ text }: InlineProps): JSX.Element => (
|
|
34
|
+
// <ContainerInline>
|
|
35
|
+
// <SpinnerRoundFilled
|
|
36
|
+
// size="30px"
|
|
37
|
+
// color="#FBC02D"
|
|
38
|
+
// speed={ 75 }
|
|
39
|
+
// thickness={ 120 }
|
|
40
|
+
// />
|
|
41
|
+
|
|
42
|
+
// { text }
|
|
43
|
+
// </ContainerInline>
|
|
44
|
+
// );
|
|
45
|
+
|
|
46
|
+
interface ParagraphProps {
|
|
47
|
+
count?: number
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export const Paragraph = ({ count = 3 }: ParagraphProps): JSX.Element => (
|
|
51
|
+
<ContainerParagraph>
|
|
52
|
+
<Skeleton count={ count - 1 } /> <br />
|
|
53
|
+
<Skeleton count={ count + 1 } /> <br />
|
|
54
|
+
<Skeleton count={ count } />
|
|
55
|
+
</ContainerParagraph>
|
|
56
|
+
);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
|
|
3
|
+
export const ContainerGeneral = styled.div`
|
|
4
|
+
width: 100%;
|
|
5
|
+
height: 100%;
|
|
6
|
+
display: flex;
|
|
7
|
+
align-items: center;
|
|
8
|
+
justify-content: center;
|
|
9
|
+
`;
|
|
10
|
+
|
|
11
|
+
// export const ContainerInline = styled.div`
|
|
12
|
+
// display: flex;
|
|
13
|
+
// gap: 10px;
|
|
14
|
+
// align-items: center;
|
|
15
|
+
// justify-content: center;
|
|
16
|
+
// font-size: ${ props => props.theme.size.info };
|
|
17
|
+
// color: ${ props => props.theme.faded };
|
|
18
|
+
// `;
|
|
19
|
+
|
|
20
|
+
export const ContainerParagraph = styled.div`
|
|
21
|
+
padding: 15px 0;
|
|
22
|
+
`;
|
package/Modal/Modal.tsx
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { AiOutlineClose } from 'react-icons/ai';
|
|
2
|
+
import { useOverflow } from '@autobusal/hooks';
|
|
3
|
+
import { Paragraph } from '../index';
|
|
4
|
+
import { Background, Container, Title, ButtonClose } from './styles';
|
|
5
|
+
|
|
6
|
+
interface Props {
|
|
7
|
+
loading?: boolean
|
|
8
|
+
width: number
|
|
9
|
+
title: string
|
|
10
|
+
content: JSX.Element
|
|
11
|
+
onClose: () => void
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const Modal = ({ loading, width, title, content, onClose }: Props): JSX.Element => {
|
|
15
|
+
// hide the scroll
|
|
16
|
+
useOverflow();
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<>
|
|
20
|
+
<Background />
|
|
21
|
+
|
|
22
|
+
<Container className="box" $width={ width }>
|
|
23
|
+
<Title>
|
|
24
|
+
<h1>{ title }</h1>
|
|
25
|
+
|
|
26
|
+
<ButtonClose type="button" onClick={ onClose }>
|
|
27
|
+
<AiOutlineClose />
|
|
28
|
+
</ButtonClose>
|
|
29
|
+
</Title>
|
|
30
|
+
|
|
31
|
+
{ loading ? <Paragraph /> : content }
|
|
32
|
+
</Container>
|
|
33
|
+
</>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export default Modal;
|
package/Modal/styles.ts
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
|
|
3
|
+
export const Background = styled.div`
|
|
4
|
+
position: fixed;
|
|
5
|
+
top: 0;
|
|
6
|
+
left: 0;
|
|
7
|
+
z-index: 1002;
|
|
8
|
+
width: 100%;
|
|
9
|
+
height: 100%;
|
|
10
|
+
background-color: ${ props => props.theme.menu.transparent };
|
|
11
|
+
backdrop-filter: blur(25px);
|
|
12
|
+
-webkit-backdrop-filter: blur(25px);
|
|
13
|
+
`;
|
|
14
|
+
|
|
15
|
+
export const Container = styled.div<{ $width: number }>`
|
|
16
|
+
position: fixed;
|
|
17
|
+
top: 50%;
|
|
18
|
+
left: 50%;
|
|
19
|
+
z-index: 1003;
|
|
20
|
+
width: 90%;
|
|
21
|
+
max-width: ${ props => props.$width }px;
|
|
22
|
+
max-height: 80%;
|
|
23
|
+
overflow-y: auto;
|
|
24
|
+
padding: 15px;
|
|
25
|
+
text-align: left;
|
|
26
|
+
border-top: 4px solid $yellow;
|
|
27
|
+
transform: translate(-50%, -50%);
|
|
28
|
+
`;
|
|
29
|
+
|
|
30
|
+
export const Title = styled.div`
|
|
31
|
+
display: flex;
|
|
32
|
+
margin-bottom: 15px;
|
|
33
|
+
|
|
34
|
+
& > h1 {
|
|
35
|
+
margin: 0;
|
|
36
|
+
}
|
|
37
|
+
`;
|
|
38
|
+
|
|
39
|
+
export const ButtonClose = styled.button`
|
|
40
|
+
display: flex;
|
|
41
|
+
justify-content: center;
|
|
42
|
+
align-items: center;
|
|
43
|
+
width: 26px;
|
|
44
|
+
height: 26px;
|
|
45
|
+
margin-left: auto;
|
|
46
|
+
font-size: ${ props => props.theme.size.m };
|
|
47
|
+
background: ${ props => props.theme.primary.neutral };
|
|
48
|
+
border-radius: 100px;
|
|
49
|
+
`;
|
package/index.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
import CookieNotification from './CookieNotification/CookieNotification';
|
|
2
2
|
import ChangeLanguage from './ChangeLanguage/ChangeLanguage';
|
|
3
3
|
import { Button } from './Button/Button';
|
|
4
|
+
import { General, Paragraph } from './Loading/Loading';
|
|
4
5
|
import Meta from './Meta';
|
|
5
6
|
|
|
6
7
|
export {
|
|
7
8
|
Button,
|
|
8
9
|
CookieNotification,
|
|
9
10
|
ChangeLanguage,
|
|
10
|
-
|
|
11
|
+
General,
|
|
12
|
+
Meta,
|
|
13
|
+
Paragraph
|
|
11
14
|
};
|