diff --git a/phone/src/apps/contacts/components/views/ContactInfo.tsx b/phone/src/apps/contacts/components/views/ContactInfo.tsx index 57dc069..bdd2e3f 100644 --- a/phone/src/apps/contacts/components/views/ContactInfo.tsx +++ b/phone/src/apps/contacts/components/views/ContactInfo.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, { useEffect, useState } from 'react'; import { Avatar as MuiAvatar, Box, @@ -13,12 +13,18 @@ import { useContacts } from '../../hooks/useContacts'; import Nui from '../../../../os/nui-events/utils/Nui'; import ArrowBackIcon from '@material-ui/icons/ArrowBack'; import LogDebugEvent from '../../../../os/debug/LogDebugEvents'; +import { useQueryParams } from '../../../../common/hooks/useQueryParams'; interface ContactInfoRouteParams { mode: string; id: string; } +interface ContactInfoRouteQuery { + addNumber?: string; + referal?: string; +} + const useStyles = makeStyles((theme: Theme) => ({ root: { height: '100%', @@ -54,6 +60,7 @@ const ContactsInfoPage = () => { const { getContact } = useContacts(); const { id } = useParams(); + const { addNumber, referal } = useQueryParams({ referal: '/contacts' }); const contact = getContact(parseInt(id)); @@ -64,6 +71,12 @@ const ContactsInfoPage = () => { const { t } = useTranslation(); + useEffect(() => { + if (addNumber) { + setNumber(addNumber); + } + }, [addNumber]); + const handleContactAdd = () => { LogDebugEvent({ action: 'Handling Contact Add', @@ -75,7 +88,7 @@ const ContactsInfoPage = () => { number, avatar, }); - history.goBack(); + history.replace(referal); }; const handleContactSave = () => { @@ -113,6 +126,7 @@ const ContactsInfoPage = () => {
setName(e.target.value)} diff --git a/phone/src/apps/dialer/components/ContactSearch.tsx b/phone/src/apps/dialer/components/ContactSearch.tsx index f5e1f02..99203a6 100644 --- a/phone/src/apps/dialer/components/ContactSearch.tsx +++ b/phone/src/apps/dialer/components/ContactSearch.tsx @@ -4,7 +4,7 @@ import { makeStyles, Theme } from '@material-ui/core/styles'; const useStyles = makeStyles((theme: Theme) => ({ root: { - backgroundColor: '#e9e9e9', + backgroundColor: theme.palette.background.default, }, })); diff --git a/phone/src/apps/dialer/components/DialerApp.tsx b/phone/src/apps/dialer/components/DialerApp.tsx index 7be6360..4ce7eb0 100644 --- a/phone/src/apps/dialer/components/DialerApp.tsx +++ b/phone/src/apps/dialer/components/DialerApp.tsx @@ -10,6 +10,32 @@ import DialerNavBar from './DialerNavBar'; import { useDialHistory } from '../hooks/useDialHistory'; import InjectDebugData from '../../../os/debug/InjectDebugData'; import { ContactList } from '../../contacts/components/List/ContactList'; +import { DialerThemeProvider } from '../providers/DialerThemeProvider'; + +export const DialerApp = () => { + const history = useDialHistory(); + + const dialer = useApp('DIALER'); + return ( + + + + + + + + + + + + + + + + + + ); +}; InjectDebugData([ { @@ -29,26 +55,3 @@ InjectDebugData([ ], }, ]); - -export const DialerApp = () => { - const history = useDialHistory(); - - const dialer = useApp('DIALER'); - return ( - - - - - - - - - - - - - - - - ); -}; diff --git a/phone/src/apps/dialer/components/DialerInput.tsx b/phone/src/apps/dialer/components/DialerInput.tsx index 4fe1822..2ab6f73 100644 --- a/phone/src/apps/dialer/components/DialerInput.tsx +++ b/phone/src/apps/dialer/components/DialerInput.tsx @@ -2,8 +2,10 @@ import React, { useContext } from 'react'; import { Box, IconButton, InputBase, Paper } from '@material-ui/core'; import { makeStyles, Theme } from '@material-ui/core/styles'; import PhoneIcon from '@material-ui/icons/Phone'; +import PersonAddIcon from '@material-ui/icons/PersonAdd'; import { DialInputCtx } from '../context/InputContext'; import Nui from '../../../os/nui-events/utils/Nui'; +import { useHistory } from 'react-router-dom'; const useStyles = makeStyles((theme: Theme) => ({ root: { @@ -26,8 +28,9 @@ const useStyles = makeStyles((theme: Theme) => ({ export const DialerInput = () => { const classes = useStyles(); + const history = useHistory(); - const { inputVal } = useContext(DialInputCtx) + const { inputVal } = useContext(DialInputCtx); const handleCall = (number: string) => { Nui.send('phone:beginCall', { @@ -35,6 +38,10 @@ export const DialerInput = () => { }); }; + const handleNewContact = (number: string) => { + history.push(`/contacts/-1/?addNumber=${number}&referal=/phone/contacts`) + } + return ( { className={classes.input} value={inputVal} /> + + handleCall(inputVal)} /> + - handleCall(inputVal)} /> + handleNewContact(inputVal)} /> ); diff --git a/phone/src/apps/dialer/components/DialerNavBar.tsx b/phone/src/apps/dialer/components/DialerNavBar.tsx index 4e0bdb5..1904c59 100644 --- a/phone/src/apps/dialer/components/DialerNavBar.tsx +++ b/phone/src/apps/dialer/components/DialerNavBar.tsx @@ -9,10 +9,10 @@ import HistoryIcon from '@material-ui/icons/History'; const useStyles = makeStyles((theme: Theme) => ({ root: { width: '100%', - backgroundColor: theme.palette.background.default, + backgroundColor: theme.palette.background.paper, }, icon: { - color: '#43a047', + color: theme.palette.primary.main, }, })); diff --git a/phone/src/apps/dialer/dialer.theme.ts b/phone/src/apps/dialer/dialer.theme.ts new file mode 100644 index 0000000..4a7127d --- /dev/null +++ b/phone/src/apps/dialer/dialer.theme.ts @@ -0,0 +1,17 @@ +import { common, green } from "@material-ui/core/colors"; + +export const DIALER_APP_PRIMARY_COLOR = green[600]; +export const DIALER_APP_TEXT_COLOR = common.white; + +const theme = { + palette: { + primary: { + main: DIALER_APP_PRIMARY_COLOR, + dark: green[800], + light: green[400], + contrastText: DIALER_APP_TEXT_COLOR + } + } +} + +export default theme; diff --git a/phone/src/apps/dialer/providers/DialerThemeProvider.tsx b/phone/src/apps/dialer/providers/DialerThemeProvider.tsx new file mode 100644 index 0000000..60a334a --- /dev/null +++ b/phone/src/apps/dialer/providers/DialerThemeProvider.tsx @@ -0,0 +1,4 @@ +import { createAppThemeProvider } from '../../../os/apps/utils/createAppThemeProvider'; +import dialerTheme from '../dialer.theme'; + +export const DialerThemeProvider = createAppThemeProvider(dialerTheme); diff --git a/phone/src/apps/messages/components/modal/MessageBubble.tsx b/phone/src/apps/messages/components/modal/MessageBubble.tsx index de52d8a..a4ebebd 100644 --- a/phone/src/apps/messages/components/modal/MessageBubble.tsx +++ b/phone/src/apps/messages/components/modal/MessageBubble.tsx @@ -12,9 +12,11 @@ const useStyles = makeStyles((theme) => ({ mySms: { float: 'right', margin: theme.spacing(1), - padding: '6px 12px', + padding: '6px 16px', height: 'auto', - width: '80%', + width: 'auto', + minWidth: '60%', + maxWidth: '85%', background: theme.palette.background.default, color: theme.palette.text.primary, borderRadius: '20px', @@ -24,7 +26,9 @@ const useStyles = makeStyles((theme) => ({ float: 'left', margin: theme.spacing(1), padding: '6px 12px', - width: '80%', + width: 'auto', + minWidth: '60%', + maxWidth: '85%', height: 'auto', background: theme.palette.primary.light, color: theme.palette.getContrastText(theme.palette.primary.light), @@ -62,7 +66,7 @@ export const MessageBubble = ({
{message.message}
)} - + {isGroupChat && !message.isMine ? message.display || message.phone_number diff --git a/phone/src/apps/notes/NotesApp.css b/phone/src/apps/notes/NotesApp.css deleted file mode 100644 index 6728c0e..0000000 --- a/phone/src/apps/notes/NotesApp.css +++ /dev/null @@ -1,7 +0,0 @@ -#notes-app .Mui-focused::after { - border-bottom: 3px solid #f9a825; -} - -#notes-app .MuiOutlinedInput-root { - border: 2px soild #f9a825; -} diff --git a/phone/src/apps/notes/NotesApp.tsx b/phone/src/apps/notes/NotesApp.tsx index face916..9b9d223 100644 --- a/phone/src/apps/notes/NotesApp.tsx +++ b/phone/src/apps/notes/NotesApp.tsx @@ -4,17 +4,45 @@ import { AppContent } from '../../ui/components/AppContent'; import { AppTitle } from '../../ui/components/AppTitle'; import { useApp } from '../../os/apps/hooks/useApps'; import NoteList from './list/NoteList'; - -import { useNotes } from './hooks/useNotes'; import { NoteModal } from './modal/NoteModal'; import { Fab } from '@material-ui/core'; import AddIcon from '@material-ui/icons/Add'; - -import { useNoteModal } from './hooks/useNoteModal'; import { useNoteDetail } from './hooks/useNoteDetail'; - import useStyles from './notes.styles'; import InjectDebugData from '../../os/debug/InjectDebugData'; +import { NotesThemeProvider } from './providers/NotesThemeProvider'; +import { Route, useHistory } from 'react-router-dom'; + +export const NotesApp = () => { + const classes = useStyles(); + const history = useHistory(); + const notesApp = useApp('NOTES'); + const { setDetail } = useNoteDetail(); + + const onClickCreate = () => { + setDetail({ title: '', content: '' }); + history.push('/notes/detail'); + }; + + return ( + + + + + + + + + + + + + ); +}; InjectDebugData([ { @@ -34,37 +62,3 @@ InjectDebugData([ ], }, ]); - -export const NotesApp = () => { - const { setNoteModal } = useNoteModal(); - const { detail, setDetail } = useNoteDetail(); - const { notes } = useNotes(); - const notesApp = useApp('NOTES'); - - const classes = useStyles(); - - const handleModal = () => { - setNoteModal(true); - setDetail(null); - }; - - return ( - - - - - - - - - - - ); -}; diff --git a/phone/src/apps/notes/NotesTitle.tsx b/phone/src/apps/notes/NotesTitle.tsx index 9d4404a..d3c2171 100644 --- a/phone/src/apps/notes/NotesTitle.tsx +++ b/phone/src/apps/notes/NotesTitle.tsx @@ -1,18 +1,30 @@ import React from 'react'; -import { yellow } from '@material-ui/core/colors'; - -import useStyles from './notes.styles'; - -import { Paper } from '@material-ui/core'; +import { makeStyles, Paper } from '@material-ui/core'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faStickyNote } from '@fortawesome/free-solid-svg-icons'; +const useStyles = makeStyles((theme) => ({ + header: { + width: '100%', + display: 'flex', + flexFlow: 'row nowrap', + justifyContent: 'center', + alignItems: 'center', + textAlign: 'center', + height: '60px', + }, + icon: { + color: theme.palette.primary.main, + fontSize: 40, + }, +})); + const NotesTitle = () => { const classes = useStyles(); return ( - + ); }; diff --git a/phone/src/apps/notes/hooks/useNoteModal.ts b/phone/src/apps/notes/hooks/useNoteModal.ts deleted file mode 100644 index f946540..0000000 --- a/phone/src/apps/notes/hooks/useNoteModal.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { useRecoilState } from 'recoil'; -import { noteStates } from './state'; - -interface NoteModalProps { - noteModal: boolean; - setNoteModal: (show: boolean) => void; -} - -export const useNoteModal = (): NoteModalProps => { - const [noteModal, setNoteModal] = useRecoilState(noteStates.noteModal); - return { noteModal, setNoteModal }; -}; diff --git a/phone/src/apps/notes/list/NoteList.tsx b/phone/src/apps/notes/list/NoteList.tsx index 0e569c0..9b5634f 100644 --- a/phone/src/apps/notes/list/NoteList.tsx +++ b/phone/src/apps/notes/list/NoteList.tsx @@ -1,18 +1,19 @@ -import { List, ListItem, ListItemText } from '@material-ui/core'; import React from 'react'; - -import { useNoteModal } from '../hooks/useNoteModal'; +import { List, ListItem, ListItemText } from '@material-ui/core'; import { useNoteDetail } from '../hooks/useNoteDetail'; +import { useNotes } from '../hooks/useNotes'; +import { useHistory } from 'react-router-dom'; // add search bar later // TODO: Add interface for note -const NoteList = ({ notes }) => { - const { setNoteModal } = useNoteModal(); +const NoteList = () => { + const history = useHistory(); + const { notes } = useNotes(); const { setDetail } = useNoteDetail(); const handleNoteModal = (note) => { - setNoteModal(true); setDetail(note); + history.push('/notes/detail'); }; return ( diff --git a/phone/src/apps/notes/modal/NoteModal.tsx b/phone/src/apps/notes/modal/NoteModal.tsx index 08d099e..2b3b110 100644 --- a/phone/src/apps/notes/modal/NoteModal.tsx +++ b/phone/src/apps/notes/modal/NoteModal.tsx @@ -1,41 +1,39 @@ -import { Button, TextField, Slide } from '@material-ui/core'; -import React, { useState } from 'react'; +import { + Button, + TextField, + Slide, + Paper, + Typography, + Container, + CircularProgress, + Box, +} from '@material-ui/core'; +import React from 'react'; import ArrowBackIcon from '@material-ui/icons/ArrowBack'; - -import { useNoteModal } from '../hooks/useNoteModal'; import { useNoteDetail } from '../hooks/useNoteDetail'; - import useStyles from './modal.styles'; - -import '../NotesApp.css'; import Nui from '../../../os/nui-events/utils/Nui'; +import { useTranslation } from 'react-i18next'; +import { useHistory } from 'react-router-dom'; +import { StatusButton } from '../../../ui/components/StatusButton'; -// TODO: Fix input focus color export const NoteModal = () => { - const { noteModal, setNoteModal } = useNoteModal(); + const classes = useStyles(); + const history = useHistory(); + const { t } = useTranslation(); const { detail, setDetail } = useNoteDetail(); - const [title, setTitle] = useState(detail ? detail.title : ''); - const [content, setContent] = useState(detail ? detail.content : ''); - const classes = useStyles() - - + const onClose = () => history.goBack(); const _handleClose = () => { setDetail(null); - setNoteModal(false); + onClose(); }; const handleNoteSave = () => { - Nui.send('phone:addNote', { - title, - content, - }); + Nui.send('phone:addNote', detail); setDetail(null); - setNoteModal(false); - - setTitle('') - setContent('') + onClose(); }; const handleDeleteNote = () => { @@ -44,78 +42,112 @@ export const NoteModal = () => { id, }); setDetail(null); - setNoteModal(false); + onClose(); }; const handleUpdateNote = () => { - Nui.send('phone:updateNote', { - id: detail.id, - title, - content, - }); + Nui.send('phone:updateNote', detail); setDetail(null); - setNoteModal(false); + onClose(); }; return ( -
- -
- -
- setTitle(e.target.value)} - /> - setContent(e.target.value)} - /> -

{content.length}/250

- {!detail &&( - - )} - {detail && ( - - )} - {detail && ( - - )} -
-
-
-
+ + + {!detail ? ( + + ) : ( + + + + + + + setDetail((d) => ({ ...d, title: e.target.value })) + } + /> + + setDetail((d) => ({ ...d, content: e.target.value })) + } + /> + {detail.content.length}/250 + {!detail.id ? ( + <> + + + + + + {t('GENERIC_CANCEL')} + + + + ) : ( + <> + + + + + + {t('GENERIC_DELETE')} + + + + )} + + + )} + + ); }; diff --git a/phone/src/apps/notes/modal/modal.styles.ts b/phone/src/apps/notes/modal/modal.styles.ts index 44d1f40..f706446 100644 --- a/phone/src/apps/notes/modal/modal.styles.ts +++ b/phone/src/apps/notes/modal/modal.styles.ts @@ -4,23 +4,9 @@ const useStyles = makeStyles((theme) => ({ modalRoot: { zIndex: 20, position: 'absolute', - height: '100%', + height: '99%', width: '100%', - background: '#232323', - }, - modalHide: { - display: 'none', - }, - closeButton: { - width: '10%', - position: 'absolute', - top: 10, - left: 0, - }, - noteContainer: { - width: '90%', - marginTop: 80, - margin: '0 auto', + background: theme.palette.background.default, }, input: { marginBottom: 20, @@ -30,19 +16,7 @@ const useStyles = makeStyles((theme) => ({ }, inputPropsContent: { fontSize: 20, - }, - saveButton: { - background: '#f9a825', - padding: '10px 30px', - }, - updateButton: { - background: '#f9a825', - padding: '10px 30px', - marginRight: '8px', - }, - deleteButton: { - background: '#c62828', - padding: '10px 30px', + lineHeight: 1.2, }, })); diff --git a/phone/src/apps/notes/notes.styles.ts b/phone/src/apps/notes/notes.styles.ts index c1b1cc5..71b03e3 100644 --- a/phone/src/apps/notes/notes.styles.ts +++ b/phone/src/apps/notes/notes.styles.ts @@ -1,15 +1,6 @@ import { makeStyles } from '@material-ui/core'; const useStyles = makeStyles((theme) => ({ - header: { - width: '100%', - display: 'flex', - flexFlow: 'row nowrap', - justifyContent: 'center', - alignItems: 'center', - textAlign: 'center', - height: '60px', - }, backgroundModal: { background: 'black', opacity: '0.6', diff --git a/phone/src/apps/notes/notes.theme.ts b/phone/src/apps/notes/notes.theme.ts new file mode 100644 index 0000000..dddda36 --- /dev/null +++ b/phone/src/apps/notes/notes.theme.ts @@ -0,0 +1,18 @@ +import { common, yellow } from "@material-ui/core/colors"; + +export const NOTES_APP_PRIMARY_COLOR = yellow[800]; +export const NOTES_APP_ICON_COLOR = common.white; +export const NOTES_APP_TEXT_COLOR = common.black; + +const theme = { + palette: { + primary: { + main: NOTES_APP_PRIMARY_COLOR, + dark: yellow[900], + light: yellow[500], + contrastText: NOTES_APP_TEXT_COLOR + } + } +} + +export default theme; diff --git a/phone/src/apps/notes/providers/NotesThemeProvider.tsx b/phone/src/apps/notes/providers/NotesThemeProvider.tsx new file mode 100644 index 0000000..d336e03 --- /dev/null +++ b/phone/src/apps/notes/providers/NotesThemeProvider.tsx @@ -0,0 +1,4 @@ +import { createAppThemeProvider } from "../../../os/apps/utils/createAppThemeProvider"; +import notesTheme from '../notes.theme'; + +export const NotesThemeProvider = createAppThemeProvider(notesTheme); diff --git a/phone/src/apps/sellout/sellout.theme.ts b/phone/src/apps/sellout/sellout.theme.ts index b1b511a..92e3f23 100644 --- a/phone/src/apps/sellout/sellout.theme.ts +++ b/phone/src/apps/sellout/sellout.theme.ts @@ -1,12 +1,16 @@ -import { common } from "@material-ui/core/colors"; +import { common, red } from "@material-ui/core/colors"; + +export const SELLOUT_APP_PRIMARY_COLOR = red[500]; +export const SELLOUT_APP_ICON_COLOR = common.white; +export const SELLOUT_APP_TEXT_COLOR = common.black; const theme = { palette: { primary: { - main: '#f44336', - dark: '#b3251b', - light: 'f87f76', - contrastText: common.black + main: SELLOUT_APP_PRIMARY_COLOR, + dark: red[700], + light: red[200], + contrastText: SELLOUT_APP_TEXT_COLOR } } } diff --git a/phone/src/common/hooks/useQueryParams.ts b/phone/src/common/hooks/useQueryParams.ts index 7512025..105984e 100644 --- a/phone/src/common/hooks/useQueryParams.ts +++ b/phone/src/common/hooks/useQueryParams.ts @@ -10,7 +10,12 @@ import { useLocation } from 'react-router-dom'; * * const { id, title } = useQueryParams<{ id: string, title: string }>(); */ -export function useQueryParams>() { - return qs.parse(useLocation().search, { ignoreQueryPrefix: true }) as T & - Partial; +export function useQueryParams>( + defaultValues: T = null +) { + const query = qs.parse(useLocation().search, { ignoreQueryPrefix: true }); + if (!defaultValues) { + return query as T & Partial; + } + return { ...defaultValues, ...query } as T & Partial; } diff --git a/phone/src/locale/en.json b/phone/src/locale/en.json index 049b0f6..a36c0c1 100644 --- a/phone/src/locale/en.json +++ b/phone/src/locale/en.json @@ -106,6 +106,9 @@ "GENERIC_SAVE": "Save", "GENERIC_UPDATE": "Update", "GENERIC_DELETE": "Delete", - "GENERIC_CLOSE": "Close" + "GENERIC_CLOSE": "Close", + "GENERIC_CANCEL": "Cancel", + "GENERIC_TITLE": "Title", + "GENERIC_CONTENT": "Content" } } diff --git a/phone/src/os/apps/config/apps.tsx b/phone/src/os/apps/config/apps.tsx index 98320de..e386969 100644 --- a/phone/src/os/apps/config/apps.tsx +++ b/phone/src/os/apps/config/apps.tsx @@ -3,10 +3,7 @@ import { blue, common, grey, - green, purple, - yellow, - red, } from '@material-ui/core/colors'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { @@ -35,6 +32,7 @@ import { SelloutApp } from '../../../apps/sellout/components/SelloutApp'; import { NotesApp } from '../../../apps/notes/NotesApp'; import CameraApp from '../../../apps/camera/components/CameraApp'; import { AppRoute } from '../components/AppRoute'; + import { MESSAGES_APP_PRIMARY_COLOR, MESSAGES_APP_TEXT_COLOR, @@ -43,6 +41,9 @@ import { CONTACTS_APP_PRIMARY_COLOR, CONTACTS_APP_TEXT_COLOR, } from '../../../apps/contacts/contacts.theme'; +import { SELLOUT_APP_PRIMARY_COLOR, SELLOUT_APP_ICON_COLOR } from '../../../apps/sellout/sellout.theme'; +import { NOTES_APP_ICON_COLOR, NOTES_APP_PRIMARY_COLOR } from '../../../apps/notes/notes.theme'; +import { DIALER_APP_PRIMARY_COLOR, DIALER_APP_TEXT_COLOR } from '../../../apps/dialer/dialer.theme'; export interface IAppConfig { id: string; @@ -61,8 +62,8 @@ export const APPS: IAppConfig[] = [ nameLocale: 'APPS_DIALER', icon: , notificationIcon: , - backgroundColor: green[600], - color: common.white, + backgroundColor: DIALER_APP_PRIMARY_COLOR, + color: DIALER_APP_TEXT_COLOR, path: '/phone', Route: () => , }, @@ -141,8 +142,8 @@ export const APPS: IAppConfig[] = [ nameLocale: 'APPS_SELLOUT', icon: , notificationIcon: , - backgroundColor: red[500], - color: common.white, + backgroundColor: SELLOUT_APP_PRIMARY_COLOR, + color: SELLOUT_APP_ICON_COLOR, path: '/sellout', Route: () => ( @@ -155,8 +156,8 @@ export const APPS: IAppConfig[] = [ notificationIcon: ( ), - backgroundColor: yellow[800], - color: common.white, + backgroundColor: NOTES_APP_PRIMARY_COLOR, + color: NOTES_APP_ICON_COLOR, path: '/notes', Route: () => , }, diff --git a/phone/src/ui/components/Alert.tsx b/phone/src/ui/components/Alert.tsx index 697fb4c..edfd7f7 100644 --- a/phone/src/ui/components/Alert.tsx +++ b/phone/src/ui/components/Alert.tsx @@ -1,8 +1,30 @@ import React from 'react'; import MuiAlert from '@material-ui/lab/Alert'; +import { makeStyles, Typography } from '@material-ui/core'; -export function Alert(props) { - return ; +const useStyles = makeStyles({ + root: { + zIndex: 10000, + }, + msg: { + maxWidth: '300px', + wordWrap: 'break-word', + fontSize: '1em' + }, +}); + +export function Alert({ children, ...props }) { + const classes = useStyles(); + return ( + + {children} + + ); } export default Alert; diff --git a/phone/src/ui/components/StatusButton.tsx b/phone/src/ui/components/StatusButton.tsx new file mode 100644 index 0000000..01e11f9 --- /dev/null +++ b/phone/src/ui/components/StatusButton.tsx @@ -0,0 +1,58 @@ +import { Button, ButtonProps, fade, makeStyles } from '@material-ui/core'; +import React from 'react'; + +type StatusButtonStyleColor = 'success' | 'error' | 'warning' | 'info'; + +interface IStatusButtonStyleProps { + color: StatusButtonStyleColor; +} + +const useStyles = makeStyles( + (theme) => ({ + root: { + color: ({ color }: IStatusButtonStyleProps) => theme.palette[color].main, + '&:hover': { + backgroundColor: ({ color }: IStatusButtonStyleProps) => + fade(theme.palette[color].light, theme.palette.action.hoverOpacity), + }, + }, + outlined: { + border: ({ color }: IStatusButtonStyleProps) => + `1px solid ${fade(theme.palette[color].main, 0.5)}`, + '&:hover': { + border: ({ color }: IStatusButtonStyleProps) => + `1px solid ${theme.palette[color].main}`, + }, + '&$disabled': { + border: `1px solid ${theme.palette.action.disabled}`, + }, + }, + contained: { + color: ({ color }: IStatusButtonStyleProps) => + theme.palette[color].contrastText, + backgroundColor: ({ color }: IStatusButtonStyleProps) => + theme.palette[color].main, + '&:hover': { + backgroundColor: ({ color }: IStatusButtonStyleProps) => + theme.palette[color].dark, + }, + }, + }), + { name: 'MuiButton' } +); + +export const StatusButton = ({ + color = 'info', + variant, + className, + ...props +}: Omit & { color: StatusButtonStyleColor }) => { + const classes = useStyles({ color }); + return ( +