From 106e5141332a4d11dd055941394d4a8b4bc83f10 Mon Sep 17 00:00:00 2001 From: Jeremy Davis Date: Mon, 17 Jul 2023 13:55:19 +0200 Subject: [PATCH] SONAR-19936 New UnorderedList components --- .../src/components/UnorderedList.tsx | 34 +++++++++++++++++++ .../src/components/UnorderedListItem.tsx | 28 +++++++++++++++ .../__tests__/UnorderedList-test.tsx | 33 ++++++++++++++++++ 3 files changed, 95 insertions(+) create mode 100644 server/sonar-web/design-system/src/components/UnorderedList.tsx create mode 100644 server/sonar-web/design-system/src/components/UnorderedListItem.tsx create mode 100644 server/sonar-web/design-system/src/components/__tests__/UnorderedList-test.tsx diff --git a/server/sonar-web/design-system/src/components/UnorderedList.tsx b/server/sonar-web/design-system/src/components/UnorderedList.tsx new file mode 100644 index 00000000000..b63f1e322b1 --- /dev/null +++ b/server/sonar-web/design-system/src/components/UnorderedList.tsx @@ -0,0 +1,34 @@ +/* + * 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'; + +export const UnorderedList = styled.ul` + list-style: none; + ${tw`sw-mt-4`} + ${tw`sw-pl-0`} + + li:last-child { + ${tw`sw-mb-0`} + } +`; + +UnorderedList.displayName = 'UnorderedList'; diff --git a/server/sonar-web/design-system/src/components/UnorderedListItem.tsx b/server/sonar-web/design-system/src/components/UnorderedListItem.tsx new file mode 100644 index 00000000000..21d7348a574 --- /dev/null +++ b/server/sonar-web/design-system/src/components/UnorderedListItem.tsx @@ -0,0 +1,28 @@ +/* + * 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'; + +export const UnorderedListItem = styled.li` + ${tw`sw-my-3`} +`; + +UnorderedListItem.displayName = 'UnorderedListItem'; diff --git a/server/sonar-web/design-system/src/components/__tests__/UnorderedList-test.tsx b/server/sonar-web/design-system/src/components/__tests__/UnorderedList-test.tsx new file mode 100644 index 00000000000..515e39e42ef --- /dev/null +++ b/server/sonar-web/design-system/src/components/__tests__/UnorderedList-test.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 { screen } from '@testing-library/react'; +import { render } from '../../helpers/testUtils'; +import { UnorderedList } from '../UnorderedList'; +import { UnorderedListItem } from '../UnorderedListItem'; + +it('renders correctly', () => { + render( + + First item + Second item + + ); + expect(screen.getAllByRole('listitem')).toHaveLength(2); +}); -- 2.39.5