mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-21 12:06:35 +08:00
refactor(component): refactor the implementation of Button and IconButton (#7716)
## Button
- Remove props withoutHoverStyle
refactor hover impl with independent layer, so that hover-color won't affect the background even if is overridden outside
- Update `type` (renamed to `variant`):
- remove `processing` and `warning`
- rename `default` with `secondary`
- Remove `shape` props
- Remove `icon` and `iconPosition`, replaced with `prefix: ReactNode` and `suffix: ReactNode`
- Integrate tooltip for more convenient usage
- New Storybook document
- Focus style
## IconButton
- A Wrapper base on `<Button />`
- Override Button size and variant
- size: `'12' | '14' | '16' | '20' | '24' | number`
These presets size are referenced from the design system.
- variant: `'plain' | 'solid' | 'danger' | 'custom'`
- Inset icon via Button 's prefix
## Fix
- fix some button related issues
- close AF-1159, AF-1160, AF-1161, AF-1162, AF-1163, AF-1158, AF-1157
## Storybook

This commit is contained in:
@@ -17,7 +17,7 @@ export const Component = () => {
|
||||
title={t['com.affine.expired.page.title']()}
|
||||
subtitle={t['com.affine.expired.page.subtitle']()}
|
||||
>
|
||||
<Button type="primary" size="large" onClick={onOpenAffine}>
|
||||
<Button variant="primary" size="large" onClick={onOpenAffine}>
|
||||
{t['com.affine.auth.open.affine']()}
|
||||
</Button>
|
||||
</AuthPageContainer>
|
||||
|
||||
@@ -154,7 +154,7 @@ export const Component = () => {
|
||||
<>
|
||||
{error}
|
||||
<br />
|
||||
<Button type="primary" onClick={() => setRetryKey(i => i + 1)}>
|
||||
<Button variant="primary" onClick={() => setRetryKey(i => i + 1)}>
|
||||
Retry
|
||||
</Button>
|
||||
</>
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
import { style } from '@vanilla-extract/css';
|
||||
|
||||
export const headerCreateNewCollectionIconButton = style({
|
||||
padding: '4px 8px',
|
||||
fontSize: '16px',
|
||||
width: '32px',
|
||||
height: '28px',
|
||||
borderRadius: '8px',
|
||||
transition: 'opacity 0.1s ease-in-out',
|
||||
height: '32px',
|
||||
borderRadius: 8,
|
||||
transition: 'all 0.1s ease-in-out',
|
||||
});
|
||||
export const headerCreateNewButtonHidden = style({
|
||||
opacity: 0,
|
||||
|
||||
@@ -17,8 +17,8 @@ export const AllCollectionHeader = ({
|
||||
<Header
|
||||
right={
|
||||
<IconButton
|
||||
type="default"
|
||||
icon={<PlusIcon fontSize={16} />}
|
||||
size="16"
|
||||
icon={<PlusIcon />}
|
||||
onClick={onCreateCollection}
|
||||
className={clsx(
|
||||
styles.headerCreateNewCollectionIconButton,
|
||||
|
||||
@@ -27,10 +27,8 @@ export const headerCreateNewButton = style({
|
||||
transition: 'opacity 0.1s ease-in-out',
|
||||
});
|
||||
export const headerCreateNewCollectionIconButton = style({
|
||||
padding: '4px 8px',
|
||||
fontSize: '16px',
|
||||
width: '32px',
|
||||
height: '28px',
|
||||
width: '30px',
|
||||
height: '30px',
|
||||
borderRadius: '8px',
|
||||
});
|
||||
export const headerCreateNewButtonHidden = style({
|
||||
|
||||
@@ -19,8 +19,8 @@ export const CollectionDetailHeader = ({
|
||||
right={
|
||||
<>
|
||||
<IconButton
|
||||
type="default"
|
||||
icon={<PlusIcon fontSize={16} />}
|
||||
size="16"
|
||||
icon={<PlusIcon />}
|
||||
onClick={onCreate}
|
||||
className={clsx(
|
||||
styles.headerCreateNewButton,
|
||||
|
||||
@@ -330,7 +330,7 @@ const ConflictList = ({
|
||||
/>
|
||||
}
|
||||
>
|
||||
<IconButton type="plain">
|
||||
<IconButton>
|
||||
<MoreHorizontalIcon />
|
||||
</IconButton>
|
||||
</Menu>
|
||||
|
||||
Reference in New Issue
Block a user