Skip to content

Commit

Permalink
feat(react): tooltip component
Browse files Browse the repository at this point in the history
  • Loading branch information
VojtechVidra committed Nov 2, 2024
1 parent bccb56c commit 2945635
Show file tree
Hide file tree
Showing 17 changed files with 370 additions and 21 deletions.
62 changes: 51 additions & 11 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion tsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"extends": "@vercel/style-guide/typescript",
"compilerOptions": {
"noEmit": true,
"target": "ES2015",
"target": "ES2017",
"moduleResolution": "Bundler",
"module": "ESNext"
},
Expand Down
3 changes: 2 additions & 1 deletion workspaces/react/.eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
tsup.config.ts
dist
dist
index.d.ts
4 changes: 4 additions & 0 deletions workspaces/react/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
declare module "*.module.css" {
const classes: { readonly [key: string]: string };
export default classes;
}
14 changes: 11 additions & 3 deletions workspaces/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@
},
"devDependencies": {
"@types/node": "^20.16.3",
"@types/react": "^18.3.7",
"tsup": "^8.2.4",
"typescript": "^5.5.4"
"@types/react": "^18.3.12",
"tsup": "^8.3.5",
"typescript": "^5.6.3"
},
"peerDependencies": {
"react": ">=17.0.2"
Expand All @@ -28,6 +28,14 @@
"import": "./dist/index.mjs",
"require": "./dist/index.js",
"types": "./dist/index.d.ts"
},
"./index.css": {
"import": "./dist/index.css",
"require": "./dist/index.css"
}
},
"dependencies": {
"@floating-ui/react-dom": "^2.1.2",
"classnames": "^2.5.1"
}
}
33 changes: 33 additions & 0 deletions workspaces/react/src/components/button/button.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.button {
border-radius: var(--flows-borderRadius-small);
cursor: pointer;
transition:
background-color 120ms ease-in-out,
border-color 120ms ease-in-out;
padding: 4px 8px;
font-family: var(--flows-font-family);
font-size: var(--flows-base-font-size);
line-height: var(--flows-base-line-height);
font-weight: 600;
white-space: nowrap;
text-decoration: none;
}

.primary {
background-color: var(--flows-bg-primary);
border: 1px solid var(--flows-bg-primary);
color: var(--flows-fg-onPrimary);
}
.primary:hover {
background-color: var(--flows-bg-primary-hover);
border: 1px solid var(--flows-bg-primary-hover);
}

.secondary {
background-color: var(--flows-bg-subtle);
border: var(--flows-border);
color: var(--flows-fg-default);
}
.secondary:hover {
background-color: var(--flows-bg-hover);
}
20 changes: 20 additions & 0 deletions workspaces/react/src/components/button/button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import classNames from "classnames";
import { type FC, type ReactNode } from "react";
import classes from "./button.module.css";

interface Props {
className?: string;
children?: ReactNode;
onClick?: () => void;
variant: "primary" | "secondary";
}

export const Button: FC<Props> = ({ className, variant, ...props }) => {
return (
<button
type="button"
className={classNames(classes.button, classes[variant], className)}
{...props}
/>
);
};
17 changes: 17 additions & 0 deletions workspaces/react/src/components/icon-button/icon-button.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
.button {
border-radius: var(--flows-borderRadius-small);
cursor: pointer;
transition:
background-color 120ms ease-in-out,
border-color 120ms ease-in-out;
background-color: rgba(0, 0, 0, 0);
border: none;
padding: 0;
width: 20px;
height: 20px;
display: grid;
place-items: center;
}
.button:hover {
background-color: var(--flows-bg-hover);
}
13 changes: 13 additions & 0 deletions workspaces/react/src/components/icon-button/icon-button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { type FC, type ReactNode } from "react";
import classNames from "classnames";
import classes from "./icon-button.module.css";

interface Props {
className?: string;
children?: ReactNode;
onClick?: () => void;
}

export const IconButton: FC<Props> = ({ className, ...props }) => {
return <button type="button" className={classNames(classes.button, className)} {...props} />;
};
15 changes: 15 additions & 0 deletions workspaces/react/src/components/text/text.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.text {
font-family: var(--flows-font-family);
margin: 0;
}

.body {
font-size: var(--flows-base-font-size);
line-height: var(--flows-base-line-height);
}

.title {
font-size: var(--flows-title-font-size);
line-height: var(--flows-title-line-height);
font-weight: var(--flows-title-font-weight);
}
13 changes: 13 additions & 0 deletions workspaces/react/src/components/text/text.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import classNames from "classnames";
import { type FC, type ReactNode } from "react";
import classes from "./Text.module.css";

interface Props {
className?: string;
children?: ReactNode;
variant: "title" | "body";
}

export const Text: FC<Props> = ({ className, variant, ...props }) => {
return <p className={classNames(classes.text, classes[variant], className)} {...props} />;
};
Loading

0 comments on commit 2945635

Please sign in to comment.