-
Notifications
You must be signed in to change notification settings - Fork 49
feat: add navbar settings and notifications pop-ups #824
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
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
22ac06a
feat: add navbar settings and notifications pop-ups
kemuru 1658af7
chore: remove redundant import library
kemuru e695a64
feat: add updated yarn.lock
kemuru b2385bc
fix: notifications triggered notifications settings
kemuru e9ef68e
fix: correct import orders
kemuru 20e1a97
fix: correct another import statement
kemuru 2e8e80e
refactor: refactor Notifications to SendMeNotifications to avoid comp…
kemuru b0b994e
fix: all suggestions from PR
kemuru 6654213
fix: overlay z-index to 1
kemuru bb11c16
Merge branch 'dev' into feat(web)/add-navbar-settings
alcercu 654df53
fix: add getfieldvariant usememo
kemuru 1369e54
refactor: better naming of variable
kemuru File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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,75 @@ | ||
import React from "react"; | ||
import styled from "styled-components"; | ||
import Identicon from "react-identicons"; | ||
import ConnectButton, { AddressDisplay, ChainDisplay } from "components/ConnectButton"; | ||
import { useWeb3 } from "hooks/useWeb3"; | ||
|
||
const Container = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
margin-top: 32px; | ||
`; | ||
|
||
const StyledChainContainer = styled.div` | ||
display: flex; | ||
height: 34px; | ||
gap: 0.5rem; | ||
justify-content: center; | ||
align-items: center; | ||
:before { | ||
content: ""; | ||
width: 8px; | ||
height: 8px; | ||
border-radius: 50%; | ||
background-color: ${({ theme }) => theme.success}; | ||
} | ||
> small { | ||
color: ${({ theme }) => theme.success}; | ||
} | ||
`; | ||
|
||
const StyledAddressContainer = styled.div` | ||
display: flex; | ||
justify-content: center; | ||
margin-top: 12px; | ||
padding-bottom: 32px; | ||
`; | ||
|
||
const StyledIdenticon = styled.div` | ||
display: flex; | ||
justify-content: center; | ||
margin-top: 32px; | ||
`; | ||
|
||
const StyledConnectButtonContainer = styled.div` | ||
display: flex; | ||
justify-content: center; | ||
padding: 16px; | ||
`; | ||
|
||
const General: React.FC = () => { | ||
const { account } = useWeb3(); | ||
|
||
return account ? ( | ||
<Container> | ||
<StyledChainContainer> | ||
<ChainDisplay /> | ||
</StyledChainContainer> | ||
{account && ( | ||
<StyledIdenticon> | ||
<Identicon size="24" string={account} /> | ||
</StyledIdenticon> | ||
)} | ||
<StyledAddressContainer> | ||
<AddressDisplay /> | ||
</StyledAddressContainer> | ||
</Container> | ||
) : ( | ||
<StyledConnectButtonContainer> | ||
<ConnectButton /> | ||
</StyledConnectButtonContainer> | ||
); | ||
}; | ||
|
||
export default General; |
45 changes: 45 additions & 0 deletions
45
web/src/layout/Header/navbar/Menu/Settings/SendMeNotifications/FormNotifs/FormEmail.tsx
This file contains hidden or 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,45 @@ | ||
import React, { Dispatch, SetStateAction, useEffect, useMemo } from "react"; | ||
import styled from "styled-components"; | ||
import { Field } from "@kleros/ui-components-library"; | ||
|
||
const StyledField = styled(Field)` | ||
display: flex; | ||
width: 100%; | ||
margin-top: 34px; | ||
`; | ||
|
||
interface IFormEmail { | ||
emailInput: string; | ||
emailIsValid: boolean; | ||
setEmailInput: Dispatch<SetStateAction<string>>; | ||
setEmailIsValid: Dispatch<SetStateAction<boolean>>; | ||
} | ||
|
||
const FormEmail: React.FC<IFormEmail> = ({ emailInput, setEmailInput, setEmailIsValid, emailIsValid }) => { | ||
useEffect(() => { | ||
setEmailIsValid(/^[\w-.]+@([\w-]+\.)+[\w-]{2,4}$/.test(emailInput)); | ||
}, [emailInput]); | ||
|
||
const handleInputChange = (event: React.ChangeEvent<HTMLInputElement>) => { | ||
event.preventDefault(); | ||
setEmailInput(event.target.value); | ||
}; | ||
|
||
const fieldVariant = useMemo(() => { | ||
if (emailInput === "") { | ||
return undefined; | ||
} | ||
return emailIsValid ? "success" : "error"; | ||
}, [emailInput, emailIsValid]); | ||
|
||
return ( | ||
<StyledField | ||
variant={fieldVariant} | ||
value={emailInput} | ||
onChange={handleInputChange} | ||
placeholder="youremail@email.com" | ||
/> | ||
); | ||
}; | ||
|
||
export default FormEmail; |
76 changes: 76 additions & 0 deletions
76
web/src/layout/Header/navbar/Menu/Settings/SendMeNotifications/FormNotifs/index.tsx
This file contains hidden or 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,76 @@ | ||
import React, { useState } from "react"; | ||
import styled from "styled-components"; | ||
import { Checkbox, Button } from "@kleros/ui-components-library"; | ||
import FormEmail from "./FormEmail"; | ||
|
||
const FormContainer = styled.div` | ||
position: relative; | ||
display: flex; | ||
flex-direction: column; | ||
padding: 0 calc(12px + (32 - 12) * ((100vw - 300px) / (1250 - 300))); | ||
padding-bottom: 32px; | ||
`; | ||
|
||
const StyledCheckbox = styled(Checkbox)` | ||
margin-top: 20px; | ||
`; | ||
|
||
const ButtonContainer = styled.div` | ||
display: flex; | ||
justify-content: end; | ||
margin-top: 16px; | ||
`; | ||
|
||
const FormEmailContainer = styled.div` | ||
position: relative; | ||
`; | ||
|
||
const EmailErrorContainer = styled.div` | ||
position: absolute; | ||
color: ${({ theme }) => theme.error}; | ||
font-size: 12px; | ||
padding-top: 4px; | ||
padding-left: 16px; | ||
`; | ||
|
||
const OPTIONS = [{ label: "When x." }, { label: "When y." }, { label: "When z." }, { label: "When w." }]; | ||
|
||
const FormNotifs: React.FC = () => { | ||
const [checkboxStates, setCheckboxStates] = useState<boolean[]>(new Array(OPTIONS.length)); | ||
const [emailInput, setEmailInput] = useState<string>(""); | ||
const [emailIsValid, setEmailIsValid] = useState<boolean>(false); | ||
|
||
const handleCheckboxChange = (index: number) => (e: React.ChangeEvent<HTMLInputElement>) => { | ||
const newCheckboxStates = [...checkboxStates]; | ||
newCheckboxStates[index] = e.target.checked; | ||
setCheckboxStates(newCheckboxStates); | ||
}; | ||
|
||
return ( | ||
<FormContainer> | ||
{OPTIONS.map(({ label }, index) => ( | ||
<StyledCheckbox | ||
key={label} | ||
onChange={handleCheckboxChange(index)} | ||
checked={checkboxStates[index]} | ||
small={true} | ||
label={label} | ||
/> | ||
))} | ||
<FormEmailContainer> | ||
<FormEmail | ||
emailInput={emailInput} | ||
emailIsValid={emailIsValid} | ||
setEmailInput={setEmailInput} | ||
setEmailIsValid={setEmailIsValid} | ||
/> | ||
</FormEmailContainer> | ||
|
||
<ButtonContainer> | ||
<Button text="Save" disabled={!emailIsValid} /> | ||
</ButtonContainer> | ||
</FormContainer> | ||
); | ||
}; | ||
|
||
export default FormNotifs; |
33 changes: 33 additions & 0 deletions
33
web/src/layout/Header/navbar/Menu/Settings/SendMeNotifications/index.tsx
This file contains hidden or 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,33 @@ | ||
import React from "react"; | ||
import styled from "styled-components"; | ||
import FormNotifs from "./FormNotifs"; | ||
|
||
const Container = styled.div` | ||
display: flex; | ||
flex-direction: column; | ||
`; | ||
|
||
const HeaderContainer = styled.div` | ||
display: flex; | ||
justify-content: center; | ||
font-size: 16px; | ||
font-weight: 600; | ||
color: ${({ theme }) => theme.primaryText}; | ||
margin-top: 32px; | ||
margin-bottom: 12px; | ||
`; | ||
|
||
const HeaderNotifs: React.FC = () => { | ||
return <HeaderContainer>Send Me Notifications</HeaderContainer>; | ||
}; | ||
|
||
const SendMeNotifications: React.FC = () => { | ||
return ( | ||
<Container> | ||
<HeaderNotifs /> | ||
<FormNotifs /> | ||
</Container> | ||
); | ||
}; | ||
|
||
export default SendMeNotifications; |
This file contains hidden or 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,83 @@ | ||
import React, { Dispatch, SetStateAction, useRef, useState } from "react"; | ||
import styled from "styled-components"; | ||
import { Tabs } from "@kleros/ui-components-library"; | ||
import General from "./General"; | ||
import SendMeNotifications from "./SendMeNotifications"; | ||
import { useFocusOutside } from "hooks/useFocusOutside"; | ||
|
||
const Container = styled.div` | ||
display: flex; | ||
position: absolute; | ||
z-index: 1; | ||
background-color: ${({ theme }) => theme.whiteBackground}; | ||
flex-direction: column; | ||
border: 1px solid ${({ theme }) => theme.stroke}; | ||
border-radius: 3px; | ||
overflow-y: auto; | ||
top: 5%; | ||
left: 50%; | ||
transform: translateX(-50%); | ||
`; | ||
|
||
const StyledSettingsText = styled.div` | ||
display: flex; | ||
justify-content: center; | ||
font-size: 24px; | ||
color: ${({ theme }) => theme.primaryText}; | ||
margin-top: 24px; | ||
`; | ||
|
||
const StyledTabs = styled(Tabs)` | ||
padding: 0 calc(8px + (32 - 8) * ((100vw - 300px) / (1250 - 300))); | ||
width: calc(300px + (424 - 300) * ((100vw - 300px) / (1250 - 300))); | ||
`; | ||
|
||
const Overlay = styled.div` | ||
position: fixed; | ||
top: 0; | ||
left: 0; | ||
width: 100vw; | ||
height: 100vh; | ||
background-color: ${({ theme }) => theme.blackLowOpacity}; | ||
z-index: 1; | ||
`; | ||
|
||
const TABS = [ | ||
{ | ||
text: "General", | ||
value: 0, | ||
}, | ||
{ | ||
text: "Notifications", | ||
value: 1, | ||
}, | ||
]; | ||
|
||
interface ISettings { | ||
setIsSettingsOpen: Dispatch<SetStateAction<boolean>>; | ||
} | ||
|
||
const Settings: React.FC<ISettings> = ({ setIsSettingsOpen }) => { | ||
const [currentTab, setCurrentTab] = useState<number>(0); | ||
const containerRef = useRef(null); | ||
useFocusOutside(containerRef, () => setIsSettingsOpen(false)); | ||
|
||
return ( | ||
<> | ||
<Overlay /> | ||
<Container ref={containerRef}> | ||
<StyledSettingsText>Settings</StyledSettingsText> | ||
<StyledTabs | ||
currentValue={currentTab} | ||
items={TABS} | ||
callback={(n: number) => { | ||
setCurrentTab(n); | ||
}} | ||
/> | ||
{currentTab === 0 ? <General /> : <SendMeNotifications />} | ||
</Container> | ||
</> | ||
); | ||
}; | ||
|
||
export default Settings; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.