From 5055a96a89b0a2eaa4854ae233e43823a975129c Mon Sep 17 00:00:00 2001 From: ayeaye Date: Mon, 12 Apr 2021 12:13:07 -0700 Subject: [PATCH] Added many UI options --- Config.coffee | 31 ++++++++++++++ client/App.coffee | 4 +- client/FrontPage.coffee | 4 +- client/Room.coffee | 95 +++++++++++++++++++++-------------------- client/RoomList.coffee | 54 +++++++++++++---------- client/Settings.coffee | 58 +++++++++++++++++++------ client/TabIFrame.coffee | 4 +- client/TabJitsi.coffee | 4 +- client/main.styl | 3 ++ 9 files changed, 168 insertions(+), 89 deletions(-) diff --git a/Config.coffee b/Config.coffee index 6bda7a4..48efe7a 100644 --- a/Config.coffee +++ b/Config.coffee @@ -36,3 +36,34 @@ export Config = defaultSort: key: 'title' # see client/RoomList.coffee for other options reverse: false + + ## Whether to show darkmode toggle + showUI_dark: true + + ## Whether to change rooms on click (instead of needing shift-click) by default + default_quickJoin: false + showUI_quickJoin: true + + ## Whether to have a compact room list by default + default_compact: false + showUI_compact: true + + ## Whether to hide the room creation widget at the bottom of the room list by default + default_hideCreate: false + showUI_hideCreate: true + + ## Whether to hide the room search widget in the room list by default + default_hideSearch: false + showUI_hideSearch: true + + ## Whether to hide the starred rooms accordion in the room list by default + default_hideStarred: false + showUI_hideStarred: true + + ## Whether to hide the title / header at the top of the room list by default + default_hideTitle: false + showUI_hideTitle: true + + ## Whether to hide the title / button bar at the top of the room tabset by default + default_hideRoombar: false + showUI_hideRoombar: true diff --git a/client/App.coffee b/client/App.coffee index ea8d29d..08af22f 100644 --- a/client/App.coffee +++ b/client/App.coffee @@ -3,7 +3,7 @@ import {BrowserRouter as Router, Switch, Route} from 'react-router-dom' import {FrontPage} from './FrontPage' import {Meeting} from './Meeting' -import {useDark} from './Settings' +import {useUI} from './Settings' import {Redirect} from './lib/Redirect' export App = React.memo -> @@ -31,7 +31,7 @@ export AppRouter = React.memo -> AppRouter.displayName = 'AppRouter' export DarkClass = React.memo -> - dark = useDark() + dark = useUI('dark') if dark document.body.classList.add 'dark' else diff --git a/client/FrontPage.coffee b/client/FrontPage.coffee index 3dde2df..37b964a 100644 --- a/client/FrontPage.coffee +++ b/client/FrontPage.coffee @@ -4,7 +4,7 @@ import {Button, ButtonGroup, Form, Jumbotron} from 'react-bootstrap' import {FontAwesomeIcon} from '@fortawesome/react-fontawesome' import {faGithub} from '@fortawesome/free-brands-svg-icons' -import {Dark} from './Settings' +import {UIToggle} from './Settings' import {setMeetingSecret} from './MeetingSecret' import {VisitedMeetings} from './VisitedMeetings' import {getUpdator} from './lib/presenceId' @@ -45,7 +45,7 @@ export FrontPage = React.memo ->

- +

- - - + {unless getUI('hideStarred') + findMyPresence(presenceByRoom[room._id]).starred} + className="starred"> + + + Unstar all rooms + + }> +

+ +
+ + + } not room.archived and @@ -266,7 +271,9 @@ export RoomList = React.memo ({loading, model, extraData, updateTab}) -> filter={(room) -> room.archived and (not nonempty or hasJoined(room) or selected == room._id)}/> - + {unless getUI('hideCreate') + + } RoomList.displayName = 'RoomList' @@ -360,17 +367,20 @@ export RoomInfo = React.memo ({room, search, presence, selected, selectRoom, lea roomInfoClass += " presence-#{type}" for type of myPresence roomInfoClass += " selected" if selected roomInfoClass += " archived" if room.archived + roomInfoClass += " compact" if getUI("compact") adminVisit = useAdminVisit() onClick = (force) -> (e) -> e.preventDefault() e.stopPropagation() currentRoom = Session.get 'currentRoom' - ## Open room with focus in the following cases: + ## Open room with focus if we're not currently in this room, and any of the following cases: ## * We're not in any rooms - ## * Shift/Ctrl/Meta-click => force open + ## * Shift/Ctrl/Meta-click xor quickJoin => force open ## * We clicked on the Switch button (force == true) - if not currentRoom? or e.shiftKey or e.ctrlKey or e.metaKey or force == true + if ((not currentRoom?) or + ((e.shiftKey or e.ctrlKey or e.metaKey) ^ getUI('quickJoin')) or + (force == true)) and currentRoom != room._id openRoom room._id selectRoom null ## Otherwise, toggle whether this room is selected. diff --git a/client/Settings.coffee b/client/Settings.coffee index 022b4bb..2139d19 100644 --- a/client/Settings.coffee +++ b/client/Settings.coffee @@ -1,10 +1,11 @@ import React from 'react' import {useParams} from 'react-router-dom' -import {Card, Form} from 'react-bootstrap' +import {Card, Form, OverlayTrigger, Tooltip} from 'react-bootstrap' import {LocalStorageVar, StorageDict} from './lib/useLocalStorage' import {MeetingTitle} from './MeetingTitle' import {MeetingSecret, useMeetingAdmin} from './MeetingSecret' +import {Config} from '/Config' export Settings = React.memo -> admin = useMeetingAdmin() @@ -13,7 +14,7 @@ export Settings = React.memo -> Settings
- +
@@ -34,17 +35,48 @@ export Settings = React.memo -> Settings.displayName = 'Settings' -darkVar = new LocalStorageVar 'dark', -> - window.matchMedia('(prefers-color-scheme: dark)').matches -, sync: true -export useDark = -> darkVar.use() -export getDark = -> darkVar.get() - -export Dark = React.memo -> - dark = useDark() - darkVar.set e.target.checked}/> -Dark.displayName = 'Dark' +uiVars = {} +uiLabels = {} +export useUI = (name) -> uiVars[name].use() +export getUI = (name) -> uiVars[name].get() + +addUIVar = (name, label, tooltip, init) -> + unless init? + init = -> + Config["default_" + name] + uiVars[name] = new LocalStorageVar name, init, sync: true + uiLabels[name] = + label: label + tooltip: tooltip + +addUIVar('quickJoin', 'Quick Join', 'Immediately change rooms on click (shift-click to open the room menu)') +addUIVar('dark', 'Dark Mode', 'Light text on dark background', -> window.matchMedia('(prefers-color-scheme: dark)').matches) +addUIVar('compact', 'Compact Mode', 'Condense the list in the "Meeting Rooms" sidebar') +addUIVar('hideCreate', 'Hide Create', 'Hide "Create Room" widget in the "Meeting Rooms" sidebar') +addUIVar('hideSearch', 'Hide Search', 'Hide "Room Search" widget in the "Meeting Rooms" sidebar') +addUIVar('hideStarred', 'Hide Starred', 'Hide "Your Starred Rooms" accordion in the "Meeting Rooms" sidebar') +addUIVar('hideTitle', 'Hide Title', 'Hide meeting title in the "Meeting Rooms" sidebar') +addUIVar('hideRoombar', 'Hide Menubar', 'Hide menubar in room tabset') + +export UIToggles = React.memo -> + for name, label of uiLabels + if Config["showUI_" + name] + +UIToggles.displayName = 'UIToggles' + +export UIToggle = React.memo ({name}) -> + value = useUI(name) + label = uiLabels[name]?.label + tooltip = uiLabels[name]?.tooltip + + {tooltip} + }> +
+ uiVars[name].set e.target.checked}/> +
+
+UIToggle.displayName = 'UIToggle' adminVisitVars = new StorageDict LocalStorageVar, 'adminVisit', false, sync: true diff --git a/client/TabIFrame.coffee b/client/TabIFrame.coffee index ebf10a4..8713762 100644 --- a/client/TabIFrame.coffee +++ b/client/TabIFrame.coffee @@ -3,7 +3,7 @@ import {useTracker} from 'meteor/react-meteor-data' import useEventListener from '@use-it/event-listener' import {useName} from './Name' -import {useDark} from './Settings' +import {useUI} from './Settings' import {Tabs} from '/lib/tabs' ### @@ -47,7 +47,7 @@ export TabIFrame = React.memo ({tabId}) -> ## Send name to tab if it speaks coop protocol name = useName() - dark = useDark() + dark = useUI("dark") [coop, setCoop] = useState 0 useEventListener 'message', (e) -> return unless ref.current diff --git a/client/TabJitsi.coffee b/client/TabJitsi.coffee index 06a8c21..992bbf5 100644 --- a/client/TabJitsi.coffee +++ b/client/TabJitsi.coffee @@ -3,7 +3,7 @@ import {useTracker} from 'meteor/react-meteor-data' import {allow} from './TabIFrame' import {getName} from './Name' -import {getDark} from './Settings' +import {getUI} from './Settings' import {Tabs} from '/lib/tabs' export TabJitsi = React.memo ({tabId, room}) -> @@ -36,7 +36,7 @@ export TabJitsi = React.memo ({tabId, room}) -> https://github.com/jitsi/jitsi-meet/blob/master/interface_config.js ### 'interfaceConfig.DEFAULT_BACKGROUND': - if getDark() then '#111' else '#474747' + if getUI('dark') then '#111' else '#474747' 'interfaceConfig.DISABLE_VIDEO_BACKGROUND': true 'interfaceConfig.TOOLBAR_BUTTONS': [ 'microphone', 'camera', 'closedcaptions', 'desktop', diff --git a/client/main.styl b/client/main.styl index 4134cb6..a0d7e35 100644 --- a/client/main.styl +++ b/client/main.styl @@ -58,6 +58,9 @@ nav margin-top: 0.75rem font-size: 80% cursor: pointer + .compact + padding: 0.25rem 1rem 0.25rem 0.25rem + font-size: 80% // Give dismissible alerts normal margin; instead use float for close button .alert-dismissible padding-right: 1.25rem