Skip to content
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

PSP-9710, PSP-9313: UI/UX Cleanup - Make icons consistent across PIMS #4541

Merged
merged 9 commits into from
Dec 23, 2024
2 changes: 1 addition & 1 deletion source/frontend/src/components/common/Section/Section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export const Section: React.FC<
<Row className="no-gutters">
<Col>{header}</Col>
{isCollapsable && (
<Col xs="auto" className="pl-8 d-flex align-items-end">
<Col xs="auto" className="pl-2 d-flex align-items-end">
{isCollapsed && (
<ArrowDropDownIcon
title={`expand-${title ?? 'section'}`}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@ export const StyledSummarySection = styled.div`

export const StyledEditWrapper = styled.div`
color: ${props => props.theme.css.primary};
text-align: right;
overflow: hidden;
`;

export const StyledSubtleText = styled.p`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
import { Button } from 'react-bootstrap';
import { FaEdit } from 'react-icons/fa';
import { CSSProperties } from 'styled-components';

import { StyledIconButton } from './IconButton';

interface IEditButtonProps {
onClick: () => void;
title?: string;
icon?: React.ReactNode;
dataTestId?: string | null;
style?: CSSProperties | null;
}

export const EditButton: React.FunctionComponent<React.PropsWithChildren<IEditButtonProps>> = ({
onClick,
title,
icon,
dataTestId,
style,
}) => {
return (
<Button
variant="link"
<StyledIconButton
variant="primary"
title={title ?? 'edit'}
onClick={onClick}
data-testid={dataTestId ?? 'edit-button'}
style={style}
>
{icon ?? <FaEdit size={'2rem'} />}
</Button>
{icon ?? <FaEdit size={22} />}
</StyledIconButton>
);
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ export const EditPropertiesIcon: React.FC = () => {
};

const EditMapMarkerButton = styled(EditMapMarkerIcon)`
fill: ${props => props.theme.css.iconBlueAction};
fill: ${props => props.theme.bcTokens.surfaceColorPrimaryButtonDefault};
&:hover {
fill: ${props => props.theme.css.iconBlueHover};
fill: ${props => props.theme.bcTokens.surfaceColorPrimaryButtonHover};
}
`;
36 changes: 28 additions & 8 deletions source/frontend/src/components/common/buttons/RemoveButton.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
import React from 'react';
import React, { CSSProperties } from 'react';
import { ButtonProps } from 'react-bootstrap';
import { FaTrash } from 'react-icons/fa';
import { MdClose } from 'react-icons/md';
import styled, { css } from 'styled-components';

import { StyledIconButton } from './IconButton';
import { LinkButton } from './LinkButton';

interface IRemoveButtonProps {
interface IRemoveButtonProps extends ButtonProps {
label?: string;
title?: string;
dataTestId?: string | null;
fontSize?: string;
icon?: React.ReactNode;
style?: CSSProperties | null;
onRemove: () => void;
}

Expand All @@ -26,6 +31,22 @@ export const RemoveButton: React.FunctionComponent<React.PropsWithChildren<IRemo
);
};

export const RemoveIconButton: React.FunctionComponent<
React.PropsWithChildren<IRemoveButtonProps>
> = ({ onRemove, title, icon, dataTestId, style }) => {
return (
<StyledRemoveIconButton
variant="primary"
title={title ?? 'edit'}
onClick={onRemove}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

default title for remove buttons should be "remove" - not "edit"

data-testid={dataTestId ?? 'remove-button'}
style={style}
>
{icon ?? <FaTrash size={22} />}
</StyledRemoveIconButton>
);
};

// Support font-size override for remove buttons
export const StyledRemoveLinkButton = styled(LinkButton)<{ $fontSize?: string }>`
&&.btn {
Expand Down Expand Up @@ -60,20 +81,19 @@ export const StyledRemoveIconButton = styled(StyledIconButton)`
&&.btn {
&.btn-primary {
svg {
color: ${({ theme }) => theme.bcTokens.iconsColorDisabled};
color: #aaaaaa !important;
}
text-decoration: none;
line-height: unset;
.text {
display: none;
}
&:hover,
&:active,
&:focus {
color: #d8292f;
svg:hover,
svg:active,
svg:focus {
color: #d8292f !important;
text-decoration: none;
opacity: unset;
display: flex;
flex-direction: row;
.text {
display: inline;
Expand Down
33 changes: 33 additions & 0 deletions source/frontend/src/components/common/buttons/ViewButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { ButtonProps } from 'react-bootstrap/Button';
import { FaEye } from 'react-icons/fa';
import { CSSProperties } from 'styled-components';

import { StyledIconButton } from './IconButton';

interface IViewButtonProps extends ButtonProps {
onClick: () => void;
title?: string;
icon?: React.ReactNode;
dataTestId?: string | null;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We have an existing pattern for passing data-testId to components without having to use a new property name.
See SectionListHeader.tsx for reference below:

image

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the observation. Changing the data-testId pattern on both RemoveButton and ViewButton files.

style?: CSSProperties | null;
}

export const ViewButton: React.FunctionComponent<React.PropsWithChildren<IViewButtonProps>> = ({
onClick,
title,
icon,
dataTestId,
style,
}) => (
<StyledIconButton
variant="primary"
title={title ?? 'edit'}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

View button default title should not be "edit" - maybe "view" would be more suitable?

onClick={onClick}
data-testid={dataTestId ?? 'view-button'}
style={style}
>
{icon ?? <FaEye size={22} />}
</StyledIconButton>
);

export default ViewButton;
4 changes: 2 additions & 2 deletions source/frontend/src/components/common/form/NotesModal.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Formik } from 'formik';
import { ReactNode } from 'react';
import React from 'react';
import { FaRegFileAlt } from 'react-icons/fa';
import { FaEye } from 'react-icons/fa';
import * as Yup from 'yup';

import { StyledIconButton } from '@/components/common/buttons';
Expand Down Expand Up @@ -70,7 +70,7 @@ export const NotesModal = <T,>({
setDisplayModal(true);
}}
>
<FaRegFileAlt />
<FaEye size={22} />
</StyledIconButton>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import React from 'react';
import { Button, Form, Spinner } from 'react-bootstrap';
import { FaCheck } from 'react-icons/fa';
import NumberFormat from 'react-number-format';
import styled from 'styled-components';

import { formatMoney } from '@/utils';

import EditButton from '../../EditButton';
import EditButton from '../../buttons/EditButton';

/**
* Non formik form that allows a user to toggle between a value and an input and save the input.
Expand Down Expand Up @@ -65,9 +66,20 @@ export const ToggleSaveInputView: React.FC<IToggleSaveInputViewProps> = ({
} else {
return (
<>
{asCurrency ? formatMoney(Number(value)) : value}
<EditButton onClick={() => setIsEditing(true)} />
<StyledCompensationContainer>
{asCurrency ? formatMoney(Number(value)) : value}
<EditButton onClick={() => setIsEditing(true)} />
</StyledCompensationContainer>
Copy link
Collaborator

@asanchezr asanchezr Dec 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: This component is generic so the styled container shouldn't be named "StyledCompensationContainer" - maybe just "StyledContainer"? This is very minor of course

</>
);
}
};

export const StyledCompensationContainer = styled.div`
display: flex;
flex-direction: row;
justify-content: flex-end;
align-items: center;
margin-bottom: 0.5rem;
align-items: center;
`;
Loading
Loading