diff options
author | David Cho-Lerat <david.cho-lerat@sonarsource.com> | 2023-05-30 16:00:31 +0200 |
---|---|---|
committer | sonartech <sonartech@sonarsource.com> | 2023-06-09 20:03:09 +0000 |
commit | 40e061b25b152d7704a989240c12191317a81f3f (patch) | |
tree | d4281cec8e1ce5597d1a5504b62e2a48d1850e36 /server/sonar-web/design-system/src/components/FacetItem.tsx | |
parent | 319b9ad6352943fcf6265a589d7dba6ce659fa0a (diff) | |
download | sonarqube-40e061b25b152d7704a989240c12191317a81f3f.tar.gz sonarqube-40e061b25b152d7704a989240c12191317a81f3f.zip |
SONAR-19345 Issues page - list view: new facets using MIUI elements
Diffstat (limited to 'server/sonar-web/design-system/src/components/FacetItem.tsx')
-rw-r--r-- | server/sonar-web/design-system/src/components/FacetItem.tsx | 31 |
1 files changed, 26 insertions, 5 deletions
diff --git a/server/sonar-web/design-system/src/components/FacetItem.tsx b/server/sonar-web/design-system/src/components/FacetItem.tsx index 0d318feec0a..62d5e38b150 100644 --- a/server/sonar-web/design-system/src/components/FacetItem.tsx +++ b/server/sonar-web/design-system/src/components/FacetItem.tsx @@ -26,8 +26,9 @@ import { ButtonProps, ButtonSecondary } from './buttons'; export type FacetItemProps = Omit<ButtonProps, 'name' | 'onClick'> & { active?: boolean; - name: string; + name: string | React.ReactNode; onClick: (x: string, multiple?: boolean) => void; + small?: boolean; stat?: React.ReactNode; /** Textual version of `name` */ tooltip?: string; @@ -41,11 +42,12 @@ export function FacetItem({ icon, name, onClick, + small, stat, tooltip, value, }: FacetItemProps) { - const disabled = disabledProp || (stat as number) === 0; + const disabled = disabledProp || (stat !== undefined && stat === 0); const handleClick = (event: React.MouseEvent<HTMLButtonElement>) => { event.preventDefault(); @@ -56,12 +58,15 @@ export function FacetItem({ return ( <StyledButton active={active} + aria-checked={active} + aria-label={typeof name === 'string' ? name : undefined} className={className} data-facet={value} disabled={disabled} icon={icon} onClick={handleClick} - role="listitem" + role="checkbox" + small={small} title={tooltip} > <span className="container"> @@ -72,10 +77,17 @@ export function FacetItem({ ); } -const StyledButton = styled(ButtonSecondary)<{ active?: boolean }>` +FacetItem.displayName = 'FacetItem'; // so that tests don't see the obfuscated production name + +const StyledButton = styled(ButtonSecondary)<{ active?: boolean; small?: boolean }>` ${tw`sw-body-sm`}; - ${tw`sw-p-1`}; + ${tw`sw-box-border`}; + ${tw`sw-h-7`}; + ${tw`sw-px-1`}; ${tw`sw-rounded-1`}; + ${tw`sw-w-full`}; + + ${({ small }) => (small ? tw`sw-body-xs sw-pr-0` : '')}; --background: ${({ active }) => (active ? themeColor('facetItemSelected') : 'transparent')}; --backgroundHover: ${({ active }) => (active ? themeColor('facetItemSelected') : 'transparent')}; @@ -95,6 +107,15 @@ const StyledButton = styled(ButtonSecondary)<{ active?: boolean }>` ${tw`sw-items-center`}; ${tw`sw-justify-between`}; + & span.name { + ${tw`sw-pr-1`}; + ${tw`sw-truncate`}; + + & mark { + background-color: ${themeColor('searchHighlight')}; + } + } + & span.stat { color: ${themeColor('facetItemLight')}; } |