Skip to content

Commit

Permalink
add: color and hover
Browse files Browse the repository at this point in the history
  • Loading branch information
Khumoyun Inoyatov authored and souljja committed Mar 11, 2024
1 parent 5706a53 commit a00fed4
Show file tree
Hide file tree
Showing 4 changed files with 155 additions and 17 deletions.
1 change: 1 addition & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@
"no-void": "off",
"no-continue": "off",
"no-unused-vars": "off",
"no-case-declarations": "off",
"no-restricted-imports": [
"error",
{
Expand Down
3 changes: 3 additions & 0 deletions src/assets/wavy_line.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
114 changes: 114 additions & 0 deletions src/components/text/text.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,118 @@
line-height: 24px;
letter-spacing: 0;
text-align: left;
}

.white {
color: #ffffff;
}

.black {
color: #002F3F;
}

.primary {
color: #0E7C73;
}

.secondary {
color: #97CAEF;
}

.tertiary {
color: #973CEF;
}

.link {
font-family: Lato, sans-serif;
font-size: 16px;
font-weight: 600;
line-height: 24px;
letter-spacing: 0;
text-align: left;
}

.title {
font-family: Lato, sans-serif;
font-weight: 500;
&:hover {
span {
&:before {
width: 100%;
transition: all ease-out 0.3s;
}
}
}
span {
display: inline;
position: relative;
&:before {
content: "";
position: absolute;
left: 0;
bottom: -2px;
height: 2px;
width: 33%;
background-color: #0E7C73;
}
}

&.h1 {
font-size: 40px;
line-height: 48px;
letter-spacing: 0;
text-align: left;
}

&.h2 {
font-size: 32px;
line-height: 48px;
letter-spacing: 0;
text-align: left;
}

&.h3 {
font-size: 24px;
line-height: 36px;
letter-spacing: 0;
text-align: left;
}

&.h4 {
font-size: 20px;
line-height: 30px;
letter-spacing: 0;
text-align: left;
span {
&:before {
display: none;
}
}
}
}

.paragraph {
font-family: Open Sans, sans-serif;
font-size: 16px;
font-weight: 400;
line-height: 24px;
letter-spacing: 0;
text-align: left;
}

.small {
font-family: Open Sans, sans-serif;
font-size: 14px;
font-weight: 400;
line-height: 24px;
letter-spacing: 0;
}

.default {
font-family: Lato, sans-serif;
font-size: 16px;
font-weight: 600;
line-height: 24px;
letter-spacing: 0;
text-align: left;
}
54 changes: 37 additions & 17 deletions src/components/text/text.tsx
Original file line number Diff line number Diff line change
@@ -1,41 +1,61 @@
import { ReactNode } from "react";
import cc from "classcat";
import { Link } from "react-router-dom";
import "./text.scss";

export type TextVariant = "link" | "name" | "title" | "text" | "default";
export type TextVariant = "link" | "title" | "paragraph" | "small" | "default";
export type TextColor =
| "primary"
| "secondary"
| "tertiary"
| "black"
| "white";

export interface IProps {
variant: TextVariant;
className: string;
variant?: TextVariant;
className?: string;
children: string | ReactNode;
link: string;
link?: string;
headingLevel?: keyof JSX.IntrinsicElements;
color?: TextColor;
}

export const Text = ({
variant = "default",
className,
children,
link,
headingLevel = "h2",
color = "black",
}: IProps) => {
const commonProps = {
className: cc(["text", variant, headingLevel, className, color]),
children,
};

switch (variant) {
case "link":
return (
<Link to={link} className={cc(["text", variant, className])}>
{children}
</Link>
return link ? (
// eslint-disable-next-line jsx-a11y/anchor-has-content
<a href={link} {...commonProps} />
) : (
<span {...commonProps} />
);
case "name":
case "title":
const HeadingComponent: React.ElementType = headingLevel;
return (
<span className={cc(["text", variant, className])}>{children}</span>
<HeadingComponent
className={cc(["text", variant, headingLevel, color, className])}
>
<span>{children}</span>
</HeadingComponent>
);
case "title":
return <h1 className={cc(["text", variant, className])}>{children}</h1>;
case "text":
return <p className={cc(["text", variant, className])}>{children}</p>;
case "paragraph":
return <p {...commonProps} />;
case "small":
return <p {...commonProps} />;
case "default":
return <div className={cc(["text", variant, className])}>{children}</div>;
return <div {...commonProps} />;
default:
return <div className={cc(["text", variant, className])}>{children}</div>;
return <div {...commonProps} />;
}
};

0 comments on commit a00fed4

Please sign in to comment.