Skip to content

Commit

Permalink
Revert "Revert "issue developerforce#7""
Browse files Browse the repository at this point in the history
This reverts commit 94400e6.
  • Loading branch information
DKulan committed Apr 7, 2021
1 parent 94400e6 commit 257f261
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 3 deletions.
4 changes: 4 additions & 0 deletions client/src/pages/Create/Create.css
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ textarea::placeholder {
transition: color 150ms ease-in-out;
}

.text-limit-error {
color: var(--color-error-500)
}

@media (min-width: 560px) {
.gif-video {
height: 288px;
Expand Down
17 changes: 15 additions & 2 deletions client/src/pages/Create/Create.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function Create({ history }) {
const [isWebcamReady, setIsWebcamReady] = useState(false)
const [gifId, setGifId] = useState()
const [text, setText] = useState('')
const [textLimitError, setTextLimitError] = useState('')
const [isProcessingGif, setIsProcessingGif] = useState('')
const [isUploading, setUploading] = useState(false)
const [warning, setWarning] = useState(
Expand Down Expand Up @@ -135,6 +136,15 @@ function Create({ history }) {
download(fileBlob, `${gifId}.gif`)
}

const handleText = (input) => {
if (input.length === 30) {
setTextLimitError('Caption must have a maximum limit of 30 characters.')
} else {
setText(input)
setTextLimitError('')
}
}

const header = (
<>
<h1>Create Your Own GIF</h1>
Expand Down Expand Up @@ -224,9 +234,12 @@ function Create({ history }) {
)}
{phase === PHASE_TEXT && (
<>
{textLimitError && (
<p className="text-limit-error">{textLimitError}</p>
)}
<textarea
placeholder="Add a caption to your GIF!"
onChange={(e) => setText(e.target.value)}
placeholder="Add a caption to your GIF! (maximum 30 characters)"
onChange={(e) => handleText(e.target.value)}
value={text}
/>
<div className="gif-button-group">
Expand Down
7 changes: 6 additions & 1 deletion server/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ app.post('/uploadGIF', ({ body }, res) => {
})
})

/* eslint-disable */
app.post('/video2gif', upload.none(), ({ body }, res) => {
const { videoId, text, fontsize } = body
ffmpeg()
Expand All @@ -192,7 +193,11 @@ app.post('/video2gif', upload.none(), ({ body }, res) => {
{
filter: 'drawtext',
options: {
text: text.replace(/\r?\n|\r/gm, '\v'),
text: text
.replaceAll('\\\\', '\\\\\\\\\\\\\\\\')
.replaceAll("'", "'\\\\\\\\\\\\''")
.replaceAll('%', '\\\\\\\\\\\\%')
.replaceAll(':', '\\\\\\\\\\\\:'),
fontsize,
fontcolor: 'white',
x: '(w-text_w)/2',
Expand Down

0 comments on commit 257f261

Please sign in to comment.