Skip to content

Commit d025cec

Browse files
committed
Tweaker download link css
1 parent b06961b commit d025cec

File tree

4 files changed

+77
-39
lines changed

4 files changed

+77
-39
lines changed

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

+13-1
Original file line numberDiff line numberDiff line change
@@ -44,5 +44,17 @@
4444
.multiSelectButtons {
4545
display: flex;
4646
gap: 0.5rem;
47-
padding: 0.5rem 0.125rem;
47+
padding: 0.5rem 0.25rem;
48+
49+
visibility: visible;
50+
max-height: 5rem;
51+
transition-property: visibility, max-height, padding;
52+
transition-timing-function: ease-out;
53+
transition-duration: 200ms;
54+
55+
&.hidden {
56+
visibility: hidden;
57+
max-height: 0;
58+
padding: 0 0.25rem;
59+
}
4860
}

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

+20-19
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const PdfExporter = ({ content, hidden }: Props) => {
2323

2424
const { versionKey: currentVersionKey, versions } = content;
2525

26-
const versionsSelectedMapEmpty = useMemo(
26+
const versionsSelectedMapNew = useMemo(
2727
() =>
2828
Object.values(content.versions).reduce<VersionsSelectedMap>((acc, version, index) => {
2929
acc[index] = { selected: false, versionKey: version.key };
@@ -33,7 +33,7 @@ export const PdfExporter = ({ content, hidden }: Props) => {
3333
);
3434

3535
const [versionsSelectedMap, setVersionsSelectedMap] =
36-
useState<VersionsSelectedMap>(versionsSelectedMapEmpty);
36+
useState<VersionsSelectedMap>(versionsSelectedMapNew);
3737
const [prevClickedIndex, setPrevClickedIndex] = useState(0);
3838
const [versionKeysSelected, setVersionKeysSelected] = useState<string[]>([]);
3939

@@ -81,10 +81,10 @@ export const PdfExporter = ({ content, hidden }: Props) => {
8181
}, [versionsSelectedMap]);
8282

8383
useEffect(() => {
84-
setVersionsSelectedMap(versionsSelectedMapEmpty);
84+
setVersionsSelectedMap(versionsSelectedMapNew);
8585
setVersionKeysSelected([]);
8686
setPrevClickedIndex(0);
87-
}, [versionsSelectedMapEmpty]);
87+
}, [versionsSelectedMapNew]);
8888

8989
return (
9090
<div className={classNames(style.exporter, hidden && style.hidden)}>
@@ -95,6 +95,7 @@ export const PdfExporter = ({ content, hidden }: Props) => {
9595
<DownloadLink
9696
href={`${pdfApi}/single/${currentVersionKey}`}
9797
icon={<ArrowDownRightIcon className={style.downloadCurrentIcon} />}
98+
small={true}
9899
>
99100
{'Last ned denne versjonen'}
100101
</DownloadLink>
@@ -128,25 +129,25 @@ export const PdfExporter = ({ content, hidden }: Props) => {
128129
);
129130
})}
130131
</CheckboxGroup>
131-
<div className={style.multiSelectButtons}>
132+
<div
133+
className={classNames(
134+
style.multiSelectButtons,
135+
versionKeysSelected.length === 0 && style.hidden
136+
)}
137+
>
132138
<DownloadLink
133139
href={`${pdfApi}/multi/${versionKeysSelected.join(',')}`}
134-
icon={versionKeysSelected.length > 0 && <DownloadIcon />}
135-
disabled={versionKeysSelected.length === 0}
140+
icon={<DownloadIcon />}
136141
>
137-
{versionKeysSelected.length === 0
138-
? 'Ingen versjoner valgt'
139-
: `Last ned ${versionKeysSelected.length} ${versionKeysSelected.length > 1 ? 'valgte versjoner' : 'valgt versjon'}`}
142+
{`Last ned ${versionKeysSelected.length} ${versionKeysSelected.length === 1 ? 'valgt versjon' : 'valgte versjoner'}`}
140143
</DownloadLink>
141-
{versionKeysSelected.length > 0 && (
142-
<Button
143-
variant={'tertiary-neutral'}
144-
size={'xsmall'}
145-
onClick={() => setVersionsSelectedMap(versionsSelectedMapEmpty)}
146-
>
147-
{'Nullstill valg'}
148-
</Button>
149-
)}
144+
<Button
145+
variant={'tertiary-neutral'}
146+
size={'xsmall'}
147+
onClick={() => setVersionsSelectedMap(versionsSelectedMapNew)}
148+
>
149+
{'Nullstill valg'}
150+
</Button>
150151
</div>
151152
</div>
152153
);

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

+35-16
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,59 @@
44
gap: 0.5rem;
55
text-decoration: none;
66
font-weight: bold;
7-
/*border: solid 2px var(--a-border-action);*/
7+
border: solid 2px var(--a-border-action);
88
border-radius: var(--a-border-radius-medium);
9-
padding: 0.5rem;
9+
padding: 0.5rem 0.75rem;
1010
min-height: 3rem;
11+
background-color: var(--a-surface-action);
12+
color: var(--a-text-on-action);
1113

1214
&:hover {
13-
background-color: var(--a-surface-neutral-subtle-hover);
15+
background-color: var(--a-surface-action-hover);
1416
}
1517

1618
&:active {
1719
outline: none;
1820
box-shadow: none;
19-
color: var(--a-text-action);
20-
background-color: var(--a-surface-action-subtle);
21+
background-color: var(--a-surface-action-active);
2122
}
22-
}
2323

24-
.disabled {
25-
color: var(--a-gray-400);
26-
cursor: not-allowed;
27-
28-
&:hover {
24+
&.small {
2925
background-color: unset;
26+
color: var(--a-text-action);
27+
border: none;
28+
padding: 0.25rem 0.5rem;
29+
30+
&:hover {
31+
background-color: var(--a-surface-action-subtle-hover);
32+
}
33+
34+
&:active {
35+
background-color: var(--a-surface-action-subtle);
36+
}
3037
}
3138

32-
&:active {
33-
color: unset;
34-
background-color: unset;
39+
&.disabled {
40+
color: var(--a-gray-400);
41+
cursor: not-allowed;
42+
43+
&:hover {
44+
background-color: unset;
45+
}
46+
47+
&:active {
48+
color: unset;
49+
background-color: unset;
50+
}
3551
}
3652
}
3753

3854
.iconContainer {
55+
display: flex;
56+
align-items: center;
57+
3958
> * {
40-
width: 1.375rem;
41-
height: 1.375rem;
59+
width: 1.5rem;
60+
height: 1.5rem;
4261
}
4362
}

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

+9-3
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ import style from './DownloadLink.module.css';
88

99
type Props = {
1010
href: string;
11+
small?: boolean;
1112
icon?: React.ReactNode;
1213
className?: string;
1314
disabled?: boolean;
14-
children: React.ReactNode | string;
15+
children: React.ReactNode;
1516
};
1617

17-
export const DownloadLink = ({ href, icon, disabled, className, children }: Props) => {
18+
export const DownloadLink = ({ href, small, icon, disabled, className, children }: Props) => {
1819
const [isWaiting, setIsWaiting] = useState(false);
1920

2021
const onDownload = (e: React.MouseEvent) => {
@@ -45,7 +46,12 @@ export const DownloadLink = ({ href, icon, disabled, className, children }: Prop
4546
<Link
4647
href={href}
4748
download={true}
48-
className={classNames(style.link, (isWaiting || disabled) && style.disabled, className)}
49+
className={classNames(
50+
style.link,
51+
small && style.small,
52+
(isWaiting || disabled) && style.disabled,
53+
className
54+
)}
4955
onClick={onDownload}
5056
>
5157
{children}

0 commit comments

Comments
 (0)