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

chore(Anchor): make it possible to remove launch icon #4245

Merged
merged 4 commits into from
Nov 8, 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
1 change: 1 addition & 0 deletions packages/dnb-eufemia/src/components/anchor/Anchor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ export function AnchorInstance(localProps: AnchorAllProps) {
const showLaunchIcon =
_opensNewTab &&
!className?.includes('dnb-anchor--no-icon') &&
langz marked this conversation as resolved.
Show resolved Hide resolved
!className?.includes('dnb-anchor--no-launch-icon') &&
!omitClass
const showTooltip = (tooltip || _opensNewTab) && !allProps.title

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,21 @@ describe('Anchor element', () => {
).not.toBeInTheDocument()
})

it('has no "__launch-icon" class when adding class dnb-anchor--no-launch-icon', () => {
render(
<Anchor
href="/url"
target="_blank"
className="dnb-anchor--no-launch-icon"
>
<span>text</span>
</Anchor>
)
expect(
document.querySelector('.dnb-anchor--launch-icon')
).not.toBeInTheDocument()
})

it('has no tooltip when title was given', () => {
render(
<Anchor href="/url" target="_blank" title="Title">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useRef } from 'react'
import classnames from 'classnames'

// Components
import Anchor from '../../components/Anchor'
import Button from '../button/Button'
import Icon from '../../components/Icon'
import FormStatus from '../../components/FormStatus'
Expand Down Expand Up @@ -163,18 +164,18 @@ const UploadFileListCell = ({
</div>
) : (
<div className="dnb-upload__file-cell__text-container">
<a
<Anchor
target="_blank"
href={imageUrl}
download={download ? file.name : null}
className={classnames(
'dnb-anchor',
'dnb-anchor--no-launch-icon',
'dnb-upload__file-cell__title'
)}
rel="noopener noreferrer"
>
{file.name}
</a>
</Anchor>
</div>
)
}
Expand Down
Loading