Files
pybricks-code/src/toolbar/buttons/settings/SettingsButton.tsx
T
Laurens Valk 51b0988dac app: Improve split view behavior.
**Move activity buttons to main toolbar**
This was on a vscode-style sidebar because we originally thought we would add more. It turns out we will not. Having explorer/settings with the other buttons simplifies the UI.

This also makes the buttons not jump around when you open/close the explorer.

Also improves on small screens, where the explorer would obscure all buttons. Also lets us remove the blueprint hacks we had to make this work.

**Add toggles for sideviews.**
This lets us fix several UI/UX problems. It used to be easy to lose the terminal or docs forever. Now you can toggle them back on with a button and conveniently close them rather than dragging them down.

**Improve splitters**
Switch to react-resizable-panels which lets us control the split as needed. Also when dragging to near closed, it will snap to properly closed. Toggling on then restores normal size. Otherwise it preserves the split value.

The collapsed state of this library is made for hiding the docs without destroying them, so we don't need some of the hacks we had to preserve the terminal and docs state.
2026-04-02 13:08:25 +02:00

38 lines
1.2 KiB
TypeScript

// SPDX-License-Identifier: MIT
// Copyright (c) 2026 The Pybricks Authors
import React from 'react';
import { Activity, useActivitiesSelectedActivity } from '../../../activities/hooks';
import ActionButton, { ActionButtonProps } from '../../ActionButton';
import { useI18n } from './i18n';
import icon from './icon.svg';
type SettingsButtonProps = Pick<ActionButtonProps, 'id'>;
const SettingsButton: React.FunctionComponent<SettingsButtonProps> = ({ id }) => {
const i18n = useI18n();
const [selectedActivity, setSelectedActivity] = useActivitiesSelectedActivity();
return (
<ActionButton
id={id}
label={i18n.translate('label')}
tooltip={i18n.translate(
selectedActivity === Activity.Settings
? 'tooltip.hide'
: 'tooltip.show',
)}
icon={icon}
onAction={() =>
setSelectedActivity(
selectedActivity === Activity.Settings
? Activity.None
: Activity.Settings,
)
}
/>
);
};
export default SettingsButton;