mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-16 17:46:18 +08:00
5870a6097a
* Chore/unit test (#538) * chore: add unit test * chore: add github action for unit test * feat: init firebase * chore: add development secrets * fix: rename auth -> data-services * feat: update blocksuite 0.3.0-alpha.4 (#543) * feat: add requests * feat: optimize swr cache * feat: add Authorization * feat: add confirm-invitation page * feat: add account sdk api and proxy * docs: update contributing (#550) * docs: update contributing * Update CONTRIBUTING.md * Update CONTRIBUTING.md Co-authored-by: ShortCipher5 <me@shortcipher.me> * feat: update api * feat: remove babelrc setting * feat: add create workspace ui * feat: choose workspaces * feat: login modal * feat: authorization api * feat: login status * fix: remove unused variables * feat: login button * fix: lint * fix: workspace id * fix: i18n type error Co-authored-by: MingLiang Wang <mingliangwang0o0@gmail.com> Co-authored-by: ShortCipher5 <me@shortcipher.me>
205 lines
4.5 KiB
TypeScript
205 lines
4.5 KiB
TypeScript
import { absoluteCenter, displayInlineFlex, styled } from '@/styles';
|
|
import { CSSProperties } from 'react';
|
|
import { ButtonProps } from '@/ui/button/interface';
|
|
import { getSize, getButtonColors } from './utils';
|
|
|
|
export const StyledIconButton = styled('button', {
|
|
shouldForwardProp: prop => {
|
|
return ![
|
|
'borderRadius',
|
|
'top',
|
|
'right',
|
|
'width',
|
|
'height',
|
|
'hoverBackground',
|
|
'hoverColor',
|
|
'hoverStyle',
|
|
].includes(prop);
|
|
},
|
|
})<{
|
|
width: number;
|
|
height: number;
|
|
borderRadius: number;
|
|
disabled?: boolean;
|
|
hoverBackground?: CSSProperties['background'];
|
|
hoverColor?: string;
|
|
hoverStyle?: CSSProperties;
|
|
}>(
|
|
({
|
|
theme,
|
|
width,
|
|
height,
|
|
disabled,
|
|
hoverBackground,
|
|
hoverColor,
|
|
hoverStyle,
|
|
}) => {
|
|
return {
|
|
width,
|
|
height,
|
|
color: theme.colors.iconColor,
|
|
...displayInlineFlex('center', 'center'),
|
|
position: 'relative',
|
|
...(disabled ? { cursor: 'not-allowed', pointerEvents: 'none' } : {}),
|
|
transition: 'background .15s',
|
|
|
|
// TODO: we need to add @emotion/babel-plugin
|
|
'::after': {
|
|
content: '""',
|
|
width,
|
|
height,
|
|
borderRadius: width / 5,
|
|
transition: 'background .15s',
|
|
...absoluteCenter({ horizontal: true, vertical: true }),
|
|
},
|
|
|
|
svg: {
|
|
position: 'relative',
|
|
zIndex: 1,
|
|
},
|
|
|
|
':hover': {
|
|
color: hoverColor ?? theme.colors.primaryColor,
|
|
'::after': {
|
|
background: hoverBackground ?? theme.colors.hoverBackground,
|
|
},
|
|
...(hoverStyle ?? {}),
|
|
},
|
|
};
|
|
}
|
|
);
|
|
|
|
export const StyledTextButton = styled('button', {
|
|
shouldForwardProp: prop => {
|
|
return ![
|
|
'borderRadius',
|
|
'top',
|
|
'right',
|
|
'width',
|
|
'height',
|
|
'hoverBackground',
|
|
'hoverColor',
|
|
'hoverStyle',
|
|
].includes(prop);
|
|
},
|
|
})<
|
|
Pick<
|
|
ButtonProps,
|
|
| 'size'
|
|
| 'disabled'
|
|
| 'hoverBackground'
|
|
| 'hoverColor'
|
|
| 'hoverStyle'
|
|
| 'shape'
|
|
| 'type'
|
|
| 'bold'
|
|
>
|
|
>(
|
|
({
|
|
theme,
|
|
size = 'default',
|
|
disabled,
|
|
hoverBackground,
|
|
hoverColor,
|
|
hoverStyle,
|
|
bold = false,
|
|
shape = 'default',
|
|
// TODO: Implement type
|
|
type = 'default',
|
|
}) => {
|
|
const { fontSize, borderRadius, padding, height } = getSize(size);
|
|
console.log('size', size, height);
|
|
|
|
return {
|
|
height,
|
|
paddingLeft: padding,
|
|
paddingRight: padding,
|
|
...displayInlineFlex('flex-start', 'center'),
|
|
position: 'relative',
|
|
...(disabled ? { cursor: 'not-allowed', pointerEvents: 'none' } : {}),
|
|
transition: 'background .15s',
|
|
// TODO: Implement circle shape
|
|
borderRadius: shape === 'default' ? borderRadius : height / 2,
|
|
fontSize,
|
|
fontWeight: bold ? '500' : '400',
|
|
|
|
':hover': {
|
|
color: hoverColor ?? theme.colors.primaryColor,
|
|
background: hoverBackground ?? theme.colors.hoverBackground,
|
|
...(hoverStyle ?? {}),
|
|
},
|
|
};
|
|
}
|
|
);
|
|
|
|
export const StyledButton = styled('button', {
|
|
shouldForwardProp: prop => {
|
|
return !['hoverBackground', 'hoverColor', 'hoverStyle', 'type'].includes(
|
|
prop
|
|
);
|
|
},
|
|
})<
|
|
Pick<
|
|
ButtonProps,
|
|
| 'size'
|
|
| 'disabled'
|
|
| 'hoverBackground'
|
|
| 'hoverColor'
|
|
| 'hoverStyle'
|
|
| 'shape'
|
|
| 'type'
|
|
| 'bold'
|
|
>
|
|
>(
|
|
({
|
|
theme,
|
|
size = 'default',
|
|
disabled,
|
|
hoverBackground,
|
|
hoverColor,
|
|
hoverStyle,
|
|
bold = false,
|
|
shape = 'default',
|
|
type = 'default',
|
|
}) => {
|
|
const { fontSize, borderRadius, padding, height } = getSize(size);
|
|
|
|
return {
|
|
height,
|
|
paddingLeft: padding,
|
|
paddingRight: padding,
|
|
border: '1px solid',
|
|
...displayInlineFlex('flex-start', 'center'),
|
|
position: 'relative',
|
|
...(disabled ? { cursor: 'not-allowed', pointerEvents: 'none' } : {}),
|
|
transition: 'background .15s',
|
|
// TODO: Implement circle shape
|
|
borderRadius: shape === 'default' ? borderRadius : height / 2,
|
|
fontSize,
|
|
fontWeight: bold ? '500' : '400',
|
|
'.affine-button-icon': {
|
|
color: theme.colors.iconColor,
|
|
},
|
|
'>span': {
|
|
marginLeft: '5px',
|
|
},
|
|
// @ts-ignore
|
|
...getButtonColors(theme, type, {
|
|
hoverBackground,
|
|
hoverColor,
|
|
hoverStyle,
|
|
}),
|
|
|
|
//
|
|
// ':hover': {
|
|
// color: hoverColor ?? theme.colors.primaryColor,
|
|
// background: hoverBackground ?? theme.colors.hoverBackground,
|
|
// '.affine-button-icon':{
|
|
//
|
|
// }
|
|
// ...(hoverStyle ?? {}),
|
|
// },
|
|
};
|
|
}
|
|
);
|