Skip to content

Commit

Permalink
Merge pull request #9664 from Automattic/add/auto-direction
Browse files Browse the repository at this point in the history
Add auto language direction in reader
  • Loading branch information
blowery authored Dec 7, 2016
2 parents a3803e0 + 09a0fc2 commit 8da32e5
Show file tree
Hide file tree
Showing 10 changed files with 1,013 additions and 23 deletions.
23 changes: 13 additions & 10 deletions client/blocks/comments/form.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { translate } from 'i18n-calypso';
/**
* Internal dependencies
*/
import AutoDirection from 'components/auto-direction';
import Gravatar from 'components/gravatar';
import Notice from 'components/notice';
import {
Expand Down Expand Up @@ -200,16 +201,18 @@ class PostCommentForm extends React.Component {
<label>
<div className={ expandingAreaClasses }>
<pre><span>{ this.state.commentText }</span><br /></pre>
<textarea
value={ this.state.commentText }
placeholder={ translate( 'Enter your comment here…' ) }
ref={ this.handleTextAreaNode }
onKeyUp={ this.handleKeyUp }
onKeyDown={ this.handleKeyDown }
onFocus={ this.handleFocus }
onBlur={ this.handleBlur }
onChange={ this.handleTextChange }
/>
<AutoDirection>
<textarea
value={ this.state.commentText }
placeholder={ translate( 'Enter your comment here…' ) }
ref={ this.handleTextAreaNode }
onKeyUp={ this.handleKeyUp }
onKeyDown={ this.handleKeyDown }
onFocus={ this.handleFocus }
onBlur={ this.handleBlur }
onChange={ this.handleTextChange }
/>
</AutoDirection>
</div>
<button
ref="commentButton"
Expand Down
7 changes: 5 additions & 2 deletions client/blocks/comments/post-comment-content.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
* External dependencies
*/
import React, { PropTypes } from 'react';
import AutoDirection from 'components/auto-direction';

export default class PostCommentContent extends React.Component {
render() {
Expand All @@ -12,8 +13,10 @@ export default class PostCommentContent extends React.Component {

/*eslint-disable react/no-danger*/
return (
<div className="comments__comment-content" dangerouslySetInnerHTML={ { __html: this.props.content } }>
</div>
<AutoDirection>
<div className="comments__comment-content" dangerouslySetInnerHTML={ { __html: this.props.content } }>
</div>
</AutoDirection>
);
/*eslint-enable react/no-danger*/
}
Expand Down
13 changes: 8 additions & 5 deletions client/blocks/reader-full-post/header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import classNames from 'classnames';
/**
* Internal dependencies
*/
import AutoDirection from 'components/auto-direction';
import ExternalLink from 'components/external-link';
import { recordPermalinkClick } from 'reader/stats';
import PostTime from 'reader/post-time';
Expand All @@ -32,11 +33,13 @@ const ReaderFullPostHeader = ( { post } ) => {
return (
<div className={ classNames( classes ) }>
{ post.title
? <h1 className="reader-full-post__header-title" onClick={ handlePermalinkClick }>
<ExternalLink className="reader-full-post__header-title-link" href={ post.URL } target="_blank" icon={ false }>
{ post.title }
</ExternalLink>
</h1>
? <AutoDirection>
<h1 className="reader-full-post__header-title" onClick={ handlePermalinkClick }>
<ExternalLink className="reader-full-post__header-title-link" href={ post.URL } target="_blank" icon={ false }>
{ post.title }
</ExternalLink>
</h1>
</AutoDirection>
: null }
<div className="reader-full-post__header-meta">
{ post.date
Expand Down
5 changes: 4 additions & 1 deletion client/blocks/reader-full-post/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { get } from 'lodash';
/**
* Internal Dependencies
*/
import AutoDirection from 'components/auto-direction';
import ReaderMain from 'components/reader-main';
import EmbedContainer from 'components/embed-container';
import PostExcerpt from 'components/post-excerpt';
Expand Down Expand Up @@ -316,10 +317,12 @@ export class FullPostView extends React.Component {
{ post.use_excerpt
? <PostExcerpt content={ post.better_excerpt ? post.better_excerpt : post.excerpt } />
: <EmbedContainer>
<AutoDirection>
<div
className="reader-full-post__story-content"
dangerouslySetInnerHTML={ { __html: post.content } } />
</EmbedContainer>
</AutoDirection>
</EmbedContainer>
}

{ post.use_excerpt && ! isDiscoverPost( post )
Expand Down
4 changes: 4 additions & 0 deletions client/blocks/reader-full-post/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,10 @@
margin-top: 8px;
}

.reader-full-post__header-title-link {
display: block;
}

.reader-full-post__header-title-link,
.reader-full-post__header-title-link:hover {
color: $gray-dark;
Expand Down
11 changes: 7 additions & 4 deletions client/blocks/reader-post-card/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import closest from 'component-closest';
/**
* Internal Dependencies
*/
import AutoDirection from 'components/auto-direction';
import Card from 'components/card';
import DisplayTypes from 'state/reader/posts/display-types';
import ReaderPostActions from 'blocks/reader-post-actions';
Expand Down Expand Up @@ -152,10 +153,12 @@ export default class RefreshPostCard extends React.Component {
{ ! isGallery && featuredAsset }
{ isGallery && <PostGallery post={ post } /> }
<div className="reader-post-card__post-details">
<h1 className="reader-post-card__title">
<a className="reader-post-card__title-link" href={ post.URL }>{ title }</a>
</h1>
{ showExcerpt && <div className="reader-post-card__excerpt">{ post[ excerptAttribute ] }</div> }
<AutoDirection>
<h1 className="reader-post-card__title">
<a className="reader-post-card__title-link" href={ post.URL }>{ title }</a>
</h1>
</AutoDirection>
{ showExcerpt && <AutoDirection><div className="reader-post-card__excerpt">{ post[ excerptAttribute ] }</div></AutoDirection> }
{ isDailyPostChallengeOrPrompt( post ) && <DailyPostButton post={ post } tagName="span" /> }
{ post &&
<ReaderPostActions
Expand Down
17 changes: 17 additions & 0 deletions client/blocks/reader-post-card/style.scss
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ $reader-post-card-breakpoint-small: "( max-width: 550px )";
cursor: pointer;
font-size: 18px;
font-weight: 700;
display: block;

&:hover {
color: $gray-dark;
Expand Down Expand Up @@ -381,6 +382,22 @@ $reader-post-card-breakpoint-small: "( max-width: 550px )";
height: 15px * 1.6;
}
}

.reader-post-card__excerpt[direction=rtl] {
&::before {
@include long-content-fade( $direction: left, $size: 15px * 1.6 * 5 );
top: inherit;
height: 15px * 1.6;
}
}

.reader-post-card__excerpt[direction=ltr] {
&::before {
@include long-content-fade( $direction: right, $size: 15px * 1.6 * 5 );
top: inherit;
height: 15px * 1.6;
}
}
}

// Action buttons in post card
Expand Down
Loading

0 comments on commit 8da32e5

Please sign in to comment.