From 38617abc174a4339822f73166c6f2669b2d51568 Mon Sep 17 00:00:00 2001 From: JimmFly <447268514@qq.com> Date: Tue, 19 Dec 2023 08:27:46 +0000 Subject: [PATCH] fix(component): fix incorrect input component width and height styling (#5292) after: https://github.com/toeverything/AFFiNE/assets/102217452/5d8f51c5-c7a6-4ec8-b2b0-7f1391f045c7 --- .../src/components/auth-components/auth-input.tsx | 13 +++++-------- .../auth-components/change-email-page.tsx | 2 ++ .../components/member-components/invite-modal.tsx | 3 --- .../src/components/rename-modal/index.css.ts | 6 ++++++ .../component/src/components/rename-modal/index.tsx | 4 ++-- packages/frontend/component/src/ui/input/input.tsx | 8 +------- .../frontend/component/src/ui/input/style.css.ts | 9 ++------- .../affine/new-workspace-setting-detail/profile.tsx | 9 ++++----- .../new-workspace-setting-detail/style.css.ts | 5 +++++ .../affine/setting-modal/account-setting/index.tsx | 13 ++++++------- .../setting-modal/account-setting/style.css.ts | 5 +++++ packages/plugins/copilot/src/UI/debug-content.tsx | 3 ++- packages/plugins/copilot/src/UI/index.css.ts | 4 ++++ tests/storybook/src/stories/input.stories.tsx | 2 +- 14 files changed, 45 insertions(+), 41 deletions(-) create mode 100644 packages/frontend/component/src/components/rename-modal/index.css.ts diff --git a/packages/frontend/component/src/components/auth-components/auth-input.tsx b/packages/frontend/component/src/components/auth-components/auth-input.tsx index 523b47cb43..8dd8b72605 100644 --- a/packages/frontend/component/src/components/auth-components/auth-input.tsx +++ b/packages/frontend/component/src/components/auth-components/auth-input.tsx @@ -1,5 +1,4 @@ import clsx from 'clsx'; -import type { FC, HTMLAttributes } from 'react'; import { Input, type InputProps } from '../../ui/input'; import * as styles from './share.css'; @@ -9,27 +8,25 @@ export type AuthInputProps = InputProps & { errorHint?: string; withoutHint?: boolean; onEnter?: () => void; - wrapperProps?: HTMLAttributes; }; -export const AuthInput: FC = ({ +export const AuthInput = ({ label, error, errorHint, withoutHint = false, onEnter, - wrapperProps: { className, ...otherWrapperProps } = {}, + className, ...inputProps -}) => { +}: AuthInputProps) => { return (
{label ? : null} { diff --git a/packages/frontend/component/src/components/auth-components/change-email-page.tsx b/packages/frontend/component/src/components/auth-components/change-email-page.tsx index c7b6291eb4..c3694dc130 100644 --- a/packages/frontend/component/src/components/auth-components/change-email-page.tsx +++ b/packages/frontend/component/src/components/auth-components/change-email-page.tsx @@ -4,6 +4,7 @@ import { useCallback, useState } from 'react'; import { Button } from '../../ui/button'; import { AuthInput } from './auth-input'; import { AuthPageContainer } from './auth-page-container'; +import * as styles from './share.css'; import { emailRegex } from './utils'; export const ChangeEmailPage = ({ @@ -44,6 +45,7 @@ export const ChangeEmailPage = ({ > <> diff --git a/packages/frontend/component/src/components/rename-modal/index.css.ts b/packages/frontend/component/src/components/rename-modal/index.css.ts new file mode 100644 index 0000000000..c62659e122 --- /dev/null +++ b/packages/frontend/component/src/components/rename-modal/index.css.ts @@ -0,0 +1,6 @@ +import { style } from '@vanilla-extract/css'; + +export const input = style({ + height: '34px', + width: '220px', +}); diff --git a/packages/frontend/component/src/components/rename-modal/index.tsx b/packages/frontend/component/src/components/rename-modal/index.tsx index 18e0b3013f..453d4e3649 100644 --- a/packages/frontend/component/src/components/rename-modal/index.tsx +++ b/packages/frontend/component/src/components/rename-modal/index.tsx @@ -2,6 +2,7 @@ import { useCallback, useState } from 'react'; import Input from '../../ui/input'; import { Menu } from '../../ui/menu'; +import * as styles from './index.css'; export const RenameModal = ({ onRename, @@ -32,9 +33,8 @@ export const RenameModal = ({ }} items={ void; onBlur?: FocusEventHandler; onKeyDown?: KeyboardEventHandler; @@ -34,7 +32,6 @@ export type InputProps = { export const Input = forwardRef(function Input( { disabled, - width, onChange: propsOnChange, noBorder = false, className, @@ -78,9 +75,6 @@ export const Input = forwardRef(function Input( 'extra-large': size === 'extraLarge', })} style={{ - ...assignInlineVars({ - [widthVar]: width ? `${width}px` : '100%', - }), ...style, }} > diff --git a/packages/frontend/component/src/ui/input/style.css.ts b/packages/frontend/component/src/ui/input/style.css.ts index 2c49ca54f2..3d3ce2bc2d 100644 --- a/packages/frontend/component/src/ui/input/style.css.ts +++ b/packages/frontend/component/src/ui/input/style.css.ts @@ -1,12 +1,7 @@ -import { createVar, style } from '@vanilla-extract/css'; - -export const widthVar = createVar('widthVar'); +import { style } from '@vanilla-extract/css'; export const inputWrapper = style({ - vars: { - [widthVar]: '100%', - }, - width: widthVar, + width: '100%', height: 28, lineHeight: '22px', padding: '0 10px', diff --git a/packages/frontend/core/src/components/affine/new-workspace-setting-detail/profile.tsx b/packages/frontend/core/src/components/affine/new-workspace-setting-detail/profile.tsx index fa4943970c..c33ed29100 100644 --- a/packages/frontend/core/src/components/affine/new-workspace-setting-detail/profile.tsx +++ b/packages/frontend/core/src/components/affine/new-workspace-setting-detail/profile.tsx @@ -22,7 +22,7 @@ import { import { validateAndReduceImage } from '../../../utils/reduce-image'; import { Upload } from '../../pure/file-upload'; -import * as style from './style.css'; +import * as styles from './style.css'; import type { WorkspaceSettingDetailProps } from './types'; export interface ProfilePanelProps extends WorkspaceSettingDetailProps { @@ -168,7 +168,7 @@ export const ProfilePanel = ({ isOwner, workspace }: ProfilePanelProps) => { const canAdjustAvatar = !workspaceIsLoading && avatarUrl && isOwner; return ( -
+
{ -
{t['Workspace Name']()}
+
{t['Workspace Name']()}
{ const t = useAFFiNEI18N(); @@ -133,17 +133,16 @@ export const AvatarAndName = () => { -
+
@@ -151,7 +150,7 @@ export const AvatarAndName = () => { @@ -252,7 +251,7 @@ export const AccountSetting: FC = () => { name={t['com.affine.settings.password']()} desc={t['com.affine.settings.password.message']()} > -