Skip to content

Commit

Permalink
[Fix] Skill table styling (#10440)
Browse files Browse the repository at this point in the history
* update cells for skill table

* add translation
  • Loading branch information
esizer authored May 24, 2024
1 parent 985936f commit 333dfb9
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 5 deletions.
4 changes: 4 additions & 0 deletions apps/web/src/lang/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -6842,6 +6842,10 @@
"defaultMessage": "Votre numéro de suivi pour cette demande est : <strong>{requestId}</strong>",
"description": "Message to the user about the ID of their request for referencing the request"
},
"aq2pSe": {
"defaultMessage": "description pour {name}",
"description": "Link text suffix to read more of the description for a skill"
},
"aqkSW2": {
"defaultMessage": "Inscrivez-vous plutôt",
"description": "Link text to register instead of signing in"
Expand Down
7 changes: 7 additions & 0 deletions apps/web/src/pages/Skills/components/SkillTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import * as messages from "~/lang/frCompiled.json";

import {
categoryAccessor,
descriptionCell,
familiesAccessor,
skillFamiliesCell,
} from "./tableHelpers";
Expand Down Expand Up @@ -213,6 +214,12 @@ const SkillTable = ({
{
id: "description",
sortingFn: normalizedText,
cell: ({ row: { original: skill } }) =>
descriptionCell(
intl,
getLocalizedName(skill.name, intl),
getLocalizedName(skill.description, intl),
),
header: intl.formatMessage({
defaultMessage: "Description",
id: "9yGJ6k",
Expand Down
31 changes: 26 additions & 5 deletions apps/web/src/pages/Skills/components/tableHelpers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
getLocalizedArray,
} from "@gc-digital-talent/i18n";
import { notEmpty } from "@gc-digital-talent/helpers";
import { Chip, Chips } from "@gc-digital-talent/ui";
import { Spoiler } from "@gc-digital-talent/ui";
import {
Maybe,
Skill,
Expand All @@ -32,12 +32,10 @@ export function skillFamiliesCell(
?.filter(notEmpty)
.sort()
.map((family) => (
<Chip color="primary" key={family?.key}>
{getLocalizedName(family.name, intl)}
</Chip>
<li key={family?.key}>{getLocalizedName(family.name, intl)}</li>
));

return families ? <Chips>{families}</Chips> : null;
return families ? <ul>{families}</ul> : null;
}

export function familiesAccessor(skill: Skill, intl: IntlShape) {
Expand All @@ -51,3 +49,26 @@ export function familiesAccessor(skill: Skill, intl: IntlShape) {
export function keywordsAccessor(skill: Skill, intl: IntlShape) {
return getLocalizedArray(skill.keywords as LocalizedArray, intl);
}

export function descriptionCell(
intl: IntlShape,
name: string,
description?: Maybe<string>,
) {
return description ? (
<Spoiler
text={description}
linkSuffix={intl.formatMessage(
{
defaultMessage: "description for {name}",
id: "aq2pSe",
description:
"Link text suffix to read more of the description for a skill",
},
{
name,
},
)}
/>
) : null;
}

0 comments on commit 333dfb9

Please sign in to comment.