@lynx-js/lynx-ui-button 3.139.0 → 3.143.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +17 -0
- package/SKILL.md +127 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/index.docs.d.ts +1 -1
- package/dist/types/index.jsx +1 -1
- package/package.json +7 -6
- package/src/types/index.docs.ts +1 -1
- package/src/types/index.ts +1 -1
- package/tsconfig.docs.json +0 -7
- package/tsconfig.json +0 -14
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# @lynx-js/lynx-ui-button
|
|
2
2
|
|
|
3
|
+
## 3.143.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Include missing README/CHANGELOG/SKILL/LICENSE files in published tarballs and exclude test and workspace-only config files. ([#404](https://github.com/lynx-family/lynx-ui/pull/404))
|
|
8
|
+
- Updated dependencies [[`29beec7`](https://github.com/lynx-family/lynx-ui/commit/29beec7b241026010b83c417f7e1d1c961cd4f09)]:
|
|
9
|
+
- @lynx-js/lynx-ui-common@3.143.0
|
|
10
|
+
|
|
11
|
+
## 3.142.0
|
|
12
|
+
|
|
13
|
+
### Patch Changes
|
|
14
|
+
|
|
15
|
+
- Accept React 18 and newer types. ReactLynx still defines the compatible versions for each app. ([#383](https://github.com/lynx-family/lynx-ui/pull/383))
|
|
16
|
+
|
|
17
|
+
- Updated dependencies [[`49cb3c5`](https://github.com/lynx-family/lynx-ui/commit/49cb3c5b20d9346ff0f8b314367b4c8e354d195d)]:
|
|
18
|
+
- @lynx-js/lynx-ui-common@3.142.0
|
|
19
|
+
|
|
3
20
|
## 3.139.0
|
|
4
21
|
|
|
5
22
|
### Patch Changes
|
package/SKILL.md
ADDED
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
# lynx-ui-button SKILL
|
|
2
|
+
|
|
3
|
+
`Button` is a member of the `lynx-ui` atomic library. It provides an unstyled, fully functional button "skeleton", focusing on handling interaction behaviors and accessibility.
|
|
4
|
+
|
|
5
|
+
## 1. Core Capabilities
|
|
6
|
+
|
|
7
|
+
Unlike `lynx-ui-button`, which is a high-level component providing complete styling and multiple variants, the goal of `Button` is to:
|
|
8
|
+
|
|
9
|
+
- **Provide core button behavior**: Encapsulates `onClick` events, `disabled` state, and the active state during press (`active` state).
|
|
10
|
+
- **Complete style freedom**: Comes with no background, border, color, or other styles, allowing developers to build buttons of any appearance from scratch.
|
|
11
|
+
- **Expose state via Render Props**: It exposes whether the button is in the "pressed" state (`active`) through the `children` Render Prop pattern, facilitating the implementation of complex press effects.
|
|
12
|
+
|
|
13
|
+
When you need an interactive element that is visually completely custom but behaviorally conforms to standard button specifications, you should use `Button`.
|
|
14
|
+
|
|
15
|
+
## 2. AI Coding Guide
|
|
16
|
+
|
|
17
|
+
### Minimal Usable Example
|
|
18
|
+
|
|
19
|
+
The core feature of `Button` is its Render Prop. You need to provide a function as `children` to receive the `active` state.
|
|
20
|
+
|
|
21
|
+
```tsx
|
|
22
|
+
import { Button } from '@lynx-js/lynx-ui'
|
|
23
|
+
|
|
24
|
+
function App() {
|
|
25
|
+
const handleClick = () => {
|
|
26
|
+
console.log('Button clicked!')
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
return (
|
|
30
|
+
<Button onClick={handleClick}>
|
|
31
|
+
{({ active }) => (
|
|
32
|
+
<view
|
|
33
|
+
style={{
|
|
34
|
+
padding: '10px 20px',
|
|
35
|
+
backgroundColor: active ? '#cccccc' : '#eeeeee',
|
|
36
|
+
border: '1px solid #999999',
|
|
37
|
+
borderRadius: 4,
|
|
38
|
+
}}
|
|
39
|
+
>
|
|
40
|
+
<text>My Custom Button</text>
|
|
41
|
+
</view>
|
|
42
|
+
)}
|
|
43
|
+
</Button>
|
|
44
|
+
)
|
|
45
|
+
}
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Recommended Prompt Formula
|
|
49
|
+
|
|
50
|
+
> **Scenario**: I want to use `Button` to create a custom button.
|
|
51
|
+
> **Appearance Requirement**: This button's background color is `[normal_color]` in its normal state, and when the user presses it (`active` state), the background color changes to `[active_color]`.
|
|
52
|
+
> **Behavior Requirement**: In the [enabled/disabled] state, the button needs to [perform some action, e.g., "print a log"] when clicked.
|
|
53
|
+
|
|
54
|
+
**Example Prompt**:
|
|
55
|
+
|
|
56
|
+
> I want to use `Button` to create an icon button. It should be a circular button with no background color. When the user presses it, the entire button area's background should become semi-transparent gray (`rgba(0,0,0,0.1)`). When the button is clicked, it should call the `handleIconClick` function. Please provide the implementation code.
|
|
57
|
+
|
|
58
|
+
## 4. FAQ
|
|
59
|
+
|
|
60
|
+
**Q: Why doesn’t the button react to the `active` state?**
|
|
61
|
+
|
|
62
|
+
A: `Button` uses a Render Prop. Provide a function as `children` so you can receive `{ active }` and style accordingly.
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
// Correct usage
|
|
66
|
+
<Button onClick={handleClick}>
|
|
67
|
+
{({ active }) => (
|
|
68
|
+
<view style={{ backgroundColor: active ? '#ccc' : '#eee' }}>
|
|
69
|
+
<text>My Button</text>
|
|
70
|
+
</view>
|
|
71
|
+
)}
|
|
72
|
+
</Button>
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Q: How do I handle disabled styles?**
|
|
76
|
+
|
|
77
|
+
A: `disabled` prevents `onClick` from firing but doesn’t auto-style the button. Pass `disabled` into your style logic and apply the visual state manually.
|
|
78
|
+
|
|
79
|
+
```tsx
|
|
80
|
+
<Button disabled={true} onClick={handleClick}>
|
|
81
|
+
{({ active }) => (
|
|
82
|
+
<view style={{ opacity: 0.5 }}>
|
|
83
|
+
<text>Disabled Button</text>
|
|
84
|
+
</view>
|
|
85
|
+
)}
|
|
86
|
+
</Button>
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## 3. Use Cases & Best Practices
|
|
90
|
+
|
|
91
|
+
### Scenario 1: Building a unique button in a design system
|
|
92
|
+
|
|
93
|
+
When your design system requires a button with a completely new look and feel that cannot be met by overriding the styles of `lynx-ui-button`.
|
|
94
|
+
|
|
95
|
+
```tsx
|
|
96
|
+
// GradientButton.tsx
|
|
97
|
+
const GradientButton = ({ children, onClick }) => (
|
|
98
|
+
<Button onClick={onClick}>
|
|
99
|
+
{({ active }) => (
|
|
100
|
+
<view
|
|
101
|
+
style={{
|
|
102
|
+
background: active
|
|
103
|
+
? 'linear-gradient(to right, #ff7e5f, #feb47b)'
|
|
104
|
+
: 'linear-gradient(to right, #6a11cb, #2575fc)',
|
|
105
|
+
color: 'white',
|
|
106
|
+
padding: '12px 24px',
|
|
107
|
+
borderRadius: 50,
|
|
108
|
+
boxShadow: active ? 'none' : '0 4px 15px rgba(0,0,0,0.2)',
|
|
109
|
+
transition: 'all 0.2s',
|
|
110
|
+
}}
|
|
111
|
+
>
|
|
112
|
+
{children}
|
|
113
|
+
</view>
|
|
114
|
+
)}
|
|
115
|
+
</Button>
|
|
116
|
+
)
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
**Practice**: With the `active` state, you can easily implement complex press effects, such as changing gradients, shadows, scaling, etc.
|
|
120
|
+
|
|
121
|
+
<!-- Removed Key APIs & Props Overview to align with FeedList structure -->
|
|
122
|
+
|
|
123
|
+
## 5. Sub components
|
|
124
|
+
|
|
125
|
+
`Button` is a single component and does not contain sub components.
|
|
126
|
+
|
|
127
|
+
<!-- Removed the "More Examples" section to align with FeedList structure -->
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export * from './index.docs.js';
|
|
1
|
+
export type * from './index.docs.js';
|
|
2
2
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAIA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAIA,mBAAmB,cAAc,CAAA"}
|
|
@@ -78,7 +78,7 @@ export interface ButtonRenderProps {
|
|
|
78
78
|
/**
|
|
79
79
|
* UI variants applied by Button based on its interactive status.
|
|
80
80
|
* Use them as CSS selectors to style different states.
|
|
81
|
-
* @zh Button 根据交互状态注入的
|
|
81
|
+
* @zh Button 根据交互状态注入的 UI variants,可用于 CSS selector 按状态定制样式。
|
|
82
82
|
*/
|
|
83
83
|
export interface ButtonUIVariants {
|
|
84
84
|
/**
|
package/dist/types/index.jsx
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export
|
|
1
|
+
export { };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynx-js/lynx-ui-button",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.143.0",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/lynx-family/lynx-ui.git",
|
|
@@ -16,18 +16,19 @@
|
|
|
16
16
|
"module": "./dist/index.jsx",
|
|
17
17
|
"types": "./dist/index.d.ts",
|
|
18
18
|
"files": [
|
|
19
|
-
"src
|
|
19
|
+
"src",
|
|
20
|
+
"!src/**/__tests__/**",
|
|
21
|
+
"!src/**/*.test.*",
|
|
20
22
|
"README.md",
|
|
23
|
+
"SKILL.md",
|
|
21
24
|
"CHANGELOG.md",
|
|
22
25
|
"LICENSE",
|
|
23
|
-
"tsconfig.docs.json",
|
|
24
|
-
"tsconfig.json",
|
|
25
26
|
"dist/**"
|
|
26
27
|
],
|
|
27
28
|
"dependencies": {
|
|
28
29
|
"@lynx-js/react-use": "0.2.2",
|
|
29
30
|
"clsx": "^2.1.1",
|
|
30
|
-
"@lynx-js/lynx-ui-common": "3.
|
|
31
|
+
"@lynx-js/lynx-ui-common": "3.143.0"
|
|
31
32
|
},
|
|
32
33
|
"devDependencies": {
|
|
33
34
|
"@lynx-js/react": "0.123.1",
|
|
@@ -39,7 +40,7 @@
|
|
|
39
40
|
"peerDependencies": {
|
|
40
41
|
"@lynx-js/react": ">=0.100.0",
|
|
41
42
|
"@lynx-js/types": "*",
|
|
42
|
-
"@types/react": "
|
|
43
|
+
"@types/react": ">=18"
|
|
43
44
|
},
|
|
44
45
|
"publishConfig": {
|
|
45
46
|
"access": "public"
|
package/src/types/index.docs.ts
CHANGED
|
@@ -91,7 +91,7 @@ export interface ButtonRenderProps {
|
|
|
91
91
|
/**
|
|
92
92
|
* UI variants applied by Button based on its interactive status.
|
|
93
93
|
* Use them as CSS selectors to style different states.
|
|
94
|
-
* @zh Button 根据交互状态注入的
|
|
94
|
+
* @zh Button 根据交互状态注入的 UI variants,可用于 CSS selector 按状态定制样式。
|
|
95
95
|
*/
|
|
96
96
|
export interface ButtonUIVariants {
|
|
97
97
|
/**
|
package/src/types/index.ts
CHANGED
package/tsconfig.docs.json
DELETED