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

Otvaranie PDF nahrateho/opraveneho riesenia v novom tabe #152

Merged
merged 2 commits into from
Nov 10, 2023
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
6 changes: 5 additions & 1 deletion src/components/Archive/Archive.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,11 @@ const PublicationButton: FC<{
publicationId: number
publicationName: string
}> = ({publicationId, publicationName}) => {
return <Link href={`/api/competition/publication/${publicationId}/download`}>{publicationName}</Link>
return (
<Link href={`/api/competition/publication/${publicationId}/download`} target="_blank">
{publicationName}
</Link>
)
}

const ResultsButton: FC<{
Expand Down
10 changes: 5 additions & 5 deletions src/components/Clickable/Clickable.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import clsx from 'clsx'
import NextLink from 'next/link'
import {ButtonHTMLAttributes, FC, ReactNode} from 'react'
import {ButtonHTMLAttributes, ComponentProps, FC, ReactNode} from 'react'

import styles from './Clickable.module.scss'

Expand All @@ -24,20 +24,20 @@ export const Button: FC<ButtonProps> = ({children, onClick, disabled, type}) =>
)
}

interface LinkProps {
type LinkProps = {
href?: string
disabled?: boolean
children: ReactNode
}
} & Pick<ComponentProps<typeof NextLink>, 'target'>

export const Link: FC<LinkProps> = ({children, href, disabled}) => {
export const Link: FC<LinkProps> = ({children, href, disabled, target}) => {
// https://a11y-guidelines.orange.com/en/articles/disable-elements/#disable-a-link
return disabled ? (
<a className={clsx(styles.actionButton, styles.disabled)} aria-disabled role="link">
{children}
</a>
) : (
<NextLink href={href ?? ''} className={clsx(styles.actionButton)}>
<NextLink href={href ?? ''} target={target} className={clsx(styles.actionButton)}>
{children}
</NextLink>
)
Expand Down
13 changes: 11 additions & 2 deletions src/components/Problems/Problems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -72,14 +72,23 @@ const Problem: FC<{
)}
{displayActions && (
<div className={styles.actions}>
{problem.solution_pdf && <Link href={problem.solution_pdf}>vzorové riešenie</Link>}
{problem.solution_pdf && (
<Link href={problem.solution_pdf} target="_blank">
vzorové riešenie
</Link>
)}
{registered && (
<>
<Link href={`/api/competition/problem/${problem.id}/my-solution`} disabled={!problem.submitted}>
<Link
href={`/api/competition/problem/${problem.id}/my-solution`}
target="_blank"
disabled={!problem.submitted}
>
moje riešenie
</Link>
<Link
href={`/api/competition/problem/${problem.id}/corrected-solution`}
target="_blank"
disabled={!problem.submitted?.corrected_solution}
>
opravené riešenie{!!problem.submitted?.corrected_solution && ` (${problem.submitted.score || '?'})`}
Expand Down
Loading