@autobusal/common 1.2.0 → 1.3.0

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
  `;
@@ -5,7 +5,7 @@ import { Container, Crumb, Current } from './styles';
5
5
  import useBreadcrumbsStore from '@autobusal/providers/stores/breadcrumbs';
6
6
 
7
7
  interface Props {
8
- t: TFunction<'normal'>
8
+ t: TFunction<'common'>
9
9
  }
10
10
 
11
11
  const Breadcrumbs = ({ t }: Props): JSX.Element => {
@@ -25,7 +25,7 @@ const Breadcrumbs = ({ t }: Props): JSX.Element => {
25
25
 
26
26
  return (
27
27
  <Container>
28
- <Crumb to="/account"><GoHomeFill /> { t('private.layout.breadcrumbs.account') }</Crumb>
28
+ <Crumb to="/account"><GoHomeFill /> { t('breadcrumbs.account', { ns: 'common' }) }</Crumb>
29
29
 
30
30
  { final }
31
31
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autobusal/common",
3
- "version": "1.2.0",
3
+ "version": "1.3.0",
4
4
  "type": "module",
5
5
  "main": "index.ts"
6
6
  }