@autobusal/common 0.0.1 → 0.0.3

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.
@@ -0,0 +1,28 @@
1
+ import { RiLoader2Fill } from 'react-icons/ri';
2
+ import { ButtonStyled } from './styles';
3
+
4
+ interface Props {
5
+ type?: 'button' | 'submit'
6
+ size?: 'medium' | 'small'
7
+ loading?: boolean
8
+ active?: boolean
9
+ subtype?: 'secondary' | 'delete'
10
+ text: string | JSX.Element
11
+ noMargin?: boolean
12
+ maxWidth?: number
13
+ onClick?: any
14
+ }
15
+
16
+ export const Button = ({ type, size, loading, active, subtype, text, noMargin, maxWidth, onClick }: Props) => (
17
+ <ButtonStyled
18
+ $size={ size }
19
+ type={ loading ? 'button' : type }
20
+ $active={ active ?? true }
21
+ $subtype={ subtype }
22
+ $margin={ noMargin ? false : true }
23
+ $maxWidth={ maxWidth }
24
+ onClick={ onClick }
25
+ >
26
+ { loading ? <RiLoader2Fill /> : text }
27
+ </ButtonStyled>
28
+ );
@@ -0,0 +1,71 @@
1
+ import styled, { css } from 'styled-components';
2
+
3
+ interface ButtonType {
4
+ $size?: 'medium' | 'small'
5
+ $active: boolean
6
+ $subtype?: 'secondary' | 'delete'
7
+ $margin: boolean
8
+ $maxWidth?: number
9
+ }
10
+
11
+ export const ButtonStyled = styled.button<ButtonType>`
12
+ display: flex;
13
+ gap: 6px;
14
+ height: 38px;
15
+ overflow: hidden;
16
+ white-space: nowrap;
17
+ text-overflow: ellipsis;
18
+ ${ props => props.$margin && css`
19
+ margin-top: 12px;
20
+ ` }
21
+ align-items: center;
22
+ justify-content: center;
23
+ padding: 0 20px;
24
+ font-weight: 700;
25
+ background: ${ props => props.theme.primary.normal };
26
+ border: 1px solid ${ props => props.theme.primary.normal };
27
+ border-radius: 100px;
28
+ cursor: pointer;
29
+ transition: all 0.3s ease;
30
+
31
+ ${ props => props.$size === 'medium' && css`
32
+ height: 32px;
33
+ ` }
34
+
35
+ ${ props => props.$size === 'small' && css`
36
+ height: 26px;
37
+ padding: 0 10px;
38
+ font-size: calc(${ props => props.theme.size.xs } + 1px);
39
+ ` }
40
+
41
+ ${ props => props.$active === false && css`
42
+ opacity: .6;
43
+ ` }
44
+
45
+ ${ props => props.$subtype === 'secondary' && css`
46
+ background: ${ props => props.theme.forground.neutral };
47
+ border: 1px solid ${ props => props.theme.foreground.neutral };
48
+
49
+ &:hover {
50
+ box-shadow: 0 4px 15px ${ props => props.theme.foreground.neutral } !important;
51
+ }
52
+ ` }
53
+
54
+ ${ props => props.$subtype === 'delete' && css`
55
+ color: #FFF;
56
+ background: ${ props => props.theme.font.error };
57
+ border: 1px solid ${ props => props.theme.font.error };
58
+
59
+ &:hover {
60
+ box-shadow: 0 4px 15px ${ props => props.theme.font.error } !important;
61
+ }
62
+ ` }
63
+
64
+ ${ props => props.$maxWidth && css<ButtonType>`
65
+ max-width: ${ props => props.$maxWidth }px;
66
+ ` }
67
+
68
+ &:hover {
69
+ box-shadow: 0 4px 15px ${ props => props.theme.primary.normal };
70
+ }
71
+ `;
@@ -0,0 +1,41 @@
1
+ import { useState } from 'react';
2
+ import { TFunction } from 'i18next';
3
+ import { Button } from '../Button/Button';
4
+ import { Container, Info } from './styles';
5
+
6
+ interface Props {
7
+ t: TFunction<'common'>
8
+ }
9
+
10
+ const CookieNotification = ({ t }: Props): (JSX.Element | null) => {
11
+ const status = document.cookie.indexOf('CookieNotification=viewed') == -1;
12
+
13
+ const [ show, setShow ] = useState<boolean>(status);
14
+
15
+ const onClick = (): void => {
16
+ setShow(false);
17
+
18
+ const CookieDate = new Date();
19
+ CookieDate.setFullYear(CookieDate.getFullYear() + 1);
20
+
21
+ document.cookie = 'AutobusCookieNotification=viewed; expires=' + CookieDate.toUTCString() + "; path=/; SameSite=None; Secure";
22
+ };
23
+
24
+ if (! show) {
25
+ return null;
26
+ }
27
+
28
+ return (
29
+ <Container>
30
+ <Info>{ t('cookies.content', { ns: 'common' }) }</Info>
31
+
32
+ <Button
33
+ type="button"
34
+ size="medium"
35
+ text={ t('cookies.agree', { ns: 'common' }) }
36
+ onClick={ onClick } />
37
+ </Container>
38
+ );
39
+ };
40
+
41
+ export default CookieNotification;
@@ -0,0 +1,17 @@
1
+ import styled from 'styled-components';
2
+
3
+ export const Container = styled.div`
4
+ position: fixed;
5
+ bottom: 20px;
6
+ left: 4%;
7
+ z-index: 500;
8
+ width: 92%;
9
+ padding: 15px;
10
+ background-color: ${ props => props.theme.foreground.normal };
11
+ box-shadow: ${ props => props.theme.boxShadow };
12
+ border-radius: ${ props => props.theme.borderRadius };
13
+ `;
14
+
15
+ export const Info = styled.div`
16
+ font-weight: 700;
17
+ `;
package/index.ts CHANGED
@@ -1,5 +1,7 @@
1
+ import CookieNotification from './CookieNotification/CookieNotification';
1
2
  import Meta from './Meta';
2
3
 
3
4
  export {
5
+ CookieNotification,
4
6
  Meta
5
7
  };
package/package.json CHANGED
@@ -1,9 +1,13 @@
1
1
  {
2
2
  "name": "@autobusal/common",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "type": "module",
5
5
  "main": "index.ts",
6
6
  "dependencies": {
7
- "react-helmet": "^6.1.0"
7
+ "i18next": "^23.7.18",
8
+ "react": "^18.2.0",
9
+ "react-helmet": "^6.1.0",
10
+ "react-icons": "^5.0.1",
11
+ "styled-components": "^6.1.8"
8
12
  }
9
13
  }