fix(component): fix incorrect input component width and height styling (#5292)
after: https://github.com/toeverything/AFFiNE/assets/102217452/5d8f51c5-c7a6-4ec8-b2b0-7f1391f045c7
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import type { FC, HTMLAttributes } from 'react';
|
|
||||||
|
|
||||||
import { Input, type InputProps } from '../../ui/input';
|
import { Input, type InputProps } from '../../ui/input';
|
||||||
import * as styles from './share.css';
|
import * as styles from './share.css';
|
||||||
@@ -9,27 +8,25 @@ export type AuthInputProps = InputProps & {
|
|||||||
errorHint?: string;
|
errorHint?: string;
|
||||||
withoutHint?: boolean;
|
withoutHint?: boolean;
|
||||||
onEnter?: () => void;
|
onEnter?: () => void;
|
||||||
wrapperProps?: HTMLAttributes<HTMLDivElement>;
|
|
||||||
};
|
};
|
||||||
export const AuthInput: FC<AuthInputProps> = ({
|
export const AuthInput = ({
|
||||||
label,
|
label,
|
||||||
error,
|
error,
|
||||||
errorHint,
|
errorHint,
|
||||||
withoutHint = false,
|
withoutHint = false,
|
||||||
onEnter,
|
onEnter,
|
||||||
wrapperProps: { className, ...otherWrapperProps } = {},
|
className,
|
||||||
...inputProps
|
...inputProps
|
||||||
}) => {
|
}: AuthInputProps) => {
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={clsx(styles.authInputWrapper, className, {
|
className={clsx(styles.authInputWrapper, {
|
||||||
'without-hint': withoutHint,
|
'without-hint': withoutHint,
|
||||||
})}
|
})}
|
||||||
{...otherWrapperProps}
|
|
||||||
>
|
>
|
||||||
{label ? <label>{label}</label> : null}
|
{label ? <label>{label}</label> : null}
|
||||||
<Input
|
<Input
|
||||||
className={styles.input}
|
className={clsx(className)}
|
||||||
size="extraLarge"
|
size="extraLarge"
|
||||||
status={error ? 'error' : 'default'}
|
status={error ? 'error' : 'default'}
|
||||||
onKeyDown={e => {
|
onKeyDown={e => {
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import { useCallback, useState } from 'react';
|
|||||||
import { Button } from '../../ui/button';
|
import { Button } from '../../ui/button';
|
||||||
import { AuthInput } from './auth-input';
|
import { AuthInput } from './auth-input';
|
||||||
import { AuthPageContainer } from './auth-page-container';
|
import { AuthPageContainer } from './auth-page-container';
|
||||||
|
import * as styles from './share.css';
|
||||||
import { emailRegex } from './utils';
|
import { emailRegex } from './utils';
|
||||||
|
|
||||||
export const ChangeEmailPage = ({
|
export const ChangeEmailPage = ({
|
||||||
@@ -44,6 +45,7 @@ export const ChangeEmailPage = ({
|
|||||||
>
|
>
|
||||||
<>
|
<>
|
||||||
<AuthInput
|
<AuthInput
|
||||||
|
className={styles.input}
|
||||||
label={t['com.affine.settings.email']()}
|
label={t['com.affine.settings.email']()}
|
||||||
placeholder={t['com.affine.auth.sign.email.placeholder']()}
|
placeholder={t['com.affine.auth.sign.email.placeholder']()}
|
||||||
value={email}
|
value={email}
|
||||||
|
|||||||
@@ -74,9 +74,6 @@ export const InviteModal = ({
|
|||||||
error={!isValidEmail}
|
error={!isValidEmail}
|
||||||
errorHint={isValidEmail ? '' : t['com.affine.auth.sign.email.error']()}
|
errorHint={isValidEmail ? '' : t['com.affine.auth.sign.email.error']()}
|
||||||
onEnter={handleConfirm}
|
onEnter={handleConfirm}
|
||||||
wrapperProps={{
|
|
||||||
style: { padding: 0 },
|
|
||||||
}}
|
|
||||||
size="large"
|
size="large"
|
||||||
/>
|
/>
|
||||||
</ConfirmModal>
|
</ConfirmModal>
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
import { style } from '@vanilla-extract/css';
|
||||||
|
|
||||||
|
export const input = style({
|
||||||
|
height: '34px',
|
||||||
|
width: '220px',
|
||||||
|
});
|
||||||
@@ -2,6 +2,7 @@ import { useCallback, useState } from 'react';
|
|||||||
|
|
||||||
import Input from '../../ui/input';
|
import Input from '../../ui/input';
|
||||||
import { Menu } from '../../ui/menu';
|
import { Menu } from '../../ui/menu';
|
||||||
|
import * as styles from './index.css';
|
||||||
|
|
||||||
export const RenameModal = ({
|
export const RenameModal = ({
|
||||||
onRename,
|
onRename,
|
||||||
@@ -32,9 +33,8 @@ export const RenameModal = ({
|
|||||||
}}
|
}}
|
||||||
items={
|
items={
|
||||||
<Input
|
<Input
|
||||||
|
className={styles.input}
|
||||||
autoFocus
|
autoFocus
|
||||||
width={220}
|
|
||||||
style={{ height: 34 }}
|
|
||||||
defaultValue={value}
|
defaultValue={value}
|
||||||
onChange={setValue}
|
onChange={setValue}
|
||||||
onEnter={handleRename}
|
onEnter={handleRename}
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
import { assignInlineVars } from '@vanilla-extract/dynamic';
|
|
||||||
import clsx from 'clsx';
|
import clsx from 'clsx';
|
||||||
import type {
|
import type {
|
||||||
ChangeEvent,
|
ChangeEvent,
|
||||||
@@ -13,11 +12,10 @@ import type {
|
|||||||
} from 'react';
|
} from 'react';
|
||||||
import { forwardRef, useCallback, useState } from 'react';
|
import { forwardRef, useCallback, useState } from 'react';
|
||||||
|
|
||||||
import { input, inputWrapper, widthVar } from './style.css';
|
import { input, inputWrapper } from './style.css';
|
||||||
|
|
||||||
export type InputProps = {
|
export type InputProps = {
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
width?: CSSProperties['width'];
|
|
||||||
onChange?: (value: string) => void;
|
onChange?: (value: string) => void;
|
||||||
onBlur?: FocusEventHandler<HTMLInputElement>;
|
onBlur?: FocusEventHandler<HTMLInputElement>;
|
||||||
onKeyDown?: KeyboardEventHandler<HTMLInputElement>;
|
onKeyDown?: KeyboardEventHandler<HTMLInputElement>;
|
||||||
@@ -34,7 +32,6 @@ export type InputProps = {
|
|||||||
export const Input = forwardRef<HTMLInputElement, InputProps>(function Input(
|
export const Input = forwardRef<HTMLInputElement, InputProps>(function Input(
|
||||||
{
|
{
|
||||||
disabled,
|
disabled,
|
||||||
width,
|
|
||||||
onChange: propsOnChange,
|
onChange: propsOnChange,
|
||||||
noBorder = false,
|
noBorder = false,
|
||||||
className,
|
className,
|
||||||
@@ -78,9 +75,6 @@ export const Input = forwardRef<HTMLInputElement, InputProps>(function Input(
|
|||||||
'extra-large': size === 'extraLarge',
|
'extra-large': size === 'extraLarge',
|
||||||
})}
|
})}
|
||||||
style={{
|
style={{
|
||||||
...assignInlineVars({
|
|
||||||
[widthVar]: width ? `${width}px` : '100%',
|
|
||||||
}),
|
|
||||||
...style,
|
...style,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -1,12 +1,7 @@
|
|||||||
import { createVar, style } from '@vanilla-extract/css';
|
import { style } from '@vanilla-extract/css';
|
||||||
|
|
||||||
export const widthVar = createVar('widthVar');
|
|
||||||
|
|
||||||
export const inputWrapper = style({
|
export const inputWrapper = style({
|
||||||
vars: {
|
width: '100%',
|
||||||
[widthVar]: '100%',
|
|
||||||
},
|
|
||||||
width: widthVar,
|
|
||||||
height: 28,
|
height: 28,
|
||||||
lineHeight: '22px',
|
lineHeight: '22px',
|
||||||
padding: '0 10px',
|
padding: '0 10px',
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import {
|
|||||||
|
|
||||||
import { validateAndReduceImage } from '../../../utils/reduce-image';
|
import { validateAndReduceImage } from '../../../utils/reduce-image';
|
||||||
import { Upload } from '../../pure/file-upload';
|
import { Upload } from '../../pure/file-upload';
|
||||||
import * as style from './style.css';
|
import * as styles from './style.css';
|
||||||
import type { WorkspaceSettingDetailProps } from './types';
|
import type { WorkspaceSettingDetailProps } from './types';
|
||||||
|
|
||||||
export interface ProfilePanelProps extends WorkspaceSettingDetailProps {
|
export interface ProfilePanelProps extends WorkspaceSettingDetailProps {
|
||||||
@@ -168,7 +168,7 @@ export const ProfilePanel = ({ isOwner, workspace }: ProfilePanelProps) => {
|
|||||||
const canAdjustAvatar = !workspaceIsLoading && avatarUrl && isOwner;
|
const canAdjustAvatar = !workspaceIsLoading && avatarUrl && isOwner;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={style.profileWrapper}>
|
<div className={styles.profileWrapper}>
|
||||||
<Upload
|
<Upload
|
||||||
accept="image/gif,image/jpeg,image/jpg,image/png,image/svg"
|
accept="image/gif,image/jpeg,image/jpg,image/png,image/svg"
|
||||||
fileChange={handleUploadAvatar}
|
fileChange={handleUploadAvatar}
|
||||||
@@ -198,13 +198,12 @@ export const ProfilePanel = ({ isOwner, workspace }: ProfilePanelProps) => {
|
|||||||
</Upload>
|
</Upload>
|
||||||
|
|
||||||
<Wrapper marginLeft={20}>
|
<Wrapper marginLeft={20}>
|
||||||
<div className={style.label}>{t['Workspace Name']()}</div>
|
<div className={styles.label}>{t['Workspace Name']()}</div>
|
||||||
<FlexWrapper alignItems="center" flexGrow="1">
|
<FlexWrapper alignItems="center" flexGrow="1">
|
||||||
<Input
|
<Input
|
||||||
disabled={workspaceIsLoading || !isOwner}
|
disabled={workspaceIsLoading || !isOwner}
|
||||||
width={280}
|
|
||||||
height={32}
|
|
||||||
value={input}
|
value={input}
|
||||||
|
className={styles.workspaceNameInput}
|
||||||
data-testid="workspace-name-input"
|
data-testid="workspace-name-input"
|
||||||
placeholder={t['Workspace Name']()}
|
placeholder={t['Workspace Name']()}
|
||||||
maxLength={64}
|
maxLength={64}
|
||||||
|
|||||||
@@ -201,3 +201,8 @@ export const arrowRight = style({
|
|||||||
color: 'var(--affine-text-emphasis-color)',
|
color: 'var(--affine-text-emphasis-color)',
|
||||||
cursor: 'pointer',
|
cursor: 'pointer',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const workspaceNameInput = style({
|
||||||
|
height: '32px',
|
||||||
|
width: '280px',
|
||||||
|
});
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ import { useSelfHosted } from '../../../../hooks/affine/use-server-flavor';
|
|||||||
import { useUserSubscription } from '../../../../hooks/use-subscription';
|
import { useUserSubscription } from '../../../../hooks/use-subscription';
|
||||||
import { validateAndReduceImage } from '../../../../utils/reduce-image';
|
import { validateAndReduceImage } from '../../../../utils/reduce-image';
|
||||||
import { Upload } from '../../../pure/file-upload';
|
import { Upload } from '../../../pure/file-upload';
|
||||||
import * as style from './style.css';
|
import * as styles from './style.css';
|
||||||
|
|
||||||
export const UserAvatar = () => {
|
export const UserAvatar = () => {
|
||||||
const t = useAFFiNEI18N();
|
const t = useAFFiNEI18N();
|
||||||
@@ -133,17 +133,16 @@ export const AvatarAndName = () => {
|
|||||||
<UserAvatar />
|
<UserAvatar />
|
||||||
</Suspense>
|
</Suspense>
|
||||||
|
|
||||||
<div className={style.profileInputWrapper}>
|
<div className={styles.profileInputWrapper}>
|
||||||
<label>{t['com.affine.settings.profile.name']()}</label>
|
<label>{t['com.affine.settings.profile.name']()}</label>
|
||||||
<FlexWrapper alignItems="center">
|
<FlexWrapper alignItems="center">
|
||||||
<Input
|
<Input
|
||||||
|
className={styles.userNameInput}
|
||||||
defaultValue={input}
|
defaultValue={input}
|
||||||
data-testid="user-name-input"
|
data-testid="user-name-input"
|
||||||
placeholder={t['com.affine.settings.profile.placeholder']()}
|
placeholder={t['com.affine.settings.profile.placeholder']()}
|
||||||
maxLength={64}
|
maxLength={64}
|
||||||
minLength={0}
|
minLength={0}
|
||||||
width={280}
|
|
||||||
height={28}
|
|
||||||
onChange={setInput}
|
onChange={setInput}
|
||||||
onEnter={handleUpdateUserName}
|
onEnter={handleUpdateUserName}
|
||||||
/>
|
/>
|
||||||
@@ -151,7 +150,7 @@ export const AvatarAndName = () => {
|
|||||||
<Button
|
<Button
|
||||||
data-testid="save-user-name"
|
data-testid="save-user-name"
|
||||||
onClick={handleUpdateUserName}
|
onClick={handleUpdateUserName}
|
||||||
className={style.button}
|
className={styles.button}
|
||||||
style={{
|
style={{
|
||||||
marginLeft: '12px',
|
marginLeft: '12px',
|
||||||
}}
|
}}
|
||||||
@@ -244,7 +243,7 @@ export const AccountSetting: FC = () => {
|
|||||||
/>
|
/>
|
||||||
<AvatarAndName />
|
<AvatarAndName />
|
||||||
<SettingRow name={t['com.affine.settings.email']()} desc={user.email}>
|
<SettingRow name={t['com.affine.settings.email']()} desc={user.email}>
|
||||||
<Button onClick={onChangeEmail} className={style.button}>
|
<Button onClick={onChangeEmail} className={styles.button}>
|
||||||
{t['com.affine.settings.email.action']()}
|
{t['com.affine.settings.email.action']()}
|
||||||
</Button>
|
</Button>
|
||||||
</SettingRow>
|
</SettingRow>
|
||||||
@@ -252,7 +251,7 @@ export const AccountSetting: FC = () => {
|
|||||||
name={t['com.affine.settings.password']()}
|
name={t['com.affine.settings.password']()}
|
||||||
desc={t['com.affine.settings.password.message']()}
|
desc={t['com.affine.settings.password.message']()}
|
||||||
>
|
>
|
||||||
<Button onClick={onPasswordButtonClick} className={style.button}>
|
<Button onClick={onPasswordButtonClick} className={styles.button}>
|
||||||
{user.hasPassword
|
{user.hasPassword
|
||||||
? t['com.affine.settings.password.action.change']()
|
? t['com.affine.settings.password.action.change']()
|
||||||
: t['com.affine.settings.password.action.set']()}
|
: t['com.affine.settings.password.action.set']()}
|
||||||
|
|||||||
@@ -43,3 +43,8 @@ globalStyle(`${avatarWrapper} .camera-icon-wrapper`, {
|
|||||||
export const button = style({
|
export const button = style({
|
||||||
padding: '4px 12px',
|
padding: '4px 12px',
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const userNameInput = style({
|
||||||
|
height: '32px',
|
||||||
|
width: '280px',
|
||||||
|
});
|
||||||
|
|||||||
@@ -5,6 +5,7 @@ import { type ReactElement, useCallback } from 'react';
|
|||||||
|
|
||||||
import { openAIApiKeyAtom } from '../core/hooks';
|
import { openAIApiKeyAtom } from '../core/hooks';
|
||||||
import { conversationHistoryDBName } from '../core/langchain/message-history';
|
import { conversationHistoryDBName } from '../core/langchain/message-history';
|
||||||
|
import * as styles from './index.css';
|
||||||
|
|
||||||
export const DebugContent = (): ReactElement => {
|
export const DebugContent = (): ReactElement => {
|
||||||
const [key, setKey] = useAtom(openAIApiKeyAtom);
|
const [key, setKey] = useAtom(openAIApiKeyAtom);
|
||||||
@@ -12,7 +13,7 @@ export const DebugContent = (): ReactElement => {
|
|||||||
<div>
|
<div>
|
||||||
<FlexWrapper justifyContent="space-between">
|
<FlexWrapper justifyContent="space-between">
|
||||||
<Input
|
<Input
|
||||||
width={280}
|
className={styles.debugContentInput}
|
||||||
defaultValue={key ?? undefined}
|
defaultValue={key ?? undefined}
|
||||||
onChange={useCallback(
|
onChange={useCallback(
|
||||||
(newValue: string) => {
|
(newValue: string) => {
|
||||||
|
|||||||
@@ -41,3 +41,7 @@ export const sendButtonStyle = style({
|
|||||||
backgroundColor: 'transparent',
|
backgroundColor: 'transparent',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const debugContentInput = style({
|
||||||
|
width: '280px',
|
||||||
|
});
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ Basic.play = async ({ canvasElement }) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const DynamicHeight: StoryFn<typeof Input> = () => {
|
export const DynamicHeight: StoryFn<typeof Input> = () => {
|
||||||
return <Input width={200} data-testid="test-input" />;
|
return <Input style={{ width: '200px' }} data-testid="test-input" />;
|
||||||
};
|
};
|
||||||
|
|
||||||
DynamicHeight.play = async ({ canvasElement }) => {
|
DynamicHeight.play = async ({ canvasElement }) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user