-
-
Notifications
You must be signed in to change notification settings - Fork 479
refactor: Semantic structure re-layout #1166
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
Changes from 65 commits
2d61d98
597ecab
f1e9ff9
4a6925f
2477daf
1c2573d
e1c5e34
d954431
b14de98
992b22d
012e64f
d78b95f
70fa69f
9e32905
9e78943
fe07192
85b64f7
7f38025
3ca6f16
f9e8a2c
9a4d6d3
8101a4c
fcc578d
d04df92
341a834
3f538ab
484c523
0a18a4f
1faca1f
211f982
5e712d1
db75428
c03a03e
ef34813
f71f4c5
afdf9c5
cf95331
0ed8ae6
83cd06f
2b14e52
c91c43b
8b2da80
27e7b2c
04db275
de31413
648f73d
3f98735
30bdebe
97bce99
b606279
4649241
36220d3
e81f2f5
de3f3a6
a8ca6ec
0ca69af
370a165
8234174
2cb9ad2
97ee306
7e86869
ff55f9a
250d0c8
a8d598c
7e2ffc6
d5f7692
2facc4e
1428565
41ccbca
fd508bd
be51de6
ff308c8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| @select-prefix: ~'rc-select'; | ||
| @import url('./patch.less'); | ||
|
|
||
| * { | ||
| box-sizing: border-box; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| // This is used for semantic refactoring | ||
| @import (reference) url('./index.less'); | ||
|
|
||
| .@{select-prefix}.@{select-prefix} { | ||
| display: inline-flex; | ||
| align-items: center; | ||
| user-select: none; | ||
| border: 1px solid blue; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 移除或配置化硬编码的蓝色边框。 硬编码的 应用此差异移除硬编码边框: display: inline-flex;
align-items: center;
user-select: none;
- border: 1px solid blue;
position: relative;或者使用变量: - border: 1px solid blue;
+ border: @select-border-width @select-border-style @select-border-color;🤖 Prompt for AI Agents |
||
| position: relative; | ||
|
|
||
| // Content 部分自动占据剩余宽度 | ||
| .@{select-prefix}-content { | ||
| flex: auto; | ||
| display: flex; | ||
| align-items: center; | ||
| /* Prevent content from wrapping */ | ||
| min-width: 0; /* allow flex item to shrink */ | ||
| white-space: nowrap; | ||
| overflow: hidden; | ||
| text-overflow: ellipsis; | ||
| position: relative; | ||
| } | ||
|
|
||
| .@{select-prefix}-input { | ||
| border: none; | ||
| background: transparent; | ||
| } | ||
|
|
||
| .@{select-prefix}-placeholder { | ||
| opacity: 0.5; | ||
|
|
||
| &::after { | ||
| content: '\00a0'; // nbsp placeholder | ||
| width: 0; | ||
| overflow: hidden; | ||
| } | ||
| } | ||
|
|
||
| .@{select-prefix}-content, | ||
| .@{select-prefix}-input, | ||
| .@{select-prefix}-placeholder { | ||
| padding: 0; | ||
| margin: 0; | ||
| line-height: 1.5; | ||
| font-size: 14px; | ||
| font-weight: normal; | ||
| } | ||
|
|
||
| // 其他部分禁止自动宽度,使用内容宽度 | ||
| .@{select-prefix}-prefix, | ||
| .@{select-prefix}-suffix, | ||
| .@{select-prefix}-clear { | ||
| flex: none; | ||
| } | ||
|
|
||
| .@{select-prefix}-clear { | ||
| position: absolute; | ||
| top: 0; | ||
| right: 0; | ||
| } | ||
|
|
||
| // ============================= Single ============================= | ||
| &-single { | ||
| .@{select-prefix}-input { | ||
| position: absolute; | ||
| inset: 0; | ||
| } | ||
| } | ||
|
|
||
| // ============================ Multiple ============================ | ||
| &-multiple { | ||
| .@{select-prefix}-selection-item { | ||
| background: rgba(0, 0, 0, 0.1); | ||
| border-radius: 8px; | ||
| margin-right: 4px; | ||
| } | ||
|
|
||
| .@{select-prefix}-input { | ||
| width: calc(var(--select-input-width, 10) * 1px); | ||
| min-width: 4px; | ||
| } | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,49 @@ | ||||||||||||||||||||||
| import * as React from 'react'; | ||||||||||||||||||||||
| import Input from '../src/SelectInput/Input'; | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| const InputExample = () => { | ||||||||||||||||||||||
| const [value, setValue] = React.useState(''); | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| return ( | ||||||||||||||||||||||
| <div> | ||||||||||||||||||||||
| <h2>Input Component Examples</h2> | ||||||||||||||||||||||
|
|
||||||||||||||||||||||
| <div> | ||||||||||||||||||||||
| <h3>Basic Input</h3> | ||||||||||||||||||||||
| <Input prefixCls="rc-select" placeholder="Type something..." /> | ||||||||||||||||||||||
|
||||||||||||||||||||||
| <Input prefixCls="rc-select" placeholder="Type something..." /> | |
| // In src/SelectInput/Input.tsx | |
| export interface InputProps { | |
| id?: string; | |
| readOnly?: boolean; | |
| /** CSS 类名前缀 */ | |
| prefixCls: string; | |
| // … 其他已有属性 | |
| } |
🧰 Tools
🪛 GitHub Actions: ✅ test
[error] 13-13: Type '{ prefixCls: string; placeholder: string; }' is not assignable to type 'IntrinsicAttributes & InputProps & RefAttributes'. Property 'prefixCls' does not exist on type 'IntrinsicAttributes & InputProps & RefAttributes'.
🤖 Prompt for AI Agents
In examples/InputExample.tsx around line 13 the example uses <Input
prefixCls="rc-select" /> but InputProps in src/SelectInput/Input.tsx lacks a
prefixCls declaration; update src/SelectInput/Input.tsx by adding prefixCls?:
string to the InputProps interface and ensure the component accepts and forwards
that prop to the rendered element (e.g., include prefixCls in the props
destructuring and pass it into the root element or className computation) so the
example type-checks.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,43 @@ | ||
| import * as React from 'react'; | ||
| import SelectContent from '../src/SelectInput/Content'; | ||
| import type { DisplayValueType } from '../src/interface'; | ||
|
|
||
| const SelectContentExample = () => { | ||
| const singleValue: DisplayValueType[] = [{ value: 'option1', label: 'Option 1' }]; | ||
|
|
||
| const multipleValues: DisplayValueType[] = [ | ||
| { value: 'option1', label: 'Option 1' }, | ||
| { value: 'option2', label: 'Option 2' }, | ||
| { value: 'option3', label: 'Option 3' }, | ||
| ]; | ||
|
|
||
| const emptyValues: DisplayValueType[] = []; | ||
|
|
||
| return ( | ||
| <div> | ||
| <h2>SelectContent Value Logic Examples</h2> | ||
|
|
||
| <div> | ||
| <h3>Single Mode with Value</h3> | ||
| <SelectContent prefixCls="rc-select" multiple={false} value={singleValue} /> | ||
| </div> | ||
|
|
||
| <div> | ||
| <h3>Multiple Mode with Values</h3> | ||
| <SelectContent prefixCls="rc-select" multiple={true} value={multipleValues} /> | ||
| </div> | ||
|
|
||
| <div> | ||
| <h3>Single Mode with Empty Values</h3> | ||
| <SelectContent prefixCls="rc-select" multiple={false} value={emptyValues} /> | ||
| </div> | ||
|
|
||
| <div> | ||
| <h3>Multiple Mode with Empty Values</h3> | ||
| <SelectContent prefixCls="rc-select" multiple={true} value={emptyValues} /> | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default SelectContentExample; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| module.exports = { | ||
| setupFilesAfterEnv: ['<rootDir>/tests/setup.ts'], | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using a duplicated class selector (
.@{select-prefix}.@{select-prefix}) to increase specificity can be a bit of a hack and might make the CSS harder to maintain. If this is necessary to override existing styles, please add a comment explaining why. A better long-term solution might be to refactor the base styles to avoid needing such high specificity.