Skip to content

Commit

Permalink
fix: edit app name and desc
Browse files Browse the repository at this point in the history
  • Loading branch information
leduyhien152 committed Feb 19, 2024
1 parent 6b006ac commit a930ffc
Show file tree
Hide file tree
Showing 4 changed files with 20 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
14 changes: 12 additions & 2 deletions apps/mochi-web/components/app/detail/AppDetailStatistics.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import {
FormErrorMessage,
FormLabel,
IconButton,
TextFieldInput,

Check failure on line 9 in apps/mochi-web/components/app/detail/AppDetailStatistics.tsx

View workflow job for this annotation

GitHub Actions / ESLint

'TextFieldInput' is defined but never used. Allowed unused vars must match /^_/u
Typography,

Check failure on line 10 in apps/mochi-web/components/app/detail/AppDetailStatistics.tsx

View workflow job for this annotation

GitHub Actions / ESLint

'Typography' is defined but never used. Allowed unused vars must match /^_/u
useToast,
} from '@mochi-ui/core'
import {
Expand All @@ -23,6 +25,7 @@ import { AppDetailFormValues } from '~types/app'
import { ChangeEvent, useState, useRef } from 'react'
import { API, GET_PATHS } from '~constants/api'
import { StatisticsBox } from '../StatisticsBox'
import clsx from 'clsx'

Check failure on line 28 in apps/mochi-web/components/app/detail/AppDetailStatistics.tsx

View workflow job for this annotation

GitHub Actions / ESLint

`clsx` import should occur before import of `../StatisticsBox`

interface Props {
profileId?: string
Expand Down Expand Up @@ -119,7 +122,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 +165,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 a930ffc

Please sign in to comment.