Skip to content

Commit

Permalink
otvorit PDF nahrateho/opraveneho riesenia v novom tabe
Browse files Browse the repository at this point in the history
  • Loading branch information
rtrembecky committed Nov 10, 2023
1 parent d4b53be commit b799e4e
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
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
7 changes: 6 additions & 1 deletion src/components/Problems/Problems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,16 @@ const Problem: FC<{
{problem.solution_pdf && <Link href={problem.solution_pdf}>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

0 comments on commit b799e4e

Please sign in to comment.