Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

add custom icons

Steven Tey43b23a699136
diff --git a/apps/web/ui/analytics/analytics-options.tsx b/apps/web/ui/analytics/analytics-options.tsx
index c6334c3acc..f743f2e763 100644
--- a/apps/web/ui/analytics/analytics-options.tsx
+++ b/apps/web/ui/analytics/analytics-options.tsx
@@ -1,7 +1,7 @@
import { AnimatedSizeContainer, Popover, useMediaQuery } from "@dub/ui";
import { Button } from "@dub/ui/src/button";
import { ReferredVia } from "@dub/ui/src/icons";
-import { useContext, useState } from "react";
+import { useContext, useEffect, useState } from "react";
import { AnalyticsContext } from ".";
import { ThreeDots } from "../shared/icons";
import ExportButton from "./export-button";
@@ -10,20 +10,24 @@ import ShareAnalytics from "./share-analytics";
export default function AnalyticsOptions() {
const { isMobile } = useMediaQuery();
const { key } = useContext(AnalyticsContext);
-
const [openPopover, setOpenPopover] = useState(false);
const [state, setState] = useState<"default" | "share">("default");
+ useEffect(() => {
+ if (!openPopover || !key) {
+ setState("default");
+ }
+ }, [openPopover, key]);
return (
<Popover
align="end"
content={
<AnimatedSizeContainer width={!isMobile} height>
- {key && state === "share" && <ShareAnalytics />}
+ {state === "share" && <ShareAnalytics />}
{state === "default" && (
- <div className="grid gap-px p-2 sm:w-44">
+ <div className="grid w-full gap-px p-2 sm:w-48">
<ExportButton setOpenPopover={setOpenPopover} />
{key && (
<Button
diff --git a/apps/web/ui/analytics/export-button.tsx b/apps/web/ui/analytics/export-button.tsx
index da020d28a0..572aa142e8 100644
--- a/apps/web/ui/analytics/export-button.tsx
+++ b/apps/web/ui/analytics/export-button.tsx
@@ -1,5 +1,5 @@
import { Button } from "@dub/ui/src/button";
-import { Download } from "lucide-react";
+import { Download } from "@dub/ui/src/icons";
import { Dispatch, SetStateAction, useContext, useState } from "react";
import { toast } from "sonner";
import { AnalyticsContext } from ".";
@@ -41,7 +41,7 @@ export default function ExportButton({
return (
<Button
- text="Export CSV"
+ text="Download as CSV"
variant="outline"
icon={<Download className="h-4 w-4" />}
className="h-9 justify-start px-2 text-black"
diff --git a/apps/web/ui/analytics/share-analytics.tsx b/apps/web/ui/analytics/share-analytics.tsx
index 949d8b8aac..fb459c1195 100644
--- a/apps/web/ui/analytics/share-analytics.tsx
+++ b/apps/web/ui/analytics/share-analytics.tsx
@@ -63,8 +63,8 @@ export default function ShareAnalytics() {
/>
</div>
<p className="text-gray-500">
- Making stats public will allow anyone with the link to see the stats
- for this short link.
+ Making stats public will allow anyone with the link to see the
+ analytics for this short link.
</p>
</div>
<div className="p-4">
diff --git a/packages/ui/src/icons/nucleo/download.tsx b/packages/ui/src/icons/nucleo/download.tsx
new file mode 100644
index 0000000000..3c6f631496
--- /dev/null
+++ b/packages/ui/src/icons/nucleo/download.tsx
@@ -0,0 +1,24 @@
+import { SVGProps } from "react";
+
+export function Download(props: SVGProps<SVGSVGElement>) {
+ return (
+ <svg
+ height="18"
+ width="18"
+ viewBox="0 0 18 18"
+ xmlns="http://www.w3.org/2000/svg"
+ {...props}
+ >
+ <g fill="currentColor">
+ <path
+ d="M15.25,11c-.414,0-.75,.336-.75,.75v1.5c0,.689-.561,1.25-1.25,1.25H4.75c-.689,0-1.25-.561-1.25-1.25v-1.5c0-.414-.336-.75-.75-.75s-.75,.336-.75,.75v1.5c0,1.517,1.233,2.75,2.75,2.75H13.25c1.517,0,2.75-1.233,2.75-2.75v-1.5c0-.414-.336-.75-.75-.75Z"
+ fill="currentColor"
+ />
+ <path
+ d="M8.47,10.78c.146,.146,.338,.22,.53,.22s.384-.073,.53-.22l3.5-3.5c.293-.293,.293-.768,0-1.061s-.768-.293-1.061,0l-2.22,2.22V2.75c0-.414-.336-.75-.75-.75s-.75,.336-.75,.75v5.689l-2.22-2.22c-.293-.293-.768-.293-1.061,0s-.293,.768,0,1.061l3.5,3.5Z"
+ fill="currentColor"
+ />
+ </g>
+ </svg>
+ );
+}
diff --git a/packages/ui/src/icons/nucleo/index.ts b/packages/ui/src/icons/nucleo/index.ts
index d252a53f2f..63645e9884 100644
--- a/packages/ui/src/icons/nucleo/index.ts
+++ b/packages/ui/src/icons/nucleo/index.ts
@@ -1,6 +1,7 @@
export * from "./crosshairs";
export * from "./cube";
export * from "./cursor-rays";
+export * from "./download";
export * from "./flag-wavy";
export * from "./globe";
export * from "./hyperlink";
diff --git a/packages/ui/src/switch.tsx b/packages/ui/src/switch.tsx
index 985f9f3075..fdb4b9f73c 100644
--- a/packages/ui/src/switch.tsx
+++ b/packages/ui/src/switch.tsx
@@ -36,31 +36,25 @@ export function Switch({
return (
<SwitchPrimitive.Root
- checked={checked}
+ checked={loading ? false : checked}
name="switch"
{...(fn && { onCheckedChange: fn })}
- disabled={disabled}
+ disabled={disabled || loading}
className={cn(
- loading
- ? "bg-gray-200"
- : disabled
- ? "cursor-not-allowed bg-gray-300"
- : "radix-state-checked:bg-blue-500 radix-state-unchecked:bg-gray-200 cursor-pointer focus:outline-none focus-visible:ring focus-visible:ring-blue-500 focus-visible:ring-opacity-75",
- "relative inline-flex h-4 w-8 flex-shrink-0 rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out",
+ "radix-state-checked:bg-blue-500 radix-state-unchecked:bg-gray-200 relative inline-flex h-4 w-8 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus-visible:ring focus-visible:ring-blue-500 focus-visible:ring-opacity-75",
+ (disabled || loading) && "cursor-not-allowed",
trackDimensions,
)}
>
- {!loading && (
- <SwitchPrimitive.Thumb
- className={cn(
- `radix-state-checked:${thumbTranslate}`,
- "radix-state-unchecked:translate-x-0",
- `pointer-events-none h-3 w-3 translate-x-4 transform rounded-full bg-white shadow-lg ring-0 transition duration-200 ease-in-out`,
- thumbDimensions,
- thumbTranslate,
- )}
- />
- )}
+ <SwitchPrimitive.Thumb
+ className={cn(
+ `radix-state-checked:${thumbTranslate}`,
+ "radix-state-unchecked:translate-x-0",
+ `pointer-events-none h-3 w-3 translate-x-4 transform rounded-full bg-white shadow-lg ring-0 transition duration-200 ease-in-out`,
+ thumbDimensions,
+ thumbTranslate,
+ )}
+ />
</SwitchPrimitive.Root>
);
}