@autobusal/common 0.0.33 → 0.0.35

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/BackTo.tsx CHANGED
@@ -28,7 +28,7 @@ const LinkStyled = styled(Link)`
28
28
  const BackTo = ({ to, t }: Props): JSX.Element => (
29
29
  <LinkStyled to={ to }>
30
30
  <BiChevronLeftCircle />
31
- { t('back') }
31
+ { t('back', { ns: 'common' }) }
32
32
  </LinkStyled>
33
33
  );
34
34
 
@@ -0,0 +1,43 @@
1
+ import { TFunction } from 'i18next';
2
+ import { Trans } from 'react-i18next';
3
+ import { Image, LinkTitle, PostedBy, LinkCategory, TextPreview, LinkMore, TextView } from './styles';
4
+ import { ArticleData } from '@autobusal/providers/types/articles';
5
+
6
+ interface Props {
7
+ article: ArticleData
8
+ type: 'preview' | 'view'
9
+ t: TFunction<'common'>
10
+ }
11
+
12
+ const BlogItem = ({ article, type, t }: Props): JSX.Element => (
13
+ <div className="box">
14
+ { article.image_url !== null && <Image src={ article.image_url } /> }
15
+
16
+ <LinkTitle to={ `/blog/article/${ article.internal }` }>{ article.title }</LinkTitle>
17
+
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>
31
+
32
+ { type === 'preview' && (
33
+ <TextPreview>
34
+ { article.stripped } &nbsp;
35
+ <LinkMore to={ `/blog/article/${ article.internal }` }>{ t('blog_item.read_more', { ns: 'common' }) }</LinkMore>
36
+ </TextPreview>
37
+ ) }
38
+
39
+ { type === 'view' && <TextView dangerouslySetInnerHTML={{ __html: article.content }} /> }
40
+ </div>
41
+ );
42
+
43
+ export default BlogItem;
@@ -0,0 +1,41 @@
1
+ import styled from 'styled-components';
2
+ import { Link } from 'react-router-dom';
3
+
4
+ export const Image = styled.img`
5
+ display: block;
6
+ width: 100%;
7
+ margin-bottom: 15px;
8
+ border-radius: ${ props => props.theme.borderRadius };
9
+ `;
10
+
11
+ export const LinkTitle = styled(Link)`
12
+ font-size: ${ props => props.theme.size.xl };
13
+ font-weight: 700;
14
+ `;
15
+
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 };
20
+ `;
21
+
22
+ export const LinkCategory = styled(Link)`
23
+ color: ${ props => props.theme.font.info };
24
+ font-size: ${ props => props.theme.size.xs };
25
+ `;
26
+
27
+ export const TextPreview = styled.div`
28
+ font-size: calc(${ props => props.theme.size.s } + 1px);
29
+ `;
30
+
31
+ export const TextView = styled(TextPreview)`
32
+ display: flex;
33
+ flex-direction: column;
34
+ gap: 10px;
35
+ `;
36
+
37
+ export const LinkMore = styled(Link)`
38
+ display: inline;
39
+ font-size: ${ props => props.theme.size.s };
40
+ color: ${ props => props.theme.font.info };
41
+ `;
@@ -20,11 +20,7 @@ const ChangeLanguage = ({ type, t, i18n, onClose }: Props): JSX.Element => {
20
20
  useOutside(ref, onClose);
21
21
 
22
22
  const onChange = (language: string): void => {
23
- // @todo: sa o fac cand fac in private
24
23
  i18n.changeLanguage(language);
25
-
26
- // @todo: sa fac refresh pt limba noua?
27
-
28
24
  onClose();
29
25
  };
30
26
 
package/index.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import Autocomplete from './Autocomplete/Autocomplete';
2
2
  import BackTo from './BackTo';
3
+ import BlogItem from './BlogItem/BlogItem';
3
4
  import Calendar from './Calendar/Calendar';
4
5
  import CookieNotification from './CookieNotification/CookieNotification';
5
6
  import ChangeLanguage from './ChangeLanguage/ChangeLanguage';
@@ -18,6 +19,7 @@ import RouteItem from './RouteItem/RouteItem';
18
19
  export {
19
20
  Autocomplete,
20
21
  BackTo,
22
+ BlogItem,
21
23
  Button,
22
24
  Calendar,
23
25
  CookieNotification,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autobusal/common",
3
- "version": "0.0.33",
3
+ "version": "0.0.35",
4
4
  "type": "module",
5
5
  "main": "index.ts"
6
6
  }