Skip to content

Commit

Permalink
fix: edit app name and desc (#767)
Browse files Browse the repository at this point in the history
  • Loading branch information
leduyhien152 authored Feb 22, 2024
1 parent 836acdf commit 6d96390
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 6 deletions.
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

0 comments on commit 6d96390

Please sign in to comment.