mirror of
https://github.com/blitzkit/blitzkit.git
synced 2026-10-23 19:49:50 +02:00
migrate 1
This commit is contained in:
1 parent
c637343593
commit
9839d4eef5
14 files changed
+263
-183
No files matched your search
@@ -0,0 +1,45 @@
|
||||
import type { ComponentProps } from "react";
|
||||
import { classNames } from "../../ui/classNames";
|
||||
import type { ColorWithBW } from "../../ui/color";
|
||||
import styles from "./index.module.css";
|
||||
|
||||
export interface TextProps extends ComponentProps<"span"> {
|
||||
weight?: "light" | "regular" | "medium" | "bold" | "black";
|
||||
lowContrast?: boolean;
|
||||
size?: "regular" | "minor" | "major";
|
||||
align?: "left" | "center" | "right";
|
||||
color?: ColorWithBW;
|
||||
}
|
||||
|
||||
export function Text({
|
||||
lowContrast,
|
||||
className,
|
||||
size = "regular",
|
||||
weight,
|
||||
style,
|
||||
align,
|
||||
color = "gray",
|
||||
...props
|
||||
}: TextProps) {
|
||||
const scale = color === "gray" && lowContrast ? "white" : color;
|
||||
const isBW = color === "black" || color === "white";
|
||||
let power: string | number = isBW ? "a12" : 12;
|
||||
|
||||
if (lowContrast) {
|
||||
power = color === "gray" ? "a9" : isBW ? "a11" : 11;
|
||||
}
|
||||
|
||||
return (
|
||||
<span
|
||||
className={classNames(styles.text, className)}
|
||||
data-low-contrast={lowContrast}
|
||||
data-size={size}
|
||||
data-weight={weight}
|
||||
data-align={align === "left" ? undefined : align}
|
||||
style={{
|
||||
color: `var(--${scale}-${power})`,
|
||||
}}
|
||||
{...props}
|
||||
/>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user