@autobusal/common 1.2.1 → 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.
- package/BlogItem/BlogItem.tsx +15 -18
- package/BlogItem/Image.tsx +23 -0
- package/BlogItem/styles.ts +45 -13
- package/package.json +1 -1
package/BlogItem/BlogItem.tsx
CHANGED
|
@@ -1,38 +1,35 @@
|
|
|
1
1
|
import { TFunction } from 'i18next';
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
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
|
|
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
|
-
<
|
|
19
|
-
<
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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 }
|
|
35
|
-
|
|
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;
|
package/BlogItem/styles.ts
CHANGED
|
@@ -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
|
|
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
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
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
|
|
23
|
-
|
|
24
|
-
|
|
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
|
|
38
|
-
display: inline;
|
|
39
|
-
|
|
40
|
-
|
|
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
|
`;
|