]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-19247 Introduce HighlightedSection component
authorWouter Admiraal <wouter.admiraal@sonarsource.com>
Tue, 9 May 2023 08:53:42 +0000 (10:53 +0200)
committersonartech <sonartech@sonarsource.com>
Tue, 9 May 2023 20:10:37 +0000 (20:10 +0000)
server/sonar-web/design-system/src/components/HighlightedSection.tsx [new file with mode: 0644]
server/sonar-web/design-system/src/components/__tests__/HighlightedSection-test.tsx [new file with mode: 0644]
server/sonar-web/design-system/src/components/index.ts
server/sonar-web/design-system/src/theme/light.ts

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 (file)
index 0000000..1ed0ef0
--- /dev/null
@@ -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 (file)
index 0000000..c7814a3
--- /dev/null
@@ -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)',
+  });
+});
index e1e3b1572d4f56b8106e60893ce0bf9ac0c73440..199982cd38176ddecb7ac95f65e4cb43948a929c 100644 (file)
@@ -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';
index 4d91df7c1213dd7aed6f5188d16b331e7b375b9b..e57ff1c27209c82ac0c0b853a1c427b0aa0734ba 100644 (file)
@@ -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],