Skip to content

Commit

Permalink
Merge cdbc57e into 87fae50
Browse files Browse the repository at this point in the history
  • Loading branch information
jwnasambu committed Oct 5, 2021
2 parents 87fae50 + cdbc57e commit aec6a9e
Showing 1 changed file with 53 additions and 17 deletions.
70 changes: 53 additions & 17 deletions src/apps/concepts/components/ViewConceptsHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,21 @@ import { getContainerIdFromUrl } from "../utils";
import {
Button,
createStyles,
Grid,
IconButton,
Input,
InputAdornment,
makeStyles,
Menu,
MenuItem,
TextField,
Theme
} from "@material-ui/core";
import {
PREFERRED_SOURCES_VIEW_ONLY,
useAnchor
} from "../../../utils";
import { APISource } from "../../sources";
import { AccountTreeOutlined, FolderOpen } from "@material-ui/icons";
import { AccountTreeOutlined, FolderOpen, Search as SearchIcon } from "@material-ui/icons";
import { APIDictionary } from '../../dictionaries/types';

interface Props {
Expand Down Expand Up @@ -60,6 +63,10 @@ const useStyles = makeStyles((theme: Theme) =>
marginRight: "0.2rem",
fill: "#8080809c"
},
searchInput: {
textAlign: "center",
fontSize: "larger"
},
})
);

Expand All @@ -71,6 +78,8 @@ const ViewConceptsHeader: React.FC<Props> = ({
children,
sources,
dictionaries
// showOnlyVerified,
// toggleShowVerified
}) => {
const [showSources, setShowSources] = useState(false);
const [preferredSources, setPreferredSources] = useState< { name: string; url: string }[] >();
Expand All @@ -92,7 +101,6 @@ const ViewConceptsHeader: React.FC<Props> = ({
handleSwitchSourceClick,
handleSwitchSourceClose
] = useAnchor();

const getTitleBasedOnContainerType = () => {
return isAddToDictionary
? `Import existing concept from ${getContainerIdFromUrl(containerUrl)}`
Expand Down Expand Up @@ -125,21 +133,49 @@ const ViewConceptsHeader: React.FC<Props> = ({
keepMounted
open={Boolean(switchSourceAnchor)}
onClose={handleSwitchSourceClose}
>
<TextField
multiline
className={classes.textField}
InputProps={{
className: classes.underline
}}
inputProps={{
className: classes.input
}}
value={
showSources ? "Choose a source/dictionary" : "Select a different source/dictionary"
}
onClick={() => setShowSources(!showSources)}
>
<Grid
container
// eslint-disable-next-line react/jsx-no-comment-textnodes
direction="column">
<Button
variant="text"
onClick={() => setShowSources(!showSources)}
>
{/* {showSources ? "Select a recommended source" : "Select an alternative source"} */}
</Button>
<Input
color="secondary"
type="search"
fullWidth
placeholder= {"Select an alternative source"}
//data-testid="switch-source"
endAdornment={
<InputAdornment position="end">
<IconButton
onClick={() => setShowSources(!showSources)}
data-testid="searchButton"
>
<SearchIcon />
</IconButton>
</InputAdornment>
}
/>
{/* <FormControlLabel
control={
<Switch
checkedIcon={<VerifiedSource />}
checked={showOnlyVerified}
onChange={toggleShowVerified}
color="primary"
name="displayVerified"
/>
}
label={
showOnlyVerified ? `Showing verified {"Select a recommended source"} only` : `Show verified {"Select an alternative source"} only`
}
/> */}
</Grid>
{preferredSources?.map(({ name, url }) => (
<MenuItem
// replace because we want to keep the back button useful
Expand Down

0 comments on commit aec6a9e

Please sign in to comment.