Skip to content

Commit

Permalink
chore(*): apply assignSubComponent util
Browse files Browse the repository at this point in the history
  • Loading branch information
YSMJ1994 committed Jan 26, 2024
1 parent 6caea8e commit 566df9d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 23 deletions.
6 changes: 2 additions & 4 deletions components/button/index.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
import ConfigProvider from '../config-provider';
import { assignSubComponent } from '../util/component';
import type { ButtonProps, GroupProps } from './types';
import Button from './view/button';
import Group from './view/group';

const WithSubButton = Button as typeof Button & {
Group: typeof Group;
};
WithSubButton.Group = Group;
const WithSubButton = assignSubComponent(Button, { Group });

export type { ButtonProps, GroupProps };

Expand Down
30 changes: 11 additions & 19 deletions components/typography/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,18 @@ import Paragraph from './paragraph';
import Typography from './typography';
import createTitle from './title';
import { TypographyProps, TitleProps, TextProps, ParagraphProps } from './types';
import { assignSubComponent } from '../util/component';

const WithSubTypography = Typography as typeof Typography & {
H1: ReturnType<typeof createTitle>;
H2: ReturnType<typeof createTitle>;
H3: ReturnType<typeof createTitle>;
H4: ReturnType<typeof createTitle>;
H5: ReturnType<typeof createTitle>;
H6: ReturnType<typeof createTitle>;
Text: typeof Text;
Paragraph: typeof Paragraph;
};

WithSubTypography.Text = Text;
WithSubTypography.Paragraph = Paragraph;
WithSubTypography.H1 = createTitle('h1');
WithSubTypography.H2 = createTitle('h2');
WithSubTypography.H3 = createTitle('h3');
WithSubTypography.H4 = createTitle('h4');
WithSubTypography.H5 = createTitle('h5');
WithSubTypography.H6 = createTitle('h6');
const WithSubTypography = assignSubComponent(Typography, {
Text,
Paragraph,
H1: createTitle('h1'),
H2: createTitle('h2'),
H3: createTitle('h3'),
H4: createTitle('h4'),
H5: createTitle('h5'),
H6: createTitle('h6'),
});

export type { TypographyProps, TitleProps, TextProps, ParagraphProps };

Expand Down

0 comments on commit 566df9d

Please sign in to comment.