diff options
author | David Cho-Lerat <117642976+david-cho-lerat-sonarsource@users.noreply.github.com> | 2024-10-22 15:19:18 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2024-10-22 20:03:10 +0000 |
commit | d9f6920331a0f274f1d6227c2af74d6dbfe84aa2 (patch) | |
tree | 3228b99c665c03e6c1bf2a1f68d9d90865f8558b /server/sonar-web/design-system/src/components/NavBarTabs.tsx | |
parent | c33a6b9956802dfa00133e304326887b901af901 (diff) | |
download | sonarqube-d9f6920331a0f274f1d6227c2af74d6dbfe84aa2.tar.gz sonarqube-d9f6920331a0f274f1d6227c2af74d6dbfe84aa2.zip |
SONAR-23206 Remove design-system build to have it as normal code inside sonar-web (#12088)
Co-authored-by: Grégoire Aubert <gregoire.aubert@sonarsource.com>
Co-authored-by: Jeremy Davis <jeremy.davis@sonarsource.com>
Diffstat (limited to 'server/sonar-web/design-system/src/components/NavBarTabs.tsx')
-rw-r--r-- | server/sonar-web/design-system/src/components/NavBarTabs.tsx | 145 |
1 files changed, 0 insertions, 145 deletions
diff --git a/server/sonar-web/design-system/src/components/NavBarTabs.tsx b/server/sonar-web/design-system/src/components/NavBarTabs.tsx deleted file mode 100644 index 999716d190d..00000000000 --- a/server/sonar-web/design-system/src/components/NavBarTabs.tsx +++ /dev/null @@ -1,145 +0,0 @@ -/* - * SonarQube - * Copyright (C) 2009-2024 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 { IconChevronDown } from '@sonarsource/echoes-react'; -import classNames from 'classnames'; -import React, { forwardRef } from 'react'; -import tw, { theme } from 'twin.macro'; -import { themeBorder, themeColor, themeContrast } from '../helpers/theme'; -import { isDefined } from '../helpers/types'; -import NavLink, { NavLinkProps } from './NavLink'; -import { Tooltip } from './Tooltip'; - -interface Props extends React.HTMLAttributes<HTMLUListElement> { - children?: React.ReactNode; - className?: string; -} - -export function NavBarTabs({ children, className, ...other }: Props) { - return ( - <ul className={`sw-flex sw-items-end sw-gap-8 ${className ?? ''}`} {...other}> - {children} - </ul> - ); -} - -interface NavBarTabLinkProps extends Omit<NavLinkProps, 'children'> { - active?: boolean; - children?: React.ReactNode; - className?: string; - text: string; - withChevron?: boolean; -} - -export const NavBarTabLink = forwardRef<HTMLAnchorElement, NavBarTabLinkProps>( - (props: NavBarTabLinkProps, ref) => { - const { active, children, className, text, withChevron = false, ...linkProps } = props; - return ( - <NavBarTabLinkWrapper> - <NavLink - className={({ isActive }) => - classNames( - 'sw-flex sw-items-center', - { active: isDefined(active) ? active : isActive }, - className, - ) - } - ref={ref} - {...linkProps} - > - <span className="sw-inline-block sw-text-center" data-text={text}> - {text} - </span> - - {children} - - {withChevron && ( - <span className="sw-ml-1"> - <IconChevronDown /> - </span> - )} - </NavLink> - </NavBarTabLinkWrapper> - ); - }, -); - -NavBarTabLink.displayName = 'NavBarTabLink'; - -export function DisabledTabLink(props: { label: string; overlay: React.ReactNode }) { - return ( - <NavBarTabLinkWrapper> - <Tooltip content={props.overlay}> - <a aria-disabled="true" className="disabled-link" role="link"> - {props.label} - </a> - </Tooltip> - </NavBarTabLinkWrapper> - ); -} - -// Styling for <NavLink> due to its special className function, it conflicts when styled with Emotion. -const NavBarTabLinkWrapper = styled.li` - ${tw`sw-typo-lg`}; - & > a { - ${tw`sw-pb-3`}; - ${tw`sw-block`}; - ${tw`sw-box-border`}; - ${tw`sw-transition-none`}; - - color: ${themeContrast('buttonSecondary')}; - text-decoration: none; - border-bottom: ${themeBorder('xsActive', 'transparent')}; - padding-bottom: calc(${theme('spacing.3')} + 1px); // 12px spacing + 3px border + 1px = 16px - } - - & > a.active, - & > a:active, - & > a:hover, - & > a:focus, - & > a[aria-expanded='true'] { - border-bottom-color: ${themeColor('tabBorder')}; - } - - & > a.active > span[data-text], - & > a[aria-expanded='true'] > span[data-text], - & > a:active > span { - ${tw`sw-typo-lg-semibold`}; - } - - // This is a hack to have a link take the space of the bold font, so when active other ones are not moving - & > a > span[data-text]::before { - ${tw`sw-block`}; - ${tw`sw-typo-lg-semibold`}; - ${tw`sw-h-0`}; - ${tw`sw-overflow-hidden`}; - ${tw`sw-invisible`}; - content: attr(data-text); - } - - & > a.disabled-link, - & > a.disabled-link:hover, - & > a.disabled-link.hover { - ${tw`sw-cursor-default`}; - border-bottom: ${themeBorder('xsActive', 'transparent', 1)}; - color: var(--echoes-color-text-disabled); - } -`; |