feat: select-none

This commit is contained in:
codytseng
2025-04-12 00:00:45 +08:00
parent a10c9d8ffe
commit ea5b50cf0a
7 changed files with 26 additions and 14 deletions

View File

@@ -18,7 +18,7 @@ export default function FavoriteRelaysSetting() {
<TemporaryRelaySet /> <TemporaryRelaySet />
<div className="space-y-2"> <div className="space-y-2">
<div className="flex flex-wrap items-center justify-between gap-2"> <div className="flex flex-wrap items-center justify-between gap-2">
<div className="text-muted-foreground font-semibold select-nones shrink-0"> <div className="text-muted-foreground font-semibold select-none shrink-0">
{t('Relay sets')} {t('Relay sets')}
</div> </div>
<PullRelaySetsButton /> <PullRelaySetsButton />

View File

@@ -25,7 +25,9 @@ export default function RawEventDialog({
<DialogDescription className="hidden" /> <DialogDescription className="hidden" />
</DialogHeader> </DialogHeader>
<ScrollArea className="h-full"> <ScrollArea className="h-full">
<pre className="text-sm text-muted-foreground">{JSON.stringify(event, null, 2)}</pre> <pre className="text-sm text-muted-foreground select-text">
{JSON.stringify(event, null, 2)}
</pre>
<ScrollBar orientation="horizontal" /> <ScrollBar orientation="horizontal" />
</ScrollArea> </ScrollArea>
</DialogContent> </DialogContent>

View File

@@ -20,7 +20,7 @@ export default function RelayInfo({ url }: { url: string }) {
<div className="space-y-2"> <div className="space-y-2">
<div className="flex gap-2 items-center"> <div className="flex gap-2 items-center">
<RelayIcon url={url} className="w-8 h-8" /> <RelayIcon url={url} className="w-8 h-8" />
<div className="text-2xl font-semibold truncate"> <div className="text-2xl font-semibold truncate select-text">
{relayInfo.name || relayInfo.shortUrl} {relayInfo.name || relayInfo.shortUrl}
</div> </div>
</div> </div>
@@ -33,7 +33,7 @@ export default function RelayInfo({ url }: { url: string }) {
</div> </div>
)} )}
{relayInfo.description && ( {relayInfo.description && (
<div className="text-wrap break-words whitespace-pre-wrap mt-2"> <div className="text-wrap break-words whitespace-pre-wrap mt-2 select-text">
{relayInfo.description} {relayInfo.description}
</div> </div>
)} )}
@@ -67,7 +67,7 @@ export default function RelayInfo({ url }: { url: string }) {
<a <a
href={normalizeHttpUrl(relayInfo.payments_url)} href={normalizeHttpUrl(relayInfo.payments_url)}
target="_blank" target="_blank"
className="hover:underline text-primary" className="hover:underline text-primary select-text"
> >
{relayInfo.payments_url} {relayInfo.payments_url}
</a> </a>
@@ -86,7 +86,7 @@ export default function RelayInfo({ url }: { url: string }) {
{relayInfo.contact && ( {relayInfo.contact && (
<div className="space-y-2 flex-1"> <div className="space-y-2 flex-1">
<div className="text-sm font-semibold text-muted-foreground">{t('Contact')}</div> <div className="text-sm font-semibold text-muted-foreground">{t('Contact')}</div>
<div className="flex gap-2 items-center font-semibold"> <div className="flex gap-2 items-center font-semibold select-text">
<Mail /> <Mail />
{relayInfo.contact} {relayInfo.contact}
</div> </div>
@@ -95,7 +95,7 @@ export default function RelayInfo({ url }: { url: string }) {
{relayInfo.software && ( {relayInfo.software && (
<div className="space-y-2 flex-1"> <div className="space-y-2 flex-1">
<div className="text-sm font-semibold text-muted-foreground">{t('Software')}</div> <div className="text-sm font-semibold text-muted-foreground">{t('Software')}</div>
<div className="flex gap-2 items-center font-semibold"> <div className="flex gap-2 items-center font-semibold select-text">
<SquareCode /> <SquareCode />
{formatSoftware(relayInfo.software)} {formatSoftware(relayInfo.software)}
</div> </div>
@@ -104,7 +104,7 @@ export default function RelayInfo({ url }: { url: string }) {
{relayInfo.version && ( {relayInfo.version && (
<div className="space-y-2 flex-1"> <div className="space-y-2 flex-1">
<div className="text-sm font-semibold text-muted-foreground">{t('Version')}</div> <div className="text-sm font-semibold text-muted-foreground">{t('Version')}</div>
<div className="flex gap-2 items-center font-semibold"> <div className="flex gap-2 items-center font-semibold select-text">
<GitBranch /> <GitBranch />
{relayInfo.version} {relayInfo.version}
</div> </div>

View File

@@ -7,7 +7,7 @@ const Textarea = React.forwardRef<HTMLTextAreaElement, React.ComponentProps<'tex
return ( return (
<textarea <textarea
className={cn( className={cn(
'flex min-h-[80px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm', 'flex min-h-[80px] w-full rounded-md border border-input bg-transparent select-text px-3 py-2 text-base shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50 md:text-sm',
className className
)} )}
ref={ref} ref={ref}

View File

@@ -30,6 +30,7 @@
-webkit-overflow-scrolling: touch; -webkit-overflow-scrolling: touch;
text-size-adjust: 100%; text-size-adjust: 100%;
-webkit-text-size-adjust: 100%; -webkit-text-size-adjust: 100%;
user-select: none;
} }
.clickable { .clickable {

View File

@@ -70,7 +70,13 @@ const NotePage = forwardRef(({ id, index }: { id?: string; index?: number }, ref
<ParentNote key={`root-note-${event.id}`} eventId={rootEventId} /> <ParentNote key={`root-note-${event.id}`} eventId={rootEventId} />
)} )}
<ParentNote key={`parent-note-${event.id}`} eventId={parentEventId} /> <ParentNote key={`parent-note-${event.id}`} eventId={parentEventId} />
<Note key={`note-${event.id}`} event={event} fetchNoteStats hideParentNotePreview /> <Note
key={`note-${event.id}`}
event={event}
className="select-text"
fetchNoteStats
hideParentNotePreview
/>
</div> </div>
<Separator className="mt-4" /> <Separator className="mt-4" />
{event.kind === kinds.ShortTextNote ? ( {event.kind === kinds.ShortTextNote ? (

View File

@@ -98,7 +98,7 @@ const ProfilePage = forwardRef(({ id, index }: { id?: string; index?: number },
</div> </div>
<div className="pt-2"> <div className="pt-2">
<div className="flex gap-2 items-center"> <div className="flex gap-2 items-center">
<div className="text-xl font-semibold truncate">{username}</div> <div className="text-xl font-semibold truncate select-text">{username}</div>
{isFollowingYou && ( {isFollowingYou && (
<div className="text-muted-foreground rounded-full bg-muted text-xs h-fit px-2 shrink-0"> <div className="text-muted-foreground rounded-full bg-muted text-xs h-fit px-2 shrink-0">
{t('Follows you')} {t('Follows you')}
@@ -107,7 +107,7 @@ const ProfilePage = forwardRef(({ id, index }: { id?: string; index?: number },
</div> </div>
<Nip05 pubkey={pubkey} /> <Nip05 pubkey={pubkey} />
{lightningAddress && ( {lightningAddress && (
<div className="text-sm text-yellow-400 flex gap-1 items-center"> <div className="text-sm text-yellow-400 flex gap-1 items-center select-text">
<Zap className="size-4 shrink-0" /> <Zap className="size-4 shrink-0" />
<div className="flex-1 max-w-fit w-0 truncate">{lightningAddress}</div> <div className="flex-1 max-w-fit w-0 truncate">{lightningAddress}</div>
</div> </div>
@@ -116,9 +116,12 @@ const ProfilePage = forwardRef(({ id, index }: { id?: string; index?: number },
<PubkeyCopy pubkey={pubkey} /> <PubkeyCopy pubkey={pubkey} />
<QrCodePopover pubkey={pubkey} /> <QrCodePopover pubkey={pubkey} />
</div> </div>
<ProfileAbout about={about} className="text-wrap break-words whitespace-pre-wrap mt-2" /> <ProfileAbout
about={about}
className="text-wrap break-words whitespace-pre-wrap mt-2 select-text"
/>
{website && ( {website && (
<div className="flex gap-1 items-center text-primary mt-2 truncate"> <div className="flex gap-1 items-center text-primary mt-2 truncate select-text">
<Link size={14} className="shrink-0" /> <Link size={14} className="shrink-0" />
<a <a
href={website} href={website}