-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(forum): improve topic creation onboarding
- Loading branch information
Showing
13 changed files
with
229 additions
and
8 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import Button from './Button' | ||
import { strToDom } from '/functions/dom.js' | ||
|
||
export default class CodeButton extends Button { | ||
shortcut () { | ||
return false | ||
} | ||
|
||
icon () { | ||
return strToDom( | ||
'<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor"><path d="M23 12L15.9289 19.0711L14.5147 17.6569L20.1716 12L14.5147 6.34317L15.9289 4.92896L23 12ZM3.82843 12L9.48528 17.6569L8.07107 19.0711L1 12L8.07107 4.92896L9.48528 6.34317L3.82843 12Z"></path></svg>' | ||
) | ||
} | ||
|
||
/** | ||
* @param {Editor} editor | ||
*/ | ||
action () { | ||
this.editor.wrapWith('\n```\n', '\n```\n') | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
import { flash } from '/elements/Alert.js' | ||
|
||
export class ForumOnboarding extends HTMLElement { | ||
#step = 0 | ||
|
||
onSubmit = e => { | ||
const form = e.currentTarget | ||
if (this.#step > 1) { | ||
return | ||
} | ||
e.preventDefault() | ||
const answer = new FormData(form) | ||
.get('challenge') | ||
.split('\n') | ||
.map(line => line.trim()) | ||
.filter(line => line !== '') | ||
.join('\n') | ||
if ( | ||
(this.#step === 0 && answer.includes('**vérifier**')) || | ||
(this.#step === 1 && answer.includes('```\nconst') && answer.includes(')\n```')) | ||
) { | ||
this.#step++ | ||
form.classList.add('is-done') | ||
const nextForm = form.nextElementSibling | ||
nextForm.classList.remove('is-disabled') | ||
nextForm.querySelector('button[type="submit"]').removeAttribute('disabled') | ||
} else { | ||
flash( | ||
this.#step === 0 ? 'Vous devez mettre le mot "vérifier" en gras' : 'Vous devez entourer le code de ```', | ||
'danger' | ||
) | ||
} | ||
} | ||
|
||
connectedCallback () { | ||
this.querySelectorAll('form').forEach(form => { | ||
form.addEventListener('submit', this.onSubmit) | ||
}) | ||
} | ||
} |
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
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