Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Comboboxes to Selects in example setting components #629

Merged
merged 1 commit into from
Nov 8, 2023
Merged
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
45 changes: 27 additions & 18 deletions src/renderer/components/settings-dialog/settings-tab.component.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
import { Box, List, ListItem, ListItemText, Tab, Tabs, Typography } from '@mui/material';
import {
Box,
List,
ListItem,
ListItemText,
MenuItem,
Select,
Tab,
Tabs,
Typography,
} from '@mui/material';
import { SavedTabInfo, TabInfo } from '@shared/data/web-view.model';
import {
SyntheticEvent,
Expand All @@ -8,7 +18,7 @@ import {
useCallback,
useMemo,
} from 'react';
import { Checkbox, ComboBox, SearchBar, TextField } from 'papi-components';
import { Checkbox, SearchBar, TextField } from 'papi-components';
import TabPanel from '@renderer/components/tab-panel.component';
import './settings-tab.component.scss';
import logger from '@shared/services/logger.service';
Expand Down Expand Up @@ -183,15 +193,11 @@ const options = ['English', 'Spanish', 'French'];
// Example component of a platform setting - shows how SettingProps would be used
function InterfaceLanguageSetting({ setting, setSetting }: SettingProps<string>) {
return (
<ComboBox<string>
options={options}
value={setting}
// Type asserting because combobox props aren't precise enough yet
// Issue https://github.com/paranext/paranext-core/issues/560
// eslint-disable-next-line no-type-assertion/no-type-assertion
onChange={(_e, v) => setSetting(v as string)}
width={200}
/>
<Select value={setting} onChange={(e) => setSetting(e.target.value)} sx={{ width: 200 }}>
{options.map((option) => (
<MenuItem value={option}>{option}</MenuItem>
))}
</Select>
);
}

Expand Down Expand Up @@ -250,11 +256,14 @@ function CheckboxSetting({ setting, setSetting }: SettingProps<boolean>) {
}

// Example component of a platform setting
function ComboboxSetting({ setting, setSetting }: SettingProps<string>) {
// Type asserting because combobox props aren't precise enough yet
// Issue https://github.com/paranext/paranext-core/issues/560
// eslint-disable-next-line no-type-assertion/no-type-assertion
return <ComboBox value={setting} onChange={(_e, v) => setSetting(v as string)} width={200} />;
// Since this is a blanket component for all settings that need a Select, the only option included is the default value of the setting
// Settings components will look more like InterfaceLanguageSetting, with appropriate options
function SelectSetting({ setting, setSetting }: SettingProps<string>) {
return (
<Select value={setting} onChange={(e) => setSetting(e.target.value)} sx={{ width: 200 }}>
<MenuItem value={setting}>{setting}</MenuItem>
</Select>
);
}

// Returns mock data
Expand All @@ -263,7 +272,7 @@ function fetchSettingsComponents(): SettingsComponents {
return {
'platform.interfaceLanguage': InterfaceLanguageSetting,
'platform.highlightCurrentVerse': CheckboxSetting,
'platform.brightnessOfHighlight': ComboboxSetting,
'platform.brightnessOfHighlight': SelectSetting,
'platform.displayFloatingWindows': CheckboxSetting,
'platform.hardwareAcceleration': CheckboxSetting,
'platform.scrollScripture': CheckboxSetting,
Expand All @@ -272,7 +281,7 @@ function fetchSettingsComponents(): SettingsComponents {
'platform.autoAssignProjectNotes': CheckboxSetting,
'platform.autosave': CheckboxSetting,
'platform.khmerOnly': CheckboxSetting,
'platform.internetUse': ComboboxSetting,
'platform.internetUse': SelectSetting,
'platform.shareParatextData': CheckboxSetting,
'platform.proxySettings': ProxySettings,
};
Expand Down
Loading