-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(app): add support for switching between search engines, and spec…
…ifying custom one (#12)
- Loading branch information
1 parent
f0eaf8e
commit 73e574c
Showing
10 changed files
with
334 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import styled from '@emotion/styled' | ||
import IconButton from '@components/IconButton' | ||
|
||
export const Button = styled(IconButton)`` | ||
|
||
export const Root = styled.div` | ||
position: absolute; | ||
right: ${({ theme }) => theme.spacing(2)}; | ||
bottom: ${({ theme }) => theme.spacing(2)}; | ||
z-index: 3; | ||
` | ||
|
||
export const Content = styled.div` | ||
width: 300px; | ||
height: 300px; | ||
` | ||
|
||
export const TabHeader = styled.div` | ||
display: flex; | ||
justify-content: space-around; | ||
margin-bottom: 16px; | ||
gap: 8px; | ||
border-radius: 4px; | ||
` | ||
|
||
export const TabButton = styled.button<{ isActive?: boolean }>` | ||
flex: 1; | ||
padding: 10px 0; | ||
background-color: ${({ isActive }) => (isActive ? '#444' : 'transparent')}; | ||
color: ${({ isActive }) => (isActive ? '#fff' : '#ccc')}; | ||
border: ${() => '1px solid #969696'}; | ||
border-radius: 4px; | ||
cursor: pointer; | ||
transition: | ||
color 0.3s, | ||
background-color 0.3s; | ||
&:hover { | ||
color: #fff; | ||
background-color: #444; | ||
} | ||
` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import { useState } from 'react' | ||
import { MdSettings } from 'react-icons/md' | ||
|
||
import Panel from '@components/Panel' | ||
|
||
import * as Styled from './Settings.styled' | ||
import SettingsBackground from './background/SettingsBackground' | ||
import SettingsSearch from './search/SettingsSearch' | ||
|
||
type Tabs = 'background' | 'search' | ||
|
||
function Settings() { | ||
const [open, setOpen] = useState(false) | ||
const [tab, setTab] = useState<Tabs>('background') | ||
|
||
const handleButtonClick = () => { | ||
setOpen((prev) => !prev) | ||
} | ||
|
||
const renderTabContent = () => { | ||
if (tab === 'search') { | ||
return <SettingsSearch /> | ||
} | ||
|
||
return <SettingsBackground /> | ||
} | ||
|
||
return ( | ||
<Styled.Root> | ||
<Panel open={open}> | ||
<Styled.TabHeader> | ||
<Styled.TabButton | ||
onClick={() => setTab('background')} | ||
isActive={tab === 'background'} | ||
> | ||
Background | ||
</Styled.TabButton> | ||
<Styled.TabButton | ||
onClick={() => setTab('search')} | ||
isActive={tab === 'search'} | ||
> | ||
Search | ||
</Styled.TabButton> | ||
</Styled.TabHeader> | ||
<Styled.Content>{renderTabContent()}</Styled.Content> | ||
</Panel> | ||
<Styled.Button onClick={handleButtonClick}> | ||
<MdSettings /> | ||
</Styled.Button> | ||
</Styled.Root> | ||
) | ||
} | ||
|
||
export default Settings |
12 changes: 0 additions & 12 deletions
12
src/components/Settings.styled.ts → ...s/background/SettingsBackground.styled.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.