Full width/height stories

This commit is contained in:
Josh Perez 2022-04-22 14:36:34 -04:00 committed by GitHub
parent 3a1df01c9e
commit 4602cef6da
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 163 additions and 88 deletions

View file

@ -13,6 +13,10 @@ import { TextAttachmentStyleType } from '../types/Attachment';
import { count } from '../util/grapheme';
import { getDomain } from '../types/LinkPreview';
import { getFontNameByTextScript } from '../util/getFontNameByTextScript';
import {
getHexFromNumber,
getBackgroundColor,
} from '../util/getStoryBackground';
const renderNewLines: RenderTextCallbackType = ({
text: textWithNewLines,
@ -53,20 +57,6 @@ function getTextSize(text: string): TextSize {
return TextSize.Small;
}
function getHexFromNumber(color: number): string {
return `#${color.toString(16).slice(2)}`;
}
function getBackground({ color, gradient }: TextAttachmentType): string {
if (gradient) {
return `linear-gradient(${gradient.angle}deg, ${getHexFromNumber(
gradient.startColor || COLOR_WHITE_INT
)}, ${getHexFromNumber(gradient.endColor || COLOR_WHITE_INT)})`;
}
return getHexFromNumber(color || COLOR_WHITE_INT);
}
function getFont(
text: string,
textSize: TextSize,
@ -123,7 +113,7 @@ export const TextAttachment = ({
<div
className="TextAttachment__story"
style={{
background: getBackground(textAttachment),
background: getBackgroundColor(textAttachment),
transform: `scale(${(contentRect.bounds?.height || 1) / 1280})`,
}}
>