-
-
Notifications
You must be signed in to change notification settings - Fork 873
fix message layout #819
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
fix message layout #819
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| import {Button, Theme} from '@mui/material'; | ||
| import {Button, Theme, useMediaQuery, useTheme} from '@mui/material'; | ||
| import IconButton from '@mui/material/IconButton'; | ||
| import {makeStyles} from 'tss-react/mui'; | ||
| import Typography from '@mui/material/Typography'; | ||
|
|
@@ -11,6 +11,7 @@ import {Markdown} from '../common/Markdown'; | |
| import * as config from '../config'; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The changes currently break
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Huhh, I did test with markdown formatted images. Let me double check .. Should we just have a sample database/script that posts a list of various messages so it is easy to check nothing breaks?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, we definitely should have this. |
||
| import {IMessageExtras} from '../types'; | ||
| import {contentType, RenderMode} from './extras'; | ||
| import {makeIntlFormatter} from 'react-timeago/defaultFormatter'; | ||
|
|
||
| const PREVIEW_LENGTH = 500; | ||
|
|
||
|
|
@@ -32,6 +33,7 @@ const useStyles = makeStyles()((theme: Theme) => ({ | |
| }, | ||
| messageContentWrapper: { | ||
| minWidth: 200, | ||
| width: '100%', | ||
| }, | ||
| image: { | ||
| marginRight: 15, | ||
|
|
@@ -81,6 +83,7 @@ interface IProps { | |
| date: string; | ||
| content: string; | ||
| priority: number; | ||
| appName: string; | ||
| fDelete: VoidFunction; | ||
| extras?: IMessageExtras; | ||
| expanded: boolean; | ||
|
|
@@ -105,13 +108,16 @@ const Message = ({ | |
| priority, | ||
| content, | ||
| extras, | ||
| appName, | ||
| onExpand, | ||
| expanded: initialExpanded, | ||
| }: IProps) => { | ||
| const theme = useTheme(); | ||
| const [previewRef, setPreviewRef] = React.useState<HTMLDivElement | null>(null); | ||
| const {classes} = useStyles(); | ||
| const [expanded, setExpanded] = React.useState(initialExpanded); | ||
| const [isOverflowing, setOverflowing] = React.useState(false); | ||
| const dateWrapped = useMediaQuery(theme.breakpoints.down('md')); | ||
|
|
||
| React.useEffect(() => { | ||
| setOverflowing(!!previewRef && previewRef.scrollHeight > previewRef.clientHeight); | ||
|
|
@@ -145,7 +151,7 @@ const Message = ({ | |
| {image !== null ? ( | ||
| <img | ||
| src={config.get('url') + image} | ||
| alt="app logo" | ||
| alt={`${appName} logo`} | ||
| width="70" | ||
| height="70" | ||
| className={classes.image} | ||
|
|
@@ -158,7 +164,12 @@ const Message = ({ | |
| {title} | ||
| </Typography> | ||
| <Typography variant="body1" className={classes.date}> | ||
| <TimeAgo date={date} /> | ||
| <TimeAgo | ||
| date={date} | ||
| formatter={makeIntlFormatter({ | ||
| style: dateWrapped ? 'long' : 'narrow', | ||
| })} | ||
| /> | ||
| </Typography> | ||
| <IconButton | ||
| onClick={fDelete} | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,19 @@ | ||
| declare module 'react-timeago' { | ||
| import React from 'react'; | ||
|
|
||
| export type FormatterOptions = { | ||
| style?: 'long' | 'short' | 'narrow'; | ||
| }; | ||
| export type Formatter = (options: FormatterOptions) => React.ReactNode; | ||
|
|
||
| export interface ITimeAgoProps { | ||
| date: string; | ||
| formatter?: Formatter; | ||
| } | ||
|
|
||
| export default class TimeAgo extends React.Component<ITimeAgoProps, unknown> {} | ||
| } | ||
|
|
||
| declare module 'react-timeago/defaultFormatter' { | ||
| declare function makeIntlFormatter(options: FormatterOptions): Formatter; | ||
| } |

There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should display the app images even on small screens (I can already smell the issues that the app icons aren't visible :D)
Maybe it could be formatted like this?
Maybe this could even be the default formatting on all sizes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we do this change in a separate PR independent of upgrade-ui?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose, it is complicated and I think discussion potentially change is needed.
I personally don't use this icon feature very often: reason simply being it kind of becomes an ad-hoc graphics design problem where the icon needs to be readable on any screen and the file has to be appropriately compressed so it loads fast. More often than not I find just text description being better.
For example I name my servers after mountain names: nokogiri, gorgonio, ontake, etc. It is simply much more recognizable to write the name in text than find an appropriate image for these mountains that displays well under any size.
I think that is also why most "uptime monitoring" apps don't have app icon feature, users have difficulty sourcing images that display well in a list or card grid like fashion and it's more clean and neat without it.
But I feel the text app name absolutely should be there for both accessibility and user choice reasons.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally agree with the usefulness of the icons, but I think there are a significant amount of users that would. Maybe we could hide the image if it's the default one, and only display it when the user has uploaded a custom one.
Agreed, but we should probably omit it, if the title is equal to the app name.