-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(chapter): add Intersection Observer for active sections
- Loading branch information
Gerd Müller
committed
Jun 20, 2020
1 parent
80e8413
commit b5cfea3
Showing
10 changed files
with
48 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,32 @@ | ||
import React, {useContext} from 'react'; | ||
import React, {useContext, useState} from 'react'; | ||
import { IMAGE_SUFFIX, IMAGE_SUFFIX_ALTERNATE } from '@gerdesque/data'; | ||
import {AppContext } from '../chapter/context'; | ||
import './image.scss'; | ||
|
||
/* eslint-disable-next-line */ | ||
export interface ImageProps { | ||
value: string | ||
width?: string | ||
layer?: string | ||
title?: string | ||
} | ||
|
||
export const Image = (props: ImageProps) => { | ||
const [character, setCharacter] = useContext(AppContext); | ||
const [hover, setHover] = useState(false); | ||
//const [source, setSource] = useState(props.value); | ||
|
||
const chooseCharacter = () => { | ||
setCharacter(props.title) | ||
props.title && setCharacter(props.title); | ||
} | ||
|
||
return ( | ||
<picture className={`chapter_picture ${props.width}`} onClick={() => chooseCharacter()}> | ||
<picture className={`chapter_picture ${props.layer} ${hover ? 'highlighted' : ''}`} onMouseOut={() => setHover(false)} onMouseOver={() => setHover(true)} onClick={() => chooseCharacter()}> | ||
<source srcSet={"./assets/"+props.value+IMAGE_SUFFIX} type='image/webp' /> | ||
<source srcSet={"./assets/fallback/"+props.value+IMAGE_SUFFIX_ALTERNATE} type='image/png' /> | ||
<img draggable="false" src={"./assets/fallback/"+props.value+IMAGE_SUFFIX_ALTERNATE} alt={props.value} /> | ||
</picture> | ||
) | ||
|
||
// <button type='button' className='link-button' key={avatar} onMouseOut={() => this.setState({ isHover: false })} onMouseOver={() => this.setState({ isHover: avatar })} onClick={() => this.setState({ avatar: avatar })}>{avatar}</button>)} | ||
|
||
}; | ||
|
||
export default Image; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters