Skip to content

Commit c4ab87d

Browse files
committed
fix(ui): add website label/placeholder, fix empty string validation, show buttons on mobile
1 parent 2cbf1d9 commit c4ab87d

6 files changed

Lines changed: 30 additions & 17 deletions

File tree

app/pages/profile/[handle]/index.vue

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,15 @@ async function updateProfile() {
3737
// optimistic update
3838
profile.value = {
3939
displayName: displayNameInput.value,
40-
description: descriptionInput.value,
41-
website: websiteInput.value,
40+
description: descriptionInput.value || undefined,
41+
website: websiteInput.value || undefined,
4242
}
4343
4444
try {
4545
const result = await updateProfileUtil(handle.value, {
4646
displayName: displayNameInput.value,
47-
description: descriptionInput.value,
48-
website: websiteInput.value,
47+
description: descriptionInput.value || undefined,
48+
website: websiteInput.value || undefined,
4949
})
5050
5151
if (result.success) {
@@ -103,27 +103,28 @@ defineOgImageComponent('Default', {
103103
class="w-full min-w-25 bg-bg-subtle border border-border rounded-md ps-3 pe-3 py-1.5 font-mono text-sm text-fg placeholder:text-fg-subtle transition-[border-color,outline-color] duration-300 hover:border-fg-subtle outline-2 outline-transparent focus:border-accent focus-visible:(outline-2 outline-accent/70)"
104104
/>
105105
</label>
106+
<label for="website" class="text-sm flex flex-col gap-2">
107+
{{ $t('profile.website') }}
108+
<input
109+
name="website"
110+
type="url"
111+
:placeholder="$t('profile.website_placeholder')"
112+
v-model="websiteInput"
113+
class="w-full min-w-25 bg-bg-subtle border border-border rounded-md ps-3 pe-3 py-1.5 font-mono text-sm text-fg placeholder:text-fg-subtle transition-[border-color,outline-color] duration-300 hover:border-fg-subtle outline-2 outline-transparent focus:border-accent focus-visible:(outline-2 outline-accent/70)"
114+
/>
115+
</label>
106116
<div class="flex gap-4 items-center font-mono text-sm">
107117
<h2>@{{ handle }}</h2>
108-
<div class="link-subtle font-mono text-sm inline-flex items-center gap-1.5">
109-
<span class="text-white i-carbon:link w-4 h-4" aria-hidden="true" />
110-
<input
111-
name="website"
112-
type="url"
113-
v-model="websiteInput"
114-
class="w-full min-w-25 bg-bg-subtle border border-border rounded-md ps-3 pe-3 py-1.5 font-mono text-sm text-fg placeholder:text-fg-subtle transition-[border-color,outline-color] duration-300 hover:border-fg-subtle outline-2 outline-transparent focus:border-accent focus-visible:(outline-2 outline-accent/70)"
115-
/>
116-
</div>
117118
<button
118119
@click="isEditing = false"
119-
class="hidden sm:inline-flex link-subtle font-mono text-sm items-center gap-2 px-2 py-1.5 hover:bg-bg-subtle focus-visible:outline-accent/70 rounded"
120+
class="link-subtle font-mono text-sm inline-flex items-center gap-2 px-2 py-1.5 hover:bg-bg-subtle focus-visible:outline-accent/70 rounded"
120121
>
121122
{{ $t('common.cancel') }}
122123
</button>
123124
<button
124-
@click.prevent="updateProfile"
125+
@click="updateProfile"
125126
:disabled="isUpdateProfileActionPending"
126-
class="hidden sm:inline-flex link-subtle font-mono text-sm items-center gap-2 px-2 py-1.5 hover:bg-bg-subtle focus-visible:outline-accent/70 rounded"
127+
class="link-subtle font-mono text-sm inline-flex items-center gap-2 px-2 py-1.5 hover:bg-bg-subtle focus-visible:outline-accent/70 rounded"
127128
>
128129
{{ $t('common.save') }}
129130
</button>

i18n/locales/en.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@
150150
"display_name": "Display Name",
151151
"description": "Description",
152152
"no_description": "No description",
153+
"website": "Website",
154+
"website_placeholder": "https://example.com",
153155
"likes": "Likes",
154156
"seo_title": "{handle} - npmx",
155157
"seo_description": "npmx profile by {handle}"

i18n/schema.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,12 @@
454454
"no_description": {
455455
"type": "string"
456456
},
457+
"website": {
458+
"type": "string"
459+
},
460+
"website_placeholder": {
461+
"type": "string"
462+
},
457463
"likes": {
458464
"type": "string"
459465
},

lunaria/files/en-GB.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@
149149
"display_name": "Display Name",
150150
"description": "Description",
151151
"no_description": "No description",
152+
"website": "Website",
153+
"website_placeholder": "https://example.com",
152154
"likes": "Likes",
153155
"seo_title": "{handle} - npmx",
154156
"seo_description": "npmx profile by {handle}"

lunaria/files/en-US.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@
149149
"display_name": "Display Name",
150150
"description": "Description",
151151
"no_description": "No description",
152+
"website": "Website",
153+
"website_placeholder": "https://example.com",
152154
"likes": "Likes",
153155
"seo_title": "{handle} - npmx",
154156
"seo_description": "npmx profile by {handle}"

shared/schemas/social.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export type PackageLikeBody = v.InferOutput<typeof PackageLikeBodySchema>
1313
// TODO: add 'avatar'
1414
export const ProfileEditBodySchema = v.object({
1515
displayName: v.pipe(v.string(), v.maxLength(640)),
16-
website: v.optional(v.pipe(v.string(), v.url())),
16+
website: v.optional(v.union([v.literal(''), v.pipe(v.string(), v.url())])),
1717
description: v.optional(v.pipe(v.string(), v.maxLength(2560))),
1818
})
1919

0 commit comments

Comments
 (0)