From 684955b8b6c5532413079c1bee62c2780bd255f3 Mon Sep 17 00:00:00 2001 From: 7PH Date: Thu, 27 Jul 2023 15:15:53 +0200 Subject: [PATCH] SONAR-20023 Implement software impact severity icons --- .../icons/SoftwareImpactSeverityHighIcon.tsx | 36 ++++++++++++++ .../icons/SoftwareImpactSeverityLowIcon.tsx | 39 +++++++++++++++ .../SoftwareImpactSeverityMediumIcon.tsx | 44 +++++++++++++++++ .../src/components/icons/index.ts | 3 ++ .../design-system/src/theme/light.ts | 3 ++ .../icons/SoftwareImpactSeverityIcon.tsx | 47 +++++++++++++++++++ 6 files changed, 172 insertions(+) create mode 100644 server/sonar-web/design-system/src/components/icons/SoftwareImpactSeverityHighIcon.tsx create mode 100644 server/sonar-web/design-system/src/components/icons/SoftwareImpactSeverityLowIcon.tsx create mode 100644 server/sonar-web/design-system/src/components/icons/SoftwareImpactSeverityMediumIcon.tsx create mode 100644 server/sonar-web/src/main/js/components/icons/SoftwareImpactSeverityIcon.tsx diff --git a/server/sonar-web/design-system/src/components/icons/SoftwareImpactSeverityHighIcon.tsx b/server/sonar-web/design-system/src/components/icons/SoftwareImpactSeverityHighIcon.tsx new file mode 100644 index 00000000000..eb11d28750a --- /dev/null +++ b/server/sonar-web/design-system/src/components/icons/SoftwareImpactSeverityHighIcon.tsx @@ -0,0 +1,36 @@ +/* + * SonarQube + * Copyright (C) 2009-2023 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import { useTheme } from '@emotion/react'; +import { themeColor } from '../../helpers'; +import { CustomIcon, IconProps } from './Icon'; + +export function SoftwareImpactSeverityHighIcon(iconProps: IconProps) { + const theme = useTheme(); + + return ( + + + + + ); +} diff --git a/server/sonar-web/design-system/src/components/icons/SoftwareImpactSeverityLowIcon.tsx b/server/sonar-web/design-system/src/components/icons/SoftwareImpactSeverityLowIcon.tsx new file mode 100644 index 00000000000..3a9f0f050b7 --- /dev/null +++ b/server/sonar-web/design-system/src/components/icons/SoftwareImpactSeverityLowIcon.tsx @@ -0,0 +1,39 @@ +/* + * SonarQube + * Copyright (C) 2009-2023 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import { useTheme } from '@emotion/react'; +import { themeColor } from '../../helpers'; +import { CustomIcon, IconProps } from './Icon'; + +export function SoftwareImpactSeverityLowIcon(iconProps: IconProps) { + const theme = useTheme(); + + return ( + + + + + ); +} diff --git a/server/sonar-web/design-system/src/components/icons/SoftwareImpactSeverityMediumIcon.tsx b/server/sonar-web/design-system/src/components/icons/SoftwareImpactSeverityMediumIcon.tsx new file mode 100644 index 00000000000..dca3142a9f0 --- /dev/null +++ b/server/sonar-web/design-system/src/components/icons/SoftwareImpactSeverityMediumIcon.tsx @@ -0,0 +1,44 @@ +/* + * SonarQube + * Copyright (C) 2009-2023 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import { useTheme } from '@emotion/react'; +import { themeColor } from '../../helpers'; +import { CustomIcon, IconProps } from './Icon'; + +export function SoftwareImpactSeverityMediumIcon(iconProps: IconProps) { + const theme = useTheme(); + + return ( + + + + + ); +} diff --git a/server/sonar-web/design-system/src/components/icons/index.ts b/server/sonar-web/design-system/src/components/icons/index.ts index 52d7e277eca..a10b249dd7a 100644 --- a/server/sonar-web/design-system/src/components/icons/index.ts +++ b/server/sonar-web/design-system/src/components/icons/index.ts @@ -69,6 +69,9 @@ export { SeverityCriticalIcon } from './SeverityCriticalIcon'; export { SeverityInfoIcon } from './SeverityInfoIcon'; export { SeverityMajorIcon } from './SeverityMajorIcon'; export { SeverityMinorIcon } from './SeverityMinorIcon'; +export { SoftwareImpactSeverityHighIcon } from './SoftwareImpactSeverityHighIcon'; +export { SoftwareImpactSeverityLowIcon } from './SoftwareImpactSeverityLowIcon'; +export { SoftwareImpactSeverityMediumIcon } from './SoftwareImpactSeverityMediumIcon'; export { SortAscendIcon } from './SortAscendIcon'; export { SortDescendIcon } from './SortDescendIcon'; export { StarFillIcon } from './StarFillIcon'; diff --git a/server/sonar-web/design-system/src/theme/light.ts b/server/sonar-web/design-system/src/theme/light.ts index a8eaa23912e..05e74288b53 100644 --- a/server/sonar-web/design-system/src/theme/light.ts +++ b/server/sonar-web/design-system/src/theme/light.ts @@ -317,6 +317,9 @@ export const lightTheme = { destructiveIconFocus: danger.default, // icons + iconSoftwareImpactSeverityHigh: COLORS.red[700], + iconSoftwareImpactSeverityMedium: COLORS.yellow[800], + iconSoftwareImpactSeverityLow: COLORS.blue[700], iconSeverityMajor: danger.light, iconSeverityMinor: COLORS.yellowGreen[400], iconSeverityInfo: COLORS.blue[400], diff --git a/server/sonar-web/src/main/js/components/icons/SoftwareImpactSeverityIcon.tsx b/server/sonar-web/src/main/js/components/icons/SoftwareImpactSeverityIcon.tsx new file mode 100644 index 00000000000..2a5bbed5852 --- /dev/null +++ b/server/sonar-web/src/main/js/components/icons/SoftwareImpactSeverityIcon.tsx @@ -0,0 +1,47 @@ +/* + * SonarQube + * Copyright (C) 2009-2023 SonarSource SA + * mailto:info AT sonarsource DOT com + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 3 of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + */ +import { + SoftwareImpactSeverityHighIcon, + SoftwareImpactSeverityLowIcon, + SoftwareImpactSeverityMediumIcon, +} from 'design-system'; +import * as React from 'react'; +import { SoftwareImpactSeverity } from '../../types/issues'; +import { Dict } from '../../types/types'; +import { IconProps } from './Icon'; + +interface Props extends IconProps { + severity: string | null | undefined; +} + +const severityIcons: Dict<(props: IconProps) => React.ReactElement> = { + [SoftwareImpactSeverity.High]: SoftwareImpactSeverityHighIcon, + [SoftwareImpactSeverity.Medium]: SoftwareImpactSeverityMediumIcon, + [SoftwareImpactSeverity.Low]: SoftwareImpactSeverityLowIcon, +}; + +export default function SoftwareImpactSeverityIcon({ severity, ...iconProps }: Props) { + if (typeof severity !== 'string' || !severityIcons[severity]) { + return null; + } + + const DesiredIcon = severityIcons[severity]; + return ; +} -- 2.39.5