misc: tweak placeholders

This commit is contained in:
James Xylight committed 2025-02-08 21:24:58 -08:00
1 parent 74c7368e47
commit 52bf2b835d
4 files changed
+31 -19

No files matched your search

@@ -330,7 +330,7 @@
<MarkdownEditor
label={$t('form.post.body')}
bind:value={data.body}
placeholder={placeholders.get('post')}
placeholder={placeholders.get('body')}
previewButton
/>
{#if data.url !== undefined}
+5
View File
@@ -912,5 +912,10 @@
"stats": {
"joined": "Joined",
"created": "Created"
},
"placeholders": {
"title": "Add a post title",
"body": "What do you have to say?",
"comments": "Join the conversation"
}
}
+1 -1
View File
@@ -143,7 +143,7 @@ export const defaultSettings: Settings = {
},
],
},
randomPlaceholders: toBool(env.PUBLIC_RANDOM_PLACEHOLDERS) ?? true,
randomPlaceholders: toBool(env.PUBLIC_RANDOM_PLACEHOLDERS) ?? false,
modlogCardView: toBool(env.PUBLIC_MODLOG_CARD_VIEW) ?? undefined,
debugInfo: toBool(env.PUBLIC_DEBUG_INFO) ?? false,
expandImages: toBool(env.PUBLIC_EXPAND_IMAGES) ?? true,
+24 -17
View File
@@ -7,6 +7,7 @@ import { page } from '$app/state'
import { feature } from '$lib/version.js'
import { client } from '$lib/lemmy.js'
import { site } from './lemmy'
import { t } from './translations'
// Despite the name, this will round up
// Example: findClosestNumber([8, 16, 32, 64, 128], 76) will return 128
@@ -32,32 +33,38 @@ export const fullCommunityName = (name: string, actorId: string) =>
`${name}@${new URL(actorId).hostname}`
export const placeholders = {
url: ['https://www.youtube.com/watch?v=dQw4w9WgXcQ'],
url: ['https://example.com'],
post: [
'Is starting nuclear warfare illegal?',
"AITA for making somebody's day?",
'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 would be beneficial to humanity',
'LPT: The smaller weights are easier to lift than the bigger weights in a gym',
'ELI5: What is 4 + 8?',
'Does anybody read these placeholders?',
'Top 10 reasons why a meteor would help Earth',
'Title text',
'I took a picture of something idk',
],
body: ['bottom text', 'body text', 'body text'],
comment: [
'what?',
'new response just dropped',
"i did not read this post at all and i'm about to give my opinion on it.",
'this comment placeholder is very important dont forget',
'huh. i did not understand any of that.',
'existential crisis in progress',
'hello user i am a sentient placeholder. please dont type anything or i disappear forever. thanks',
],
get: (type: 'url' | 'post' | 'comment') => {
return settings.randomPlaceholders
? placeholders[type][
Math.floor(Math.random() * placeholders[type].length)
]
: ''
get: (type: 'url' | 'post' | 'body' | 'comment') => {
if (settings.randomPlaceholders) {
return placeholders[type][
Math.floor(Math.random() * placeholders[type].length)
]
}
switch (type) {
case 'post':
return t.get('placeholders.title')
case 'body':
return t.get('placeholders.body')
case 'comment':
return t.get('placeholders.comments')
case 'url':
return 'https://example.com'
}
},
}