ArticleSection.tsx 4.17 KB
Newer Older
Matija Obreza's avatar
Matija Obreza committed
1
import * as React from 'react';
Oleksii Savran's avatar
Oleksii Savran committed
2
import { translate } from 'react-i18next';
Matija Obreza's avatar
Matija Obreza committed
3 4

import Grid from '@material-ui/core/Grid';
Oleksii Savran's avatar
Oleksii Savran committed
5 6
import withStyles from '@material-ui/core/styles/withStyles';
import { ExternalLink } from 'ui/common/Links';
Matija Obreza's avatar
Matija Obreza committed
7

Oleksii Savran's avatar
Oleksii Savran committed
8
const styles = (theme) => ({
Matija Obreza's avatar
Matija Obreza committed
9 10
  /*tslint:disable*/
  root: {
Oleksii Savran's avatar
Oleksii Savran committed
11 12 13
    height: 'calc(100% - 51px)',
  },
  wrapper: {
Matija Obreza's avatar
Matija Obreza committed
14 15
    backgroundColor: 'white',
    padding: '33px 40px 49px 40px',
Oleksii Savran's avatar
Oleksii Savran committed
16 17 18 19
    height: '100%',
    boxSizing: 'border-box' as 'border-box',
  },
  text: {
Matija Obreza's avatar
Matija Obreza committed
20 21 22
    fontFamily: 'Roboto-Light',
    fontSize: '18px',
    '& p': {
Matija Obreza's avatar
Matija Obreza committed
23
      color: '#4d4c46',
Matija Obreza's avatar
Matija Obreza committed
24 25 26 27 28
      lineHeight: '1.5em',
      margin: '0 0 1.5em 0',
    },
    '& > p:first-child': {
      fontSize: '22px',
Matija Obreza's avatar
Matija Obreza committed
29
    },
Matija Obreza's avatar
Matija Obreza committed
30
    '& h3': {
Matija Obreza's avatar
Matija Obreza committed
31 32 33 34
      fontSize: '24px',
      marginTop: '28px',
      paddingBottom: '6px',
    },
Matija Obreza's avatar
Matija Obreza committed
35
    '& ul': {
Matija Obreza's avatar
Matija Obreza committed
36 37
      marginTop: '30px',
      padding: 0,
Oleksii Savran's avatar
Oleksii Savran committed
38 39 40 41 42 43
      'html[dir="ltr"] &' : {
        paddingLeft: '11px',
      },
      'html[dir="rtl"] &' : {
        paddingRight: '11px',
      },
Matija Obreza's avatar
Matija Obreza committed
44
    },
Matija Obreza's avatar
Matija Obreza committed
45
    '& ul > li': {
Matija Obreza's avatar
Matija Obreza committed
46 47 48
      lineHeight: '30px',
    },
  },
Oleksii Savran's avatar
Oleksii Savran committed
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65
  social: {
    borderTop: '1px solid #d5d4d3',
    borderBottom: '1px solid #d5d4d3',
    marginTop: '57px',
    paddingTop: '20px',
    paddingBottom: '19px',
    fontSize: '1.3rem',
  },
  socialLink: {
    backgroundColor: 'white', //
    display: 'inline-block',
    paddingLeft: '18px',
    [theme.breakpoints.down('xs')]: {
      paddingLeft: '0',
      width: '50%',
      textAlign: 'center' as 'center',
    },
Oleksii Savran's avatar
Oleksii Savran committed
66 67 68 69
    'html[dir="rtl"] &' : {
      paddingLeft: '0',
      paddingRight: '18px',
    },
Oleksii Savran's avatar
Oleksii Savran committed
70 71 72 73 74 75 76 77 78 79
    '&:hover > a > *': {
      filter: 'brightness(0.5)',
      transition: 'all, 0.1s',
    }
  },
  socialText: {
    [theme.breakpoints.down('sm')]: {
      display: 'none',
    },
  },
Oleksii Savran's avatar
Oleksii Savran committed
80

Oleksii Savran's avatar
Oleksii Savran committed
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
  share: {
    fontSize: '1.3rem',
    display: 'inline-block',
    color: '#4d4c46',
    [theme.breakpoints.down('xs')]: {
      width: '100%',
      textAlign: 'center' as 'center',
      marginBottom: '20px',
    },
  },
  twitter: {
    color: '#1da1f2',
    verticalAlign: 'middle',
  },
  linkedin: {
    color: '#0077b5',
    verticalAlign: 'middle',
  },
  icon: {
    fontSize: '3.6rem',
    marginRight: '10px',
    [theme.breakpoints.down('xs')]: {
      marginRight: '0',
Oleksii Savran's avatar
Oleksii Savran committed
104 105 106 107 108
      marginLeft: '0',
    },
    'html[dir="rtl"] &' : {
      marginLeft: '10px',
      marginRight: '0',
Oleksii Savran's avatar
Oleksii Savran committed
109 110
    },
  },
Oleksii Savran's avatar
Oleksii Savran committed
111
  /*tslint:enable*/
Matija Obreza's avatar
Matija Obreza committed
112 113 114 115
});

interface IArticleSectionProps extends React.ClassAttributes<any> {
  classes: any;
Oleksii Savran's avatar
Oleksii Savran committed
116
  className?: string;
Oleksii Savran's avatar
Oleksii Savran committed
117 118 119
  title?: string;
  t: any;
  body: string;
Matija Obreza's avatar
Matija Obreza committed
120 121 122 123 124
}

class ArticleSection extends React.Component<IArticleSectionProps> {

  public render() {
Oleksii Savran's avatar
Oleksii Savran committed
125
    const {classes, className, title, t, body} = this.props;
Matija Obreza's avatar
Matija Obreza committed
126
    return(
Oleksii Savran's avatar
Oleksii Savran committed
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153
      <Grid item xs={ 9 } className={ `${className} ${classes.root}` }>
        <div className={ classes.wrapper }>
          <div className={ classes.text } dangerouslySetInnerHTML={ {__html: body} }/>
          { title && (
            <div className={ classes.social }>
              <div className={ classes.share }>
                { t('cms.public.c.activityPostSection.shareArticle') }
              </div>
              <div className={ classes.socialLink }>
                <ExternalLink link={ `https://twitter.com/intent/tweet?url=${window.location}&GenesysPGR` }>
                  <i className={ `fa fa-twitter-square ${classes.twitter} ${classes.icon}` }/>
                  <span className={ `${classes.twitter} ${classes.socialText}` }>
                { t('cms.public.c.activityPostSection.tweet') }
              </span>
                </ExternalLink>
              </div>
              <div className={ classes.socialLink }>
                <ExternalLink link={ `https://www.linkedin.com/shareArticle?mini=true&url=${window.location}&title=${title}&summary=${body}&source=GenesysPGR` }>
                  <i className={ `fa fa-linkedin-square ${classes.linkedin} ${classes.icon}` }/>
                  <span className={ `${classes.linkedin} ${classes.socialText}` }>
                { t('cms.public.c.activityPostSection.shareLinkedin') }
              </span>
                </ExternalLink>
              </div>
            </div>
          ) }
        </div>
Matija Obreza's avatar
Matija Obreza committed
154 155 156 157 158 159
      </Grid>
    );
  }

}

Oleksii Savran's avatar
Oleksii Savran committed
160
export default translate()(withStyles(styles)(ArticleSection));