Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enhance transparent theme & hashtag & cw button #238

Merged
merged 1 commit into from
Oct 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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