Skip to content

Commit

Permalink
Merge pull request #63 from kaishens-cn/dev/tree
Browse files Browse the repository at this point in the history
  • Loading branch information
cherishs001 authored May 20, 2024
2 parents 122785a + 2264bdd commit 7cbf39a
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 8 deletions.
8 changes: 4 additions & 4 deletions __test__/button.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,19 @@ describe('Button', () => {
test('Mouse Event', () => {
const button = baseElement.getElementsByTagName('button')[0];
fireEvent.mouseEnter(button);
expect(button.getAttribute('status')).toMatch('hover');
// expect(button.getAttribute('status')).toMatch('hover');
expect(button).toHaveStyle({ backgroundColor: ColorConfig.ActionPrimaryHover });

fireEvent.mouseLeave(button);
expect(button.getAttribute('status')).toMatch('normal');
// expect(button.getAttribute('status')).toMatch('normal');
expect(button).toHaveStyle({ backgroundColor: ColorConfig.ActionPrimaryNormal });

fireEvent.mouseDown(button);
expect(button.getAttribute('status')).toMatch('press');
// expect(button.getAttribute('status')).toMatch('press');
expect(button).toHaveStyle({ backgroundColor: ColorConfig.ActionPrimaryActive });

fireEvent.mouseUp(button);
expect(button.getAttribute('status')).toMatch('hover');
// expect(button.getAttribute('status')).toMatch('hover');
expect(button).toHaveStyle({ backgroundColor: ColorConfig.ActionPrimaryHover });
});
});
8 changes: 6 additions & 2 deletions src/components/button/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,9 @@ export interface ButtonStyleProps {
status?: 'normal' | 'hover' | 'press';
}

export const ButtonTextStyle = styled(Typography.Medium)<Omit<ButtonStyleProps, 'size'> & TypographyProps>`
export const ButtonTextStyle = styled(Typography.Medium).withConfig({
shouldForwardProp: prop => !['inline', 'status', 'button', 'appearance', 'intent'].includes(prop),
})<Omit<ButtonStyleProps, 'size'> & TypographyProps>`
color: ${props => {
if (props.appearance === 'primary' && props.button !== 'default' && props.intent === 'none') {
if (props.status === 'hover') {
Expand Down Expand Up @@ -64,7 +66,9 @@ export const ButtonTextStyle = styled(Typography.Medium)<Omit<ButtonStyleProps,
}} !important;
`;

export const ButtonStyle = styled.button<ButtonStyleProps>`
export const ButtonStyle = styled.button.withConfig({
shouldForwardProp: prop => !['inline', 'status', 'button', 'appearance', 'intent'].includes(prop),
})<ButtonStyleProps>`
outline: none;
display: ${props => {
if (props.inline) {
Expand Down
4 changes: 3 additions & 1 deletion src/components/tree/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ interface TreeNodeRowProps {
status: HandleStatus;
}

export const TreeNodeRow = styled.div<TreeNodeRowProps>`
export const TreeNodeRow = styled.div.withConfig({
shouldForwardProp: prop => !['nodeLevel'].includes(prop),
})<TreeNodeRowProps>`
position: relative;
padding-left: ${props => {
return `${props.nodeLevel * 10}px`;
Expand Down
4 changes: 3 additions & 1 deletion src/styles/typography.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,9 @@ export const getFontHeight = (size: TypographySize) => {
return fontLineHeight75;
};

export const Font = styled.span<FontProps>`
export const Font = styled.span.withConfig({
shouldForwardProp: prop => !['select'].includes(prop),
})<FontProps>`
font-family:
Inter,
-apple-system,
Expand Down

0 comments on commit 7cbf39a

Please sign in to comment.