Skip to content

Commit

Permalink
feat: added quickLinks and quickLinksOrder to Recoil
Browse files Browse the repository at this point in the history
  • Loading branch information
sereneinserenade committed Jun 12, 2022
1 parent d0c4e45 commit 9854161
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 17 deletions.
12 changes: 11 additions & 1 deletion src/Store.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { atom } from 'recoil';

import { Note } from './types'
import { Note, QuickLink } from './types'

export const notesState = atom<Note[]>({
key: 'notesState',
Expand All @@ -12,6 +12,16 @@ export const binNotesState = atom<Note[]>({
default: []
})

export const quickLinks = atom<Record<string, QuickLink>>({
key: 'quickLinks',
default: {}
})

export const quickLinksOrder = atom<string[]>({
key: 'quickLinksOrder',
default: []
})

export const sidebarActiveState = atom<boolean>({
key: 'sidebarActiveState',
default: false
Expand Down
27 changes: 11 additions & 16 deletions src/components/QuickLinks.tsx
Original file line number Diff line number Diff line change
@@ -1,33 +1,28 @@
import React, { useCallback, useEffect, useState } from 'react';

import {
DndContext,
closestCenter,
KeyboardSensor,
closestCenter, DndContext, DragStartEvent, KeyboardSensor,
PointerSensor,
useSensor,
useSensors,
DragStartEvent,
useSensors
} from '@dnd-kit/core';
import {
arrayMove,
sortableKeyboardCoordinates,
rectSortingStrategy,
useSortable,
SortableContext
arrayMove, rectSortingStrategy, SortableContext, sortableKeyboardCoordinates, useSortable
} from '@dnd-kit/sortable';
import { CSS } from '@dnd-kit/utilities';
import { v4 as uuidv4 } from 'uuid'
import { v4 as uuidv4 } from 'uuid';


import { Button, Input, Loading, Modal, Text, Tooltip } from '@nextui-org/react';

import { FiPlusCircle, FiLink, FiTrash2, FiEdit } from 'react-icons/fi'
import { test } from 'linkifyjs'
import { test } from 'linkifyjs';
import { FiEdit, FiLink, FiPlusCircle, FiTrash2 } from 'react-icons/fi';

import './css/QuickLinks.scss'
import { quickLinks, quickLinksOrder } from '../Store'
import { QuickLink } from '../types';
import { stopPrevent } from '../utils';
import './css/QuickLinks.scss';
import { useRecoilState } from 'recoil';

const urlPatternValidation = (url: string): boolean => test(url);

Expand Down Expand Up @@ -67,9 +62,9 @@ interface QuickLinksProps {
}

const QuickLinks: React.FC<QuickLinksProps> = () => {
const [localQuickLinksOrder, setLocalQuickLinksOrder] = useState<string[]>([])
const [localQuickLinksOrder, setLocalQuickLinksOrder] = useRecoilState(quickLinksOrder)

const [localQuickLinks, setLocalQuickLinks] = useState<Record<string, QuickLink>>({})
const [localQuickLinks, setLocalQuickLinks] = useRecoilState(quickLinks)

const [isAddQuickLinkModalOpen, setIsAddQuickLinkModalOpen] = useState<boolean>(false)

Expand Down

0 comments on commit 9854161

Please sign in to comment.