diff options
author | Revanshu Paliwal <revanshu.paliwal@sonarsource.com> | 2023-05-03 15:13:21 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2023-06-01 20:02:58 +0000 |
commit | cf7651008dc6326cd43624d92c45ed9c9b559283 (patch) | |
tree | 9a2fe3bbd3f6e90d0ac830e590b217e351a269d8 /server/sonar-web/design-system/src/components | |
parent | 3bcee0f3a74e7a5b144ed438f50b4239ee7339f7 (diff) | |
download | sonarqube-cf7651008dc6326cd43624d92c45ed9c9b559283.tar.gz sonarqube-cf7651008dc6326cd43624d92c45ed9c9b559283.zip |
SONAR-19174 Migrating issue code viewer header and code expander section to MIUI
Diffstat (limited to 'server/sonar-web/design-system/src/components')
3 files changed, 68 insertions, 0 deletions
diff --git a/server/sonar-web/design-system/src/components/__tests__/buttons-test.tsx b/server/sonar-web/design-system/src/components/__tests__/buttons-test.tsx new file mode 100644 index 00000000000..f2a0886ea84 --- /dev/null +++ b/server/sonar-web/design-system/src/components/__tests__/buttons-test.tsx @@ -0,0 +1,41 @@ +/* + * 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 { screen } from '@testing-library/react'; +import { render } from '../../helpers/testUtils'; +import { CodeViewerExpander } from '../buttons'; + +it('renders CodeViewerExpander correctly when direction is UP', () => { + render(<CodeViewerExpander direction="UP">Hello</CodeViewerExpander>); + const content = screen.getByText('Hello'); + expect(content).toHaveStyle({ + 'border-top': 'none', + 'border-bottom': '1px solid rgb(221,221,221)', + }); +}); + +it('renders CodeViewerExpander correctly when direction is DOWN', () => { + render(<CodeViewerExpander direction="DOWN">Hello</CodeViewerExpander>); + const content = screen.getByText('Hello'); + expect(content).toHaveStyle({ + 'border-bottom': 'none', + 'border-top': '1px solid rgb(221,221,221)', + }); +}); diff --git a/server/sonar-web/design-system/src/components/buttons.tsx b/server/sonar-web/design-system/src/components/buttons.tsx index c6d2ccd3ac8..6e955a2bb04 100644 --- a/server/sonar-web/design-system/src/components/buttons.tsx +++ b/server/sonar-web/design-system/src/components/buttons.tsx @@ -229,3 +229,29 @@ export const BareButton = styled.button` background-color: ${themeColor('dropdownMenuHover')}; } `; + +interface CodeViewerExpanderProps { + direction: 'UP' | 'DOWN'; +} + +export const CodeViewerExpander = styled(BareButton)<CodeViewerExpanderProps>` + ${tw`sw-flex sw-items-center sw-gap-2`} + ${tw`sw-px-2 sw-py-1`} + ${tw`sw-code`} + ${tw`sw-w-full`} + ${tw`sw-box-border`} + + color: ${themeContrast('codeLineEllipsis')}; + background-color: ${themeColor('codeLineEllipsis')}; + + &:hover { + color: ${themeContrast('codeLineEllipsisHover')}; + background-color: ${themeColor('codeLineEllipsisHover')}; + } + + border-top: ${(props) => + props.direction === 'DOWN' ? themeBorder('default', 'codeLineBorder') : 'none'}; + + border-bottom: ${(props) => + props.direction === 'UP' ? themeBorder('default', 'codeLineBorder') : 'none'}; +`; 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 27e7dc2d9f6..492863fb778 100644 --- a/server/sonar-web/design-system/src/components/icons/index.ts +++ b/server/sonar-web/design-system/src/components/icons/index.ts @@ -27,6 +27,7 @@ export { ChevronRightIcon } from './ChevronRightIcon'; export { ClockIcon } from './ClockIcon'; export { CodeSmellIcon } from './CodeSmellIcon'; export { CommentIcon } from './CommentIcon'; +export { CopyIcon } from './CopyIcon'; export { DirectoryIcon } from './DirectoryIcon'; export { ExecutionFlowIcon } from './ExecutionFlowIcon'; export { FileIcon } from './FileIcon'; |