mirror of
https://github.com/darksaid98/new-phone-who-dis.git
synced 2026-12-04 14:38:45 +00:00
Task/improve hardcoded styles and types (#107)
* Add working notifications with only twitter for now * feat(notification-bar): I didnt copy from NP * feat(notifications): Collapse when no more notifications after closing one * Improve overall messages styling code * Improve Routing performance * improve use keyboard hook * Remove unused returns * Button hover color :) * Button hover color :) x2 * Added hover style to containedPrimary msg btn * Replace custom components for custom theme providers for Messages and Contacts apps * Improve createAppThemeProvider * Improve createAppThemeProvider * Final housekeeping for messages styles * Change placeholder to label in Contacts app text fields * Fix alerts style with navigation and fix calc copy alerrt * Split Phone code for snackbar * Add more options and style Context Menu * Enable Sellout theme provider and make it work with light themes
This commit is contained in:
1 parent
75e23b783c
commit
4acb214ec9
56 files changed
+738
-578
No files matched your search
@@ -1,4 +1,3 @@
|
||||
import './messages.css';
|
||||
import React, { useEffect } from 'react';
|
||||
import { AppWrapper } from '../../../ui/components';
|
||||
import { AppTitle } from '../../../ui/components/AppTitle';
|
||||
@@ -10,8 +9,9 @@ import MessagesList from './list/MessagesList';
|
||||
import { Route, Switch, useHistory } from 'react-router-dom';
|
||||
import { MessageModal } from './modal/MessageModal';
|
||||
import InjectDebugData from '../../../os/debug/InjectDebugData';
|
||||
import NewMessageGroupButton from './buttons/NewMessageGroupButton';
|
||||
import NewMessageGroupButton from './form/NewMessageGroupButton';
|
||||
import Nui from '../../../os/nui-events/utils/Nui';
|
||||
import { MessagesThemeProvider } from '../providers/MessagesThemeProvider';
|
||||
|
||||
export const MessagesApp = () => {
|
||||
const messages = useApp('MESSAGES');
|
||||
@@ -22,37 +22,37 @@ export const MessagesApp = () => {
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<AppWrapper id='messages-app'>
|
||||
<AppTitle app={messages} />
|
||||
<AppContent>
|
||||
<Switch>
|
||||
<Route
|
||||
path='/messages/conversations/:groupId'
|
||||
component={MessageModal}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path='/messages'
|
||||
render={() => (
|
||||
<>
|
||||
<MessagesList />
|
||||
</>
|
||||
)}
|
||||
/>
|
||||
</Switch>
|
||||
<Switch>
|
||||
<Route
|
||||
exact
|
||||
path={['/messages/new/:phoneNumber', '/messages/new']}
|
||||
render={() => <MessageGroupModal />}
|
||||
/>
|
||||
</Switch>
|
||||
</AppContent>
|
||||
<NewMessageGroupButton
|
||||
onClick={() => history.push('/messages/new')}
|
||||
/>
|
||||
<AlertBar />
|
||||
</AppWrapper>
|
||||
<MessagesThemeProvider>
|
||||
<AppWrapper id='messages-app'>
|
||||
<AppTitle app={messages} />
|
||||
<AppContent>
|
||||
<Switch>
|
||||
<Route
|
||||
path='/messages/conversations/:groupId'
|
||||
component={MessageModal}
|
||||
/>
|
||||
<Route
|
||||
exact
|
||||
path='/messages'
|
||||
render={() => (
|
||||
<>
|
||||
<MessagesList />
|
||||
</>
|
||||
)}
|
||||
/>
|
||||
</Switch>
|
||||
<Switch>
|
||||
<Route
|
||||
exact
|
||||
path={['/messages/new/:phoneNumber', '/messages/new']}
|
||||
render={() => <MessageGroupModal />}
|
||||
/>
|
||||
</Switch>
|
||||
</AppContent>
|
||||
<NewMessageGroupButton onClick={() => history.push('/messages/new')} />
|
||||
<AlertBar />
|
||||
</AppWrapper>
|
||||
</MessagesThemeProvider>
|
||||
);
|
||||
};
|
||||
|
||||
@@ -73,7 +73,7 @@ InjectDebugData([
|
||||
updatedAt: Date.now(),
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
id: 2,
|
||||
message: 'sup!',
|
||||
user_identifier: '1234',
|
||||
phone_number: '444-4444',
|
||||
@@ -84,7 +84,7 @@ InjectDebugData([
|
||||
updatedAt: Date.now(),
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
id: 3,
|
||||
message: 'sup!',
|
||||
user_identifier: '1234',
|
||||
phone_number: '444-4444',
|
||||
@@ -95,7 +95,7 @@ InjectDebugData([
|
||||
updatedAt: Date.now(),
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
id: 4,
|
||||
message: 'sup!',
|
||||
user_identifier: '1234',
|
||||
phone_number: '444-4444',
|
||||
@@ -106,7 +106,7 @@ InjectDebugData([
|
||||
updatedAt: Date.now(),
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
id: 5,
|
||||
message: 'sup!',
|
||||
user_identifier: '1234',
|
||||
phone_number: '444-4444',
|
||||
@@ -117,7 +117,7 @@ InjectDebugData([
|
||||
updatedAt: Date.now(),
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
id: 6,
|
||||
message: 'sup!',
|
||||
user_identifier: '1234',
|
||||
phone_number: '444-4444',
|
||||
@@ -128,7 +128,7 @@ InjectDebugData([
|
||||
updatedAt: Date.now(),
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
id: 7,
|
||||
message: 'sup!',
|
||||
user_identifier: '1234',
|
||||
phone_number: '444-4444',
|
||||
@@ -139,7 +139,7 @@ InjectDebugData([
|
||||
updatedAt: Date.now(),
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
id: 8,
|
||||
message: 'sup!',
|
||||
user_identifier: '1234',
|
||||
phone_number: '444-4444',
|
||||
@@ -150,7 +150,7 @@ InjectDebugData([
|
||||
updatedAt: Date.now(),
|
||||
},
|
||||
{
|
||||
id: 1,
|
||||
id: 9,
|
||||
message: 'sup!',
|
||||
user_identifier: '1234',
|
||||
phone_number: '444-4444',
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { FormEvent, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { Paper, TextField, Button, Box, makeStyles } from '@material-ui/core';
|
||||
import { Paper, Box, makeStyles, TextField, Button } from '@material-ui/core';
|
||||
import SendIcon from '@material-ui/icons/Send';
|
||||
import ImageIcon from '@material-ui/icons/Image';
|
||||
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import React from 'react';
|
||||
import { makeStyles } from '@material-ui/core/styles';
|
||||
import { Fab } from '@material-ui/core';
|
||||
import AddIcon from '@material-ui/icons/Add';
|
||||
import { Fab } from '@material-ui/core';
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
root: {
|
||||
@@ -1,6 +1,6 @@
|
||||
import React, { FormEvent, useCallback, useEffect, useState } from 'react';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { TextField, Button, Box } from '@material-ui/core';
|
||||
import { Box, Button, TextField } from '@material-ui/core';
|
||||
|
||||
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||
import { useHistory } from 'react-router-dom';
|
||||
@@ -102,7 +102,7 @@ const NewMessageGroupForm = ({ phoneNumber }: { phoneNumber?: string }) => {
|
||||
)}
|
||||
<Box px={2} py={3}>
|
||||
<Button disabled={submitDisabled} variant='contained' fullWidth color='primary' type='submit'>
|
||||
{t('APPS_MESSAGES_NEW_MESSAGE_GROUP_SUBMIT')}
|
||||
{t('APPS_MESSAGES_NEW_MESSAGE_GROUP_SUBMIT')}
|
||||
</Button>
|
||||
</Box>
|
||||
</form>
|
||||
|
||||
@@ -17,6 +17,8 @@ const useStyles = makeStyles((theme) => ({
|
||||
inputRoot: {
|
||||
fontWeight: 400,
|
||||
fontSize: 18,
|
||||
border: '1px solid',
|
||||
borderColor: theme.palette.divider,
|
||||
},
|
||||
inputInput: {
|
||||
padding: theme.spacing(1, 4, 1, 4),
|
||||
@@ -27,7 +29,7 @@ const useStyles = makeStyles((theme) => ({
|
||||
[theme.breakpoints.up('sm')]: {
|
||||
width: '13ch',
|
||||
'&:focus': {
|
||||
width: '20ch',
|
||||
width: '24ch',
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
#messages-app {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
/* override the FAB (action buttons) background when selected */
|
||||
#messages-app .MuiFab-primary {
|
||||
background: #ffa000 !important;
|
||||
}
|
||||
|
||||
/* override the underlines of text fields */
|
||||
#messages-app .Mui-focused:after {
|
||||
border-bottom-color: #ffa000 !important;
|
||||
}
|
||||
|
||||
/* override form submit button */
|
||||
#messages-app .MuiButton-containedPrimary {
|
||||
background-color: #ffa000 !important;
|
||||
}
|
||||
|
||||
#messages-app .MuiSkeleton-text {
|
||||
border-radius: 20px !important;
|
||||
transform: none;
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
import { makeStyles } from '@material-ui/core';
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
addMessageFab: {
|
||||
position: 'sticky',
|
||||
bottom: theme.spacing(2),
|
||||
left: theme.spacing(3),
|
||||
},
|
||||
}));
|
||||
|
||||
export default useStyles;
|
||||
@@ -1,11 +1,12 @@
|
||||
import React, { useState } from 'react';
|
||||
import { Box, Paper, Typography } from '@material-ui/core';
|
||||
import { Box } from '@material-ui/core';
|
||||
|
||||
import { Message, MessageGroup } from '../../../../common/typings/messages';
|
||||
import MessageInput from '../form/MessageInput';
|
||||
import useStyles from './modal.styles';
|
||||
import { MessageImageModal } from './MessageImageModal';
|
||||
import { useQueryParams } from '../../../../common/hooks/useQueryParams';
|
||||
import { MessageBubble } from './MessageBubble';
|
||||
|
||||
interface IProps {
|
||||
activeMessageGroup: MessageGroup;
|
||||
@@ -20,10 +21,6 @@ const Conversation = ({ activeMessageGroup, messages }: IProps) => {
|
||||
const query = useQueryParams();
|
||||
const referalImage = query?.image || null;
|
||||
|
||||
const isImage = (url) => {
|
||||
return /(http(s?):)([/|.|\w|\s|-])*\.(?:jpg|png|jpeg|gif)/g.test(url);
|
||||
};
|
||||
|
||||
return (
|
||||
<>
|
||||
<MessageImageModal
|
||||
@@ -41,27 +38,11 @@ const Conversation = ({ activeMessageGroup, messages }: IProps) => {
|
||||
className={classes.overflowAutoY}
|
||||
>
|
||||
{messages.map((message) => (
|
||||
<div key={message.id}>
|
||||
<Paper
|
||||
className={message.isMine ? classes.sourceSms : classes.sms}
|
||||
variant='outlined'
|
||||
>
|
||||
{isImage(message.message) ? (
|
||||
<img
|
||||
src={message.message}
|
||||
className={classes.imageMessage}
|
||||
alt='multimedia'
|
||||
/>
|
||||
) : (
|
||||
<div>{message.message}</div>
|
||||
)}
|
||||
<Typography variant='subtitle1' color='secondary'>
|
||||
{activeMessageGroup.isGroupChat && !message.isMine
|
||||
? message.display || message.phone_number
|
||||
: null}
|
||||
</Typography>
|
||||
</Paper>
|
||||
</div>
|
||||
<MessageBubble
|
||||
key={message.id}
|
||||
message={message}
|
||||
isGroupChat={activeMessageGroup?.isGroupChat}
|
||||
/>
|
||||
))}
|
||||
</Box>
|
||||
<MessageInput
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
import { Box, makeStyles, Paper, Typography } from '@material-ui/core';
|
||||
import React from 'react';
|
||||
import { Message } from '../../../../common/typings/messages';
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
imageMessage: {
|
||||
width: '80%',
|
||||
maxWidth: '80%',
|
||||
height: '80%',
|
||||
maxHeight: '80%',
|
||||
},
|
||||
mySms: {
|
||||
float: 'right',
|
||||
margin: theme.spacing(1),
|
||||
padding: '6px 12px',
|
||||
height: 'auto',
|
||||
width: '80%',
|
||||
background: theme.palette.background.default,
|
||||
color: theme.palette.text.primary,
|
||||
borderRadius: '20px',
|
||||
textOverflow: 'ellipsis',
|
||||
},
|
||||
sms: {
|
||||
float: 'left',
|
||||
margin: theme.spacing(1),
|
||||
padding: '6px 12px',
|
||||
width: '80%',
|
||||
height: 'auto',
|
||||
background: theme.palette.primary.light,
|
||||
color: theme.palette.getContrastText(theme.palette.primary.light),
|
||||
borderRadius: '15px',
|
||||
textOverflow: 'ellipsis',
|
||||
},
|
||||
}));
|
||||
|
||||
const isImage = (url) => {
|
||||
return /(http(s?):)([/|.|\w|\s|-])*\.(?:jpg|png|jpeg|gif)/g.test(url);
|
||||
};
|
||||
|
||||
export const MessageBubble = ({
|
||||
message,
|
||||
isGroupChat,
|
||||
}: {
|
||||
message: Message;
|
||||
isGroupChat: boolean;
|
||||
}) => {
|
||||
const classes = useStyles();
|
||||
return (
|
||||
<div>
|
||||
<Paper
|
||||
className={message.isMine ? classes.mySms : classes.sms}
|
||||
variant='outlined'
|
||||
>
|
||||
<Box>
|
||||
{isImage(message.message) ? (
|
||||
<img
|
||||
src={message.message}
|
||||
className={classes.imageMessage}
|
||||
alt='multimedia'
|
||||
/>
|
||||
) : (
|
||||
<div>{message.message}</div>
|
||||
)}
|
||||
</Box>
|
||||
<Box textAlign='right'>
|
||||
<Typography variant='subtitle1' color='secondary'>
|
||||
{isGroupChat && !message.isMine
|
||||
? message.display || message.phone_number
|
||||
: null}
|
||||
</Typography>
|
||||
</Box>
|
||||
</Paper>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -1,10 +1,9 @@
|
||||
import React, { useCallback, useEffect, useMemo, useState } from 'react';
|
||||
import qs from 'qs';
|
||||
import Nui from '../../../../os/nui-events/utils/Nui';
|
||||
import CloseIcon from '@material-ui/icons/Close';
|
||||
import Modal from '../../../../ui/components/Modal';
|
||||
import PhotoLibraryIcon from '@material-ui/icons/PhotoLibrary';
|
||||
import { Box, Button, TextField, Typography } from '@material-ui/core';
|
||||
import { Box, Typography, TextField, Button } from '@material-ui/core';
|
||||
import FileCopyIcon from '@material-ui/icons/FileCopy';
|
||||
import useStyles from './modal.styles';
|
||||
import { useHistory, useLocation } from 'react-router-dom';
|
||||
@@ -85,13 +84,9 @@ export const MessageImageModal = ({
|
||||
})}`
|
||||
),
|
||||
},
|
||||
{
|
||||
label: 'Cancel',
|
||||
icon: <CloseIcon />,
|
||||
onClick: onClose,
|
||||
},
|
||||
|
||||
],
|
||||
[onClose, history, pathname, search]
|
||||
[history, pathname, search]
|
||||
);
|
||||
|
||||
return (
|
||||
@@ -110,6 +105,7 @@ export const MessageImageModal = ({
|
||||
<Button
|
||||
fullWidth
|
||||
variant='contained'
|
||||
color='primary'
|
||||
onClick={() => sendFromQueryParam(queryParamImagePreview)}
|
||||
>
|
||||
Share
|
||||
@@ -117,19 +113,19 @@ export const MessageImageModal = ({
|
||||
</Box>
|
||||
</Modal>
|
||||
<Modal visible={pasteVisible} handleClose={() => setPasteVisible(false)}>
|
||||
<div>
|
||||
<Box p={1}>
|
||||
<TextField
|
||||
placeholder='A link to your image or gif'
|
||||
onChange={(e) => setMessage(e.target.value)}
|
||||
value={message}
|
||||
className={classes.input}
|
||||
fullWidth
|
||||
inputProps={{
|
||||
className: classes.messagesInput,
|
||||
}}
|
||||
inputRef={(input) => input && input.focus()}
|
||||
onKeyPress={sendFromClipboard}
|
||||
/>
|
||||
</div>
|
||||
</Box>
|
||||
</Modal>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import React, { useEffect, useRef, useState } from 'react';
|
||||
import { Slide, Paper, Button, Typography } from '@material-ui/core';
|
||||
import { Slide, Paper, Typography, Button } from '@material-ui/core';
|
||||
import ArrowBackIcon from '@material-ui/icons/ArrowBack';
|
||||
|
||||
import useStyles from './modal.styles';
|
||||
|
||||
@@ -6,6 +6,10 @@ const useStyles = makeStyles({
|
||||
root: {
|
||||
margin: '0px 0px 12px 8px',
|
||||
},
|
||||
skeleton: {
|
||||
borderRadius: '20px',
|
||||
transform: 'none',
|
||||
},
|
||||
});
|
||||
|
||||
export default function MessageSkeleton({ height, isMine = false }) {
|
||||
@@ -14,7 +18,12 @@ export default function MessageSkeleton({ height, isMine = false }) {
|
||||
const marginLeft = isMine ? '60px' : '8px';
|
||||
return (
|
||||
<div className={classes.root} style={{ marginLeft, height: `${height}px` }}>
|
||||
<Skeleton variant='text' width={325} height={height} />
|
||||
<Skeleton
|
||||
className={classes.skeleton}
|
||||
variant='text'
|
||||
width={325}
|
||||
height={height}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -1,8 +1,8 @@
|
||||
import { makeStyles } from '@material-ui/core';
|
||||
|
||||
const useStyles = makeStyles((theme) => ({
|
||||
const useStyles = makeStyles({
|
||||
modalRoot: {
|
||||
zIndex: 10,
|
||||
zIndex: 9,
|
||||
position: 'absolute',
|
||||
height: '100%',
|
||||
width: '100%',
|
||||
@@ -31,40 +31,9 @@ const useStyles = makeStyles((theme) => ({
|
||||
paddingTop: '8px',
|
||||
fontSize: '20px',
|
||||
},
|
||||
sourceSms: {
|
||||
float: 'right',
|
||||
margin: 10,
|
||||
padding: '6px 12px',
|
||||
height: 'auto',
|
||||
width: '80%',
|
||||
background: '#0288d1',
|
||||
borderRadius: '20px',
|
||||
textOverflow: 'ellipsis',
|
||||
},
|
||||
sms: {
|
||||
float: 'left',
|
||||
margin: 10,
|
||||
padding: '6px 12px',
|
||||
width: '80%',
|
||||
height: 'auto',
|
||||
background: '#ddd',
|
||||
color: '#232323',
|
||||
borderRadius: '15px',
|
||||
textOverflow: 'ellipsis',
|
||||
},
|
||||
messagesInput: {
|
||||
fontSize: 20,
|
||||
},
|
||||
input: {
|
||||
width: '100%',
|
||||
margin: 10,
|
||||
},
|
||||
imageMessage: {
|
||||
width: '80%',
|
||||
maxWidth: '80%',
|
||||
height: '80%',
|
||||
maxHeight: '80%',
|
||||
},
|
||||
}));
|
||||
});
|
||||
|
||||
export default useStyles;
|
||||
@@ -0,0 +1,17 @@
|
||||
import { amber, common } from '@material-ui/core/colors';
|
||||
|
||||
export const MESSAGES_APP_PRIMARY_COLOR = amber[800];
|
||||
export const MESSAGES_APP_TEXT_COLOR = common.white;
|
||||
|
||||
const theme = {
|
||||
palette: {
|
||||
primary: {
|
||||
main: MESSAGES_APP_PRIMARY_COLOR,
|
||||
dark: amber[900],
|
||||
light: amber[100],
|
||||
contrastText: MESSAGES_APP_TEXT_COLOR
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
export default theme;
|
||||
@@ -0,0 +1,4 @@
|
||||
import { createAppThemeProvider } from '../../../os/apps/utils/createAppThemeProvider';
|
||||
import messagesTheme from '../messages.theme';
|
||||
|
||||
export const MessagesThemeProvider = createAppThemeProvider(messagesTheme);
|
||||
Reference in new issue
Block a user