Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft bible book grid #598

Merged
merged 4 commits into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 41 additions & 2 deletions src/components/organisms/passageNavigation.module.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
@import '../../styles/common.scss';

.wrapper {
display: flex;
background-color: $ts-bibleVersionH;
}

Expand All @@ -24,12 +23,17 @@
padding-bottom: 16px;
}

// .wrapper .books:global(.grid) {
// display: grid;
// grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
// }

.wrapper li,
.wrapper li button,
.wrapper li a {
color: $ts-lightTone;
font-weight: 700;
size: 16px;
font-size: 16px;
line-height: 19.2px;
text-transform: uppercase;
list-style-type: none;
Expand All @@ -39,12 +43,20 @@
color: $ts-salmon;
}

.switch > :global(button.active) {
color: $ts-salmon;
}

.wrapper,
.wrapper .books,
.wrapper .chapters {
width: 100%;
}

// .books:global(.grid) .chapters {
// grid-column: 1 / -1;
// }

.chapters {
display: grid;
grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
Expand All @@ -69,3 +81,30 @@
.books button:hover {
color: $ts-salmon;
}

.switch {
border-bottom: 1px solid $ts-salmon;
}

.switch > button {
color: $ts-lightTone;
font-weight: 700;
font-size: 12px;
line-height: 14.4px;
text-transform: uppercase;
}

.chaptersWrapper {
width: 100%;
display: none;
}

.chaptersWrapper:global(.active) {
display: block;
float: left;
}

.books:global(.grid) .book {
width: 70px;
display: inline-block;
}
79 changes: 55 additions & 24 deletions src/components/organisms/passageNavigation.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import clsx from 'clsx';
import React, { useState } from 'react';
import React, { useRef, useState } from 'react';

Check failure on line 2 in src/components/organisms/passageNavigation.tsx

View workflow job for this annotation

GitHub Actions / lint

'useRef' is defined but never used. Allowed unused vars must match /_/u

import Link from '~components/atoms/linkWithoutPrefetch';

Expand All @@ -14,41 +14,72 @@
const [selectedBook, setSelectedBook] = useState<string | number | null>(
null,
);
const [selectedView, setSelectedView] = useState<'grid' | 'list'>('grid');

return (
<div className={styles.wrapper}>
<ul className={styles.books}>
<div className={styles.switch}>
<button
className={clsx({ active: selectedView === 'grid' })}
onClick={() => setSelectedView('grid')}
>
Grid
</button>
<button
className={clsx({ active: selectedView === 'list' })}
onClick={() => setSelectedView('list')}
>
List
</button>
</div>

<ul className={clsx(styles.books, { grid: selectedView === 'grid' })}>
{books.map((book) => {
const chapters = book.recordings.nodes;

return (
<li
key={book.id}
className={clsx(styles.book, {
active: book.id === selectedBook,
})}
>
<button
onClick={() => {
setSelectedBook(book.id);
}}
<>
<li
key={book.id}
className={clsx(styles.book, {
active: book.id === selectedBook,
})}
>
{book.title}
</button>
<button
onClick={() => {
setSelectedBook(book.id);
}}
>
{selectedView === 'grid'
? book.title.replace(' ', '').substring(0, 3)
: book.title}
</button>
</li>
{book.id === selectedBook ? (
<ul className={styles.chapters}>
{chapters?.map((chapter) => {
const n = Number(chapter.title.split(' ').pop());
return (
<li key={n} className={styles.chapter}>
<Link href={chapter.canonicalPath}>{n}</Link>
</li>
);
<li
className={clsx(styles.chaptersWrapper, {
active: book.id === selectedBook,
})}
</ul>
>
<ul
className={clsx(styles.chapters, {
active: book.id === selectedBook,
})}
>
{chapters?.map((chapter) => {
const n = Number(chapter.title.split(' ').pop());
return (
<li key={n} className={styles.chapter}>
<Link href={chapter.canonicalPath}>{n}</Link>
</li>
);
})}
</ul>
</li>
) : (
''
)}
</li>
</>
);
})}
</ul>
Expand Down
Loading