Skip to content

Commit

Permalink
enhance transparent theme & hashtag & cw button (#238)
Browse files Browse the repository at this point in the history
  • Loading branch information
mashirozx authored Oct 19, 2020
1 parent f729b29 commit 6ab7507
Show file tree
Hide file tree
Showing 6 changed files with 566 additions and 489 deletions.
16 changes: 14 additions & 2 deletions app/javascript/mastodon/components/status_content.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,8 +232,20 @@ export default class StatusContent extends React.PureComponent {
const renderReadMore = this.props.onClick && status.get('collapsed');
const renderViewThread = this.props.showThread && status.get('in_reply_to_id') && status.get('in_reply_to_account_id') === status.getIn(['account', 'id']);

const content = { __html: status.get('contentHtml') };
const spoilerContent = { __html: status.get('spoilerHtml') };
const htmlContent = htmlPare(status.get('contentHtml'));
htmlContent.querySelectorAll('.hashtag').forEach((e)=>{
console.log(e.innerHTML);
e.set_content(e.innerHTML.replace('#', '<span class="hash_char">#</span>'));
})
const content = { __html: htmlContent.toString() };

const htmlSpoilerContent = htmlPare(status.get('spoilerHtml'));
htmlSpoilerContent.querySelectorAll('.hashtag').forEach((e)=>{
console.log(e.innerHTML);
e.set_content(e.innerHTML.replace('#', '<span class="hash_char">#</span>'));
})
const spoilerContent = { __html: htmlSpoilerContent.toString() };

const directionStyle = { direction: 'ltr' };
const classNames = classnames('status__content', {
'status__content--with-action': this.props.onClick && this.context.router,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ class ContentTypeDropdown extends React.PureComponent {
const { intl: { formatMessage } } = this.props;

this.options = [
{ icon: 'pen-nib:fas', value: 'text/plain', text: formatMessage(messages.plain), meta: null },
{ icon: 'feather:fas', value: 'text/plain', text: formatMessage(messages.plain), meta: null },
{ icon: 'markdown:fab', value: 'text/markdown', text: formatMessage(messages.markdown), meta: null },
];
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/**
* This file substitude `text_icon_button.js`
* @ mashiro
*/
import React from 'react';
import PropTypes from 'prop-types';
import IconButton from '../../../components/icon_button';
import { defineMessages, injectIntl } from 'react-intl';

const messages = defineMessages({
marked: { id: 'compose_form.spoiler.marked', defaultMessage: 'Text is hidden behind warning' },
unmarked: { id: 'compose_form.spoiler.unmarked', defaultMessage: 'Text is not hidden' },
});

const iconStyle = {
height: null,
lineHeight: '27px',
};

export default
@injectIntl
class CwMarkIconButton extends React.PureComponent {

static propTypes = {
active: PropTypes.bool,
onClick: PropTypes.func.isRequired,
intl: PropTypes.object.isRequired,
disabled: PropTypes.bool,
};

handleClick = (e) => {
e.preventDefault();
this.props.onClick();
}

render () {
const { intl, disabled, active } = this.props;

return (
<div className='compose-form__poll-button'>
<IconButton
icon='theater-masks'
title={intl.formatMessage(active ? messages.marked : messages.unmarked)}
disabled={disabled}
onClick={this.handleClick}
className={`compose-form__poll-button-icon ${active ? 'active' : ''}`}
size={18}
inverted
style={iconStyle}
/>
</div>
);
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { connect } from 'react-redux';
import TextIconButton from '../components/text_icon_button';
// import TextIconButton from '../components/text_icon_button';
import CwMarkIconButton from '../components/cw_mark_button';
import { changeComposeSpoilerness } from '../../../actions/compose';
import { injectIntl, defineMessages } from 'react-intl';

Expand All @@ -23,4 +24,5 @@ const mapDispatchToProps = dispatch => ({

});

export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(TextIconButton));
// export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(TextIconButton));
export default injectIntl(connect(mapStateToProps, mapDispatchToProps)(CwMarkIconButton));
Loading

0 comments on commit 6ab7507

Please sign in to comment.