From 94e34a782ec3682c4412da5530482dde0ca903e9 Mon Sep 17 00:00:00 2001 From: Heikki Hellgren Date: Tue, 26 Nov 2024 09:22:18 +0200 Subject: [PATCH] fix: more UI fixes after MUI4 rollback --- .../src/components/AnswerCard/AnswerCard.tsx | 16 +++++++----- .../FilterPanel/DateRangeFilter.tsx | 26 +++++++++++++++++-- .../components/FilterPanel/FilterPanel.tsx | 16 +++++++++++- .../components/QuestionCard/QuestionCard.tsx | 15 ++++++++--- .../components/QuestionPage/QuestionPage.tsx | 26 ++++++++++++++----- 5 files changed, 79 insertions(+), 20 deletions(-) diff --git a/plugins/qeta-react/src/components/AnswerCard/AnswerCard.tsx b/plugins/qeta-react/src/components/AnswerCard/AnswerCard.tsx index f040ed5c..a8d4f79e 100644 --- a/plugins/qeta-react/src/components/AnswerCard/AnswerCard.tsx +++ b/plugins/qeta-react/src/components/AnswerCard/AnswerCard.tsx @@ -29,6 +29,7 @@ export type AnswerCardClassKeys = | 'highlight' | 'buttons' | 'metadata' + | 'markdownContainer' | 'contentContainer'; const useStyles = makeStyles( @@ -37,8 +38,12 @@ const useStyles = makeStyles( marginTop: '1em', }, contentContainer: { + marginLeft: '0.5em', + display: 'inline-block', + width: 'calc(100% - 70px)', + }, + markdownContainer: { minHeight: '6em', - paddingTop: '0.5em', paddingBottom: '0.5em', }, metadata: { @@ -108,16 +113,13 @@ export const AnswerCard = (props: { justifyContent="flex-start" style={{ flexWrap: 'nowrap' }} > - + - + {editMode ? ( ) : ( <> - + diff --git a/plugins/qeta-react/src/components/FilterPanel/DateRangeFilter.tsx b/plugins/qeta-react/src/components/FilterPanel/DateRangeFilter.tsx index 0c5ba12a..f00ba143 100644 --- a/plugins/qeta-react/src/components/FilterPanel/DateRangeFilter.tsx +++ b/plugins/qeta-react/src/components/FilterPanel/DateRangeFilter.tsx @@ -1,7 +1,13 @@ import React, { useEffect, useState } from 'react'; import { formatDate } from '../../utils/utils'; import { useTranslation } from '../../hooks'; -import { Grid, MenuItem, TextField, Typography } from '@material-ui/core'; +import { + Grid, + makeStyles, + MenuItem, + TextField, + Typography, +} from '@material-ui/core'; export interface DateRangeFilterProps { value?: string; @@ -13,8 +19,21 @@ type DateRangeValidation = { message?: string; }; +const useStyles = makeStyles( + theme => ({ + root: {}, + textInput: { + minWidth: '200px', + marginTop: theme.spacing(2), + marginBottom: theme.spacing(2), + }, + }), + { name: 'QetaDateRangeFilter' }, +); + export const DateRangeFilter = (props: DateRangeFilterProps) => { const { value, onChange } = props; + const styles = useStyles(); const [dateRangeOption, setDateRangeOption] = useState( value, ); @@ -50,7 +69,7 @@ export const DateRangeFilter = (props: DateRangeFilterProps) => { }; return ( - + {validation.message && ( @@ -61,6 +80,7 @@ export const DateRangeFilter = (props: DateRangeFilterProps) => { { @@ -84,6 +104,7 @@ export const DateRangeFilter = (props: DateRangeFilterProps) => { <> { { type?: PostType; } +const useStyles = makeStyles( + theme => ({ + root: { + padding: '1em', + paddingTop: '2em', + marginTop: '1em', + border: `1px solid ${theme.palette.divider}`, + }, + }), + { name: 'QetaFilterPanel' }, +); + export const FilterPanel = (props: FilterPanelProps) => { const { onChange, @@ -133,6 +146,7 @@ export const FilterPanel = (props: FilterPanelProps) => { const starredEntitiesApi = useStarredEntities(); const catalogApi = useApi(catalogApiRef); const identityApi = useApi(identityApiRef); + const styles = useStyles(); const handleChange = (event: { target: { @@ -195,7 +209,7 @@ export const FilterPanel = (props: FilterPanelProps) => { const collectionFilters = isCollectionFilters(filters); return ( - + ({ root: {}, contentContainer: { + marginLeft: '0.5em', + }, + markdownContainer: { minHeight: '6em', - paddingTop: '0.5em', paddingBottom: '0.5em', }, buttons: { @@ -93,15 +96,19 @@ export const QuestionCard = (props: { question: PostResponse }) => { justifyContent="flex-start" style={{ flexWrap: 'nowrap' }} > - + - - + + diff --git a/plugins/qeta/src/components/QuestionPage/QuestionPage.tsx b/plugins/qeta/src/components/QuestionPage/QuestionPage.tsx index 87bb09db..74cf96ac 100644 --- a/plugins/qeta/src/components/QuestionPage/QuestionPage.tsx +++ b/plugins/qeta/src/components/QuestionPage/QuestionPage.tsx @@ -26,17 +26,29 @@ import { Divider, FormControl, Grid, + makeStyles, MenuItem, TextField, Typography, } from '@material-ui/core'; import { Skeleton } from '@material-ui/lab'; +const useDescriptionStyles = makeStyles( + () => ({ + root: {}, + box: { + display: 'inline', + }, + }), + { name: 'QetaDescription' }, +); + export const QuestionPage = () => { const { id } = useParams(); const { t } = useTranslation(); const [newAnswers, setNewAnswers] = React.useState([]); const [answerSort, setAnswerSort] = React.useState('default'); + const dStyles = useDescriptionStyles(); const [answersCount, setAnswersCount] = useState(0); const [views, setViews] = useState(0); @@ -115,21 +127,23 @@ export const QuestionPage = () => { const getDescription = (q: PostResponse) => { return ( - - {t('authorBox.postedAtTime')}{' '} - + + + {t('authorBox.postedAtTime')}{' '} + {' · '} {q.updated && ( - {t('authorBox.updatedAtTime')}{' '} - + + {t('authorBox.updatedAtTime')}{' '} {' '} {t('authorBox.updatedBy')} + {' · '} )} - + {t('common.views', { count: views })}