-
Notifications
You must be signed in to change notification settings - Fork 24
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-8228 | Updated header status display #4028
Changes from all commits
4d24f42
bc8376f
76de8ff
1eebb52
5049c54
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,23 +1,45 @@ | ||
@import '@/../node_modules/@bcgov/design-tokens/css/variables.css'; | ||
|
||
$pims-blue-20: #d9eaf7; | ||
$pims-blue-80: #1a5496; | ||
|
||
$pims-blue-50: #428bca; | ||
$pims-grey-80: #606060; | ||
|
||
$pims-yellow-10: #fef1d8; | ||
$pims-yellow-30: #fcba19; | ||
$pims-red-10: #f2dede; | ||
$pims-red-80: #a12622; | ||
$pims-white: #f2f2f2; | ||
$pims-blue-20: #d9eaf7; | ||
$pims-yellow-100: #6c4a00; | ||
|
||
$pims-grey-10: #e8ecef; | ||
|
||
$pims-grey-20: #959da5; | ||
$pims-grey-80: #606060; | ||
|
||
$pims-green-20: #dff0d8; | ||
$pims-green-80: #2e8540; | ||
|
||
$active-action-color: $pims-blue-50; | ||
$border-outline-color: $pims-grey-80; | ||
$warning-background-color: $pims-yellow-10; | ||
$number-background-color: $pims-yellow-30; | ||
$danger-background-color: $pims-red-10; | ||
$light-danger-color: $pims-red-10; | ||
$highlight-background-color: $pims-white; | ||
$filter-box-color: $pims-blue-20; | ||
$text-warning-color: $pims-yellow-100; | ||
$header-text-color: #{'var(--theme-blue-100)'}; | ||
$header-border-color: #{'var(--theme-blue-90)'}; | ||
$link-color: #{'var(--surface-color-primary-button-default)'}; | ||
$link-hover-color: #{'var(--surface-color-primary-button-hover)'}; | ||
|
||
$completed-color: $pims-green-80; | ||
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. some of the names here don't seem to match up with their usage in the app which I don't understand. I think the idea behind these mappings are as follows:
Anyways, these colour subjective names seem to have been introduced specifically for these new status labels, and the status labels only, but these names don't seem to reflect that. 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. I dont like the color names at all either. However, that's what they are called on figma, so I went for that for now. 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. If ana went with that as a color name, it would likely be because she misunderstood the documentation I sent her during the color palette rework. She asked me for a list of old colors and new colors, and maybe got confused as to which was which (perhaps thinking that the list with more colors was newer, which is actually not the case). This is actually very unfortunate, because she may have chosen a number of colors from the list that we both (Ana and myself) agreed to remove from the application in favour of colors already in the bcgov spec. We can go with this for now, and I'll log another tech debt item to clean up the colors again with Ana. |
||
$selected-color: $pims-green-20; | ||
|
||
$disabled-color: $pims-grey-20; | ||
$disabled-field-background-color: $pims-grey-10; | ||
|
||
$slide-out-blue: $pims-blue-80; | ||
|
||
$font-danger-color: $pims-red-80; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,138 @@ | ||
import { Col, Row } from 'react-bootstrap'; | ||
import { IconType } from 'react-icons'; | ||
import { BiDuplicate } from 'react-icons/bi'; | ||
import { FaCheck, FaPauseCircle, FaStopCircle } from 'react-icons/fa'; | ||
import { MdArchive, MdCancel, MdCircle, MdEdit } from 'react-icons/md'; | ||
import styled from 'styled-components'; | ||
|
||
import { Dictionary } from '@/interfaces/Dictionary'; | ||
import { ApiGen_Base_CodeType } from '@/models/api/generated/ApiGen_Base_CodeType'; | ||
|
||
import { InlineFlexDiv } from '../styles'; | ||
|
||
interface IStatusFieldProps { | ||
statusCodeType: ApiGen_Base_CodeType<string>; | ||
} | ||
|
||
interface StatusStyle { | ||
icon: IconType; | ||
colorVariant: string; | ||
} | ||
|
||
const statusDictionary: Dictionary<StatusStyle> = { | ||
active: { icon: MdCircle, colorVariant: 'green' }, | ||
archived: { icon: MdArchive, colorVariant: 'grey' }, | ||
completed: { icon: FaCheck, colorVariant: 'blue' }, | ||
hold: { icon: FaPauseCircle, colorVariant: 'yellow' }, | ||
cancelled: { icon: MdCancel, colorVariant: 'red' }, | ||
draft: { icon: MdEdit, colorVariant: 'yellow' }, | ||
terminated: { icon: FaStopCircle, colorVariant: 'red' }, | ||
duplicate: { icon: BiDuplicate, colorVariant: 'blue' }, | ||
}; | ||
|
||
const StatusField: React.FunctionComponent<React.PropsWithChildren<IStatusFieldProps>> = ({ | ||
statusCodeType, | ||
}) => { | ||
const translateStatusCode = (statusCodeType: ApiGen_Base_CodeType<string>) => { | ||
switch (statusCodeType.id.toLowerCase()) { | ||
case 'active': | ||
case 'ac': | ||
return statusDictionary['active']; | ||
case 'archived': | ||
case 'cncn': | ||
case 'archiv': | ||
return statusDictionary['archived']; | ||
case 'cancelled': | ||
case 'ca': | ||
case 'cancel': | ||
case 'discard': | ||
return statusDictionary['cancelled']; | ||
case 'complete': | ||
case 'closed': | ||
case 'co': | ||
case 'complt': | ||
return statusDictionary['completed']; | ||
case 'draft': | ||
case 'pl': | ||
return statusDictionary['draft']; | ||
case 'duplicate': | ||
return statusDictionary['duplicate']; | ||
case 'hold': | ||
case 'inactive': | ||
case 'ho': | ||
return statusDictionary['hold']; | ||
case 'terminated': | ||
return statusDictionary['terminated']; | ||
default: | ||
break; | ||
} | ||
return statusDictionary['cancelled']; | ||
}; | ||
|
||
const statusFound = translateStatusCode(statusCodeType); | ||
return ( | ||
<StyledBottomRow className="no-gutters justify-content-end align-items-end"> | ||
<Col /> | ||
<Col xs="auto" className="align-self-end"> | ||
<RetiredWarning $variant={statusFound.colorVariant}> | ||
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. a prop with a name starting with a dollar sign seems new, what does that naming indicate? 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. I set it like to differentiate it from a react component (that one is a style). I dont feel strongly about it so will change if it helps |
||
<statusFound.icon size={16} /> | ||
{statusCodeType?.description.toUpperCase()} | ||
</RetiredWarning> | ||
</Col> | ||
</StyledBottomRow> | ||
); | ||
}; | ||
|
||
export default StatusField; | ||
|
||
const RetiredWarning = styled(InlineFlexDiv)<{ $variant: string }>` | ||
//font-weight: bold; TODO: Bold should be enough, but atm the bcsans-bold is different | ||
font-family: 'BCSans-Bold'; | ||
font-size: 1.4rem; | ||
|
||
border-radius: 0.4rem; | ||
|
||
letter-spacing: 0.1rem; | ||
align-items: center; | ||
|
||
padding: 0.2rem 0.5rem; | ||
|
||
gap: 0.5rem; | ||
|
||
${props => { | ||
if (props.$variant === 'green') { | ||
return ` | ||
color: ${props.theme.css.completedColor}; | ||
background-color: ${props.theme.css.selectedColor}; | ||
`; | ||
} else if (props.$variant === 'grey') { | ||
return ` | ||
color: ${props.theme.css.disabledColor}; | ||
background-color: ${props.theme.css.disabledFieldBackgroundColor}; | ||
`; | ||
} else if (props.$variant === 'blue') { | ||
return ` | ||
color: ${props.theme.css.slideOutBlue}; | ||
background-color: ${props.theme.css.filterBoxColor}; | ||
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. I'm confused about the naming choices here. It seems like you could have named these colors whatever you wanted, but ended up going with some of the previously used colors that have since been removed. For example, why call the blue slideOutBlue? I recognize that as a color that we used to have, but if this is the only incidence of this color, why not name this something closer to the usage. Ie. 'completedStatusColor' or similar. 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. tbh I had a hard time with the colors and the documentation on figma so I decided to name it exactly like the figma ones . I will chat with ana when she is back to get those names aligned. |
||
`; | ||
} else if (props.$variant === 'yellow') { | ||
return ` | ||
color: ${props.theme.css.textWarningColor}; | ||
background-color: ${props.theme.css.warningBackgroundColor}; | ||
`; | ||
} else if (props.$variant === 'red') { | ||
return ` | ||
color: ${props.theme.css.fontDangerColor}; | ||
background-color: ${props.theme.css.dangerBackgroundColor}; | ||
`; | ||
} else { | ||
return `color: red`; | ||
} | ||
}} | ||
`; | ||
|
||
const StyledBottomRow = styled(Row)` | ||
margin-top: auto; | ||
padding-top: 1rem; | ||
padding-bottom: 1rem; | ||
`; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { Row } from 'react-bootstrap'; | ||
import styled from 'styled-components'; | ||
|
||
export const StyledRow = styled(Row)` | ||
margin-top: 0.5rem; | ||
margin-bottom: 1.5rem; | ||
border-bottom-style: solid; | ||
border-bottom-color: grey; | ||
border-bottom-width: 0.1rem; | ||
`; | ||
|
||
export const StyledFiller = styled.div` | ||
height: 100%; | ||
display: flex; | ||
flex-direction: column; | ||
`; |
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'm hesitant to introduce our own greys when grey 10 to 100 exists in the bcgov standard spec already:
https://github.com/bcgov/design-system/blob/main/packages/design-tokens/dist/css/variables.css
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.
That is reasonable. I added it like that because the figma spec used the code instead of a color name. The rest is the same as the response above.