notification count positioning

pull/1113/head
Vincent 5 years ago
parent 5564bfa134
commit a0cec3f0fd

@ -295,19 +295,21 @@ textarea {
display: flex; display: flex;
align-items: center; align-items: center;
justify-content: center; justify-content: center;
font-family: $session-font-accent; font-family: $session-font-default;
border-radius: 50%; border-radius: 50%;
font-weight: 700; font-weight: 700;
background: $session-color-danger; background: $session-color-danger;
color: $session-color-white; color: $session-color-white;
text-align: center; text-align: center;
span { div {
position: relative; position: relative;
sup { sup {
font-size: 130%;
position: absolute; position: absolute;
font-size: 1.3em;
top: -0.5em;
margin-left: -0.125em;
} }
} }

@ -30,28 +30,24 @@ export class SessionNotificationCount extends React.Component<Props> {
const MAX_SINGLE_DIGIT = 9; const MAX_SINGLE_DIGIT = 9;
const overflow = typeof count === 'number' && count > MAX_SINGLE_DIGIT; const overflow = typeof count === 'number' && count > MAX_SINGLE_DIGIT;
const fontSizeVal = overflow ? size / 2 : size / 2 + 2;
const fontSize = `${fontSizeVal}px`;
const bubbleStyle = { const bubbleStyle = {
width: `${size}px`, width: `${size}px`,
height: `${size}px`, height: `${size}px`,
fontSize: `${size}px`,
}; };
const fontSize = overflow ? '0.5em' : '0.6em';
const countStyle = { const countStyle = {
fontSize, fontSize,
marginTop: overflow ? `${size / 8}px` : '0px', marginTop: overflow ? '0.35em' : '0em',
marginLeft: overflow ? `-${size / 4}px` : '0px', marginLeft: overflow ? '-0.45em' : '0em',
};
const supStyle = {
top: `-${size * (3 / 8)}px`,
}; };
const countElement: JSX.Element = overflow ? ( const countElement: JSX.Element = overflow ? (
<> <>
{MAX_SINGLE_DIGIT} {MAX_SINGLE_DIGIT}
<sup style={supStyle}>+</sup> <sup>+</sup>
</> </>
) : ( ) : (
<>{count}</> <>{count}</>
@ -68,7 +64,7 @@ export class SessionNotificationCount extends React.Component<Props> {
style={bubbleStyle} style={bubbleStyle}
role="button" role="button"
> >
<span style={countStyle}>{countElement}</span> <div style={countStyle}>{countElement}</div>
</div> </div>
)} )}
</> </>

Loading…
Cancel
Save