Skip to content

Commit

Permalink
feat: add ability to focus actions
Browse files Browse the repository at this point in the history
  • Loading branch information
Quentin-Guillemin committed Apr 18, 2023
1 parent 471d87f commit 19d9d34
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 28 deletions.
24 changes: 19 additions & 5 deletions client/src/assets/scss/editor.scss
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ tldraw-editor {
border-bottom-left-radius: $border-radius;
background-color: var(--colors-panel);
border: 1px solid var(--colors-panelContrast);
border-top: 0px;

div {
display: flex;
}

.sharing-item {
button.sharing-item,
input.sharing-item {
width: fit-content;
min-width: $height;
height: $height;
Expand All @@ -31,10 +33,13 @@ tldraw-editor {
font-size: var(--fontSizes-1);
font-family: var(--fonts-ui);
color: var(--colors-text);
background: none;
outline: none;
border: 1px solid var(--colors-panel);
user-select: none;
}

a.sharing-item-enabled {
button.sharing-item-enabled {
width: fit-content;
min-width: $height;
height: $height;
Expand All @@ -48,19 +53,28 @@ tldraw-editor {
font-family: var(--fonts-ui);
color: white;
background-color: var(--colors-selected);
outline: none;
border: 1px solid var(--colors-panel);
user-select: none;
}

input.input-join {
border: none;
outline: none;
width: 280px;
text-align: center;
outline: none;
border: 1px solid var(--colors-panel);
}

.sharing-item:hover,
button.sharing-item:hover,
input.sharing-item:hover,
button.sharing-item:focus,
input.input-join:focus {
background-color: var(--colors-hover);
}

button.sharing-item-enabled:focus {
color: var(--colors-selected);
background-color: var(--colors-hover);
}
}
}
54 changes: 31 additions & 23 deletions client/src/components/Editor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -128,27 +128,30 @@ function Editor({
<ToastContainer />
<div className="sharing-container">
{nextcloudUrl && !nextcloudSaveHide && userApi && !wantJoinRoom && (
<a
<button
type="button"
className={`sharing-item${saveOnNextcloudState ? "-enabled" : ""}`}
onClick={() => setSaveOnNextcloudState(!saveOnNextcloudState)}
title={t("sharingItem.nextcloudSave") as string}
>
<FontAwesomeIcon icon={faCloud} />
</a>
</button>
)}
{wsUrl && !room && (
<div>
{!noShare && !readOnly && !wantJoinRoom && (
<a
<button
type="button"
className="sharing-item"
onClick={() => setRoom(uuidv4())}
title={t("sharingItem.generateRoom") as string}
>
<FontAwesomeIcon icon={faUsers} />
</a>
</button>
)}
{!noShare && !readOnly && !wantJoinRoom && (
<a
<button
type="button"
className="sharing-item"
onClick={() => {
setUseLocalDoc(true);
Expand All @@ -157,16 +160,27 @@ function Editor({
title={t("sharingItem.shareCurrentPage") as string}
>
<FontAwesomeIcon icon={faShareNodes} />
</a>
</button>
)}
{!noJoin && !wantJoinRoom && (
<a
<button
type="button"
className="sharing-item"
onClick={() => setWantJoinRoom(true)}
title={t("sharingItem.joinRoom") as string}
>
<FontAwesomeIcon icon={faArrowRightToBracket} />
</a>
</button>
)}
{!noJoin && wantJoinRoom && (
<button
type="button"
className="sharing-item"
onClick={resetStates}
title={t("sharingItem.closeJoinRoom") as string}
>
<FontAwesomeIcon icon={faXmark} />
</button>
)}
{!noJoin && wantJoinRoom && (
<input
Expand All @@ -181,45 +195,39 @@ function Editor({
autoFocus
></input>
)}
{!noJoin && wantJoinRoom && (
<a
className="sharing-item"
onClick={resetStates}
title={t("sharingItem.closeJoinRoom") as string}
>
<FontAwesomeIcon icon={faXmark} />
</a>
)}
{!noJoin && joinRoom && uuidValidate(joinRoom) && (
<a
<button
type="button"
className="sharing-item"
onClick={joinRoomHandler}
title={t("sharingItem.joinRoom") as string}
>
<FontAwesomeIcon icon={faArrowRightToBracket} />
</a>
</button>
)}
</div>
)}
{wsUrl && room && (
<div>
{!noShare && (
<a
<button
type="button"
className="sharing-item"
onClick={() => navigator.clipboard.writeText(room)}
title={t("sharingItem.roomId") as string}
>
{room}
</a>
</button>
)}
{!noLeave && (
<a
<button
type="button"
className="sharing-item"
onClick={resetStates}
title={t("sharingItem.leaveRoom") as string}
>
<FontAwesomeIcon icon={faArrowRightFromBracket} />
</a>
</button>
)}
</div>
)}
Expand Down

0 comments on commit 19d9d34

Please sign in to comment.