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(time-picker): 新增前缀后缀内容扩展(#2903) #2904

Merged
merged 7 commits into from
Jun 28, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
5 changes: 5 additions & 0 deletions .changeset/rude-sheep-argue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hi-ui/time-picker": minor
---

feat: 新增前缀后缀内容扩展
5 changes: 5 additions & 0 deletions .changeset/silent-gifts-suffer.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@hi-ui/hiui": patch
---

feat(time-picker): 新增前缀后缀内容扩展
6 changes: 6 additions & 0 deletions packages/ui/time-picker/src/TimePicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export const TimePicker = forwardRef<HTMLDivElement | null, TimePickerProps>(
overlay,
size = 'md',
invalid = false,
prefix,
},
ref
) => {
Expand Down Expand Up @@ -258,6 +259,7 @@ export const TimePicker = forwardRef<HTMLDivElement | null, TimePickerProps>(
return (
<div ref={ref} role={role} className={cls}>
<div ref={setAttachEl} className={`${prefixCls}__input-wrapper`}>
{prefix ? <span className={`${prefixCls}__prefix`}>{prefix}</span> : null}
<Input
size={size}
isFitContent={appearance === 'unset'}
Expand Down Expand Up @@ -409,6 +411,10 @@ export interface TimePickerProps extends ExtendType {
* @default false
*/
invalid?: boolean
/**
* 选择框前置内容
*/
prefix?: React.ReactNode
}

if (__DEV__) {
Expand Down
9 changes: 9 additions & 0 deletions packages/ui/time-picker/src/styles/time-picker.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ $input-wrapper-class: '#{$prefix}__input-wrapper' !default;
align-items: center;
}

&__prefix {
display: inline-flex;
align-items: center;
flex-shrink: 0;
color: use-color('gray', 700);
font-size: inherit;
text-align: center;
}

&--appearance-line {
position: relative;
z-index: 0;
Expand Down
27 changes: 27 additions & 0 deletions packages/ui/time-picker/stories/addon.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React, { useState } from 'react'
import TimePicker from '../src'
import { AppStoreOutlined } from '@hi-ui/icons'

/**
* @title 前置后置内容扩展
*/
export const Addon = () => {
const [addonValue, setAddonValue] = useState<string | string[]>(['12:00:00'])

return (
<>
<h1>Addon</h1>
<div className="time-picker-addon__wrap">
<TimePicker
placeholder={['请选择时间']}
value={addonValue}
onChange={(e) => {
console.log('basic-default', e)
setAddonValue(e)
}}
prefix={<AppStoreOutlined />}
/>
</div>
</>
)
}
1 change: 1 addition & 0 deletions packages/ui/time-picker/stories/index.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export * from './disabled.stories'
export * from './range.stories'
export * from './format.stories'
export * from './custom-disabled.stories'
export * from './addon.stories'

export default {
title: 'Data Input/TimePicker',
Expand Down