aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWouter Admiraal <wouter.admiraal@sonarsource.com>2023-05-09 10:53:42 +0200
committersonartech <sonartech@sonarsource.com>2023-05-09 20:10:37 +0000
commitcc4bd651486f96d3e2b1211449cd679c887faea7 (patch)
tree250da896ab4d3c1e020295053adc9413cc3222da
parent9957e4aacaab10021c16d971a2b1de227a611c4b (diff)
downloadsonarqube-cc4bd651486f96d3e2b1211449cd679c887faea7.tar.gz
sonarqube-cc4bd651486f96d3e2b1211449cd679c887faea7.zip
SONAR-19247 Introduce HighlightedSection component
-rw-r--r--server/sonar-web/design-system/src/components/HighlightedSection.tsx33
-rw-r--r--server/sonar-web/design-system/src/components/__tests__/HighlightedSection-test.tsx31
-rw-r--r--server/sonar-web/design-system/src/components/index.ts1
-rw-r--r--server/sonar-web/design-system/src/theme/light.ts5
4 files changed, 68 insertions, 2 deletions
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(<HighlightedSection>content</HighlightedSection>);
+
+ 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],