Skip to content

Commit

Permalink
fix: export HTMLCoralProps
Browse files Browse the repository at this point in the history
  • Loading branch information
wwsun committed Jan 11, 2022
1 parent f8072a6 commit 06a1d8c
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 11 deletions.
10 changes: 8 additions & 2 deletions docs/box.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ export default {

/**
* 必须加 args 参数才能在 docs 中展示 codes,参考 https://github.com/storybookjs/storybook/issues/8104#issuecomment-932310244
* @param args
* @returns
* @param args
* @returns
*/
export const Basic = (args: any) => (
<Box as="button" bg="#FF0000" color="#FFFFFF" fontSize="14px" px="12px" py="4px" border="0" borderRadius="99px">
Expand Down Expand Up @@ -42,6 +42,12 @@ export const As = (args: any) => (
</Box>
);

export const Link = (args: any) => (
<Box as="a" href="https://www.163.com" target="_blank">
open 163.com
</Box>
);

const injectStyle = css`
background: red;
color: white;
Expand Down
6 changes: 3 additions & 3 deletions src/components/flex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { Box } from './box';
import { space, toPercent, toNumber } from '../helpers';
import { useSystem } from '../provider';
import { forwardRef } from '../forwad-ref';
import type { StringOrNumber, CoralProps } from '../types';
import type { StringOrNumber, CoralProps, HTMLCoralProps } from '../types';

export interface FlexProps extends CoralProps {
export interface FlexProps extends HTMLCoralProps<'div'> {
/**
* 间距
*/
Expand Down Expand Up @@ -61,7 +61,7 @@ export const Flex = forwardRef<FlexProps, 'div'>((props, ref) => {
);
});

export interface FlexItemProps extends CoralProps {
export interface FlexItemProps extends HTMLCoralProps<'div'> {
span?: StringOrNumber | 'auto';
}

Expand Down
6 changes: 3 additions & 3 deletions src/components/grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { Box } from './box';
import { isNumber, space } from '../helpers';
import { useSystem } from '../provider';
import { forwardRef } from '../forwad-ref';
import type { StringOrNumber, CoralProps } from '../types';
import type { StringOrNumber, CoralProps, HTMLCoralProps } from '../types';

export interface GridProps extends CoralProps {
export interface GridProps extends HTMLCoralProps<'div'> {
/**
* 列数
*/
Expand Down Expand Up @@ -70,7 +70,7 @@ export const Grid = forwardRef<GridProps, 'div'>((props, ref) => {
);
});

export interface GridItemProps extends CoralProps {
export interface GridItemProps extends HTMLCoralProps<'div'> {
colSpan?: StringOrNumber;
colStart?: CoralProps['gridColumnStart'];
colEnd?: CoralProps['gridColumnEnd'];
Expand Down
4 changes: 2 additions & 2 deletions src/components/group.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { css } from 'styled-components';
import { CoralProps, StringOrNumber } from '../types';
import { HTMLCoralProps, StringOrNumber } from '../types';
import { space } from '../helpers';
import { Box } from './box';
import { useSystem } from '../provider';
Expand Down Expand Up @@ -33,7 +33,7 @@ const normalStyle = css<any>`
}
`;

export interface GroupProps extends CoralProps {
export interface GroupProps extends HTMLCoralProps<'div'> {
/**
* 是否吸附在一起
*/
Expand Down
1 change: 0 additions & 1 deletion src/components/text.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ export interface TextProps {

export const Text = coral<As, TextProps>('span', textStyle, {
attrs: (props) => ({
color: 'text.normal',
textAlign: props.align,
$truncated: props.truncated,
$lineClamp: props.lineClamp,
Expand Down
6 changes: 6 additions & 0 deletions src/types/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,12 @@ export interface CoralProps extends SystemProps {
css?: Interpolation<any>;
}

export type HTMLCoralProps<T extends As> = Omit<
PropsOf<T>,
T extends 'svg' ? 'ref' | 'children' | keyof SystemProps : 'ref' | keyof SystemProps
> &
CoralProps & { as?: As };

export type OmitCommonProps<Target, OmitAdditionalProps extends keyof any = never> = Omit<
Target,
'transition' | 'as' | 'color' | OmitAdditionalProps
Expand Down

0 comments on commit 06a1d8c

Please sign in to comment.