mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-04 00:18:01 +01:00
fix: constraint-related UI fixes (#1069)
* fix: constraint-related UI fixes * test spans on values list * fix: values truncation, misc UI fixes * fix: no longer assign const variable (debug)
This commit is contained in:
parent
ee52f224bc
commit
81c25c7774
@ -3,13 +3,11 @@ import { makeStyles } from 'tss-react/mui';
|
|||||||
export const useStyles = makeStyles()(theme => ({
|
export const useStyles = makeStyles()(theme => ({
|
||||||
constraintIconContainer: {
|
constraintIconContainer: {
|
||||||
backgroundColor: theme.palette.primary.main,
|
backgroundColor: theme.palette.primary.main,
|
||||||
height: '28px',
|
|
||||||
width: '28px',
|
|
||||||
borderRadius: '50%',
|
borderRadius: '50%',
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
marginRight: '2rem',
|
marginRight: theme.spacing(2),
|
||||||
[theme.breakpoints.down(650)]: {
|
[theme.breakpoints.down(650)]: {
|
||||||
marginBottom: '1rem',
|
marginBottom: '1rem',
|
||||||
marginRight: 0,
|
marginRight: 0,
|
||||||
@ -17,8 +15,6 @@ export const useStyles = makeStyles()(theme => ({
|
|||||||
},
|
},
|
||||||
constraintIcon: {
|
constraintIcon: {
|
||||||
fill: '#fff',
|
fill: '#fff',
|
||||||
width: '26px',
|
|
||||||
height: '26px',
|
|
||||||
},
|
},
|
||||||
accordion: {
|
accordion: {
|
||||||
border: `1px solid ${theme.palette.grey[300]}`,
|
border: `1px solid ${theme.palette.grey[300]}`,
|
||||||
@ -44,7 +40,7 @@ export const useStyles = makeStyles()(theme => ({
|
|||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
width: '100%',
|
width: '100%',
|
||||||
[theme.breakpoints.down(650)]: {
|
[theme.breakpoints.down(710)]: {
|
||||||
flexDirection: 'column',
|
flexDirection: 'column',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
position: 'relative',
|
position: 'relative',
|
||||||
@ -56,10 +52,13 @@ export const useStyles = makeStyles()(theme => ({
|
|||||||
},
|
},
|
||||||
headerValues: {
|
headerValues: {
|
||||||
fontSize: theme.fontSizes.smallBody,
|
fontSize: theme.fontSizes.smallBody,
|
||||||
color: theme.palette.primary.main,
|
|
||||||
},
|
},
|
||||||
headerValuesExpand: {
|
headerValuesExpand: {
|
||||||
fontSize: theme.fontSizes.smallBody,
|
fontSize: theme.fontSizes.smallBody,
|
||||||
|
color: theme.palette.primary.dark,
|
||||||
|
[theme.breakpoints.down(710)]: {
|
||||||
|
textAlign: 'center',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
headerConstraintContainer: {
|
headerConstraintContainer: {
|
||||||
minWidth: '220px',
|
minWidth: '220px',
|
||||||
@ -69,11 +68,6 @@ export const useStyles = makeStyles()(theme => ({
|
|||||||
paddingRight: 0,
|
paddingRight: 0,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
headerViewValuesContainer: {
|
|
||||||
[theme.breakpoints.down(990)]: {
|
|
||||||
display: 'none',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
editingBadge: {
|
editingBadge: {
|
||||||
borderRadius: theme.shape.borderRadiusExtraLarge,
|
borderRadius: theme.shape.borderRadiusExtraLarge,
|
||||||
padding: '0.25rem 0.5rem',
|
padding: '0.25rem 0.5rem',
|
||||||
@ -122,9 +116,8 @@ export const useStyles = makeStyles()(theme => ({
|
|||||||
headerActions: {
|
headerActions: {
|
||||||
marginLeft: 'auto',
|
marginLeft: 'auto',
|
||||||
whiteSpace: 'nowrap',
|
whiteSpace: 'nowrap',
|
||||||
[theme.breakpoints.down(660)]: {
|
[theme.breakpoints.down(710)]: {
|
||||||
marginLeft: '0',
|
display: 'none',
|
||||||
marginTop: '0.5rem',
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
accordionDetails: {
|
accordionDetails: {
|
||||||
@ -140,9 +133,8 @@ export const useStyles = makeStyles()(theme => ({
|
|||||||
summary: {
|
summary: {
|
||||||
border: 'none',
|
border: 'none',
|
||||||
padding: '0.25rem 1rem',
|
padding: '0.25rem 1rem',
|
||||||
height: '85px',
|
'&:hover .valuesExpandLabel': {
|
||||||
[theme.breakpoints.down(770)]: {
|
textDecoration: 'underline',
|
||||||
height: '200px',
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
settingsParagraph: {
|
settingsParagraph: {
|
||||||
|
@ -2,6 +2,7 @@ import { makeStyles } from 'tss-react/mui';
|
|||||||
|
|
||||||
export const useStyles = makeStyles()(theme => ({
|
export const useStyles = makeStyles()(theme => ({
|
||||||
container: {
|
container: {
|
||||||
|
width: '100%',
|
||||||
display: 'grid',
|
display: 'grid',
|
||||||
gap: '1rem',
|
gap: '1rem',
|
||||||
},
|
},
|
||||||
|
@ -72,9 +72,9 @@ const SingleValue = ({ value, operator }: ISingleValueProps) => {
|
|||||||
<Chip
|
<Chip
|
||||||
label={
|
label={
|
||||||
<StringTruncator
|
<StringTruncator
|
||||||
maxWidth="200"
|
maxWidth="400"
|
||||||
text={value}
|
text={value}
|
||||||
maxLength={25}
|
maxLength={50}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
className={styles.chip}
|
className={styles.chip}
|
||||||
@ -95,7 +95,15 @@ const MultipleValues = ({ values }: IMultipleValuesProps) => {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<ConstraintValueSearch filter={filter} setFilter={setFilter} />
|
<ConditionallyRender
|
||||||
|
condition={values.length > 20}
|
||||||
|
show={
|
||||||
|
<ConstraintValueSearch
|
||||||
|
filter={filter}
|
||||||
|
setFilter={setFilter}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
/>
|
||||||
{values
|
{values
|
||||||
.filter(value => value.includes(filter))
|
.filter(value => value.includes(filter))
|
||||||
.map((value, index) => (
|
.map((value, index) => (
|
||||||
@ -103,9 +111,9 @@ const MultipleValues = ({ values }: IMultipleValuesProps) => {
|
|||||||
key={`${value}-${index}`}
|
key={`${value}-${index}`}
|
||||||
label={
|
label={
|
||||||
<StringTruncator
|
<StringTruncator
|
||||||
maxWidth="200"
|
maxWidth="400"
|
||||||
text={value}
|
text={value}
|
||||||
maxLength={25}
|
maxLength={50}
|
||||||
className={styles.chipValue}
|
className={styles.chipValue}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
import StringTruncator from 'component/common/StringTruncator/StringTruncator';
|
import { Chip, IconButton, Tooltip, styled } from '@mui/material';
|
||||||
import { Chip, useMediaQuery, IconButton, Tooltip } from '@mui/material';
|
|
||||||
import { ConstraintIcon } from 'component/common/ConstraintAccordion/ConstraintIcon';
|
import { ConstraintIcon } from 'component/common/ConstraintAccordion/ConstraintIcon';
|
||||||
import { Delete, Edit } from '@mui/icons-material';
|
import { Delete, Edit } from '@mui/icons-material';
|
||||||
import { IConstraint } from 'interfaces/strategy';
|
import { IConstraint } from 'interfaces/strategy';
|
||||||
@ -10,6 +9,44 @@ import React from 'react';
|
|||||||
import { formatConstraintValue } from 'utils/formatConstraintValue';
|
import { formatConstraintValue } from 'utils/formatConstraintValue';
|
||||||
import { useLocationSettings } from 'hooks/useLocationSettings';
|
import { useLocationSettings } from 'hooks/useLocationSettings';
|
||||||
import { ConstraintOperator } from 'component/common/ConstraintAccordion/ConstraintOperator/ConstraintOperator';
|
import { ConstraintOperator } from 'component/common/ConstraintAccordion/ConstraintOperator/ConstraintOperator';
|
||||||
|
import classnames from 'classnames';
|
||||||
|
|
||||||
|
const StyledHeaderText = styled('span')(({ theme }) => ({
|
||||||
|
display: '-webkit-box',
|
||||||
|
WebkitLineClamp: 3,
|
||||||
|
WebkitBoxOrient: 'vertical',
|
||||||
|
overflow: 'hidden',
|
||||||
|
maxWidth: '100px',
|
||||||
|
minWidth: '100px',
|
||||||
|
marginRight: '10px',
|
||||||
|
wordBreak: 'break-word',
|
||||||
|
fontSize: theme.fontSizes.smallBody,
|
||||||
|
[theme.breakpoints.down(710)]: {
|
||||||
|
textAlign: 'center',
|
||||||
|
padding: theme.spacing(1, 0),
|
||||||
|
marginRight: 'inherit',
|
||||||
|
maxWidth: 'inherit',
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
const StyledValuesSpan = styled('span')(({ theme }) => ({
|
||||||
|
display: '-webkit-box',
|
||||||
|
WebkitLineClamp: 2,
|
||||||
|
WebkitBoxOrient: 'vertical',
|
||||||
|
overflow: 'hidden',
|
||||||
|
wordBreak: 'break-word',
|
||||||
|
fontSize: theme.fontSizes.smallBody,
|
||||||
|
[theme.breakpoints.down(710)]: {
|
||||||
|
margin: theme.spacing(1, 0),
|
||||||
|
textAlign: 'center',
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
|
const StyledSingleValueChip = styled(Chip)(({ theme }) => ({
|
||||||
|
[theme.breakpoints.down(710)]: {
|
||||||
|
margin: theme.spacing(1, 0),
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
|
||||||
interface IConstraintAccordionViewHeaderProps {
|
interface IConstraintAccordionViewHeaderProps {
|
||||||
compact: boolean;
|
compact: boolean;
|
||||||
@ -28,9 +65,6 @@ export const ConstraintAccordionViewHeader = ({
|
|||||||
}: IConstraintAccordionViewHeaderProps) => {
|
}: IConstraintAccordionViewHeaderProps) => {
|
||||||
const { classes: styles } = useStyles();
|
const { classes: styles } = useStyles();
|
||||||
const { locationSettings } = useLocationSettings();
|
const { locationSettings } = useLocationSettings();
|
||||||
const smallScreen = useMediaQuery(`(max-width:${790}px)`);
|
|
||||||
|
|
||||||
const minWidthHeader = compact || smallScreen ? '100px' : '175px';
|
|
||||||
|
|
||||||
const onEditClick =
|
const onEditClick =
|
||||||
onEdit &&
|
onEdit &&
|
||||||
@ -50,42 +84,43 @@ export const ConstraintAccordionViewHeader = ({
|
|||||||
<div className={styles.headerContainer}>
|
<div className={styles.headerContainer}>
|
||||||
<ConstraintIcon />
|
<ConstraintIcon />
|
||||||
<div className={styles.headerMetaInfo}>
|
<div className={styles.headerMetaInfo}>
|
||||||
<div style={{ minWidth: minWidthHeader }}>
|
<Tooltip title={constraint.contextName} arrow>
|
||||||
<StringTruncator
|
<StyledHeaderText>
|
||||||
text={constraint.contextName}
|
{constraint.contextName}
|
||||||
maxWidth="175px"
|
</StyledHeaderText>
|
||||||
maxLength={25}
|
</Tooltip>
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className={styles.headerConstraintContainer}>
|
<div className={styles.headerConstraintContainer}>
|
||||||
<ConstraintOperator constraint={constraint} />
|
<ConstraintOperator constraint={constraint} />
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.headerViewValuesContainer}>
|
<ConditionallyRender
|
||||||
<ConditionallyRender
|
condition={singleValue}
|
||||||
condition={singleValue}
|
show={
|
||||||
show={
|
<StyledSingleValueChip
|
||||||
<Chip
|
label={formatConstraintValue(
|
||||||
label={formatConstraintValue(
|
constraint,
|
||||||
constraint,
|
locationSettings
|
||||||
locationSettings
|
)}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
elseShow={
|
||||||
|
<div className={styles.headerValuesContainer}>
|
||||||
|
<StyledValuesSpan>
|
||||||
|
{constraint?.values
|
||||||
|
?.map(value => value)
|
||||||
|
.join(', ')}
|
||||||
|
</StyledValuesSpan>
|
||||||
|
<p
|
||||||
|
className={classnames(
|
||||||
|
styles.headerValuesExpand,
|
||||||
|
'valuesExpandLabel'
|
||||||
)}
|
)}
|
||||||
/>
|
>
|
||||||
}
|
Expand to view all ({constraint?.values?.length}
|
||||||
elseShow={
|
)
|
||||||
<div className={styles.headerValuesContainer}>
|
</p>
|
||||||
<p className={styles.headerValues}>
|
</div>
|
||||||
{constraint?.values?.length}{' '}
|
}
|
||||||
{constraint?.values?.length === 1
|
/>
|
||||||
? 'value'
|
|
||||||
: 'values'}
|
|
||||||
</p>
|
|
||||||
<p className={styles.headerValuesExpand}>
|
|
||||||
Expand to view
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
<div className={styles.headerActions}>
|
<div className={styles.headerActions}>
|
||||||
<ConditionallyRender
|
<ConditionallyRender
|
||||||
|
@ -6,6 +6,7 @@ export const useStyles = makeStyles()(theme => ({
|
|||||||
margin: '0.25rem',
|
margin: '0.25rem',
|
||||||
},
|
},
|
||||||
paragraph: {
|
paragraph: {
|
||||||
|
display: 'inline',
|
||||||
margin: '0.25rem 0',
|
margin: '0.25rem 0',
|
||||||
maxWidth: '95%',
|
maxWidth: '95%',
|
||||||
textAlign: 'center',
|
textAlign: 'center',
|
||||||
|
@ -13,6 +13,8 @@ export const useStyles = makeStyles()(theme => ({
|
|||||||
link: {
|
link: {
|
||||||
textDecoration: 'none',
|
textDecoration: 'none',
|
||||||
fontWeight: theme.fontWeight.bold,
|
fontWeight: theme.fontWeight.bold,
|
||||||
color: theme.palette.primary.main,
|
'&:hover': {
|
||||||
|
textDecoration: 'underline',
|
||||||
|
},
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
@ -14,6 +14,10 @@ export const useStyles = makeStyles()(theme => ({
|
|||||||
[theme.breakpoints.down('sm')]: {
|
[theme.breakpoints.down('sm')]: {
|
||||||
justifyContent: 'center',
|
justifyContent: 'center',
|
||||||
},
|
},
|
||||||
|
'&:hover': {
|
||||||
|
transition: 'background-color 0.2s ease-in-out',
|
||||||
|
backgroundColor: theme.palette.grey[100],
|
||||||
|
},
|
||||||
},
|
},
|
||||||
header: {
|
header: {
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
|
Loading…
Reference in New Issue
Block a user