diff --git a/client/css/style.css b/client/css/style.css index 94d8f7e2..03dfe793 100644 --- a/client/css/style.css +++ b/client/css/style.css @@ -598,7 +598,8 @@ kbd { border-radius: 3px; width: 18px; height: 18px; - transition: opacity 0.2s, background-color 0.2s; + opacity: 0.4; + transition: opacity 0.2s, background-color 0.2s, transform 0.2s; } #sidebar .lobby .add-channel::before { @@ -611,14 +612,14 @@ kbd { color: #fff; } -#sidebar .lobby .add-channel { - opacity: 0.4; -} - #sidebar .lobby .add-channel:hover { opacity: 1; } +#sidebar .lobby .add-channel.opened { + transform: rotate(45deg); +} + #sidebar .chan.active .close { opacity: 0.4; display: unset; diff --git a/client/js/join-channel.js b/client/js/join-channel.js index a8858ffd..811a2e70 100644 --- a/client/js/join-channel.js +++ b/client/js/join-channel.js @@ -8,18 +8,39 @@ const utils = require("./utils"); const sidebar = $("#sidebar"); +function toggleButton(network) { + // Transform the + button to a × + network.find("button.add-channel").toggleClass("opened"); + + // Toggle content of tooltip + const tooltip = network.find(".add-channel-tooltip"); + const altLabel = tooltip.data("alt-label"); + tooltip.data("alt-label", tooltip.attr("aria-label")); + tooltip.attr("aria-label", altLabel); +} + function closeForm(network) { const form = network.find(".join-form"); form.find("input[name='channel']").val(""); form.find("input[name='key']").val(""); form.hide(); + + toggleButton(network); } -sidebar.on("click", ".add-channel", (e) => { +sidebar.on("click", ".add-channel", function(e) { const id = $(e.target).data("id"); const joinForm = $(`#join-channel-${id}`); - joinForm.toggle(); - joinForm.find(".input[name='channel']").focus(); + const network = joinForm.closest(".network"); + + if (joinForm.is(":visible")) { + closeForm(network); + } else { + joinForm.show(); + joinForm.find(".input[name='channel']").focus(); + toggleButton(network); + } + return false; }); diff --git a/client/js/lounge.js b/client/js/lounge.js index 52703016..5bcf4d63 100644 --- a/client/js/lounge.js +++ b/client/js/lounge.js @@ -485,7 +485,7 @@ $(function() { const contextMenuActions = { join: function(itemData) { - $(`#join-channel-${itemData}`).show(); + $(`#join-channel-${itemData}`).closest(".network").find("button.add-channel").click(); }, close: function(itemData) { closeChan($(`.networks .chan[data-target="${itemData}"]`)); diff --git a/client/views/chan.tpl b/client/views/chan.tpl index 939a69eb..c84608a6 100644 --- a/client/views/chan.tpl +++ b/client/views/chan.tpl @@ -1,7 +1,7 @@ {{#each channels}}