Skip to content

Create polished demo videos without editing skills. Mac/Windows/Linux

add: source selector with incredible marquee !!!

Alan Trebugeaisd3246ad85ff9
diff --git a/src/components/launch/LaunchWindow.module.css b/src/components/launch/LaunchWindow.module.css
index 59ab66c1..9a60e307 100644
--- a/src/components/launch/LaunchWindow.module.css
+++ b/src/components/launch/LaunchWindow.module.css
@@ -98,39 +98,7 @@
color: #4eeeb0;
}
-.screenSel {
- position: relative;
- display: inline-flex;
- align-items: center;
- gap: 7px;
- height: 40px;
- min-width: 0;
- max-width: 640px;
- padding: 0 14px 0 12px;
- border-radius: 11px;
- border: 1px solid #2a2a34;
- background: #1a1a22;
- color: #eeeef2;
- font-size: 12px;
- font-weight: 500;
- cursor: pointer;
- transition: all 0.15s ease;
- flex: 0 1 auto;
-}
-
-.screenSel:hover {
- border-color: #3e3e4c;
- background: #20202a;
-}
-.sourceLabel {
- display: inline-block;
- min-width: 0;
- max-width: 520px;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
-}
.menuArea {
flex: 1;
diff --git a/src/components/launch/LaunchWindow.tsx b/src/components/launch/LaunchWindow.tsx
index 5adc58bc..864e8de6 100644
--- a/src/components/launch/LaunchWindow.tsx
+++ b/src/components/launch/LaunchWindow.tsx
@@ -812,7 +812,11 @@ export function LaunchWindow() {
useEffect(() => {
const handleClick = (e: MouseEvent) => {
- if (dropdownRef.current && !dropdownRef.current.contains(e.target as Node)) {
+ const target = e.target as Node;
+ const isInsideDropdown = dropdownRef.current?.contains(target);
+ const isInsideHudBar = hudBarRef.current?.contains(target);
+
+ if (!isInsideDropdown && !isInsideHudBar) {
setActiveDropdown("none");
setProjectBrowserOpen(false);
}
@@ -984,23 +988,16 @@ export function LaunchWindow() {
<>
{platform !== "linux" && (
<>
- <button
- type="button"
- className={`${styles.screenSel} ${styles.electronNoDrag}`}
- onClick={() => toggleDropdown("sources")}
- title={selectedSource}
- >
- <Monitor size={16} />
- <ContentClamp className={styles.sourceLabel} truncateLength={36}>
- {selectedSource}
- </ContentClamp>
- <ChevronUp
- size={10}
- className={`text-[#6b6b78] ml-0.5 transition-transform duration-200 ${
- activeDropdown === "sources" ? "" : "rotate-180"
- }`}
- />
- </button>
+ <SourceSelector
+ screenSources={screenSources}
+ windowSources={windowSources}
+ selectedSource={selectedSource}
+ loading={sourcesLoading}
+ onSourceSelect={handleSourceSelect}
+ onFetchSources={fetchSources}
+ open={activeDropdown === "sources"}
+ onOpenChange={(open) => setActiveDropdown(open ? "sources" : "none")}
+ />
<Separator orientation="vertical" className="mx-[5px] h-6" />
</>
@@ -1146,23 +1143,9 @@ export function LaunchWindow() {
/>
</div>
) : null}
- {activeDropdown !== "none" && (
+ {activeDropdown !== "none" && activeDropdown !== "sources" && (
<div className={`${styles.menuCard} ${styles.electronNoDrag}`}>
- {activeDropdown === "sources" && (
- <div className="p-2">
- <SourceSelector
- screenSources={screenSources}
- windowSources={windowSources}
- selectedSource={selectedSource}
- loading={sourcesLoading}
- onSourceSelect={handleSourceSelect}
- onFetchSources={fetchSources}
- open={activeDropdown === "sources"}
- onOpenChange={(open) => setActiveDropdown(open ? "sources" : "none")}
- />
- </div>
- )}
-
+
{activeDropdown === "mic" && (
<>
<div className={styles.ddLabel}>
diff --git a/src/components/launch/SourceSelector.css b/src/components/launch/SourceSelector.css
new file mode 100644
index 00000000..07198774
--- /dev/null
+++ b/src/components/launch/SourceSelector.css
@@ -0,0 +1,35 @@
+/* Custom Scrollbar for Source Selector */
+.source-selector-scroll::-webkit-scrollbar {
+ width: 5px;
+ height: 5px;
+}
+
+.source-selector-scroll::-webkit-scrollbar-track {
+ background: transparent;
+}
+
+.source-selector-scroll::-webkit-scrollbar-thumb {
+ background: rgba(107, 107, 120, 0.2);
+ border-radius: 20px;
+ transition: background 0.2s ease;
+}
+
+.source-selector-scroll::-webkit-scrollbar-thumb:hover {
+ background: rgba(107, 107, 120, 0.4);
+}
+
+/* Support for Firefox */
+.source-selector-scroll {
+ scrollbar-width: thin;
+ scrollbar-color: rgba(107, 107, 120, 0.2) transparent;
+}
+
+/* Marquee Animation */
+@keyframes marquee {
+ 0% {
+ transform: translateX(0);
+ }
+ 100% {
+ transform: translateX(var(--marquee-translate));
+ }
+}
diff --git a/src/components/launch/SourceSelector.tsx b/src/components/launch/SourceSelector.tsx
index 2c62f2b3..1266733d 100644
--- a/src/components/launch/SourceSelector.tsx
+++ b/src/components/launch/SourceSelector.tsx
@@ -1,10 +1,11 @@
import * as React from "react";
-import { Monitor, AppWindow } from "@phosphor-icons/react";
+import { Monitor, AppWindow, CaretUp as ChevronUp } from "@phosphor-icons/react";
import { useMemo, useCallback, useEffect } from "react";
import { useScopedT } from "@/contexts/I18nContext";
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover";
import { Button } from "@/components/ui/button";
import { cn } from "@/lib/utils";
+import "./SourceSelector.css";
interface DesktopSource {
id: string;
@@ -17,6 +18,83 @@ interface DesktopSource {
windowTitle?: string;
}
+const MarqueeText = ({
+ text,
+ className,
+ speed = 50, // px per second
+}: {
+ text: string;
+ className?: string;
+ speed?: number;
+}) => {
+ const containerRef = React.useRef<HTMLDivElement>(null);
+ const [shouldMarquee, setShouldMarquee] = React.useState(false);
+ const [duration, setDuration] = React.useState(0);
+ const [translate, setTranslate] = React.useState("0px");
+
+ React.useEffect(() => {
+ const checkOverflow = () => {
+ const container = containerRef.current;
+ if (container) {
+ const containerWidth = container.clientWidth;
+ // Create a temporary span to measure the text width accurately
+ const span = document.createElement("span");
+ span.style.visibility = "hidden";
+ span.style.position = "absolute";
+ span.style.whiteSpace = "nowrap";
+ span.style.font = window.getComputedStyle(container).font;
+ span.innerText = text;
+ document.body.appendChild(span);
+
+ const textWidth = span.offsetWidth;
+ document.body.removeChild(span);
+
+ const hasOverflow = textWidth > containerWidth && containerWidth > 0;
+ setShouldMarquee(hasOverflow);
+
+ if (hasOverflow) {
+ const overflow = textWidth - containerWidth;
+ setDuration(textWidth / speed);
+ setTranslate(`-${overflow}px`);
+ }
+ }
+ };
+
+ // Use a small timeout to ensure layout is done
+ const timeout = setTimeout(checkOverflow, 50);
+
+ window.addEventListener("resize", checkOverflow);
+ return () => {
+ clearTimeout(timeout);
+ window.removeEventListener("resize", checkOverflow);
+ };
+ }, [text, speed]);
+
+ return (
+ <div
+ ref={containerRef}
+ className={cn("relative overflow-hidden w-full", className)}
+ >
+ <div
+ className={cn(
+ "whitespace-nowrap transition-all duration-500",
+ shouldMarquee ? "truncate group-hover:overflow-visible group-hover:w-max group-hover:animate-[marquee_var(--marquee-duration)_linear_infinite_alternate]" : "truncate"
+ )}
+ style={
+ shouldMarquee
+ ? ({
+ "--marquee-duration": `${duration}s`,
+ "--marquee-translate": translate,
+ } as React.CSSProperties)
+ : {}
+ }
+ >
+ {text}
+ </div>
+ </div>
+ );
+};
+
interface SourceSelectorProps {
/** List of available screen sources */
screenSources?: DesktopSource[];
@@ -34,6 +112,8 @@ interface SourceSelectorProps {
open?: boolean;
/** Callback when open state changes */
onOpenChange?: (open: boolean) => void;
+ /** Optional custom trigger element */
+ children?: React.ReactNode;
}
/**
@@ -49,6 +129,7 @@ export const SourceSelector = React.memo(function SourceSelector({
onFetchSources = async () => {},
open = false,
onOpenChange = () => {},
+ children,
}: SourceSelectorProps) {
const t = useScopedT("launch");
@@ -65,7 +146,7 @@ export const SourceSelector = React.memo(function SourceSelector({
<button
type="button"
className={cn(
- "flex items-center gap-3 px-3 py-2.5 rounded-md transition-colors",
+ "group flex items-center gap-3 px-3 py-2.5 rounded-md transition-colors w-full text-left",
"hover:bg-accent hover:text-accent-foreground",
isSelected && "bg-accent text-accent-foreground",
)}
@@ -99,18 +180,20 @@ export const SourceSelector = React.memo(function SourceSelector({
</div>
{/* Source info */}
- <div className="flex-1 min-w-0">
- <div className="flex items-center gap-2">
- <span className="text-sm font-medium truncate">
- {source.windowTitle || source.name}
- </span>
+ <div className="flex-1 min-w-0 flex flex-col items-start text-left">
+ <div className="flex items-center gap-2 w-full overflow-hidden">
+ <MarqueeText
+ text={source.windowTitle || source.name}
+ className="text-sm font-medium"
+ speed={40}
+ />
{source.appName && source.appName !== source.name && (
- <span className="text-xs text-muted-foreground truncate">
+ <span className="text-xs text-muted-foreground truncate shrink-0">
{source.appName}
</span>
)}
</div>
- <div className="text-xs text-muted-foreground truncate">
+ <div className="text-xs text-muted-foreground truncate w-full text-left">
{source.sourceType === "screen" ? t("recording.screen") : t("recording.window")}
</div>
</div>
@@ -166,17 +249,33 @@ export const SourceSelector = React.memo(function SourceSelector({
return (
<Popover open={open} onOpenChange={onOpenChange}>
<PopoverTrigger asChild>
- <Button
- variant="outline"
- size="sm"
- className={cn(
- "w-full justify-between",
- "data-[state=open]:bg-accent",
- )}
- >
- <span className="truncate">{selectedSource}</span>
- <Monitor className="w-4 h-4 ml-2 opacity-50" />
- </Button>
+ {children || (
+ <Button
+ variant="outline"
+ size="lg"
+ className={cn(
+ "group gap-2 px-3 min-w-0 max-w-[180px] rounded-[11px] font-medium text-[12px] [ -webkit-app-region:no-drag ] shrink-0",
+ "border-[#2a2a34] bg-[#1a1a22] text-[#eeeef2] hover:border-[#3e3e4c] hover:bg-[#20202a] transition-all",
+ "data-[state=open]:border-[#3e3e4c] data-[state=open]:bg-[#20202a]",
+ )}
+ title={selectedSource}
+ >
+ <Monitor size={16} className="shrink-0" />
+ <div className="flex-1 min-w-0">
+ <MarqueeText
+ text={selectedSource}
+ speed={40}
+ />
+ </div>
+ <ChevronUp
+ size={10}
+ className={cn(
+ "text-[#6b6b78] ml-0.5 shrink-0 transition-transform duration-200",
+ open ? "" : "rotate-180",
+ )}
+ />
+ </Button>
+ )}
</PopoverTrigger>
<PopoverContent
className="w-80 p-0"
@@ -186,13 +285,14 @@ export const SourceSelector = React.memo(function SourceSelector({
alignOffset={-8}
avoidCollisions={true}
collisionPadding={10}
+ usePortal={false}
>
{loading ? (
<div className="flex items-center justify-center py-8">
<div className="animate-spin rounded-full h-5 w-5 border-b-2 border-primary" />
</div>
) : (
- <div className="max-h-[320px] overflow-y-auto overflow-x-hidden p-2">
+ <div className="max-h-[320px] overflow-y-auto overflow-x-hidden p-2 source-selector-scroll">
{screenSection || windowSection ? (
<>
{screenSection}
diff --git a/src/components/ui/popover.tsx b/src/components/ui/popover.tsx
index 8d723908..e50d1d13 100644
--- a/src/components/ui/popover.tsx
+++ b/src/components/ui/popover.tsx
@@ -18,26 +18,32 @@ function PopoverContent({
align = "center",
sideOffset = 4,
animated = true,
+ usePortal = true,
...props
}: React.ComponentProps<typeof PopoverPrimitive.Content> & {
animated?: boolean;
+ usePortal?: boolean;
}) {
- return (
- <PopoverPrimitive.Portal>
- <PopoverPrimitive.Content
- data-slot="popover-content"
- align={align}
- sideOffset={sideOffset}
- className={cn(
- "bg-popover text-popover-foreground z-50 w-72 rounded-md border p-4 shadow-md outline-hidden",
- animated &&
- "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-(--radix-popover-content-transform-origin)",
- className,
- )}
- {...props}
- />
- </PopoverPrimitive.Portal>
+ const content = (
+ <PopoverPrimitive.Content
+ data-slot="popover-content"
+ align={align}
+ sideOffset={sideOffset}
+ className={cn(
+ "bg-popover text-popover-foreground z-50 w-72 rounded-md border p-4 shadow-md outline-hidden",
+ animated &&
+ "data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 origin-(--radix-popover-content-transform-origin)",
+ className,
+ )}
+ {...props}
+ />
);
+
+ if (usePortal === false) {
+ return content;
+ }
+
+ return <PopoverPrimitive.Portal>{content}</PopoverPrimitive.Portal>;
}
function PopoverAnchor({ ...props }: React.ComponentProps<typeof PopoverPrimitive.Anchor>) {
diff --git a/src/index.css b/src/index.css
index 765a6239..4a90d3d1 100644
--- a/src/index.css
+++ b/src/index.css
@@ -262,3 +262,7 @@
transform: translateX(270%);
}
}
+
+
+
+