@autobusal/common 1.2.1 → 1.3.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.
@@ -1,38 +1,35 @@
1
1
  import { TFunction } from 'i18next';
2
- import { Trans } from 'react-i18next';
3
- import { Image, LinkTitle, PostedBy, LinkCategory, TextPreview, LinkMore, TextView } from './styles';
2
+ import { FiCalendar } from 'react-icons/fi';
3
+ import Image from './Image';
4
+ import { LinkTitle, Details, DisplayDate, TextPreview, TextView, ButtonLink } from './styles';
4
5
  import { ArticleData } from '@autobusal/providers/types/articles';
5
6
 
6
7
  interface Props {
7
8
  article: ArticleData
8
- type: 'preview' | 'view'
9
+ type: 'preview' | 'view' | 'short'
9
10
  t: TFunction<'common'>
10
11
  }
11
12
 
12
13
  const BlogItem = ({ article, type, t }: Props): JSX.Element => (
13
14
  <div className="box">
14
- { article.image_url !== null && <Image src={ article.image_url } /> }
15
+ { article.image_url !== null && <Image type={ type } internal={ article.internal } image_url={ article.image_url } /> }
15
16
 
16
17
  <LinkTitle to={ `/blog/article/${ article.internal }` }>{ article.title }</LinkTitle>
17
18
 
18
- <PostedBy>
19
- <Trans
20
- i18nKey="blog_item.posted_by"
21
- ns="common"
22
- values={{
23
- date: article.created_at,
24
- name: article.category.name
25
- }}
26
- components={{
27
- category: <LinkCategory to={ `/blog?category=${ article.category.id }` } />
28
- }}
29
- />
30
- </PostedBy>
19
+ <Details>
20
+ <DisplayDate>
21
+ <FiCalendar />
22
+ { article.display_at }
23
+ </DisplayDate>
24
+
25
+ { article.category && <ButtonLink to={ `/blog?category=${ article.category.id }` }>{ article.category.name }</ButtonLink> }
26
+ </Details>
31
27
 
32
28
  { type === 'preview' && (
33
29
  <TextPreview>
34
30
  { article.stripped } &nbsp;
35
- <LinkMore to={ `/blog/article/${ article.internal }` }>{ t('blog_item.read_more', { ns: 'common' }) }</LinkMore>
31
+
32
+ <ButtonLink $marginTop={ 10 } to={ `/blog/article/${ article.internal }` }>{ t('blog_item.read_more', { ns: 'common' }) }</ButtonLink>
36
33
  </TextPreview>
37
34
  ) }
38
35
 
@@ -0,0 +1,23 @@
1
+ import { ContainerImage, ImageLink } from './styles';
2
+
3
+ interface Props {
4
+ type: 'preview' | 'view' | 'short'
5
+ internal: string
6
+ image_url: string
7
+ }
8
+
9
+ const Image = ({ type, internal, image_url }: Props): JSX.Element => {
10
+ if (type === 'preview' || type === 'short') {
11
+ return (
12
+ <ImageLink to={ `/blog/article/${ internal }` }>
13
+ <ContainerImage src={ image_url } />
14
+ </ImageLink>
15
+ );
16
+ }
17
+
18
+ return (
19
+ <ContainerImage src={ image_url } />
20
+ );
21
+ };
22
+
23
+ export default Image;
@@ -1,27 +1,45 @@
1
- import styled from 'styled-components';
1
+ import styled, { css } from 'styled-components';
2
2
  import { Link } from 'react-router-dom';
3
3
 
4
- export const Image = styled.img`
4
+ export const ContainerImage = styled.img`
5
5
  display: block;
6
6
  width: 100%;
7
7
  margin-bottom: 15px;
8
8
  border-radius: ${ props => props.theme.borderRadius };
9
9
  `;
10
10
 
11
+ export const ImageLink = styled(Link)`
12
+ display: block;
13
+ transition: opacity 0.3s ease;
14
+
15
+ &:hover {
16
+ opacity: .8;
17
+ }
18
+ `;
19
+
11
20
  export const LinkTitle = styled(Link)`
12
21
  font-size: ${ props => props.theme.size.xl };
13
22
  font-weight: 700;
23
+ transition: opacity 0.3s ease;
24
+
25
+ &:hover {
26
+ text-decoration: none;
27
+ opacity: .7;
28
+ }
14
29
  `;
15
30
 
16
- export const PostedBy = styled.div`
17
- padding: 10px 0;
18
- color: ${ props => props.theme.font.info };
19
- font-size: ${ props => props.theme.size.xs };
31
+ export const Details = styled.div`
32
+ display: flex;
33
+ gap: 15px;
34
+ align-items: center;
35
+ margin: 10px 0;
20
36
  `;
21
37
 
22
- export const LinkCategory = styled(Link)`
23
- color: ${ props => props.theme.font.info };
24
- font-size: ${ props => props.theme.size.xs };
38
+ export const DisplayDate = styled.div`
39
+ display: flex;
40
+ align-items: center;
41
+ gap: 5px;
42
+ font-size: ${ props => props.theme.size.s };
25
43
  `;
26
44
 
27
45
  export const TextPreview = styled.div`
@@ -34,8 +52,22 @@ export const TextView = styled(TextPreview)`
34
52
  gap: 10px;
35
53
  `;
36
54
 
37
- export const LinkMore = styled(Link)`
38
- display: inline;
39
- font-size: ${ props => props.theme.size.s };
40
- color: ${ props => props.theme.font.info };
55
+ export const ButtonLink = styled(Link)<{ $marginTop?: number }>`
56
+ display: inline-block;
57
+ padding: 3px 10px;
58
+ ${ props => props.$marginTop && css<{ $marginTop?: number }>`
59
+ margin-top: ${ props => props.$marginTop }px;
60
+ ` }
61
+ font-size: ${ props => props.theme.size.xs };
62
+ font-weight: 700;
63
+ color: ${ props => props.theme.primary.contrast };
64
+ background: ${ props => props.theme.primary.normal };
65
+ border: 1px solid ${ props => props.theme.primary.normal };
66
+ border-radius: 100px;
67
+ transition: all 0.3s ease;
68
+
69
+ &:hover {
70
+ text-decoration: none;
71
+ box-shadow: 0 4px 15px ${ props => props.theme.primary.normal };
72
+ }
41
73
  `;
@@ -1,7 +1,7 @@
1
1
  import { useRef } from 'react';
2
2
  import { TFunction, i18n } from 'i18next';
3
- import { IoGlobeOutline } from 'react-icons/io5';
4
3
  import { useOutside } from '@autobusal/hooks';
4
+ import Flag from './Flag';
5
5
  import { Container, Title, ContainerButtons, ButtonChange } from './styles';
6
6
  import { useGetSettings } from '@autobusal/providers/services';
7
7
 
@@ -28,7 +28,7 @@ const ChangeLanguage = ({ type, t, i18n, onClose }: Props): JSX.Element => {
28
28
 
29
29
  const items = available.map((item, index) => (
30
30
  <ButtonChange key={ index } onClick={ () => onChange(item) }>
31
- <IoGlobeOutline />
31
+ <Flag language={ item } size={ 22 } />
32
32
  { `${ t('languages.change', { ns: 'common' }) } ${ t(`languages.${ item }`, { ns: 'common' }) }` }
33
33
  </ButtonChange>
34
34
  ));
@@ -0,0 +1,12 @@
1
+ import { ContainerFlag } from './styles';
2
+
3
+ interface Props {
4
+ language: string
5
+ size: number
6
+ }
7
+
8
+ const Flag = ({ language, size }: Props): JSX.Element => (
9
+ <ContainerFlag $size={ size } src={ `${ import.meta.env.VITE_API_OBT }/languages/${ language }.svg` } />
10
+ );
11
+
12
+ export default Flag;
@@ -1,4 +1,4 @@
1
- import styled from 'styled-components';
1
+ import styled, { css } from 'styled-components';
2
2
 
3
3
  export const Container = styled.div<{
4
4
  $type: 'top' | 'bottom'
@@ -12,6 +12,11 @@ export const Container = styled.div<{
12
12
  background-color: ${ props => props.theme.background.normal };
13
13
  box-shadow: ${ props => props.theme.boxShadow };
14
14
  border-radius: ${ props => props.theme.borderRadius };
15
+
16
+ ${ props => props.$type === 'bottom' && css`
17
+ right: 10px;
18
+ bottom: 50px;
19
+ ` }
15
20
  `;
16
21
 
17
22
  export const Title = styled.h5`
@@ -23,7 +28,13 @@ export const Title = styled.h5`
23
28
  export const ContainerButtons = styled.div`
24
29
  display: flex;
25
30
  flex-direction: column;
26
- gap: 5px;
31
+ gap: 6px;
32
+ `;
33
+
34
+ export const ContainerFlag = styled.img<{ $size: number }>`
35
+ display: block;
36
+ width: ${ props => props.$size }px;
37
+ border-radius: 4px;
27
38
  `;
28
39
 
29
40
  export const ButtonChange = styled.button`
@@ -33,13 +44,10 @@ export const ButtonChange = styled.button`
33
44
  justify-content: center;
34
45
  gap: 8px;
35
46
  font-size: ${ props => props.theme.size.xs };
47
+ background: ${ props => props.theme.background.neutral };
36
48
  border-radius: ${ props => props.theme.borderRadius };
37
49
  transition: all 0.3s ease;
38
50
 
39
- > svg {
40
- color: ${ props => props.theme.primary.normal };
41
- }
42
-
43
51
  &:hover {
44
52
  background-color: ${ props => props.theme.primary.neutral };
45
53
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autobusal/common",
3
- "version": "1.2.1",
3
+ "version": "1.3.1",
4
4
  "type": "module",
5
5
  "main": "index.ts"
6
6
  }