-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #316 from AppQuality/profile-modal-notifications
Profile modal notifications
- Loading branch information
Showing
11 changed files
with
222 additions
and
55 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
12 changes: 6 additions & 6 deletions
12
src/stories/profile-modal/UserContainer.tsx → ...rofile-modal/components/UserContainer.tsx
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
8 changes: 4 additions & 4 deletions
8
src/stories/profile-modal/menuItem.tsx → ...ies/profile-modal/components/menuItem.tsx
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
4 changes: 2 additions & 2 deletions
4
src/stories/profile-modal/menuItemIcon.tsx → ...profile-modal/components/menuItemIcon.tsx
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
6 changes: 3 additions & 3 deletions
6
...ries/profile-modal/previousMenuButton.tsx → ...e-modal/components/previousMenuButton.tsx
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
32 changes: 16 additions & 16 deletions
32
src/stories/profile-modal/helpMenuItem.tsx → ...ries/profile-modal/items/helpMenuItem.tsx
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
24 changes: 12 additions & 12 deletions
24
...tories/profile-modal/languageMenuItem.tsx → .../profile-modal/items/languageMenuItem.tsx
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,118 @@ | ||
import { Paragraph } from "@zendeskgarden/react-notifications"; | ||
import { MenuItemProps } from "../_types"; | ||
import { PreviousButton } from "../components/previousMenuButton"; | ||
import { ReactComponent as GearIcon } from "../../../assets/icons/gear-fill.svg"; | ||
import styled from "styled-components"; | ||
import { Separator } from "../../dropdowns/menu"; | ||
import { Toggle } from "../../forms/toggle"; | ||
import { MenuItem } from "../components/menuItem"; | ||
import { theme } from "../../theme"; | ||
import { Field } from "../../forms/field"; | ||
import { Label } from "../../label"; | ||
import { useState } from "react"; | ||
import { MD, SM } from "../../typography/typescale"; | ||
|
||
interface SettingsProps extends MenuItemProps { | ||
settingValue?: number; | ||
|
||
onSetSettings?: (value: number) => void; | ||
i18n?: { | ||
settingsTitle?: string; | ||
settingsIntroText?: string; | ||
settingsOutroText?: { | ||
paragraph_1?: string; | ||
paragraph_2?: string; | ||
paragraph_3?: string; | ||
}; | ||
settingsToggle?: { | ||
title: string; | ||
on: string; | ||
off: string; | ||
}; | ||
}; | ||
} | ||
|
||
const StyledBody = styled.div` | ||
margin: ${({ theme }) => theme.space.base * 6}px | ||
${({ theme }) => theme.space.base * 4}px; | ||
`; | ||
|
||
const TriggerTitle = styled(MD)` | ||
color: ${({ theme }) => theme.palette.blue[700]}; | ||
margin-bottom: ${({ theme }) => theme.space.xs}; | ||
`; | ||
|
||
const SettingsIntroText = styled(Paragraph)` | ||
margin-bottom: ${({ theme }) => theme.space.md}; | ||
`; | ||
|
||
const SettingsOutroText = styled(Paragraph)` | ||
display: flex; | ||
flex-direction: column; | ||
margin-top: ${({ theme }) => theme.space.md}; | ||
`; | ||
|
||
export const SettingsItem = (props: SettingsProps) => { | ||
const [value, setValue] = useState(props.settingValue || 0); | ||
|
||
const onToggleSettings = (value: number) => { | ||
setValue(value); | ||
props.onSetSettings && props.onSetSettings(value); | ||
}; | ||
|
||
const content = ( | ||
<> | ||
<PreviousButton onClick={() => props.setActive("")} isBasic> | ||
{props.i18n?.settingsTitle ?? "Notifications Settings"} | ||
</PreviousButton> | ||
<Separator /> | ||
<StyledBody> | ||
{props.i18n && props.i18n.settingsIntroText && ( | ||
<SettingsIntroText> | ||
<SM>{props.i18n.settingsIntroText}</SM> | ||
</SettingsIntroText> | ||
)} | ||
<Field> | ||
<TriggerTitle isBold> | ||
{props.i18n?.settingsToggle?.title ?? "Allow notifications"} | ||
</TriggerTitle> | ||
<Toggle | ||
checked={value === 1} | ||
onChange={() => onToggleSettings(value === 1 ? 0 : 1)} | ||
> | ||
<Label> | ||
{value === 1 | ||
? props.i18n?.settingsToggle?.on ?? "Yes" | ||
: props.i18n?.settingsToggle?.off ?? "No"} | ||
</Label> | ||
</Toggle> | ||
</Field> | ||
{props.i18n && props.i18n.settingsOutroText && ( | ||
<> | ||
<SettingsOutroText> | ||
<SM>{props.i18n.settingsOutroText.paragraph_1}</SM> | ||
<SM>{props.i18n.settingsOutroText.paragraph_2}</SM> | ||
</SettingsOutroText> | ||
<SettingsOutroText> | ||
<SM>{props.i18n.settingsOutroText.paragraph_3}</SM> | ||
</SettingsOutroText> | ||
</> | ||
)} | ||
</StyledBody> | ||
</> | ||
); | ||
|
||
return ( | ||
<> | ||
<MenuItem | ||
content={content} | ||
value={props.value} | ||
selectedItem={props.selectedItem} | ||
setActive={props.setActive} | ||
icon={<GearIcon color={theme.palette.blue[600]} />} | ||
> | ||
{props.title} | ||
</MenuItem> | ||
</> | ||
); | ||
}; |
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