signal-desktop/sticker-creator/elements/Typography.tsx

77 lines
1.5 KiB
TypeScript
Raw Normal View History

2020-10-30 20:34:04 +00:00
// Copyright 2019-2020 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
2019-12-17 20:25:57 +00:00
import * as React from 'react';
import classnames from 'classnames';
2019-12-17 20:25:57 +00:00
import * as styles from './Typography.scss';
export type Props = {
children: React.ReactNode;
};
export type HeadingProps = React.HTMLAttributes<HTMLHeadingElement>;
export type ParagraphProps = React.HTMLAttributes<HTMLParagraphElement> & {
2019-12-17 20:25:57 +00:00
center?: boolean;
wide?: boolean;
secondary?: boolean;
2019-12-17 20:25:57 +00:00
};
export type SpanProps = React.HTMLAttributes<HTMLSpanElement>;
2019-12-17 20:25:57 +00:00
2022-11-18 00:45:19 +00:00
export const H1 = React.memo(function H1Inner({
children,
className,
...rest
}: Props & HeadingProps) {
return (
2019-12-17 20:25:57 +00:00
<h1 className={classnames(styles.h1, className)} {...rest}>
{children}
</h1>
2022-11-18 00:45:19 +00:00
);
});
2019-12-17 20:25:57 +00:00
2022-11-18 00:45:19 +00:00
export const H2 = React.memo(function H2Inner({
children,
className,
...rest
}: Props & HeadingProps) {
return (
2019-12-17 20:25:57 +00:00
<h2 className={classnames(styles.h2, className)} {...rest}>
{children}
</h2>
2022-11-18 00:45:19 +00:00
);
});
2019-12-17 20:25:57 +00:00
2022-11-18 00:45:19 +00:00
export const Text = React.memo(function TextInner({
children,
className,
center,
secondary,
...rest
}: Props & ParagraphProps) {
return (
2019-12-17 20:25:57 +00:00
<p
className={classnames(
center ? styles.textCenter : styles.text,
secondary ? styles.secondary : null,
2019-12-17 20:25:57 +00:00
className
)}
{...rest}
>
{children}
</p>
2022-11-18 00:45:19 +00:00
);
});
2019-12-17 20:25:57 +00:00
2022-11-18 00:45:19 +00:00
export const Inline = React.memo(function InlineInner({
children,
className,
...rest
}: Props & SpanProps) {
return (
2019-12-17 20:25:57 +00:00
<span className={classnames(styles.text, className)} {...rest}>
{children}
</span>
2022-11-18 00:45:19 +00:00
);
});