-
Notifications
You must be signed in to change notification settings - Fork 4
feat: 增加 input 组件 #13
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
Merged
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
39706c2
feat: input 初版
vaebe bea6c41
feat: 代码优化
vaebe cb2a1d9
fix: 去处文档的多余 style 设置
vaebe 3ea03ef
feat: 代码优化
vaebe ec8d7e2
style: 样式优化
vaebe 6f540c4
style: 样式优化
vaebe c939d5b
feat: 逻辑优化
vaebe 4cc898a
style: input 组件样式优化
vaebe 035ce68
feat: 代码优化
vaebe 78af026
feat: 将Input组件改回使用标准的Vue 3 v-model
vaebe File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| import type { App } from 'vue' | ||
| import Input from './src/input' | ||
|
|
||
| Input.install = function (app: App): void { | ||
| app.component(Input.name, Input) | ||
| } | ||
|
|
||
| export { Input } | ||
|
|
||
| export default { | ||
| title: 'Input 输入框', | ||
| category: '数据录入', | ||
| status: '100%', | ||
| install(app: App): void { | ||
| app.component(Input.name, Input) | ||
| }, | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| import type { ExtractPropTypes, PropType } from 'vue' | ||
|
|
||
| export type InputType = 'text' | 'password' | ||
| export type InputSize = 'large' | 'default' | 'small' | ||
|
|
||
| export const inputProps = { | ||
| type: { | ||
| type: String as PropType<InputType>, | ||
| default: 'text', | ||
| }, | ||
| size: { | ||
| type: String as PropType<InputSize>, | ||
| default: 'default', | ||
| }, | ||
| placeholder: { | ||
| type: String, | ||
| default: '', | ||
| }, | ||
| disabled: { | ||
| type: Boolean, | ||
| default: false, | ||
| }, | ||
| readonly: { | ||
| type: Boolean, | ||
| default: false, | ||
| }, | ||
| clearable: { | ||
| type: Boolean, | ||
| default: false, | ||
| }, | ||
| showPassword: { | ||
| type: Boolean, | ||
| default: false, | ||
| }, | ||
| prepend: { | ||
| type: String, | ||
| default: '', | ||
| }, | ||
| append: { | ||
| type: String, | ||
| default: '', | ||
| }, | ||
| modelValue: { | ||
| type: String, | ||
| default: '', | ||
| }, | ||
| } as const | ||
|
|
||
| export type InputProps = ExtractPropTypes<typeof inputProps> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,177 @@ | ||
| @use '../../style-var/index.scss' as *; | ||
|
|
||
| .#{$cls-prefix}-input { | ||
| display: flex; | ||
| align-items: center; | ||
| width: 100%; | ||
| box-sizing: border-box; | ||
| background-color: $ccui-base-bg; | ||
| border: 1px solid $ccui-line; | ||
| border-radius: $ccui-border-radius; | ||
| color: $ccui-text; | ||
| font-size: 14px; | ||
| transition: | ||
| border-color $ccui-animation-duration-base, | ||
| box-shadow $ccui-animation-duration-base; | ||
|
|
||
| &:hover { | ||
| border-color: $ccui-brand-hover; | ||
| } | ||
|
|
||
| &:focus-within { | ||
| border-color: $ccui-brand; | ||
| box-shadow: 0 0 0 2px rgba($ccui-brand, 0.2); | ||
| } | ||
|
|
||
| &--disabled { | ||
| background-color: $ccui-disabled-bg; | ||
| border-color: $ccui-disabled-line; | ||
| color: $ccui-disabled-text; | ||
| cursor: not-allowed; | ||
|
|
||
| &:hover { | ||
| border-color: $ccui-disabled-line; | ||
| } | ||
| } | ||
|
|
||
| &--large { | ||
| height: $ccui-size-lg; | ||
| font-size: $ccui-font-size-lg; | ||
|
|
||
| &.#{$cls-prefix}-input--prefix { | ||
| .#{$cls-prefix}-input__inner { | ||
| padding-left: 24px; | ||
| } | ||
| } | ||
|
|
||
| &.#{$cls-prefix}-input--suffix, | ||
| &.#{$cls-prefix}-input--clearable { | ||
| .#{$cls-prefix}-input__inner { | ||
| padding-right: 24px; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| &--default { | ||
| height: $ccui-size-md; | ||
| font-size: $ccui-font-size-md; | ||
|
|
||
| &.#{$cls-prefix}-input--prefix { | ||
| .#{$cls-prefix}-input__inner { | ||
| padding-left: 24px; | ||
| } | ||
| } | ||
|
|
||
| &.#{$cls-prefix}-input--suffix, | ||
| &.#{$cls-prefix}-input--clearable { | ||
| .#{$cls-prefix}-input__inner { | ||
| padding-right: 24px; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| &--small { | ||
| height: $ccui-size-sm; | ||
| font-size: $ccui-font-size-sm; | ||
|
|
||
| &.#{$cls-prefix}-input--prefix { | ||
| .#{$cls-prefix}-input__inner { | ||
| padding-left: 20px; | ||
| } | ||
| } | ||
|
|
||
| &.#{$cls-prefix}-input--suffix, | ||
| &.#{$cls-prefix}-input--clearable { | ||
| .#{$cls-prefix}-input__inner { | ||
| padding-right: 20px; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| &__wrapper { | ||
| position: relative; | ||
| width: 100%; | ||
| padding: 0 8px; | ||
| } | ||
|
|
||
| &__prepend, | ||
| &__append { | ||
| display: flex; | ||
| align-items: center; | ||
| white-space: nowrap; | ||
| background-color: $ccui-area; | ||
| color: $ccui-text; | ||
| font-size: inherit; | ||
| line-height: 1; | ||
| height: 100%; | ||
| padding: 0 10px; | ||
| } | ||
|
|
||
| &__prepend { | ||
| border-radius: $ccui-border-radius 0 0 $ccui-border-radius; | ||
| border-right: 1px solid $ccui-line; | ||
| } | ||
|
|
||
| &__append { | ||
| border-radius: 0 $ccui-border-radius $ccui-border-radius 0; | ||
| border-left: 1px solid $ccui-line; | ||
| } | ||
|
|
||
| &__inner { | ||
| width: 100%; | ||
| height: 100%; | ||
| background: transparent; | ||
| border: none; | ||
| outline: none; | ||
| color: inherit; | ||
| font-size: inherit; | ||
| font-family: inherit; | ||
| position: relative; | ||
| z-index: 0; | ||
| box-sizing: border-box; | ||
| padding: 4px 0; | ||
|
|
||
| &::placeholder { | ||
| color: $ccui-placeholder; | ||
| } | ||
|
|
||
| &:disabled { | ||
| cursor: not-allowed; | ||
| color: $ccui-disabled-text; | ||
| } | ||
| } | ||
|
|
||
| &__prefix, | ||
| &__suffix { | ||
| position: absolute; | ||
| top: 0; | ||
| bottom: 0; | ||
| display: flex; | ||
| align-items: center; | ||
| justify-content: center; | ||
| color: $ccui-placeholder; | ||
| pointer-events: none; | ||
| z-index: 1; | ||
| } | ||
|
|
||
| &__prefix { | ||
| left: 8px; | ||
| } | ||
|
|
||
| &__suffix { | ||
| right: 8px; | ||
| } | ||
|
|
||
| &__clear, | ||
| &__password-visible, | ||
| &__password-hidden { | ||
| cursor: pointer; | ||
| pointer-events: auto; | ||
| color: $ccui-placeholder; | ||
| transition: color $ccui-animation-duration-base; | ||
|
|
||
| &:hover { | ||
| color: $ccui-text; | ||
| } | ||
| } | ||
| } | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Size‑based padding rules expect block modifiers, not element modifiers
The selectors like:
compile to
.ccui-input--large.ccui-input--prefix .ccui-input__inner { ... }etc., i.e. they assume--prefix/--suffix/--clearableare applied on the block element.Currently, in
input.tsxthese modifiers are added to the input element viainputClass, not to the block container, so these padding rules won’t ever match. After you fix the TSX to put these modifiers on the block (see comment ininput.tsx), these SCSS rules will start working as intended.