feat: markdown, github file and UI improvements

This commit is contained in:
Morten Olsen
2023-06-19 16:33:42 +02:00
parent 4ec88717b0
commit 5c23cef034
27 changed files with 767 additions and 26 deletions

View File

@@ -12,6 +12,7 @@ type BoardsContextValue = {
selected?: string;
boards: Boards;
addBoard: (name: string) => void;
setName: (id: string, name: string) => void;
selectBoard: (id: string) => void;
removeBoard: (id: string) => void;
addWidget: (boardId: string, type: string, data: string) => void;
@@ -46,6 +47,16 @@ const BoardsProvider: React.FC<BoardsProviderProps> = ({
}));
}, []);
const setName = useCallback((id: string, name: string) => {
setBoards((currentBoards) => ({
...currentBoards,
[id]: {
...currentBoards[id],
name,
},
}));
}, []);
const removeBoard = useCallback((id: string) => {
setBoards((currentBoards) => {
const copy = { ...currentBoards };
@@ -116,6 +127,7 @@ const BoardsProvider: React.FC<BoardsProviderProps> = ({
addBoard,
removeBoard,
addWidget,
setName,
removeWidget,
selectBoard,
updateWidget,
@@ -126,6 +138,7 @@ const BoardsProvider: React.FC<BoardsProviderProps> = ({
addBoard,
removeBoard,
addWidget,
setName,
removeWidget,
selectBoard,
updateWidget,

View File

@@ -65,6 +65,14 @@ const useUpdateWidget = () => {
return context.updateWidget;
};
const useSetBoardName = () => {
const context = useContext(BoardsContext);
if (!context) {
throw new Error('useSetBoardName must be used within a BoardsProvider');
}
return context.setName;
};
export {
useBoards,
useSelectedBoard,
@@ -74,4 +82,5 @@ export {
useRemoveBoard,
useSelectBoard,
useUpdateWidget,
useSetBoardName,
};

View File

@@ -8,5 +8,6 @@ export {
useRemoveBoard,
useSelectBoard,
useUpdateWidget,
useSetBoardName,
} from './hooks';
export * from './types';

View File

@@ -47,7 +47,7 @@ const WidgetProvider = ({
const addGlobalNotification = useNotificationAdd();
const dissmissGlobalNotification = useNotificationDismiss();
const notifications = useMemo(() => {
return globalNotifications.filter((n) => n.view !== ref.current);
return globalNotifications.filter((n) => n.view === ref.current);
}, [globalNotifications]);
const addNotification = useCallback(