Skip to content
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

fix: edit app name and desc #767

Merged
merged 1 commit into from
Feb 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/silver-dryers-bathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@mochi-ui/theme": minor
---

Fix ContentEditable style
12 changes: 10 additions & 2 deletions apps/mochi-web/components/app/detail/AppDetailStatistics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { Control, Controller } from 'react-hook-form'
import { AppDetailFormValues } from '~types/app'
import { ChangeEvent, useState, useRef } from 'react'
import { API, GET_PATHS } from '~constants/api'
import clsx from 'clsx'
import { StatisticsBox } from '../StatisticsBox'

interface Props {
Expand Down Expand Up @@ -119,7 +120,11 @@ export const AppDetailStatistics = ({
<FormLabel>Display name</FormLabel>
<ContentEditable
{...field}
className="text-sm font-medium"
className={clsx('text-sm font-medium', {
'border border-divider rounded px-3.5 py-2.5':
editing === field.name,
})}
placeholder="Provide a name for your app..."
disabled={editing !== field.name}
onBlur={() => setEditing('')}
ref={(ref) => {
Expand Down Expand Up @@ -158,7 +163,10 @@ export const AppDetailStatistics = ({
<FormLabel>Description</FormLabel>
<ContentEditable
{...field}
className="text-sm font-medium"
className={clsx('text-sm font-medium', {
'border border-divider rounded px-3.5 py-2.5':
editing === field.name,
})}
placeholder="Provide a description for your app..."
disabled={editing !== field.name}
onBlur={() => setEditing('')}
Expand Down
5 changes: 2 additions & 3 deletions apps/mochi-web/pages/applications/[id].tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { AppDetailUrl } from '~cpn/app/detail/AppDetailUrl'
import {
DtoUpdateApplicationInfoRequest,
ViewApplication,
ViewApplicationResponse,
ViewFullApplicationResponse,
} from '~types/mochi-pay-schema'
import { API, GET_PATHS } from '~constants/api'
Expand Down Expand Up @@ -157,8 +156,8 @@ const App: NextPageWithLayout = () => {
body,
GET_PATHS.UPDATE_APPLICATION_DETAIL(profileId, appId),
)
.json((r: ViewApplicationResponse) => {
resetApp(r.data)
.json(() => {
refresh()
})
.catch((e) => {
const err = JSON.parse(e.message)
Expand Down
2 changes: 1 addition & 1 deletion packages/theme/src/components/content-editable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import clsx from 'clsx'

const contentEditableClsx = ({ className = '' }: { className?: string } = {}) =>
clsx(
'outline-none break-all empty:before:content-[attr(placeholder)] before:text-text-secondary before:font-normal',
'outline-none break-all empty:before:content-[attr(placeholder)] before:text-text-disabled before:font-normal',
className,
)

Expand Down
Loading