import { useState } from "react"; import styled from "styled-components"; import Select from "./select"; import { ISearchProps } from "./searchBar"; import { setTheme, IThemeProps, getTheme } from "../lib/useTheme"; import { Button, SubHeadline } from "./elements"; import Modal from "./modal"; export const FormContainer = styled.div` margin-bottom: 1em; `; export const Table = styled.table` font-weight: 400; background: none; width: 100%; color: ${(props) => props.theme.mainColor}; `; export const TableRow = styled.tr` border-bottom: 1px solid ${(props) => props.theme.mainColor}; `; export const TableCell = styled.td` background: none; padding-top: 0.5rem; `; export const HeadCell = styled.th` font-weight: 700; text-align: left; `; export const Section = styled.div` padding: 1rem 0; `; export const SectionHeadline = styled(SubHeadline)` width: 100%; border-bottom: 1px solid ${(props) => props.theme.accentColor}; margin-bottom: 0.5rem; `; const Text = styled.p` font-weight: 700; color: ${(props) => props.theme.accentColor}; `; const Code = styled.p` font-family: monospace; color: ${(props) => props.theme.accentColor}; `; const ThemeSelect = styled(Select)` -webkit-appearance: button; -moz-appearance: button; text-transform: uppercase; font-family: Roboto, sans-serif; font-weight: 400; border-radius: 0; border: 1px solid ${(props) => props.theme.mainColor}; color: ${(props) => props.theme.mainColor}; background: none; & > option { background-color: ${(props) => props.theme.backgroundColor}; } `; interface ISettingsProps { themes?: Array; search?: ISearchProps; } /** * Handles the settings-modal * @param {Array} themes - the list of themes a user can select between * @param {ISearchProps} search - the list of search providers */ const Settings = ({ themes, search }: ISettingsProps) => { const [newLightTheme, setNewLightTheme] = useState(); const [newDarkTheme, setNewDarkTheme] = useState(); const currentLightTheme = getTheme("light").label; const currentDarkTheme = getTheme("dark").label; if (themes || search) { return ( {themes && (
Theme: Light Dark setNewLightTheme(theme) } current={currentLightTheme} testId="light" > setNewDarkTheme(theme) } current={currentDarkTheme} testId="dark" >
)} {search && (
Search Providers <> Default Search Provider {search.defaultProvider} <> {search.providers && ( Search Provider Prefix {search.providers.map(({ name, prefix }, index) => ( {name} {prefix} ))}
)}
)}
); } else { return <>; } }; export default Settings;