-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #79 from vevcom/feat/new-nav
Feat/new nav
- Loading branch information
Showing
15 changed files
with
456 additions
and
420 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,25 @@ | ||
'use client' | ||
import { useContext, useEffect, useRef } from 'react' | ||
import { useContext } from 'react' | ||
import { EditModeContext } from '@/context/EditMode' | ||
import styles from './EditModeSwitch.module.scss' | ||
import type { ChangeEvent } from 'react' | ||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' | ||
import { faPencil } from '@fortawesome/free-solid-svg-icons' | ||
|
||
export default function EditModeSwitch() { | ||
const editingContext = useContext(EditModeContext) | ||
const ref = useRef<HTMLInputElement>(null) | ||
if (!editingContext) throw new Error('No EditModeContext found') | ||
|
||
const handleChange = (e: ChangeEvent<HTMLInputElement>) => { | ||
editingContext.setEditMode(e.target.checked) | ||
} | ||
|
||
useEffect(() => { | ||
console.log(editingContext.editMode) | ||
if (ref.current) { | ||
ref.current.checked = editingContext.editMode | ||
} | ||
}, [editingContext.editMode]) | ||
|
||
return ( | ||
<div className={styles.EditModeSwitch}> | ||
<label>Edit</label> | ||
<div> | ||
<input type="checkbox" id="editModeSwitch" onChange={handleChange} /> | ||
<span className={styles.slider}></span> | ||
</div> | ||
<label> | ||
<input checked={editingContext.editMode} type="checkbox" id="editModeSwitch" onChange={handleChange} /> | ||
<FontAwesomeIcon className={styles.EditModeSwitchIcon} icon={faPencil} /> | ||
</label> | ||
</div> | ||
) | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.