Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add button link type #6679

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/components/button/button.less
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@
&-warning {
--color: var(--adm-color-warning);
}
&-link {
color: var(--adm-color-link);
}

&-block {
display: block;
Expand Down
12 changes: 6 additions & 6 deletions src/components/button/button.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import React, { forwardRef, useImperativeHandle, useRef, useState } from 'react'
import classNames from 'classnames'
import type {
ReactNode,
ButtonHTMLAttributes,
DetailedHTMLProps,
MouseEventHandler,
ReactNode,
} from 'react'
import classNames from 'classnames'
import DotLoading from '../dot-loading'
import { mergeProps } from '../../utils/with-default-props'
import React, { forwardRef, useImperativeHandle, useRef, useState } from 'react'
import { NativeProps, withNativeProps } from '../../utils/native-props'
import { isPromise } from '../../utils/validate'
import { mergeProps } from '../../utils/with-default-props'
import DotLoading from '../dot-loading'

const classPrefix = `adm-button`

Expand All @@ -19,7 +19,7 @@ type NativeButtonProps = DetailedHTMLProps<
>

export type ButtonProps = {
color?: 'default' | 'primary' | 'success' | 'warning' | 'danger'
color?: 'default' | 'primary' | 'success' | 'warning' | 'danger' | 'link'
fill?: 'solid' | 'outline' | 'none'
size?: 'mini' | 'small' | 'middle' | 'large'
block?: boolean
Expand Down
3 changes: 2 additions & 1 deletion src/components/button/demos/demo1.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import { Button, Space } from 'antd-mobile'
import { DemoBlock } from 'demos'
import React from 'react'

export default () => {
return (
Expand Down Expand Up @@ -55,6 +55,7 @@ export default () => {
<Button color='success'>Success</Button>
<Button color='danger'>Danger</Button>
<Button color='warning'>Warning</Button>
<Button color='link'>Link</Button>
</Space>
</DemoBlock>
</>
Expand Down
12 changes: 8 additions & 4 deletions src/components/button/tests/button.test.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import React, { createRef } from 'react'
import {
act,
fireEvent,
render,
testA11y,
screen,
fireEvent,
sleep,
testA11y,
waitFor,
act,
} from 'testing'
import Button from '../'
import type { ButtonRef } from '..'
import Button from '../'

const classPrefix = `adm-button`

Expand All @@ -25,6 +25,7 @@ describe('Button', () => {
<Button color='success'>Success</Button>
<Button color='danger'>Danger</Button>
<Button color='warning'>Warning</Button>
<Button color='link'>Link</Button>
</>
)
expect(getByText('Primary').closest('button')).toHaveClass(
Expand All @@ -39,6 +40,9 @@ describe('Button', () => {
expect(getByText('Warning').closest('button')).toHaveClass(
`${classPrefix}-warning`
)
expect(getByText('Link').closest('button')).toHaveClass(
`${classPrefix}-link`
)
})

test('renders with fill', () => {
Expand Down
1 change: 1 addition & 0 deletions src/global/theme-dark.less
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ html[data-prefers-color-scheme='dark'] {
--adm-color-success: #34b368;
--adm-color-warning: #ffa930;
--adm-color-danger: #ff4a58;
--adm-color-link: #3086ff;

--adm-color-yellow: #ffa930;
--adm-color-orange: #e65a2b;
Expand Down
17 changes: 9 additions & 8 deletions src/global/theme-default.less
Original file line number Diff line number Diff line change
Expand Up @@ -20,27 +20,28 @@
--adm-color-success: #00b578;
--adm-color-warning: #ff8f1f;
--adm-color-danger: #ff3141;
--adm-color-link: #3086ff;

--adm-color-yellow: #ff9f18;
--adm-color-orange: #ff6430;
--adm-color-wathet: #e7f1ff;

--adm-color-text: #333333;
--adm-color-text-secondary: #666666;
--adm-color-weak: #999999;
--adm-color-light: #cccccc;
--adm-color-border: #eeeeee;
--adm-color-background: #ffffff;
--adm-color-text: #333;
--adm-color-text-secondary: #666;
--adm-color-weak: #999;
--adm-color-light: #ccc;
--adm-color-border: #eee;
--adm-color-background: #fff;

--adm-color-highlight: var(--adm-color-danger);

// Deprecated. We use `--adm-color-text-light-solid` in code
// but keep here for compatible
--adm-color-white: #ffffff;
--adm-color-white: #fff;
--adm-color-box: #f5f5f5;

--adm-color-text-light-solid: var(--adm-color-white);
--adm-color-text-dark-solid: #000000;
--adm-color-text-dark-solid: #000;
--adm-color-fill-content: var(--adm-color-box);

--adm-font-size-main: var(--adm-font-size-5);
Expand Down
Loading