-
-
Notifications
You must be signed in to change notification settings - Fork 312
Notes app #63
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
Open
jaswch
wants to merge
41
commits into
PuruVJ:main
Choose a base branch
from
jaswch:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Notes app #63
Changes from all commits
Commits
Show all changes
41 commits
Select commit
Hold shift + click to select a range
ae4650a
Update README.md
jaswch 77a8a88
Update apps.store.ts
jaswch e89fed1
Update apps-config.ts
jaswch bde2d81
Update AppNexus.svelte
jaswch f9978d4
Create Notes.svelte
jaswch bfedc3e
Create count.svelte
jaswch 58fcf90
Create stores.js
jaswch a7dbd7e
Update README.md
jaswch de3a3d4
Update apps-config.ts
jaswch 1b07714
Delete count.svelte
jaswch 8a0bd12
Update Notes.svelte
jaswch 7cd7bf3
Update AppNexus.svelte
jaswch 4d2e874
Update and rename stores.js to store.ts
jaswch a4ac47e
Update Notes.svelte
jaswch c4dad30
Delete 256.png
jaswch 91580be
Add files via upload
jaswch d65ebfa
Update Notes.svelte
jaswch f68b6e5
Update Notes.svelte
jaswch 19c2c20
Update Notes.svelte
jaswch 7717cf5
Update Notes.svelte
jaswch 845657c
Update Notes.svelte
jaswch 1d1abbc
Update Notes.svelte
jaswch 11703b0
Add files via upload
jaswch 4956615
Update Notes.svelte
jaswch d817456
Delete public/Notes-icons directory
jaswch 23a6b2e
Add files via upload
jaswch 99567a1
Update Notes.svelte
jaswch b741a0a
Add files via upload
jaswch 0df429d
Update apps.store.ts
jaswch fed2bc0
Update AppNexus.svelte
jaswch efbef61
Add files via upload
jaswch a8bbb3c
Update apps-config.ts
jaswch 225f3d4
Update apps.store.ts
jaswch 1575e17
Update apps-config.ts
jaswch 4477485
Update AppNexus.svelte
jaswch 7d1fa3f
Delete Finder.svelte
jaswch 195abe1
Delete public/Finder-side-bar-icons directory
jaswch 28b08eb
Update apps-config.ts
jaswch 1118ff1
Update apps-config.ts
jaswch fce69a7
Merge pull request #2 from jaswch/jaswch-finder
jaswch 3da7a40
Update apps-config.ts
jaswch File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,145 @@ | ||
| <script lang='ts'> | ||
| import { theme } from '🍎/stores/theme.store'; | ||
| import {addNote, notesStore} from './store'; | ||
|
|
||
| const NEW_NOTE = {title: '', text: ''}; | ||
|
|
||
| let editing = false; | ||
| let note; | ||
| let selectedId; | ||
jaswch marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| let textInput; | ||
| let titleInput; | ||
|
|
||
| $: sortedNotes = Object.values($notesStore).sort(); | ||
| $: note = $notesStore[selectedId] || NEW_NOTE; | ||
|
|
||
| function deleteNote() { | ||
| notesStore.update(notes => { | ||
| delete notes[note.id]; | ||
| return notes; | ||
| }); | ||
| } | ||
|
|
||
| function editNote() { | ||
| textInput.focus(); | ||
| editing = true; | ||
| } | ||
|
|
||
| function handleSubmit() { | ||
| // do nothing for now | ||
| } | ||
|
|
||
| function newNote() { | ||
| selectedId = addNote('', ''); | ||
| editing = true; | ||
| titleInput.focus(); | ||
| } | ||
|
|
||
| </script> | ||
|
|
||
| <section class="container"> | ||
| <header class="titlebar app-window-drag-handle"> | ||
| <span> | ||
| <label for="title"/> | ||
| <input id="title" readonly={!editing} bind:this={titleInput} bind:value={note.title} /> | ||
| </span> | ||
| <div> | ||
| <button disabled={!note.id} on:click={deleteNote}><img src="/Notes-icons/delete.webp" alt="delete"></button> | ||
| <button disabled={!note.id} on:click={editNote}><img src="/Notes-icons/edit.webp" alt="edit"></button> | ||
| <button on:click={newNote}><img src="/Notes-icons/New.webp" alt="new"></button> | ||
|
|
||
| </div> | ||
| </header> | ||
|
|
||
| <aside class:light={$theme.scheme === 'light'}> | ||
| <div> | ||
| <select bind:value={selectedId}> | ||
| <option>Select note</option> | ||
| {#each sortedNotes as note} | ||
| <option value={note.id}>{note.title}</option> | ||
| {/each} | ||
| </select> | ||
| </div> | ||
| </aside> | ||
|
|
||
| <section class="content"> | ||
| <form on:submit|preventDefault={handleSubmit}> | ||
| <textarea readonly={!editing} rows="10" bind:this={textInput} bind:value={note.text} /> | ||
| </form> | ||
| </section> | ||
| </section> | ||
|
|
||
|
|
||
| <style lang="scss"> | ||
| .container { | ||
| --color: var(--system-color-light-hsl); | ||
|
|
||
| display: grid; | ||
| grid-template-columns: 12rem 1fr; | ||
| grid-template-rows: 3rem 1fr; | ||
|
|
||
| border-radius: inherit; | ||
|
|
||
| background-image: linear-gradient( | ||
| to right, | ||
| hsla(var(--color), 0.7) 12rem, | ||
| hsla(var(--color), 1) 12rem 100% | ||
| ); | ||
|
|
||
| transition: --color 200ms ease-in; | ||
|
|
||
| color: var(--system-color-dark); | ||
| } | ||
|
|
||
| .titlebar { | ||
| grid-area: 1 / 1 / span 1 / span 2; | ||
|
|
||
| display: flex; | ||
| justify-content: right; | ||
|
|
||
| z-index: 1; | ||
|
|
||
| padding: 0.9rem 1rem; | ||
|
|
||
| width: 100%; | ||
|
|
||
| border-top-left-radius: inherit; | ||
| border-top-right-radius: inherit; | ||
|
|
||
| user-select: none; | ||
|
|
||
| } | ||
|
|
||
| .content { | ||
| border-top: solid 0.9px hsla(var(--system-color-dark-hsl), 0.3); | ||
| grid-area: 2 / 2 / span 1 / span 1; | ||
|
|
||
| display: flex; | ||
| flex-direction: column; | ||
| align-items: left; | ||
|
|
||
| padding: 1rem; | ||
| } | ||
|
|
||
| select{ | ||
| border: none; | ||
| background: none; | ||
| color: hsla(var(--system-color-dark-hsl), 0.8); | ||
| } | ||
|
|
||
| textarea{ | ||
| border: none; | ||
| background: none; | ||
| color: hsla(var(--system-color-dark-hsl), 0.8); | ||
| resize: none; | ||
| height: 295%; | ||
| width: 95%; | ||
| } | ||
|
|
||
| input{ | ||
| border: none; | ||
| background: none; | ||
| color: hsla(var(--system-color-dark-hsl), 0.8); | ||
| font-size: large; | ||
| } | ||
| </style> | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| import {writable} from 'svelte/store'; | ||
|
|
||
| let lastId = 0; | ||
|
|
||
| type Note = { | ||
| id: number; | ||
| title: string; | ||
| text: string; | ||
| } | ||
|
|
||
| // Keys are ids and values are objects with id, title, and text properties. | ||
| export const notesStore = writable<Record<number, Note>>({}); | ||
|
|
||
| export function addNote(title: string, text: string) { | ||
| lastId++; | ||
| const note = {id: lastId, title, text}; | ||
| notesStore.update(notes => { | ||
| notes[lastId] = note; | ||
| return notes; | ||
| }); | ||
| return lastId; | ||
| } | ||
|
|
||
| addNote('About macOS web', 'macOS web is a web replica of macOS created in svelte.'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.