Giter Site home page Giter Site logo

chrisnajman / markdown-notes-app-localstorage Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 738 KB

Create, edit, preview, save, and delete Markdown notes.

Home Page: https://chrisnajman.github.io/markdown-notes-app-localstorage/

License: MIT License

HTML 11.33% JavaScript 48.30% CSS 40.37%
nanoid react-icons react-mde react-split reactjs scrimba-react dark-mode html-css-javascript localstorage

markdown-notes-app-localstorage's Introduction

Markdown Notes App (Local Storage)

This is the result of the Scrimba Tutorial Notes App (registration required), specifically, the first half (excluding the setting up of Firebase / Firestore).

Much of the code was pre-written. The task was to add functionality to an existing codebase.

Functionality to Add

  1. Sync notes with localStorage.
  2. Create note titles from a summary of the note.
  3. Move modified notes to the top of the list.
  4. Delete notes.

Alternative Version using firestore to Save Notes

Note

There isn't a GitHub Page for this version. This is due to database security concerns.


React Version

Important

react-mde (the markdown editor) has not been updated for React V.18. Therefore, I have used React V.17 for this project.


Accessibility

In the markdown editor, you can't tab through the toolbar buttons (apart from 'Write' and 'Preview'). This is because tabindex="-1" is placed on these buttons, removing them from the tab order.

ChatGPT supplied a solution, which was to give ALL the buttons (including 'Write' and 'Preview') a tabindex of zero:

function Editor({ currentNote, updateNote }) {

    ...

    useEffect(() => {
    // Function to update tabindex of toolbar buttons
    const updateTabindex = () => {
        const toolbarButtons = document.querySelectorAll(".mde-header button")
        toolbarButtons.forEach((button) => {
        button.setAttribute("tabindex", "0")
        })
    }

    // Call the function initially after the component mounts
    updateTabindex()

    // Optional: observe changes to ensure tabindex stays updated
    const observer = new MutationObserver(updateTabindex)
    const toolbar = document.querySelector(".mde-header")

    if (toolbar) {
        observer.observe(toolbar, { childList: true, subtree: true })
    }

    // Cleanup the observer on component unmount
    return () => {
        observer.disconnect()
    }
    }, []) // Empty dependency array to run only once on mount

    ...
}

On reflection, however, I have decided not to include the code. This is because:

  • In order to format the text, you first have to manually select it.
  • Then you have to click a formatting button.
  • But, if you reverse tab from the selected text to a toolbar button, the text selection disappears, so there is nothing for the button to format.

Conclusion: the toolbar formatting buttons are inherently inaccessible to keyboard navigation. (But you can still write and preview markdown code.)


Testing

Tested on Windows 10 with:

  • Chrome
  • Firefox
  • Microsoft Edge

Page tested in both browser and device views.

markdown-notes-app-localstorage's People

Contributors

chrisnajman avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.