Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,19 @@
![GitHub downloads (by tag)](https://img.shields.io/github/downloads/ferdium/ferdium-app/latest/total?color=blue)

[![Open Collective backers](https://img.shields.io/static/v1?label=Contribute%20on%20Open%20Collective&message=Donate%20to%20Ferdium&color=9cf&logo=open-collective)](https://opencollective.com/ferdium#category-CONTRIBUTE)

<!-- ALL-CONTRIBUTORS-BADGE:START - Do not remove or modify this section -->

<a href='#contributors-'><img src='https://img.shields.io/badge/contributors-336-default.svg?logo=github&color=6c64e4' alt='Contributors'/></a>

<!-- ALL-CONTRIBUTORS-BADGE:END -->

- [Ferdium](#ferdium)
- [Screenshots](#screenshots)
- [Download](#download)
- [Migrating from Ferdi](#migrating-from-ferdi)
- [Styling](#styling)
- [Sidebar customization](#sidebar-customization)
- [Contributing](#contributing)
- [Contributors ✨](#contributors-)

Expand Down Expand Up @@ -76,6 +80,16 @@ You can style Ferdium's UI with the `USER_DATA/Ferdium/config/custom.css` file.
> - **Linux**: `$XDG_CONFIG_HOME` or `~/.config/`
> - **MacOS**: `~/Library/Application Support`

## Sidebar customization

The service sidebar can display service names and can be adjusted for different
screen sizes. Right-click the sidebar or a service icon to change its width,
toggle service names, select the service-name text size, or enable the compact
layout. Long service names stay on one line and are truncated when necessary;
their full value remains available in the tooltip.

See [Sidebar customization](docs/SIDEBAR_CUSTOMIZATION.md) for details.

## Contributing

Please read the [contributing guidelines](CONTRIBUTING.md) to setup your development machine and proceed.
Expand Down
35 changes: 35 additions & 0 deletions docs/SIDEBAR_CUSTOMIZATION.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Sidebar customization

Ferdium's vertical service sidebar can be adjusted without opening Settings.
Right-click an empty part of the sidebar or any service icon to access the
sidebar controls.

## Available controls

- **Sidebar width** selects a width from extremely slim to extremely wide.
- **Display service name under the icon** shows or hides each service name.
- **Service name text size** uses automatic sizing or a fixed size from 10 to
20 pixels.
- **Use compact service sidebar** reduces spacing between services and uses a
denser layout.

Icons use consistent edge spacing at every vertical sidebar width. Service
names are limited to one line. If a name does not fit, Ferdium displays an
ellipsis; hover over the service to see the complete name, shorten its custom
name, choose a smaller font, or hide service names.

The utility controls at the bottom of the vertical sidebar start collapsed.
Select the menu control to reveal them. They collapse again when the pointer
leaves the sidebar.

## Development verification

Start Ferdium in development mode:

```sh
pnpm start:all-dev
```

Verify the context menu from both a service icon and empty sidebar space. Test
all sidebar widths with service names enabled and disabled, several font sizes,
the compact layout, unread badges, and the collapsing utility controls.
128 changes: 127 additions & 1 deletion src/components/layout/Sidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { Menu } from '@electron/remote';
import {
mdiBell,
mdiBellOff,
Expand All @@ -21,6 +22,7 @@ import {
} from 'react-intl';
import { Tooltip as ReactTooltip } from 'react-tooltip';
import type { Actions } from '../../actions/lib/actions';
import { getI18nConfigObjects } from '../../config';
import {
addNewServiceShortcutKey,
downloadsShortcutKey,
Expand Down Expand Up @@ -76,6 +78,30 @@ const messages = defineMessages({
id: 'sidebar.lockFerdium',
defaultMessage: 'Lock Ferdium',
},
sidebarWidth: {
id: 'settings.app.form.serviceRibbonWidth',
defaultMessage: 'Sidebar width',
},
showServiceName: {
id: 'settings.app.form.showServiceName',
defaultMessage: 'Display service name under the icon',
},
compactServiceSidebar: {
id: 'settings.app.form.compactServiceSidebar',
defaultMessage: 'Use compact service sidebar',
},
serviceNameFontSize: {
id: 'sidebar.serviceNameFontSize',
defaultMessage: 'Service name text size',
},
automaticFontSize: {
id: 'sidebar.automaticFontSize',
defaultMessage: 'Automatic',
},
fontSizeTruncationNotice: {
id: 'sidebar.fontSizeTruncationNotice',
defaultMessage: 'Long names are truncated; shorten or hide the name',
},
});

interface IProps extends WrappedComponentProps {
Expand Down Expand Up @@ -131,6 +157,102 @@ class Sidebar extends Component<IProps, IState> {
};
}

componentDidMount() {
const { isMenuCollapsed, useHorizontalStyle } =
this.props.stores!.settings.all.app;

if (!isMenuCollapsed && !useHorizontalStyle) {
this.props.toggleCollapseMenu();
}
}

collapseUtilityMenuOnMouseLeave() {
const { isMenuCollapsed, useHorizontalStyle } =
this.props.stores!.settings.all.app;

if (!isMenuCollapsed && !useHorizontalStyle) {
this.props.toggleCollapseMenu();
}
}

showSidebarContextMenu(event) {
if ((event.target as HTMLElement).closest('.tab-item')) return;

event.preventDefault();

const { intl, actions, stores } = this.props;
const sidebarWidths = getI18nConfigObjects(intl).SIDEBAR_WIDTH;
const currentSidebarWidth = Number(stores!.settings.app.serviceRibbonWidth);
const currentFontSize = Number(
stores!.settings.app.serviceNameFontSize || 0,
);
const fontSizes = [0, 10, 12, 14, 16, 18, 20];
const menu = Menu.buildFromTemplate([
{
label: intl.formatMessage(messages.sidebarWidth),
submenu: Object.entries(sidebarWidths).map(([width, label]) => ({
label,
type: 'radio' as const,
checked: Number(width) === currentSidebarWidth,
click: () => {
actions!.settings.update({
type: 'app',
data: { serviceRibbonWidth: Number(width) },
});
},
})),
},
{
label: intl.formatMessage(messages.showServiceName),
type: 'checkbox',
checked: stores!.settings.app.showServiceName,
click: menuItem => {
actions!.settings.update({
type: 'app',
data: { showServiceName: menuItem.checked },
});
},
},
{
label: intl.formatMessage(messages.serviceNameFontSize),
submenu: [
...fontSizes.map(size => ({
label:
size === 0
? intl.formatMessage(messages.automaticFontSize)
: `${size} px`,
type: 'radio' as const,
checked: size === currentFontSize,
click: () => {
actions!.settings.update({
type: 'app',
data: { serviceNameFontSize: size },
});
},
})),
{ type: 'separator' as const },
{
label: intl.formatMessage(messages.fontSizeTruncationNotice),
enabled: false,
},
],
},
{
label: intl.formatMessage(messages.compactServiceSidebar),
type: 'checkbox',
checked: stores!.settings.app.compactServiceSidebar,
click: menuItem => {
actions!.settings.update({
type: 'app',
data: { compactServiceSidebar: menuItem.checked },
});
},
},
]);

menu.popup();
}

enableToolTip() {
this.setState({ tooltipEnabled: true });
}
Expand Down Expand Up @@ -191,7 +313,11 @@ class Sidebar extends Component<IProps, IState> {
const { isDownloading, justFinishedDownloading } = stores!.app;

return (
<div className="sidebar">
<div
className="sidebar"
onContextMenu={event => this.showSidebarContextMenu(event)}
onMouseLeave={() => this.collapseUtilityMenuOnMouseLeave()}
>
<Tabbar
useHorizontalStyle={stores!.settings.all.app.useHorizontalStyle}
showMessageBadgeWhenMutedSetting={
Expand Down
96 changes: 96 additions & 0 deletions src/components/services/tabs/TabItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
import injectSheet, { type WithStylesProps } from 'react-jss';
import { SortableElement } from 'react-sortable-hoc';
import type { Stores } from '../../../@types/stores.types';
import { getI18nConfigObjects } from '../../../config';
import { altKey, cmdOrCtrlShortcutKey, shiftKey } from '../../../environment';
import globalMessages from '../../../i18n/globalMessages';
import type Service from '../../../models/Service';
Expand Down Expand Up @@ -84,6 +85,30 @@ const messages = defineMessages({
id: 'tabs.item.confirmDeleteService',
defaultMessage: 'Do you really want to delete the {serviceName} service?',
},
sidebarWidth: {
id: 'settings.app.form.serviceRibbonWidth',
defaultMessage: 'Sidebar width',
},
showServiceName: {
id: 'settings.app.form.showServiceName',
defaultMessage: 'Display service name under the icon',
},
compactServiceSidebar: {
id: 'settings.app.form.compactServiceSidebar',
defaultMessage: 'Use compact service sidebar',
},
serviceNameFontSize: {
id: 'sidebar.serviceNameFontSize',
defaultMessage: 'Service name text size',
},
automaticFontSize: {
id: 'sidebar.automaticFontSize',
defaultMessage: 'Automatic',
},
fontSizeTruncationNotice: {
id: 'sidebar.fontSizeTruncationNotice',
defaultMessage: 'Long names are truncated; shorten or hide the name',
},
});

let pollIndicatorTransition = 'none';
Expand Down Expand Up @@ -274,8 +299,17 @@ class TabItem extends Component<IProps, IState> {
showMessageBadgeWhenMutedSetting,
showServiceNameSetting,
showMessageBadgesEvenWhenMuted,
stores,
} = this.props;
const { intl } = this.props;
const sidebarWidths = getI18nConfigObjects(intl).SIDEBAR_WIDTH;
const currentSidebarWidth = Number(
stores!.settings.all.app.serviceRibbonWidth,
);
const currentFontSize = Number(
stores!.settings.all.app.serviceNameFontSize || 0,
);
const fontSizes = [0, 10, 12, 14, 16, 18, 20];

const menuTemplate: MenuItemConstructorOptions[] = [
{
Expand Down Expand Up @@ -343,6 +377,68 @@ class TabItem extends Component<IProps, IState> {
service.isHibernating ? wakeUpService() : hibernateService(),
enabled: service.isEnabled && service.canHibernate,
},
{
label: intl.formatMessage(messages.sidebarWidth),
submenu: Object.entries(sidebarWidths).map(([width, label]) => ({
label,
type: 'radio',
checked: Number(width) === currentSidebarWidth,
click: () => {
window['ferdium'].actions.settings.update({
type: 'app',
data: {
serviceRibbonWidth: Number(width),
},
});
},
})),
},
{
label: intl.formatMessage(messages.showServiceName),
type: 'checkbox',
checked: stores!.settings.all.app.showServiceName,
click: menuItem => {
window['ferdium'].actions.settings.update({
type: 'app',
data: { showServiceName: menuItem.checked },
});
},
},
{
label: intl.formatMessage(messages.serviceNameFontSize),
submenu: [
...fontSizes.map(size => ({
label:
size === 0
? intl.formatMessage(messages.automaticFontSize)
: `${size} px`,
type: 'radio' as const,
checked: size === currentFontSize,
click: () => {
window['ferdium'].actions.settings.update({
type: 'app',
data: { serviceNameFontSize: size },
});
},
})),
{ type: 'separator' as const },
{
label: intl.formatMessage(messages.fontSizeTruncationNotice),
enabled: false,
},
],
},
{
label: intl.formatMessage(messages.compactServiceSidebar),
type: 'checkbox',
checked: stores!.settings.all.app.compactServiceSidebar,
click: menuItem => {
window['ferdium'].actions.settings.update({
type: 'app',
data: { compactServiceSidebar: menuItem.checked },
});
},
},
{
label: intl.formatMessage(globalMessages.clearCache),
click: () => clearCache(),
Expand Down
1 change: 1 addition & 0 deletions src/components/settings/settings/EditSettingsForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,7 @@ class EditSettingsForm extends Component<IProps, IState> {

<Toggle {...form.$('showDisabledServices').bind()} />
<Toggle {...form.$('showServiceName').bind()} />
<Toggle {...form.$('compactServiceSidebar').bind()} />

{isUseGrayscaleServicesEnabled && <Hr />}

Expand Down
4 changes: 3 additions & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,8 @@ export const DEFAULT_APP_SETTINGS = {
isTwoFactorAutoCatcherEnabled: false,
twoFactorAutoCatcherMatcher: 'token, code, sms, verify',
showServiceName: false,
serviceNameFontSize: 0,
compactServiceSidebar: false,
showMessageBadgeWhenMuted: true,
showDragArea: false,
enableSpellchecking: true,
Expand Down Expand Up @@ -638,7 +640,7 @@ export const DEFAULT_APP_SETTINGS = {
translatorEngine: TRANSLATOR_ENGINE_LIBRETRANSLATE,
useHorizontalStyle: false,
hideCollapseButton: false,
isMenuCollapsed: false,
isMenuCollapsed: true,
hideRecipesButton: false,
hideSplitModeButton: true,
useGrayscaleServices: false,
Expand Down
Loading
Loading