added hashtag-chooser
|
@ -2,6 +2,7 @@ import { useState, useCallback } from 'react'
|
||||||
import './App.css'
|
import './App.css'
|
||||||
import { useDropzone } from 'react-dropzone'
|
import { useDropzone } from 'react-dropzone'
|
||||||
import FrameChooser from './FrameChooser.js'
|
import FrameChooser from './FrameChooser.js'
|
||||||
|
import HashtagChooser from './HashtagChooser.js'
|
||||||
import Editor from './Editor.js'
|
import Editor from './Editor.js'
|
||||||
import HeaderImage from './HeaderImage.svg'
|
import HeaderImage from './HeaderImage.svg'
|
||||||
import purpleBG from './purpleBG.png'
|
import purpleBG from './purpleBG.png'
|
||||||
|
@ -67,6 +68,7 @@ function trigger_download(name, data){
|
||||||
|
|
||||||
function App() {
|
function App() {
|
||||||
const [frameURL, setFrameURL] = useState(null)
|
const [frameURL, setFrameURL] = useState(null)
|
||||||
|
const [hashtagURL, setHashtagURL] = useState(null)
|
||||||
const [originalPhoto, setOriginalPhoto] = useState(null)
|
const [originalPhoto, setOriginalPhoto] = useState(null)
|
||||||
const [originalPhotoRation, setOriginalPhotoRation] = useState(1)
|
const [originalPhotoRation, setOriginalPhotoRation] = useState(1)
|
||||||
const [orientation, set_orientation] = useState(null)
|
const [orientation, set_orientation] = useState(null)
|
||||||
|
@ -83,6 +85,10 @@ function App() {
|
||||||
setFrameURL(newFrameURL)
|
setFrameURL(newFrameURL)
|
||||||
}, [setFrameURL])
|
}, [setFrameURL])
|
||||||
|
|
||||||
|
const handleHashtagURL = useCallback(newHashtagURL => {
|
||||||
|
setHashtagURL(newHashtagURL)
|
||||||
|
}, [setHashtagURL])
|
||||||
|
|
||||||
const handleCordsChange = useCallback(({x, y, scale}) => {
|
const handleCordsChange = useCallback(({x, y, scale}) => {
|
||||||
setCords({ x, y, scale })
|
setCords({ x, y, scale })
|
||||||
}, [])
|
}, [])
|
||||||
|
@ -242,6 +248,7 @@ function App() {
|
||||||
purpleBG,
|
purpleBG,
|
||||||
...(pngUrl ? [pngUrl] : []),
|
...(pngUrl ? [pngUrl] : []),
|
||||||
...(frameURL ? [frameURL] : []),
|
...(frameURL ? [frameURL] : []),
|
||||||
|
...(hashtagURL ? [hashtagURL] : []),
|
||||||
])
|
])
|
||||||
.then(b64 => {
|
.then(b64 => {
|
||||||
// set_combinedImage(b64)
|
// set_combinedImage(b64)
|
||||||
|
@ -257,6 +264,7 @@ function App() {
|
||||||
cords.scale,
|
cords.scale,
|
||||||
orientation,
|
orientation,
|
||||||
frameURL,
|
frameURL,
|
||||||
|
hashtagURL,
|
||||||
height,
|
height,
|
||||||
width,
|
width,
|
||||||
])
|
])
|
||||||
|
@ -288,6 +296,7 @@ function App() {
|
||||||
|
|
||||||
{!!originalPhoto ? (<>
|
{!!originalPhoto ? (<>
|
||||||
<FrameChooser onChange={handleFrameURL} />
|
<FrameChooser onChange={handleFrameURL} />
|
||||||
|
<HashtagChooser onChange={handleHashtagURL} />
|
||||||
</>) : null}
|
</>) : null}
|
||||||
|
|
||||||
{!!originalPhoto && !!frameURL ? (<>
|
{!!originalPhoto && !!frameURL ? (<>
|
||||||
|
|
63
src/HashtagChooser.js
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
import { useState, useEffect, useCallback } from 'react'
|
||||||
|
|
||||||
|
function HashtagChooser({ onChange }) {
|
||||||
|
const [frames, setFrames] = useState([])
|
||||||
|
const [choosenFrame, setChoosenFrame] = useState(null)
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
async function loadFrames() {
|
||||||
|
Promise.all(
|
||||||
|
[
|
||||||
|
'',
|
||||||
|
'DeineWahl',
|
||||||
|
'Europa',
|
||||||
|
'JetztBistDuDran',
|
||||||
|
'paneuropäisch',
|
||||||
|
'pragmatisch',
|
||||||
|
'progressiv',
|
||||||
|
'Volt',
|
||||||
|
'Volt21',
|
||||||
|
'VoltEuropa',
|
||||||
|
'VoltRLP',
|
||||||
|
'VoteVolt',
|
||||||
|
]
|
||||||
|
.map(async frame_filename => {
|
||||||
|
return {
|
||||||
|
name: frame_filename,
|
||||||
|
src: frame_filename === '' ? '' : await import(`./hashtags/${frame_filename}.png`),
|
||||||
|
}
|
||||||
|
})
|
||||||
|
)
|
||||||
|
.then(new_frames => {
|
||||||
|
setFrames(new_frames)
|
||||||
|
setChoosenFrame(new_frames[0].src.default)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
loadFrames()
|
||||||
|
}, [])
|
||||||
|
|
||||||
|
const handleImageChoosing = useCallback(event => {
|
||||||
|
setChoosenFrame(event.target.dataset.src)
|
||||||
|
}, [setChoosenFrame])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
onChange(choosenFrame)
|
||||||
|
}, [onChange, choosenFrame])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="HashtagChooser">
|
||||||
|
<h2>Choose a Hashtag:</h2>
|
||||||
|
{
|
||||||
|
frames.map(frame => {
|
||||||
|
const frame_src_path = frame.src.default
|
||||||
|
const isChoosen = choosenFrame === frame_src_path
|
||||||
|
return <button key={frame_src_path} data-src={frame_src_path} className={isChoosen ? 'hashtag_button choosen' : 'hashtag_button'} onClick={handleImageChoosing}>
|
||||||
|
{frame.name === '' ? 'No Hashtag' : '#'+frame.name}
|
||||||
|
</button>
|
||||||
|
})
|
||||||
|
}
|
||||||
|
</div>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default HashtagChooser
|
BIN
src/hashtags/DeineWahl.png
Normal file
After Width: | Height: | Size: 3.6 KiB |
BIN
src/hashtags/Europa.png
Normal file
After Width: | Height: | Size: 2.8 KiB |
BIN
src/hashtags/JetztBistDuDran.png
Normal file
After Width: | Height: | Size: 4.2 KiB |
BIN
src/hashtags/Volt.png
Normal file
After Width: | Height: | Size: 2.6 KiB |
BIN
src/hashtags/Volt21.png
Normal file
After Width: | Height: | Size: 2.9 KiB |
BIN
src/hashtags/VoltEuropa.png
Normal file
After Width: | Height: | Size: 3.6 KiB |
BIN
src/hashtags/VoltRLP.png
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
src/hashtags/VoteVolt.png
Normal file
After Width: | Height: | Size: 3.1 KiB |
BIN
src/hashtags/paneuropäisch.png
Normal file
After Width: | Height: | Size: 4.1 KiB |
BIN
src/hashtags/pragmatisch.png
Normal file
After Width: | Height: | Size: 3.8 KiB |
BIN
src/hashtags/progressiv.png
Normal file
After Width: | Height: | Size: 3.7 KiB |