Skip to content
Snippets Groups Projects
liiibre_home.patch 5.58 KiB
Newer Older
Hugo Renard's avatar
Hugo Renard committed
diff --git a/res/css/_components.pcss b/res/css/_components.pcss
Hugo Renard's avatar
Hugo Renard committed
index 6a7bbd197f..f6558876d9 100644
Hugo Renard's avatar
Hugo Renard committed
--- a/res/css/_components.pcss
+++ b/res/css/_components.pcss
Hugo Renard's avatar
Hugo Renard committed
@@ -71,6 +71,7 @@
Hugo Renard's avatar
Hugo Renard committed
 @import "./structures/_MatrixChat.pcss";
Hugo Renard's avatar
Hugo Renard committed
 @import "./structures/_NonUrgentToastContainer.pcss";
 @import "./structures/_QuickSettingsButton.pcss";
+@import "./structures/_LiiibreHomeButton.pcss";
 @import "./structures/_RightPanel.pcss";
 @import "./structures/_RoomSearch.pcss";
Hugo Renard's avatar
Hugo Renard committed
 @import "./structures/_RoomStatusBar.pcss";
Hugo Renard's avatar
Hugo Renard committed
diff --git a/res/css/structures/_LiiibreHomeButton.pcss b/res/css/structures/_LiiibreHomeButton.pcss
new file mode 100644
Hugo Renard's avatar
Hugo Renard committed
index 0000000000..7f6ae5edf8
Hugo Renard's avatar
Hugo Renard committed
--- /dev/null
+++ b/res/css/structures/_LiiibreHomeButton.pcss
Hugo Renard's avatar
Hugo Renard committed
@@ -0,0 +1,32 @@
Hugo Renard's avatar
Hugo Renard committed
+.mx_LiiibreHomeButton {
+    flex: 0 0 auto;
+    border-radius: 8px;
+    position: relative;
+    margin: 12px auto;
+    color: $secondary-content;
+    min-width: 32px;
+    min-height: 32px;
+    line-height: 32px;
+
+    &.expanded {
+        margin-left: 20px;
+        padding-left: 44px; /* align with toggle collapse button text */
+        padding-right: 8px;
+    }
+
+    &::before {
+        content: " ";
Hugo Renard's avatar
Hugo Renard committed
+        position: absolute;
+        width: 32px;
+        height: 32px;
+        left: 0;
+        background-image: url("$(res)/img/liiibre-icons/liiibre.svg");
+        background-repeat: no-repeat;
+        background-position: center;
+        background-size: 24px;
Hugo Renard's avatar
Hugo Renard committed
+    }
+
+    &:not(.expanded):hover {
+        background-color: $quaternary-content;
+    }
+}
diff --git a/res/img/liiibre-icons/liiibre.svg b/res/img/liiibre-icons/liiibre.svg
new file mode 100644
index 0000000000..18d11fc213
--- /dev/null
+++ b/res/img/liiibre-icons/liiibre.svg
@@ -0,0 +1 @@
+<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 607.32 502.5"><defs><style>.cls-1{fill:#f27722;stroke:#f27722;}.cls-1,.cls-6{stroke-miterlimit:10;}.cls-1,.cls-4,.cls-5,.cls-6,.cls-7{stroke-width:20px;}.cls-2{fill:#f5da78;}.cls-3{fill:#398187;}.cls-4,.cls-7{fill:none;}.cls-4,.cls-5,.cls-7{stroke:#00b6c6;stroke-linejoin:round;}.cls-5{fill:#00b6c6;}.cls-6{fill:#f3b935;stroke:#f3b935;}.cls-7{stroke-linecap:round;}</style></defs><g id="Calque_2" data-name="Calque 2"><g id="Calque_1-2" data-name="Calque 1"><path class="cls-1" d="M182.09,321.91a104.1,104.1,0,1,1,0-157.61"/><path class="cls-2" d="M182.09,498.38v-348a126,126,0,0,1,126-126h0a126,126,0,0,1,126,126V295.27H355.78v98.61H256.3V492.5Z"/><polygon class="cls-3" points="258.79 492.5 434.09 492.5 434.09 295.27 357.4 295.27 357.4 393.88 258.79 393.88 258.79 492.5"/><path class="cls-4" d="M182.09,498.38v-348a126,126,0,0,1,126-126h0a126,126,0,0,1,126,126V492.5h-252"/><path class="cls-5" d="M509.47,181.61V68.3A43.93,43.93,0,0,1,553.4,24.38h0A43.93,43.93,0,0,1,597.32,68.3V181.61Z"/><circle class="cls-6" cx="81.35" cy="32.48" r="22.48"/><polyline class="cls-7" points="592.3 295.27 357.4 295.27 357.4 393.88 258.79 393.88 258.79 492.5 10 492.5"/></g></g></svg>
\ No newline at end of file
Hugo Renard's avatar
Hugo Renard committed
diff --git a/src/IConfigOptions.ts b/src/IConfigOptions.ts
Hugo Renard's avatar
Hugo Renard committed
index b2e44f23ce..102bec978d 100644
Hugo Renard's avatar
Hugo Renard committed
--- a/src/IConfigOptions.ts
+++ b/src/IConfigOptions.ts
Hugo Renard's avatar
Hugo Renard committed
@@ -186,6 +186,9 @@ export interface IConfigOptions {
         description: string;
         show_once?: boolean;
Hugo Renard's avatar
Hugo Renard committed
     };
+
+    liiibre_home_url?: string;
+    liiibre_home_label?: string;
Hugo Renard's avatar
Hugo Renard committed
 }
 
 export interface ISsoRedirectOptions {
Hugo Renard's avatar
Hugo Renard committed
diff --git a/src/components/views/spaces/LiiibreHomeButton.tsx b/src/components/views/spaces/LiiibreHomeButton.tsx
new file mode 100644
index 0000000000..0341c70c40
Hugo Renard's avatar
Hugo Renard committed
--- /dev/null
+++ b/src/components/views/spaces/LiiibreHomeButton.tsx
@@ -0,0 +1,31 @@
Hugo Renard's avatar
Hugo Renard committed
+import React, { useCallback } from "react";
+import classNames from "classnames";
+
+import AccessibleTooltipButton from "../elements/AccessibleTooltipButton";
+import SdkConfig from "../../../SdkConfig";
+
+const LiiibreHomeButton = ({ isPanelCollapsed }) => {
+    const home_url = SdkConfig.get("liiibre_home_url");
+    const label = SdkConfig.get("liiibre_home_label") || "Retour au nuage";
Hugo Renard's avatar
Hugo Renard committed
+
+    const goBackHome = useCallback(() => {
+        window.open(home_url, "_self");
+    }, [home_url]);
+
+    if (!home_url) return null;
+
+    return (
+        <AccessibleTooltipButton
+            className={classNames("mx_LiiibreHomeButton", {
+                expanded: !isPanelCollapsed,
+            })}
+            onClick={goBackHome}
+            title={label}
Hugo Renard's avatar
Hugo Renard committed
+            forceHide={!isPanelCollapsed}
+        >
+            {!isPanelCollapsed ? label : null}
Hugo Renard's avatar
Hugo Renard committed
+        </AccessibleTooltipButton>
+    );
+};
+
+export default LiiibreHomeButton;
diff --git a/src/components/views/spaces/SpacePanel.tsx b/src/components/views/spaces/SpacePanel.tsx
Hugo Renard's avatar
Hugo Renard committed
index a138b909e0..b83dfb901d 100644
Hugo Renard's avatar
Hugo Renard committed
--- a/src/components/views/spaces/SpacePanel.tsx
+++ b/src/components/views/spaces/SpacePanel.tsx
@@ -72,6 +72,7 @@ import { NotificationState } from "../../../stores/notifications/NotificationSta
 import { ALTERNATE_KEY_NAME } from "../../../accessibility/KeyboardShortcuts";
 import { shouldShowComponent } from "../../../customisations/helpers/UIComponents";
 import { UIComponent } from "../../../settings/UIFeature";
+import LiiibreHomeButton from "./LiiibreHomeButton";
 
 const useSpaces = (): [Room[], MetaSpace[], Room[], SpaceKey] => {
     const invites = useEventEmitterState<Room[]>(SpaceStore.instance, UPDATE_INVITED_SPACES, () => {
Hugo Renard's avatar
Hugo Renard committed
@@ -393,6 +394,7 @@ const SpacePanel: React.FC = () => {
Hugo Renard's avatar
Hugo Renard committed
                             )}
Hugo Renard's avatar
Hugo Renard committed
                         </Droppable>
 
+                        <LiiibreHomeButton isPanelCollapsed={isPanelCollapsed} />
                         <QuickSettingsButton isPanelCollapsed={isPanelCollapsed} />
                     </div>
Hugo Renard's avatar
Hugo Renard committed
                 )}