Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(KFLUXUI-246): allow highlightable links #49

Merged
merged 1 commit into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,7 @@ const ComponentDetails: React.FC<React.PropsWithChildren<ComponentDetailsProps>>
: `https://${componentImageURL}`
}
text={componentImageURL}
isHighlightable
/>
</DescriptionListDescription>
</DescriptionListGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/components/GitLink/GitRepoLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ const GitRepoLink: React.FC<React.PropsWithChildren<Props>> = ({

return (
<Tooltip content={fullUrl} position={TooltipPosition.bottom}>
<ExternalLink href={fullUrl} icon={icon} hideIcon dataTestID={dataTestID}>
<ExternalLink href={fullUrl} icon={icon} hideIcon dataTestID={dataTestID} isHighlightable>
{parsed.owner}/{parsed.name}
{revision ? (
<>
Expand Down
3 changes: 3 additions & 0 deletions src/shared/components/links/ExternalLink.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.highlightable-link {
user-select: text; /* Enables text selection */
}
6 changes: 5 additions & 1 deletion src/shared/components/links/ExternalLink.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import * as React from 'react';
import { ButtonProps, ButtonVariant, Icon } from '@patternfly/react-core';
import { ExternalLinkAltIcon } from '@patternfly/react-icons/dist/esm/icons/external-link-alt-icon';
import { css } from '@patternfly/react-styles';
import AnalyticsButton from '../../../components/AnalyticsButton/AnalyticsButton';
import { AnalyticsButtonProperties } from '../../../utils/analytics';
import './ExternalLink.scss';

type ExternalLinkProps = {
href: string;
Expand All @@ -18,6 +20,7 @@ type ExternalLinkProps = {
onClick?: ButtonProps['onClick'];
analytics?: AnalyticsButtonProperties;
size?: 'sm' | 'md' | 'lg' | 'xl';
isHighlightable?: boolean;
};

const ExternalLink: React.FC<React.PropsWithChildren<ExternalLinkProps>> = ({
Expand All @@ -34,11 +37,12 @@ const ExternalLink: React.FC<React.PropsWithChildren<ExternalLinkProps>> = ({
icon,
onClick,
size = 'sm',
isHighlightable,
}) => (
<AnalyticsButton
component="a"
style={style}
className={additionalClassName}
className={css(additionalClassName, isHighlightable && 'highlightable-link')}
href={href}
target="_blank"
rel="noopener noreferrer"
Expand Down
Loading