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

various fixes from testing new user path #51

Merged
merged 1 commit into from
May 20, 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
2 changes: 1 addition & 1 deletion src/components/Library/FilterBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const FilterBar = ({
onClick={() => setIsColorFiltered(!isColorFiltered)}
>
<span>Color</span>
<button
<div
className={`color-display ${CARD_COLOR_KEYS[filterColorOption] ?? '#F4F4F4'}`}
onClick={(event) => openColorDropdown(event)}
ref={colorDropdownBtnRef}
Expand Down
11 changes: 10 additions & 1 deletion src/components/Library/hooks.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState, useRef } from 'react';
import { useState, useRef, useEffect } from 'react';
import { useSelector } from 'react-redux';
import { CARD_COLOR_KEYS } from '../../styles/colors';

Expand Down Expand Up @@ -87,7 +87,9 @@ export const useLibraryHooks = () => {
const activeTab = useSelector(state => state.project.present.activeViewId);
const tabOrder = useSelector(state => state.project.present.viewOrder);
const cardCollection = useSelector(state => state.project.present.cards);
const activeProject = useSelector(state => state.session.activeCampaignId || '');

const [ showButton, setShowButton ] = useState(!!activeProject);
const [ isOpen, setIsOpen ] = useState(false);
const [ searchString, setSearchString ] = useState('');
const [ isColorFiltered, setIsColorFiltered ] = useState(false);
Expand All @@ -96,6 +98,12 @@ export const useLibraryHooks = () => {
const [ sortOption, setSortOption ] = useState(SORT_OPTIONS.abc);
const [ viewOption, setViewOption ] = useState(VIEW_OPTIONS.condensed);

// Reset when project changes
useEffect(() => {
setShowButton(!!activeProject);
setIsOpen(false);
}, [activeProject]);

let libraryCards = [];
for (let id in cardCollection) {
const card = cardCollection[id];
Expand All @@ -109,6 +117,7 @@ export const useLibraryHooks = () => {
libraryCards = sortCards(libraryCards, sortOption, cardCollection);

return {
showButton,
isOpen,
toggleLibrary: () => setIsOpen(!isOpen),
countDisplay: (libraryCards?.length ?? 0) + '/' + (cardCollection ? Object.keys(cardCollection).length : 0),
Expand Down
7 changes: 6 additions & 1 deletion src/components/Library/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import OpenLibraryIcon from '../../assets/icons/library-open.svg';

const Library = () => {
const {
showButton,
isOpen,
toggleLibrary,
countDisplay,
Expand Down Expand Up @@ -64,7 +65,11 @@ const Library = () => {
{cardComponents}
</div>
</div>
<button className='library-btn' onClick={toggleLibrary}>
<button
className='library-btn'
onClick={toggleLibrary}
style={{ display: showButton ? 'block' : 'none' }}
>
<img src={isOpen ? OpenLibraryIcon : ClosedLibraryIcon} alt='Library' />
<span className='tooltip'>Library of cards</span>
</button>
Expand Down
2 changes: 1 addition & 1 deletion src/data/api/database.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export const firstTimeSetup = () => dispatch => {
};

const saveActiveProjectId = (id, callback) => dispatch => {
updateDoc(userDoc(), { activeCampaignId: id })
setDoc(userDoc(), { activeCampaignId: id })
.then(response => {
console.log('[saveActiveProjectId] success');
if (callback) {
Expand Down
Loading