Radish alpha
r
rad:z4D5UCArafTzTQpDZNQRuqswh3ury
Radicle desktop app
Radicle
Git
.. AddRepoButton.svelte AnnounceSwitch.svelte AppSidebar.svelte AssigneeInput.svelte BadgeCounterSwitch.svelte Button.svelte Changes.svelte Changeset.svelte CheckoutPatchButton.svelte CheckoutRepoButton.svelte Clipboard.svelte CobCacheWarning.svelte CobCommitTeaser.svelte CodeFontSwitch.svelte Command.svelte Comment.svelte CommentToggleInput.svelte CommitsContainer.svelte CompactCommitAuthorship.svelte ConfirmClear.svelte CopyableId.svelte Diff.svelte DiffStatBadge.svelte Discussion.svelte DropdownList.svelte DropdownListItem.svelte EditableTitle.svelte ExtendedTextarea.svelte ExternalLink.svelte FileBlock.svelte FileDiff.svelte FileTreeFile.svelte FileTreeFolder.svelte FontSizeSwitch.svelte FullscreenModalPortal.svelte FullWindowError.svelte FuzzySearch.svelte HoverPopover.svelte Icon.svelte Id.svelte IdentityButton.svelte InboxList.svelte InfiniteScrollSentinel.svelte InlineTitle.svelte IssueStateButton.svelte IssueTeaser.svelte IssueTimeline.svelte JobCob.svelte Label.svelte LabelInput.svelte Markdown.svelte NewPatchButton.svelte NodeId.svelte NodeStatusButton.svelte NotificationsByRepo.svelte NotificationTeaser.svelte PatchMetadata.svelte PatchStateButton.svelte PatchTeaser.svelte PatchTimeline.svelte Path.svelte Popover.svelte PreviewSwitch.svelte RadicleWordmark.svelte Reactions.svelte ReactionSelector.svelte RepoAvatar.svelte RepoHeader.svelte Review.svelte Revision.svelte RevisionBadges.svelte RevisionReviews.svelte Revisions.svelte ScrollArea.svelte SidebarRepoList.svelte Spinner.svelte Textarea.svelte TextInput.svelte ThemeSwitch.svelte Thread.svelte Topbar.svelte Tree.svelte UpdateSwitch.svelte UserAvatar.svelte VerdictBadge.svelte VerdictButton.svelte VisibilityBadge.svelte
radicle-desktop src components EditableTitle.svelte
<script lang="ts">
  import Button from "@app/components/Button.svelte";
  import Icon from "@app/components/Icon.svelte";
  import InlineTitle from "@app/components/InlineTitle.svelte";
  import TextInput from "@app/components/TextInput.svelte";

  interface Props {
    allowedToEdit: true | undefined;
    cobId: string;
    title: string;
    updateTitle: (newTitle: string) => Promise<void>;
  }

  const { allowedToEdit, cobId, title, updateTitle }: Props = $props();

  let editingTitle = $state(false);
  let newTitle = $state("");

  $effect(() => {
    // eslint-disable-next-line @typescript-eslint/no-unused-expressions
    cobId;

    editingTitle = false;
    newTitle = title;
  });

  async function save() {
    if (newTitle.trim().length <= 0) {
      return;
    }

    if (title === newTitle) {
      editingTitle = false;
      return;
    }

    await updateTitle(newTitle);
  }
</script>

<style>
  .title {
    font: var(--txt-heading-m);
    -webkit-user-select: text;
    user-select: text;
    display: flex;
    align-items: center;
    word-break: break-word;
    min-height: 2rem;
    width: 100%;
  }
  .edit-title-icon {
    display: none;
  }
  .title-wrapper:hover .edit-title-icon {
    display: flex;
  }
</style>

<div class="title">
  {#if editingTitle}
    <TextInput
      valid={newTitle.trim().length > 0}
      bind:value={newTitle}
      autofocus
      onSubmit={save}
      onDismiss={() => {
        newTitle = title;
        editingTitle = false;
      }} />
    <div class="global-flex" style:margin-left="0.5rem">
      <Button
        variant="naked"
        disabled={!(newTitle.trim().length > 0)}
        onclick={save}>
        <Icon name="checkmark" />
      </Button>
      <Button
        variant="naked"
        onclick={() => {
          newTitle = title;
          editingTitle = false;
        }}>
        <Icon name="close" />
      </Button>
    </div>
  {:else}
    <div class="global-flex" style:gap="0">
      <!-- svelte-ignore a11y_click_events_have_key_events -->
      <div
        class="title-wrapper global-flex"
        role="button"
        style:cursor={allowedToEdit ? "pointer" : "default"}
        onclick={() => {
          if (allowedToEdit) {
            editingTitle = true;
          }
        }}
        tabindex="0">
        <InlineTitle content={title} fontSize="medium" />
        {#if allowedToEdit}
          <div class="edit-title-icon"><Icon name="edit" /></div>
        {/if}
      </div>
    </div>
  {/if}
</div>