feat: export all types related to components (#562)

* feat: export all types related to components

fix(tooltip): fix the vertical offset of the arrow

* refactor: optimize events of all popup related components

* test: append testcases for popup base component

* test: add testcase for visible events

* test: update snapshots
This commit is contained in:
witt
2021-06-23 23:05:59 +08:00
committed by unix
parent 7facec3849
commit de0c8fee97
117 changed files with 1062 additions and 586 deletions

View File

@@ -4,15 +4,16 @@ import { NormalTypes } from '../utils/prop-types'
import { GeistUIThemesPalette } from '../themes/presets'
import useScaleable, { withScaleable } from '../use-scaleable'
export type LoadingTypes = NormalTypes
interface Props {
type?: NormalTypes
type?: LoadingTypes
color?: string
className?: string
spaceRatio?: number
}
const defaultProps = {
type: 'default' as NormalTypes,
type: 'default' as LoadingTypes,
className: '',
spaceRatio: 1,
}
@@ -21,11 +22,11 @@ type NativeAttrs = Omit<React.HTMLAttributes<any>, keyof Props>
export type LoadingProps = Props & NativeAttrs
const getIconBgColor = (
type: NormalTypes,
type: LoadingTypes,
palette: GeistUIThemesPalette,
color?: string,
) => {
const colors: { [key in NormalTypes]: string } = {
const colors: { [key in LoadingTypes]: string } = {
default: palette.accents_6,
secondary: palette.secondary,
success: palette.success,
@@ -46,11 +47,10 @@ const LoadingComponent: React.FC<React.PropsWithChildren<LoadingProps>> = ({
}: React.PropsWithChildren<LoadingProps> & typeof defaultProps) => {
const theme = useTheme()
const { SCALES } = useScaleable()
const bgColor = useMemo(() => getIconBgColor(type, theme.palette, color), [
type,
theme.palette,
color,
])
const bgColor = useMemo(
() => getIconBgColor(type, theme.palette, color),
[type, theme.palette, color],
)
return (
<div className={`loading-container ${className}`} {...props}>