Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@
"vinyl-fs": "^4.0.0",
"vite": "^5.1.3",
"vite-plugin-dts": "4.2.1",
"vitest": "^3.0.0",
"vitest": "^3.0.7",
"vitest-canvas-mock": "^0.3.3",
"yargs": "^17.7.2"
},
Expand Down
137 changes: 77 additions & 60 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/packages/button/button.scss
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,7 @@
}

&-disabled,
&-disabled.nut-button-icononly,
&-solid-disabled {
color: $button-primary-color;
background: $button-primary-disabled;
Expand Down
47 changes: 24 additions & 23 deletions src/packages/button/demos/taro/demo4.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from 'react'
import { Text } from '@tarojs/components'
import { Button, Cell } from '@nutui/nutui-react-taro'
import { Plus, Star } from '@nutui/icons-react-taro'
import { harmony } from '@/utils/platform-taro'
Expand All @@ -13,42 +14,42 @@ const Demo4 = () => {
<Cell style={{ flexWrap: 'wrap' }}>
<Button
type="primary"
icon={<Star />}
rightIcon={<Star />}
icon={<Star color="#ffffff" />}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

其实只有 鸿蒙不支持,感觉写了浪费~
默认的放在样式里写更好。

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Icon 使用的 currentcolor,鸿蒙不支持,所以才这样写的

rightIcon={<Star color="#ffffff" />}
style={marginStyle}
Comment thread
oasis-cloud marked this conversation as resolved.
>
Button
</Button>
<Button
type="primary"
fill="outline"
icon={<Star />}
rightIcon={<Star />}
icon={<Star color="#ff0f23" />}
rightIcon={<Star color="#ff0f23" />}
style={marginStyle}
>
Button
</Button>
<Button
type="primary"
fill="dashed"
icon={<Star />}
rightIcon={<Star />}
icon={<Star color="#ff0f23" />}
rightIcon={<Star color="#ff0f23" />}
style={marginStyle}
>
Button
</Button>
<Button
icon={<Star />}
rightIcon={<Star />}
icon={<Star color="#ff0f23" />}
rightIcon={<Star color="#ff0f23" />}
style={{
margin: 8,
width: harmony() ? 140 : 'auto',
backgroundColor: `var(--nutui-color-primary-light-pressed)`,
borderColor: `var(--nutui-color-primary)`,
color: `var(--nutui-color-primary)`,
backgroundColor: `#ffebf1`,

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

这种需要给它加个 harmony 判断,保留其他端自定义变量的支持~

borderColor: `#ff0f23`,
color: `#ff0f23`,
}}
>
Button
<Text style={{ color: '#ff0f23' }}>Button</Text>
</Button>
<Button
type="default"
Expand All @@ -58,8 +59,8 @@ const Demo4 = () => {
style={{
margin: 8,
width: harmony() ? 140 : 'auto',
backgroundColor: `var(--nutui-gray-3)`,
color: `var(--nutui-gray-7)`,
backgroundColor: `#f2f3f5`,
color: `#1a1a1a`,
}}
>
Button
Expand All @@ -72,8 +73,8 @@ const Demo4 = () => {
style={{
margin: 8,
width: harmony() ? 140 : 'auto',
backgroundColor: `var(--nutui-gray-1)`,
color: `var(--nutui-gray-7)`,
backgroundColor: `#ffffff`,
Comment thread
oasis-cloud marked this conversation as resolved.
color: `#1a1a1a`,
}}
>
Button
Expand All @@ -90,23 +91,23 @@ const Demo4 = () => {
shape="square"
fill="outline"
type="primary"
icon={<Plus size={10} />}
icon={<Plus size={10} color="#ff0f23" />}
style={{
margin: 8,
}}
/>
<Button
fill="outline"
type="primary"
icon={<Plus size={10} />}
icon={<Plus size={10} color="#ff0f23" />}
style={{
margin: 8,
}}
/>
<Button
type="primary"
fill="dashed"
icon={<Plus size={10} />}
icon={<Plus size={10} color="#ff0f23" />}
style={{
margin: 8,
}}
Expand All @@ -115,8 +116,8 @@ const Demo4 = () => {
shape="round"
type="primary"
size="large"
icon={<Star />}
rightIcon={<Star />}
icon={<Star color="#ffffff" />}
rightIcon={<Star color="#ffffff" />}
style={marginStyle}
>
Button
Expand All @@ -125,8 +126,8 @@ const Demo4 = () => {
shape="round"
type="primary"
size="xlarge"
icon={<Star />}
rightIcon={<Star />}
icon={<Star color="#ffffff" />}
rightIcon={<Star color="#ffffff" />}
style={marginStyle}
>
Button
Expand Down
52 changes: 27 additions & 25 deletions src/packages/button/demos/taro/demo5.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ const Demo5 = () => {
<Button
disabled
type="primary"
icon={<Star />}
rightIcon={<Star />}
icon={<Star color="#ffffff" />}
rightIcon={<Star color="#ffffff" />}
style={marginStyle}
>
Disabled
Expand All @@ -24,8 +24,8 @@ const Demo5 = () => {
disabled
type="primary"
fill="outline"
icon={<Star />}
rightIcon={<Star />}
icon={<Star color="#ffadbe" />}
rightIcon={<Star color="#ffadbe" />}
Comment thread
oasis-cloud marked this conversation as resolved.
style={marginStyle}
>
Disabled
Expand All @@ -34,17 +34,17 @@ const Demo5 = () => {
disabled
type="primary"
fill="dashed"
icon={<Star />}
rightIcon={<Star />}
icon={<Star color="#ffadbe" />}
rightIcon={<Star color="#ffadbe" />}
style={marginStyle}
>
Disabled
</Button>
<Button
disabled
fill="solid"
icon={<Star />}
rightIcon={<Star />}
icon={<Star color="#ffffff" />}
rightIcon={<Star color="#ffffff" />}
style={marginStyle}
>
Disabled
Expand All @@ -53,13 +53,13 @@ const Demo5 = () => {
disabled
type="default"
fill="none"
icon={<Star />}
rightIcon={<Star />}
icon={<Star color="#888b94" />}
rightIcon={<Star color="#888b94" />}
style={{
margin: 8,
width: harmony() ? 140 : 'auto',
backgroundColor: `var(--nutui-gray-3)`,
color: `var(--nutui-gray-5)`,
backgroundColor: `#f2f3f5`,
color: `#888b94`,
}}
>
Disabled
Expand All @@ -68,21 +68,21 @@ const Demo5 = () => {
disabled
type="default"
fill="none"
icon={<Star />}
rightIcon={<Star />}
icon={<Star color="#888b94" />}
rightIcon={<Star color="#888b94" />}
style={{
margin: 8,
width: harmony() ? 140 : 'auto',
backgroundColor: `var(--nutui-gray-1)`,
color: `var(--nutui-gray-5)`,
backgroundColor: `#ffffff`,
color: `#888b94`,
}}
>
Disabled
</Button>
<Button
disabled
icon={<Star />}
rightIcon={<Star />}
icon={<Star color="#ffffff" />}
rightIcon={<Star color="#ffffff" />}
style={marginStyle}
>
Disabled
Expand All @@ -92,24 +92,26 @@ const Demo5 = () => {
shape="square"
fill="outline"
type="primary"
icon={<Plus size={10} />}
icon={<Plus size={10} color="rgb(255, 173, 190)" />}
style={{
margin: 8,
}}
/>
<Button
disabled
type="primary"
icon={<Plus size={10} />}
icon={<Plus size={10} color="#ffffff" />}
style={{
margin: 8,
backgroundColor: '#ffadbe',
borderColor: '#ffadbe',
}}
/>
<Button
disabled
type="primary"
fill="dashed"
icon={<Plus size={10} />}
icon={<Plus size={10} color="#ffadbe" />}
style={{
margin: 8,
}}
Expand All @@ -119,8 +121,8 @@ const Demo5 = () => {
shape="round"
type="primary"
size="large"
icon={<Star />}
rightIcon={<Star />}
icon={<Star color="#ffffff" />}
rightIcon={<Star color="#ffffff" />}
style={marginStyle}
>
Disabled
Expand All @@ -130,8 +132,8 @@ const Demo5 = () => {
shape="round"
type="primary"
size="xlarge"
icon={<Star />}
rightIcon={<Star />}
icon={<Star color="#ffffff" />}
rightIcon={<Star color="#ffffff" />}
style={marginStyle}
>
Disabled
Expand Down
26 changes: 15 additions & 11 deletions src/packages/checkbox/__test__/__snapshots__/checkbox.spec.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,22 @@ exports[`should match snapshot 1`] = `
<div
class="nut-checkbox nut-checkbox-reverse"
>
<svg
aria-labelledby="Checked"
class="nut-icon nut-icon-Checked nut-checkbox-icon nut-checkbox-icon-checked"
role="presentation"
viewBox="0 0 16 16"
xmlns="http://www.w3.org/2000/svg"
<div
class="nut-checkbox-icon-wrap"
>
<path
d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16m4.325-10.117-5.318 5.362-3.332-3.36a.25.25 0 0 1 0-.351l.701-.707a.25.25 0 0 1 .355 0L7.007 9.12l4.262-4.297a.25.25 0 0 1 .355 0l.701.707a.25.25 0 0 1 0 .352"
fill="currentColor"
/>
</svg>
<svg
aria-labelledby="Checked"
class="nut-icon nut-icon-Checked nut-checkbox-icon nut-checkbox-icon-checked"
role="presentation"
viewBox="0 0 16 16"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M8 16A8 8 0 1 0 8 0a8 8 0 0 0 0 16m4.325-10.117-5.318 5.362-3.332-3.36a.25.25 0 0 1 0-.351l.701-.707a.25.25 0 0 1 .355 0L7.007 9.12l4.262-4.297a.25.25 0 0 1 .355 0l.701.707a.25.25 0 0 1 0 .352"
fill="currentColor"
/>
</svg>
</div>
<span
class="nut-checkbox-label "
>
Expand Down
27 changes: 27 additions & 0 deletions src/packages/checkbox/__test__/checkbox.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import React, { useState } from 'react'
import { fireEvent, render } from '@testing-library/react'
import '@testing-library/jest-dom'
import { Check } from '@nutui/icons-react'
import { Checkbox } from '../checkbox'
import { CheckboxGroup } from '../../checkboxgroup/checkboxgroup'

Expand Down Expand Up @@ -36,6 +37,32 @@ test('should props correctly', () => {
expect(handleChange).not.toBeCalled()
})

test('round props correctly', () => {
const { container, queryByText, getByTestId } = render(
<Checkbox
style={{ marginInlineEnd: '8px' }}
shape="button"
activeIcon={<Check className="nut-checkbox-button-icon-checked" />}
className="test"
label={
<div
style={{
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
}}
>
<div>复选框</div>
</div>
}
defaultChecked
/>
)
expect(
container.querySelector('.nut-checkbox-button-icon-checked')
).toBeInTheDocument()
})

test('should fireEvent correctly', () => {
const handleChange = vi.fn((value) => {
value
Expand Down
Loading