From: Wouter Admiraal Date: Tue, 9 May 2023 08:53:42 +0000 (+0200) Subject: SONAR-19247 Introduce HighlightedSection component X-Git-Tag: 10.1.0.73491~326 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=cc4bd651486f96d3e2b1211449cd679c887faea7;p=sonarqube.git SONAR-19247 Introduce HighlightedSection component --- diff --git a/server/sonar-web/design-system/src/components/HighlightedSection.tsx b/server/sonar-web/design-system/src/components/HighlightedSection.tsx new file mode 100644 index 00000000000..1ed0ef02dfa --- /dev/null +++ b/server/sonar-web/design-system/src/components/HighlightedSection.tsx @@ -0,0 +1,33 @@ +/* + * 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 styled from '@emotion/styled'; +import tw from 'twin.macro'; +import { themeBorder, themeColor } from '../helpers'; + +export const HighlightedSection = styled.div` + border: ${themeBorder('default', 'highlightedSectionBorder')}; + background: ${themeColor('highlightedSection')}; + + ${tw`sw-box-border`} + ${tw`sw-flex sw-flex-col`} + ${tw`sw-gap-4`} + ${tw`sw-p-8`} + ${tw`sw-rounded-2`} +`; diff --git a/server/sonar-web/design-system/src/components/__tests__/HighlightedSection-test.tsx b/server/sonar-web/design-system/src/components/__tests__/HighlightedSection-test.tsx new file mode 100644 index 00000000000..c7814a36479 --- /dev/null +++ b/server/sonar-web/design-system/src/components/__tests__/HighlightedSection-test.tsx @@ -0,0 +1,31 @@ +/* + * 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 { render, screen } from '@testing-library/react'; +import { HighlightedSection } from '../HighlightedSection'; + +it('should render as expected', () => { + render(content); + + expect(screen.getByText('content')).toHaveStyle({ + padding: '2rem', + border: '1px solid rgb(225,230,243)', + background: 'rgb(252,252,253)', + }); +}); diff --git a/server/sonar-web/design-system/src/components/index.ts b/server/sonar-web/design-system/src/components/index.ts index e1e3b1572d4..199982cd381 100644 --- a/server/sonar-web/design-system/src/components/index.ts +++ b/server/sonar-web/design-system/src/components/index.ts @@ -32,6 +32,7 @@ export * from './DuplicationsIndicator'; export { FailedQGConditionLink } from './FailedQGConditionLink'; export { FlagMessage } from './FlagMessage'; export * from './GenericAvatar'; +export * from './HighlightedSection'; export { InputSearch } from './InputSearch'; export * from './InteractiveIcon'; export * from './Link'; diff --git a/server/sonar-web/design-system/src/theme/light.ts b/server/sonar-web/design-system/src/theme/light.ts index 4d91df7c121..e57ff1c2720 100644 --- a/server/sonar-web/design-system/src/theme/light.ts +++ b/server/sonar-web/design-system/src/theme/light.ts @@ -447,8 +447,9 @@ export const lightTheme = { newCodeLegend: [...COLORS.indigo[300], 0.15], newCodeLegendBorder: COLORS.indigo[200], - // hotspot - hotspotStatus: COLORS.blueGrey[25], + // highlighted section + highlightedSection: COLORS.blueGrey[25], + highlightedSectionBorder: COLORS.blueGrey[100], // activity comments activityCommentPipe: COLORS.tangerine[200],