Added CharacterCounter to ComposeDestinationHeader
• Added: - CharacterCounter to ComposeDestinationHeader - Styles for stroke colors for CharacterCounter • Updated: - CharacterCounter styles, heights to fit in header
This commit is contained in:
parent
0456ccfb2a
commit
5d1a40d936
|
@ -12,11 +12,12 @@ class CharacterCounter extends React.PureComponent {
|
||||||
render() {
|
render() {
|
||||||
const { text, max } = this.props
|
const { text, max } = this.props
|
||||||
|
|
||||||
const actualRadius = 16
|
const actualRadius = 10
|
||||||
const radius = 12
|
const radius = 8
|
||||||
const circumference = 2 * Math.PI * radius
|
const circumference = 2 * Math.PI * radius
|
||||||
const diff = Math.min(length(text), max) / max
|
const diff = Math.min(length(text), max) / max
|
||||||
const dashoffset = circumference * (1 - diff)
|
const dashoffset = circumference * (1 - diff)
|
||||||
|
const circleClass = length(text) > max ? _s.strokeError : _s.strokeBrand
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={[_s.d, _s.mr10, _s.jcCenter, _s.aiCenter].join(' ')}>
|
<div className={[_s.d, _s.mr10, _s.jcCenter, _s.aiCenter].join(' ')}>
|
||||||
|
@ -31,8 +32,8 @@ class CharacterCounter extends React.PureComponent {
|
||||||
cy={actualRadius}
|
cy={actualRadius}
|
||||||
r={radius}
|
r={radius}
|
||||||
fill='none'
|
fill='none'
|
||||||
stroke='#e6e6e6'
|
|
||||||
strokeWidth='2'
|
strokeWidth='2'
|
||||||
|
className={_s.strokeSecondary}
|
||||||
/>
|
/>
|
||||||
<circle
|
<circle
|
||||||
style={{
|
style={{
|
||||||
|
@ -43,9 +44,9 @@ class CharacterCounter extends React.PureComponent {
|
||||||
cx={actualRadius}
|
cx={actualRadius}
|
||||||
cy={actualRadius}
|
cy={actualRadius}
|
||||||
r={radius}
|
r={radius}
|
||||||
strokeWidth='2'
|
strokeWidth='2.25'
|
||||||
strokeLinecap='round'
|
strokeLinecap='round'
|
||||||
stroke='#21cf7a'
|
className={circleClass}
|
||||||
/>
|
/>
|
||||||
</svg>
|
</svg>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -6,6 +6,7 @@ import ImmutablePropTypes from 'react-immutable-proptypes'
|
||||||
import {
|
import {
|
||||||
CX,
|
CX,
|
||||||
MODAL_COMPOSE,
|
MODAL_COMPOSE,
|
||||||
|
MAX_POST_CHARACTER_COUNT,
|
||||||
POPOVER_COMPOSE_POST_DESTINATION,
|
POPOVER_COMPOSE_POST_DESTINATION,
|
||||||
} from '../../../constants'
|
} from '../../../constants'
|
||||||
import { openModal } from '../../../actions/modal'
|
import { openModal } from '../../../actions/modal'
|
||||||
|
@ -14,6 +15,7 @@ import Avatar from '../../../components/avatar'
|
||||||
import Button from '../../../components/button'
|
import Button from '../../../components/button'
|
||||||
import Icon from '../../../components/icon'
|
import Icon from '../../../components/icon'
|
||||||
import Text from '../../../components/text'
|
import Text from '../../../components/text'
|
||||||
|
import CharacterCounter from '../../../components/character_counter'
|
||||||
|
|
||||||
class ComposeDestinationHeader extends ImmutablePureComponent {
|
class ComposeDestinationHeader extends ImmutablePureComponent {
|
||||||
|
|
||||||
|
@ -38,6 +40,7 @@ class ComposeDestinationHeader extends ImmutablePureComponent {
|
||||||
composeGroup,
|
composeGroup,
|
||||||
composeGroupId,
|
composeGroupId,
|
||||||
formLocation,
|
formLocation,
|
||||||
|
text,
|
||||||
} = this.props
|
} = this.props
|
||||||
|
|
||||||
const isIntroduction = formLocation === 'introduction'
|
const isIntroduction = formLocation === 'introduction'
|
||||||
|
@ -85,6 +88,10 @@ class ComposeDestinationHeader extends ImmutablePureComponent {
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
{
|
||||||
|
!!text &&
|
||||||
|
<CharacterCounter max={MAX_POST_CHARACTER_COUNT} text={text} />
|
||||||
|
}
|
||||||
{
|
{
|
||||||
!isModal && !isIntroduction &&
|
!isModal && !isIntroduction &&
|
||||||
<Button
|
<Button
|
||||||
|
@ -94,6 +101,7 @@ class ComposeDestinationHeader extends ImmutablePureComponent {
|
||||||
color='tertiary'
|
color='tertiary'
|
||||||
icon='fullscreen'
|
icon='fullscreen'
|
||||||
onClick={this.handleOnExpand}
|
onClick={this.handleOnExpand}
|
||||||
|
className={_s.ml10}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
</div>
|
</div>
|
||||||
|
@ -106,6 +114,7 @@ const mapStateToProps = (state) => {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
composeGroupId,
|
composeGroupId,
|
||||||
|
text: state.getIn(['compose', 'text']),
|
||||||
isReply: !!state.getIn(['compose', 'in_reply_to']),
|
isReply: !!state.getIn(['compose', 'in_reply_to']),
|
||||||
isEdit: state.getIn(['compose', 'id']) !== null,
|
isEdit: state.getIn(['compose', 'id']) !== null,
|
||||||
composeGroup: state.getIn(['groups', composeGroupId]),
|
composeGroup: state.getIn(['groups', composeGroupId]),
|
||||||
|
|
|
@ -1137,6 +1137,10 @@ pre {
|
||||||
color: var(--navigation_brand);
|
color: var(--navigation_brand);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.strokeBrand { stroke: var(--color_brand); }
|
||||||
|
.strokeSecondary { stroke: var(--solid_color_secondary); }
|
||||||
|
.strokeError { stroke: var(--color_red); }
|
||||||
|
|
||||||
.navigationUnderlineActive:after {
|
.navigationUnderlineActive:after {
|
||||||
content: '';
|
content: '';
|
||||||
display: block;
|
display: block;
|
||||||
|
|
Loading…
Reference in New Issue