diff --git a/scripts/make-dist.mjs b/scripts/make-dist.mjs index 5a41214..cf5ed00 100644 --- a/scripts/make-dist.mjs +++ b/scripts/make-dist.mjs @@ -21,6 +21,7 @@ export { default as PasswordField } from "../src/components/PasswordField.astro" export { default as ThemeSwitcher } from "../src/components/ThemeSwitcher.astro"; export { default as TimePicker } from "../src/components/TimePicker.astro"; export { default as Drawer } from "../src/components/Drawer.astro"; +export { default as Tooltip } from "../src/components/Tooltip.astro"; export { cn } from "../src/utils/cn.js"; `; @@ -41,6 +42,7 @@ export const PasswordField: any; export const ThemeSwitcher: any; export const TimePicker: any; export const Drawer: any; +export const Tooltip: any; export function cn(...classes: Array): string; `; diff --git a/src/components/Drawer.astro b/src/components/Drawer.astro index 0133cba..de2841f 100644 --- a/src/components/Drawer.astro +++ b/src/components/Drawer.astro @@ -18,7 +18,7 @@ export interface Props { const { position = "right", - size = "320px", + size = "384px", overlay = true, closeOnOverlayClick = true, closeOnEsc = true, diff --git a/src/components/Tooltip.astro b/src/components/Tooltip.astro new file mode 100644 index 0000000..43ba2f9 --- /dev/null +++ b/src/components/Tooltip.astro @@ -0,0 +1,432 @@ +--- +import type { HTMLAttributes } from "astro/types"; + +type Placement = + | "bottom-start" + | "bottom" + | "bottom-end" + | "top-start" + | "top" + | "top-end" + | "right-start" + | "right" + | "right-end" + | "left-start" + | "left" + | "left-end"; + +interface Props extends HTMLAttributes<"div"> { + text?: string; // simple string; or use + placement?: Placement; // default: "top" + offset?: number; // gap between trigger & tooltip (default 10) + shiftPadding?: number; // viewport padding (default 8) + showArrow?: boolean; // default true + delayOpen?: number; // ms (default 80) + delayClose?: number; // ms (default 80) + interactive?: boolean; // hoverable panel (default false) + disabled?: boolean; // default false + maxWidth?: number | string; // e.g. 280 or "20rem" (default "18rem") + openOn?: "hover" | "focus" | "hover-focus"; // default "hover-focus" +} + +const { + text, + placement = "top", + offset = 10, + shiftPadding = 8, + showArrow = true, + delayOpen = 80, + delayClose = 80, + interactive = false, + disabled = false, + maxWidth = "18rem", + openOn = "hover", + class: className, + ...rest +}: Props = Astro.props; + +const id = `tt-${Math.random().toString(36).slice(2)}`; +--- + +
+ + + + + + + + + diff --git a/src/index.ts b/src/index.ts index f20e2cd..88a0f6c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -14,6 +14,7 @@ export { default as PasswordField } from "../src/components/PasswordField.astro" export { default as ThemeSwitcher } from "../src/components/ThemeSwitcher.astro"; export { default as TimePicker } from "../src/components/TimePicker.astro"; export { default as Drawer } from "../src/components/Drawer.astro"; +export { default as Tooltip } from "../src/components/Tooltip.astro"; // Utils export { cn } from "./utils/cn"; \ No newline at end of file diff --git a/src/layouts/ComponentLayout.astro b/src/layouts/ComponentLayout.astro index ba18590..74ff221 100644 --- a/src/layouts/ComponentLayout.astro +++ b/src/layouts/ComponentLayout.astro @@ -56,6 +56,9 @@ import Base from "./Base.astro";
  • Drawer
  • +
  • + Tooltip +
  • diff --git a/src/pages/tooltip.astro b/src/pages/tooltip.astro new file mode 100644 index 0000000..5a24373 --- /dev/null +++ b/src/pages/tooltip.astro @@ -0,0 +1,209 @@ +--- +import ComponentLayout from "../layouts/ComponentLayout.astro"; +import Tooltip from "../components/Tooltip.astro"; +import { Icon } from "astro-icon/components"; +--- + + +
    + + + + + + Pricing +
    +
    Pro plan
    +
    + Unlimited projects, priority support. +
    +
    +
    + + + + +
    + +
    +
    + Starter Template +
    +

    + Clean, responsive template with auth, dashboard & + billing. +

    +
    + + +
    +
    +
    +
    + +
    + + + +
    + + +
    +
    Report.pdf
    +
    + 1.2 MB ยท Updated today +
    +
    + +
    + + +
    + +
    +
    + +
    + + + + + +
    +
    + Create your first project + 1 / 3 +
    +

    + Projects group your tasks, docs and members. You can + rename anytime. +

    +
    + + +
    +
    +
    +
    +
    +