ArticleSection.tsx 4.06 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 38 39
      marginTop: '30px',
      padding: 0,
      paddingLeft: '11px',
    },
Matija Obreza's avatar
Matija Obreza committed
40
    '& ul > li': {
Matija Obreza's avatar
Matija Obreza committed
41 42 43
      lineHeight: '30px',
    },
  },
Oleksii Savran's avatar
Oleksii Savran committed
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
  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
61 62 63 64
    'html[dir="rtl"] &' : {
      paddingLeft: '0',
      paddingRight: '18px',
    },
Oleksii Savran's avatar
Oleksii Savran committed
65 66 67 68 69 70 71 72 73 74
    '&:hover > a > *': {
      filter: 'brightness(0.5)',
      transition: 'all, 0.1s',
    }
  },
  socialText: {
    [theme.breakpoints.down('sm')]: {
      display: 'none',
    },
  },
Oleksii Savran's avatar
Oleksii Savran committed
75

Oleksii Savran's avatar
Oleksii Savran committed
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
  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
99 100 101 102 103
      marginLeft: '0',
    },
    'html[dir="rtl"] &' : {
      marginLeft: '10px',
      marginRight: '0',
Oleksii Savran's avatar
Oleksii Savran committed
104 105
    },
  },
Oleksii Savran's avatar
Oleksii Savran committed
106
  /*tslint:enable*/
Matija Obreza's avatar
Matija Obreza committed
107 108 109 110
});

interface IArticleSectionProps extends React.ClassAttributes<any> {
  classes: any;
Oleksii Savran's avatar
Oleksii Savran committed
111
  className?: string;
Oleksii Savran's avatar
Oleksii Savran committed
112 113 114
  title?: string;
  t: any;
  body: string;
Matija Obreza's avatar
Matija Obreza committed
115 116 117 118 119
}

class ArticleSection extends React.Component<IArticleSectionProps> {

  public render() {
Oleksii Savran's avatar
Oleksii Savran committed
120
    const {classes, className, title, t, body} = this.props;
Matija Obreza's avatar
Matija Obreza committed
121
    return(
Oleksii Savran's avatar
Oleksii Savran committed
122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148
      <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
149 150 151 152 153 154
      </Grid>
    );
  }

}

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