feat: update placeholder system
This commit is contained in:
1 parent
d24e94b365
commit
f2c9b5171b
5 files changed
+60
-25
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "photon-lemmy",
|
"name": "photon-lemmy",
|
||||||
"version": "0.5.1",
|
"version": "0.5.2",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "vite dev",
|
"dev": "vite dev",
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
import { profile } from '$lib/auth.js'
|
import { profile } from '$lib/auth.js'
|
||||||
import { toast } from '$lib/components/ui/toasts/toasts.js'
|
import { toast } from '$lib/components/ui/toasts/toasts.js'
|
||||||
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
||||||
|
import { placeholders } from '$lib/util.js'
|
||||||
|
|
||||||
export let postId: number
|
export let postId: number
|
||||||
export let parentId: number | undefined = undefined
|
export let parentId: number | undefined = undefined
|
||||||
@@ -68,7 +69,9 @@
|
|||||||
{:else}
|
{:else}
|
||||||
<MarkdownEditor
|
<MarkdownEditor
|
||||||
rows={4}
|
rows={4}
|
||||||
placeholder={locked ? 'This post is locked.' : 'What are you thinking?'}
|
placeholder={locked
|
||||||
|
? 'This post is locked.'
|
||||||
|
: placeholders.get('comment')}
|
||||||
bind:value
|
bind:value
|
||||||
disabled={locked}
|
disabled={locked}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
import { Check, Icon } from 'svelte-hero-icons'
|
import { Check, Icon } from 'svelte-hero-icons'
|
||||||
import { profile } from '$lib/auth.js'
|
import { profile } from '$lib/auth.js'
|
||||||
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
|
||||||
|
import { placeholders } from '$lib/util.js'
|
||||||
|
|
||||||
export let edit = false
|
export let edit = false
|
||||||
|
|
||||||
@@ -42,25 +43,6 @@
|
|||||||
loading: false,
|
loading: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
const placeholders = [
|
|
||||||
'Is starting nuclear warfare illegal?',
|
|
||||||
'A cool photo I took before the destruction of mankind!',
|
|
||||||
'AITA for ending all contention and causing world peace?',
|
|
||||||
'BREAKING NEWS: Police break into gun shop, find weapons',
|
|
||||||
'How do I make sure my pet rock stays alive?',
|
|
||||||
'My cat just invented a time machine, what do I do?',
|
|
||||||
'Unpopular opinion: world peace and global happiness would be beneficial to humanity',
|
|
||||||
'LPT: The smaller weights are easier to lift than the bigger weights in a gym',
|
|
||||||
'javascript bad',
|
|
||||||
'ELI5: What is 4 + 8?',
|
|
||||||
]
|
|
||||||
|
|
||||||
const placeholder =
|
|
||||||
placeholders[Math.floor(Math.random() * placeholders.length)]
|
|
||||||
|
|
||||||
const placeholder2 =
|
|
||||||
placeholders[Math.floor(Math.random() * placeholders.length)]
|
|
||||||
|
|
||||||
let communities: Community[] = []
|
let communities: Community[] = []
|
||||||
|
|
||||||
const dispatcher = createEventDispatcher<{ submit: PostView }>()
|
const dispatcher = createEventDispatcher<{ submit: PostView }>()
|
||||||
@@ -96,6 +78,17 @@
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!data.title || !$profile?.jwt) return
|
if (!data.title || !$profile?.jwt) return
|
||||||
|
if (data.url && data.url != '') {
|
||||||
|
try {
|
||||||
|
new URL(data.url)
|
||||||
|
} catch (err) {
|
||||||
|
toast({
|
||||||
|
content: 'Invalid URL',
|
||||||
|
type: 'warning',
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
data.loading = true
|
data.loading = true
|
||||||
|
|
||||||
@@ -193,17 +186,22 @@
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/if}
|
||||||
<TextInput required label="Title" bind:value={data.title} {placeholder} />
|
<TextInput
|
||||||
|
required
|
||||||
|
label="Title"
|
||||||
|
bind:value={data.title}
|
||||||
|
placeholder={placeholders.get('post')}
|
||||||
|
/>
|
||||||
<TextInput
|
<TextInput
|
||||||
label="URL"
|
label="URL"
|
||||||
bind:value={data.url}
|
bind:value={data.url}
|
||||||
placeholder="https://notascam.com"
|
placeholder={placeholders.get('url')}
|
||||||
/>
|
/>
|
||||||
<MarkdownEditor
|
<MarkdownEditor
|
||||||
rows={6}
|
rows={6}
|
||||||
label="Body"
|
label="Body"
|
||||||
bind:value={data.body}
|
bind:value={data.body}
|
||||||
placeholder={placeholder2}
|
placeholder={placeholders.get('post')}
|
||||||
previewButton
|
previewButton
|
||||||
/>
|
/>
|
||||||
<div>
|
<div>
|
||||||
|
|||||||
@@ -111,7 +111,9 @@ overflow-hidden"
|
|||||||
{:else}
|
{:else}
|
||||||
<!--Toolbar-->
|
<!--Toolbar-->
|
||||||
<div
|
<div
|
||||||
class="[&>*]:flex-shrink-0 flex flex-row overflow-auto p-1.5 gap-1.5"
|
class="[&>*]:flex-shrink-0 flex flex-row overflow-auto p-1.5 gap-1.5 {$$props.disabled
|
||||||
|
? 'opacity-60 pointer-events-none'
|
||||||
|
: ''}"
|
||||||
>
|
>
|
||||||
<Button
|
<Button
|
||||||
on:click={() => wrapSelection('**', '**')}
|
on:click={() => wrapSelection('**', '**')}
|
||||||
|
|||||||
@@ -20,3 +20,35 @@ export const searchParam = (
|
|||||||
|
|
||||||
export const fullCommunityName = (name: string, actorId: string) =>
|
export const fullCommunityName = (name: string, actorId: string) =>
|
||||||
`${name}@${new URL(actorId).hostname}`
|
`${name}@${new URL(actorId).hostname}`
|
||||||
|
|
||||||
|
export const placeholders = {
|
||||||
|
url: ['https://notas.cam', 'https://www.youtube.com/watch?v=dQw4w9WgXcQ'],
|
||||||
|
post: [
|
||||||
|
'Is starting nuclear warfare illegal?',
|
||||||
|
'A cool photo I took before the destruction of mankind!',
|
||||||
|
'AITA for ending all contention and causing world peace?',
|
||||||
|
'BREAKING NEWS: Police break into gun shop, find weapons',
|
||||||
|
'How do I make sure my pet rock stays alive?',
|
||||||
|
'My cat just invented a time machine, what do I do?',
|
||||||
|
'Unpopular opinion: world peace and global happiness would be beneficial to humanity',
|
||||||
|
'LPT: The smaller weights are easier to lift than the bigger weights in a gym',
|
||||||
|
'javascript bad',
|
||||||
|
'ELI5: What is 4 + 8?',
|
||||||
|
],
|
||||||
|
comment: [
|
||||||
|
'aint no way',
|
||||||
|
'new response just dropped',
|
||||||
|
'<insert funny joke here>',
|
||||||
|
'say, why did we name restaurant staff after computers, anyway?',
|
||||||
|
`this.\nedit: thanks for 1 upvote😃😃😃!`,
|
||||||
|
'Officer, I drop kicked that child in self defense! You gotta believe me man.',
|
||||||
|
'this comment placeholder is very important dont forget',
|
||||||
|
'As Abraham Lincoln once said, "don\'t believe everything you see on the internet."',
|
||||||
|
'existential crisis in progress',
|
||||||
|
],
|
||||||
|
get: (type: 'url' | 'post' | 'comment') => {
|
||||||
|
return placeholders[type][
|
||||||
|
Math.floor(Math.random() * placeholders[type].length)
|
||||||
|
]
|
||||||
|
},
|
||||||
|
}
|
||||||
Reference in new issue
Block a user