import { useState } from "react"; import styled from "styled-components"; import Select from "./select"; import { ISearchProps } from "./searchBar"; import { setTheme, IThemeProps, IThemeDataProps, getTheme, } from "../lib/useTheme"; import { Button, SubHeadline } from "./elements"; import Modal from "./modal"; export const FormContainer = styled.div` display: inline-grid; grid-template-columns: auto auto; grid-gap: 0.5rem 1rem; 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 ThemeHeader = styled.p` 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: 1px solid ${(props) => props.theme.mainColor}; color: ${(props) => props.theme.mainColor}; background: none; & > option { background-color: ${(props) => props.theme.backgroundColor}; } `; const ContentContainer = styled.div` display: flex; justify-content: space-between; flex-direction: row; @media (max-width: 766px) { flex-direction: column; } `; interface ISettingsProps { themes?: IThemeDataProps; search?: ISearchProps; } /** * Handles the settings-modal * @param {IThemeDataProps} 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").value; const currentDarkTheme = getTheme("dark").value; if (themes === undefined && search === undefined) return <>; return ( {themes !== undefined && (
Theme
Light setNewLightTheme(theme)} current={currentLightTheme} testId="light" >
Dark setNewDarkTheme(theme)} current={currentDarkTheme} testId="dark" >
)} {search !== undefined && (
Search Providers <> Default Search Provider {search.defaultProvider} <> {search.providers && ( Search Provider Prefix {search.providers.map(({ name, prefix }, index) => ( {name} {prefix} ))}
)}
)}
); }; export default Settings;