Skip to content
Open
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
43 changes: 38 additions & 5 deletions src/partials/ProgrammingExercise/ProgrammingExerciseCard.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@ import styled from "styled-components"
import ContentLoader from "react-content-loader"
import { withTranslation } from "react-i18next"
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"
import { faPencilAlt as icon, faRedo } from "@fortawesome/free-solid-svg-icons"
import {
faPencilAlt as icon,
faRedo,
faLink,
} from "@fortawesome/free-solid-svg-icons"
import { Card, CardContent, Button, Typography } from "@material-ui/core"

import { normalizeExerciseId } from "../../util/strings"
Expand Down Expand Up @@ -109,6 +113,27 @@ const StyledRefreshIcon = styled(FontAwesomeIcon)`
color: white;
`

const Permalink = styled.a`
color: inherit;
display: inline-block;
margin-left: 0.5rem;
font-size: 0.5em;
text-decoration: none;
vertical-align: middle;
opacity: 0;

h3:hover &,
h3:focus-within &,
&:focus {
opacity: 1;
}

&:hover,
&:focus {
color: inherit;
}
`

class ProgrammingExerciseCard extends React.Component {
render() {
const {
Expand All @@ -122,15 +147,23 @@ class ProgrammingExerciseCard extends React.Component {
difficulty,
} = this.props

const exerciseId = normalizeExerciseId(`programming-exercise-${name}`)

return (
<ProgrammingExerciseWrapper
id={normalizeExerciseId(`programming-exercise-${name}`)}
>
<ProgrammingExerciseWrapper id={exerciseId}>
<Header completed={completed}>
<StyledIcon icon={icon} size="2x" />
<HeaderTitleContainer>
<HeaderMuted>{this.props.t("programmingExercise")} </HeaderMuted>
<h3>{name}</h3>
<h3>
{name}
<Permalink
href={`#${exerciseId}`}
aria-label={`${name} permalink`}
>
<FontAwesomeIcon icon={faLink} aria-hidden="true" />
</Permalink>
</h3>
{/*Ikävän kompleksinen. Onko syytä laittaa omaan komponenttiin?*/}
{difficulty ? (
<Difficulty>
Expand Down