Skip to content

Commit

Permalink
dummy fav
Browse files Browse the repository at this point in the history
  • Loading branch information
cglotr committed Jun 18, 2023
1 parent 94c0d8f commit afed762
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 14 deletions.
21 changes: 20 additions & 1 deletion src/pages/bookmark.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export default function BookmarkPage() {
const [currentPointer, setCurrentPointer] = useState<string>("")
const [verse, setVerse] = useState<Verse>({ key: "", verse: "", translation: "" })
const [isLoading, setIsLoading] = useState<boolean>(false)
const [isFav, setIsFav] = useState<boolean>(false)

useEffect(() => {
(async () => {
Expand Down Expand Up @@ -99,6 +100,21 @@ export default function BookmarkPage() {
)
}

const renderFav = () => {
return (
<Button
onClick={() => {
setIsFav(!isFav)
}}
style={{
textDecoration: isFav ? undefined : "underline"
}}
>
{!isFav ? "favorite" : <div style={{ fontSize: `${FONT.FONT_SIZE_S}` }}>❤️</div>}
</Button>
)
}

const renderShowHideVerse = () => {
return (
<Button
Expand Down Expand Up @@ -172,8 +188,11 @@ export default function BookmarkPage() {
justifyContent: "space-between"
}}
>
{renderTag()}
<div>
{renderTag()}
</div>
<div>
{renderFav()}
{renderShowHideVerse()}
{renderShowHideTranslation()}
</div>
Expand Down
20 changes: 16 additions & 4 deletions src/pages/favs.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import { useContext, useEffect } from 'react'
import { useContext, useEffect, useState } from 'react'
import Head from "next/head"
import { useRouter } from 'next/router'

import { AuthContext } from './app'
import { DIMENSIONS } from '../constants/dimensions'
import { FONT } from "../constants/font"

export default function ProfilePage() {
export default function FavsPage() {
const authContext = useContext(AuthContext)
const router = useRouter()
const [isEditing, setIsEditing] = useState(false)

useEffect(() => {
if (!authContext.isLoggedIn()) {
Expand All @@ -31,10 +32,21 @@ export default function ProfilePage() {
fontSize: FONT.FONT_SIZE_S,
display: "flex",
justifyContent: "space-between",
paddingLeft: `${DIMENSIONS.SZ_6}px`
paddingLeft: `${DIMENSIONS.SZ_6}px`,
flexDirection: "column"
}}
>
<div>Coming soon.</div>
<div style={{
alignItems: "center",
display: "flex",
flexDirection: "row",
alignSelf: "end"
}}>
<div>Edit</div>
<input type="checkbox" id="toggle" checked={isEditing} onClick={() => {
setIsEditing(!isEditing)
}}></input>
</div>
</div>
</>
)
Expand Down
56 changes: 47 additions & 9 deletions src/pages/surahs/[id].tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Head from 'next/head'
import { useRouter } from 'next/router'
import { useState } from 'react'

import { Break } from '../../components/break'
import { Button } from './../../components/button'
Expand Down Expand Up @@ -27,6 +28,33 @@ export default function SurahPage(props: { surah: Surah }) {
hideTranslation: false
},
)
const [favSet, setFavSet] = useState<Set<string>>(new Set())

const renderFav = (surahVerse: string) => {
const isFav = favSet.has(surahVerse)

return (
<Button
onClick={() => {
if (!isFav) {
setFavSet(prev => {
return new Set(prev.add(surahVerse))
})
} else {
setFavSet(prev => {
prev.delete(surahVerse)
return new Set(prev)
})
}
}}
style={{
textDecoration: isFav ? undefined : "underline"
}}
>
{!favSet.has(surahVerse) ? "favorite" : <div style={{ fontSize: `${FONT.FONT_SIZE_S}` }}>❤️</div>}
</Button>
)
}

const renderShowHideVerse = () => {
return (
Expand Down Expand Up @@ -94,13 +122,16 @@ export default function SurahPage(props: { surah: Surah }) {
<div>
{`${props.surah.surahId}:${verse.verseId}`}
</div>
<Button
onClick={() => {
router.back()
}}
>
back
</Button>
<div>
{renderFav(`${props.surah.surahId}:${verse.verseId}`)}
<Button
onClick={() => {
router.back()
}}
>
back
</Button>
</div>
</div>
<Break size={DIMENSIONS.SZ_8} />
{renderVerse(verse.text)}
Expand Down Expand Up @@ -176,8 +207,15 @@ export default function SurahPage(props: { surah: Surah }) {
<title>{props.surah.englishName}</title>
</Head>
{renderShortcuts()}
{renderUserActions()}
{renderVerses()}
<div
style={{
paddingLeft: `${DIMENSIONS.SZ_6}px`,
paddingRight: `${DIMENSIONS.SZ_6}px`
}}
>
{renderUserActions()}
{renderVerses()}
</div>
</>
)
}
Expand Down

0 comments on commit afed762

Please sign in to comment.