Skip to content

Commit 6bb1d07

Browse files
committed
Håndterer disabled state
1 parent c95849a commit 6bb1d07

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

src/components/main-section/content-view/pdf-exporter/PdfExporter.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ export const PdfExporter = ({ content, hidden }: Props) => {
132132
<DownloadLink
133133
href={`${pdfApi}/multi/${versionKeysSelected.join(',')}`}
134134
icon={versionKeysSelected.length > 0 && <DownloadIcon />}
135+
disabled={versionKeysSelected.length === 0}
135136
>
136137
{versionKeysSelected.length === 0
137138
? 'Ingen versjoner valgt'

src/components/main-section/content-view/pdf-exporter/download-link/DownloadLink.module.css

+11-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,17 @@
2222
}
2323

2424
.disabled {
25-
pointer-events: none;
26-
color: var(--a-gray-300);
25+
color: var(--a-gray-400);
26+
cursor: not-allowed;
27+
28+
&:hover {
29+
background-color: unset;
30+
}
31+
32+
&:active {
33+
color: unset;
34+
background-color: unset;
35+
}
2736
}
2837

2938
.iconContainer {

src/components/main-section/content-view/pdf-exporter/download-link/DownloadLink.tsx

+6-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ type Props = {
1717
export const DownloadLink = ({ href, icon, disabled, className, children }: Props) => {
1818
const [isWaiting, setIsWaiting] = useState(false);
1919

20-
const onDownload = () => {
20+
const onDownload = (e: React.MouseEvent) => {
21+
if (disabled) {
22+
e.preventDefault();
23+
return;
24+
}
25+
2126
Cookies.remove(DOWNLOAD_COOKIE_NAME);
2227
setIsWaiting(true);
2328

0 commit comments

Comments
 (0)