-
Notifications
You must be signed in to change notification settings - Fork 576
/
Copy pathtext.jsx
62 lines (53 loc) · 1.27 KB
/
text.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* @flow */
/** @jsx node */
import {
node,
Style,
type ChildType,
type NullableChildrenType,
} from "@krakenjs/jsx-pragmatic/src";
import { getCSPNonce } from "@paypal/sdk-client/src";
import { CLASS, TEXT_COLOR } from "../../constants";
import css from "./style.scoped.scss";
type TextProps = {|
optional?: boolean | number,
className?: $ReadOnlyArray<string>,
animate?: boolean,
children: NullableChildrenType,
|};
export function Text(
{ optional, className = [], animate, ...rest }: TextProps,
children: NullableChildrenType
): ChildType {
return (
<span
class={[CLASS.TEXT, ...className, animate || CLASS.IMMEDIATE]
.filter(Boolean)
.join(" ")}
optional={optional}
{...rest}
>
{children}
</span>
);
}
export function Space(): ChildType {
return <span class={[CLASS.SPACE].join(" ")}> </span>;
}
type PlaceHolderProps = {|
chars: number,
color?: $Values<typeof TEXT_COLOR>,
|};
export function PlaceHolder({
chars,
color = TEXT_COLOR.WHITE,
}: PlaceHolderProps): ChildType {
const cspNonce = getCSPNonce();
return (
<Style nonce={cspNonce} css={css}>
<div class={["placeholder", `color-${color}`].join(" ")}>
{new Array(chars).fill("x").join("")}
</div>
</Style>
);
}