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
Changes from 2 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
22,792 changes: 12,549 additions & 10,243 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions src/components/button/button.less
Original file line number Diff line number Diff line change
@@ -91,6 +91,9 @@
&-warning {
--color: var(--adm-color-warning);
}
&-link {
color: var(--adm-color-primary);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is better to have separate CSS variable for link --adm-color-link, some themes' primary color is different from links. CC @zombieJ

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it is better to have separate CSS variable for link --adm-color-link, some themes' primary color is different from links. CC @zombieJ

done

}

&-block {
display: block;
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`

@@ -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
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 (
@@ -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>
</>
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`

@@ -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(
@@ -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', () => {

Unchanged files with check annotations Beta

)
// Trigger scroll
ref.current!.jumpToToday()

Check warning on line 62 in src/components/calendar-picker/tests/calendar-picker.test.tsx

GitHub Actions / check

Forbidden non-null assertion
act(() => {
jest.runAllTimers()
})
}
render(<Demo />)
expect(Object.keys(config!)).toEqual(['locale'])

Check warning on line 124 in src/components/config-provider/tests/config-provider.test.tsx

GitHub Actions / check

Forbidden non-null assertion
})
})
// Till Now
if (tillNow) {
ret[0].push({
label: renderLabel('now', null!),

Check warning on line 173 in src/components/date-picker/date-picker-date-utils.ts

GitHub Actions / check

Forbidden non-null assertion
value: TILL_NOW,
})
</div>
)
fireEvent.click(container.querySelector('.adm-form-item-label-help')!)

Check warning on line 349 in src/components/form/tests/form.test.tsx

GitHub Actions / check

Forbidden non-null assertion
expect(onClick).not.toHaveBeenCalled()
// Click input
fireEvent.click(container.querySelector('input')!)

Check warning on line 353 in src/components/form/tests/form.test.tsx

GitHub Actions / check

Forbidden non-null assertion
expect(onClick).toHaveBeenCalled()
jest.useRealTimers()
test('numbers that start with 0 should be work', () => {
const ref = createRef<InputRef>()
render(<Input type='number' ref={ref} />)
const input = document.querySelector('input')!

Check warning on line 198 in src/components/input/tests/input.test.tsx

GitHub Actions / check

Forbidden non-null assertion
fireEvent.change(input, {
target: { value: '012' },
})
).toEqual('Bamboo')
// Not close
fireEvent.touchMove(document.querySelector('.adm-popover-inner-content')!)

Check warning on line 20 in src/components/popover/tests/popover.test.tsx

GitHub Actions / check

Forbidden non-null assertion
expect(document.querySelector('.adm-popover-hidden')).toBeFalsy()
// Close
fireEvent.click(plusButton)
expect(onChange).toHaveBeenCalledWith('0.000000000000003')
expect(container.querySelector('input')!.value).toEqual('0.000000000000003')

Check warning on line 255 in src/components/stepper/tests/stepper.test.tsx

GitHub Actions / check

Forbidden non-null assertion
})
})
const maxRows = 5
const { getByRole } = render(<TextArea autoSize={{ minRows, maxRows }} />)
const textarea = getByRole('textbox')
const hiddenTextarea = document.querySelector(

Check warning on line 36 in src/components/text-area/tests/text-area.test.tsx

GitHub Actions / check

Forbidden non-null assertion
`.${classPrefix}-element-hidden`
)!
// mock
test('set rows should be work', () => {
const { getByRole } = render(<TextArea rows={1} autoSize />)
const hiddenTextarea = document.querySelector(

Check warning on line 126 in src/components/text-area/tests/text-area.test.tsx

GitHub Actions / check

Forbidden non-null assertion
`.${classPrefix}-element-hidden`
)!
const textarea = getByRole('textbox')