Skip to content

Commit 4e03e12

Browse files
committed
feat(ui): add image component
1 parent 9ff78cc commit 4e03e12

92 files changed

Lines changed: 1858 additions & 545 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.gitattributes

Lines changed: 0 additions & 2 deletions
This file was deleted.

packages/site/src/app/styles/_app.scss

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,8 @@ h3 {
185185
section[id^='Compose'],
186186
section[id^='Cascader'],
187187
section[id^='Select'] {
188-
.d-selectbox {
188+
.d-select,
189+
.d-cascader {
189190
width: 400px;
190191
}
191192
}
@@ -225,7 +226,8 @@ h3 {
225226
'Switch': 'switch',
226227
'Time-picker': 'time-picker',
227228
'Date-picker': 'date-picker',
228-
'Auto-complete': 'input'
229+
'Auto-complete': 'input',
230+
'Image': 'image'
229231
)
230232
{
231233
section[id^='#{$id}'] {
118 KB
Loading
94.4 KB
Loading
98.7 KB
Loading
1.25 MB
Loading

packages/ui/src/components/_alert-dialog/index.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

packages/ui/src/components/_alert-dialog/AlertDialog.tsx renamed to packages/ui/src/components/_alert/Alert.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,21 @@ import { useRef } from 'react';
33
import { useAsync, useMount, usePrefixConfig } from '../../hooks';
44
import { getClassName } from '../../utils';
55

6-
export interface DAlertDialogProps extends React.HTMLAttributes<HTMLDivElement> {
6+
export interface DAlertProps extends React.HTMLAttributes<HTMLDivElement> {
7+
dClassNamePrefix: string;
78
dDuration: number;
89
dEscClosable?: boolean;
9-
dDialogRef?: React.Ref<HTMLDivElement>;
10+
dAlertRef?: React.Ref<HTMLDivElement>;
1011
onClose?: () => void;
1112
}
1213

13-
export function DAlertDialog(props: DAlertDialogProps): JSX.Element | null {
14+
export function DAlert(props: DAlertProps): JSX.Element | null {
1415
const {
1516
children,
17+
dClassNamePrefix,
1618
dDuration,
1719
dEscClosable = true,
18-
dDialogRef,
20+
dAlertRef,
1921
onClose,
2022

2123
...restProps
@@ -29,6 +31,8 @@ export function DAlertDialog(props: DAlertDialogProps): JSX.Element | null {
2931
clearTid?: () => void;
3032
}>({});
3133

34+
const prefix = `${dPrefix}${dClassNamePrefix}`;
35+
3236
const asyncCapture = useAsync();
3337

3438
useMount(() => {
@@ -42,8 +46,8 @@ export function DAlertDialog(props: DAlertDialogProps): JSX.Element | null {
4246
return (
4347
<div
4448
{...restProps}
45-
className={getClassName(restProps.className, `${dPrefix}alert-dialog`)}
46-
ref={dDialogRef}
49+
className={getClassName(restProps.className, prefix)}
50+
ref={dAlertRef}
4751
tabIndex={restProps.tabIndex ?? -1}
4852
role={restProps.role ?? 'alert'}
4953
onMouseEnter={(e) => {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './Alert';

packages/ui/src/components/_date-input/DateInput.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ export interface DDateInputRenderProps {
3434

3535
export interface DDateInputProps extends Omit<React.HTMLAttributes<HTMLDivElement>, 'children'> {
3636
children: (props: DDateInputRenderProps) => JSX.Element | null;
37+
dClassNamePrefix: string;
3738
dFormControl?: DFormControl;
3839
dVisible?: boolean;
3940
dPlacement?: 'top' | 'top-left' | 'top-right' | 'bottom' | 'bottom-left' | 'bottom-right';
@@ -53,6 +54,7 @@ export interface DDateInputProps extends Omit<React.HTMLAttributes<HTMLDivElemen
5354
function DateInput(props: DDateInputProps, ref: React.ForwardedRef<DDateInputRef>): JSX.Element | null {
5455
const {
5556
children,
57+
dClassNamePrefix,
5658
dFormControl,
5759
dVisible,
5860
dPlacement = 'bottom-left',
@@ -87,6 +89,8 @@ function DateInput(props: DDateInputProps, ref: React.ForwardedRef<DDateInputRef
8789
clearTid?: () => void;
8890
}>({});
8991

92+
const prefix = `${dPrefix}${dClassNamePrefix}`;
93+
9094
const [dInputRefLeft, dInputRefRight] = dInputRef ?? [];
9195
const combineInputRefLeft = useForkRef(inputRefLeft, dInputRefLeft);
9296
const combineInputRefRight = useForkRef(inputRefRight, dInputRefRight);
@@ -112,10 +116,10 @@ function DateInput(props: DDateInputProps, ref: React.ForwardedRef<DDateInputRef
112116
const clearable = dClearable && !dVisible && !dDisabled;
113117

114118
const containerEl = useElement(() => {
115-
let el = document.getElementById(`${dPrefix}date-input-root`);
119+
let el = document.getElementById(`${prefix}-root`);
116120
if (!el) {
117121
el = document.createElement('div');
118-
el.id = `${dPrefix}date-input-root`;
122+
el.id = `${prefix}-root`;
119123
document.body.appendChild(el);
120124
}
121125
return el;
@@ -199,7 +203,7 @@ function DateInput(props: DDateInputProps, ref: React.ForwardedRef<DDateInputRef
199203
<DBaseInput
200204
{...inputProps}
201205
ref={isLeft ? combineInputRefLeft : combineInputRefRight}
202-
className={getClassName(inputProps?.className, `${dPrefix}date-input__input`)}
206+
className={getClassName(inputProps?.className, `${prefix}__input`)}
203207
type="text"
204208
autoComplete="off"
205209
disabled={dDisabled}
@@ -253,8 +257,8 @@ function DateInput(props: DDateInputProps, ref: React.ForwardedRef<DDateInputRef
253257
<div
254258
{...restProps}
255259
ref={boxRef}
256-
className={getClassName(restProps.className, `${dPrefix}date-input`, {
257-
[`${dPrefix}date-input--${dSize}`]: dSize,
260+
className={getClassName(restProps.className, prefix, {
261+
[`${prefix}--${dSize}`]: dSize,
258262
'is-disabled': dDisabled,
259263
'is-focus': isFocus,
260264
})}
@@ -280,14 +284,14 @@ function DateInput(props: DDateInputProps, ref: React.ForwardedRef<DDateInputRef
280284
{getInputNode(true)}
281285
{dRange && (
282286
<>
283-
<div ref={indicatorRef} className={`${dPrefix}date-input__indicator`}></div>
284-
<SwapRightOutlined className={`${dPrefix}date-input__separator`} />
287+
<div ref={indicatorRef} className={`${prefix}__indicator`}></div>
288+
<SwapRightOutlined className={`${prefix}__separator`} />
285289
{getInputNode(false)}
286290
</>
287291
)}
288292
{clearable && (
289293
<button
290-
className={getClassName(`${dPrefix}icon-button`, `${dPrefix}date-input__clear`)}
294+
className={`${prefix}__clear`}
291295
aria-label={t('Clear')}
292296
onClick={(e) => {
293297
e.stopPropagation();
@@ -299,7 +303,7 @@ function DateInput(props: DDateInputProps, ref: React.ForwardedRef<DDateInputRef
299303
</button>
300304
)}
301305
{dSuffix && (
302-
<div className={`${dPrefix}date-input__icon`} style={{ opacity: clearable ? 0 : 1 }}>
306+
<div className={`${prefix}__icon`} style={{ opacity: clearable ? 0 : 1 }}>
303307
{dSuffix}
304308
</div>
305309
)}

0 commit comments

Comments
 (0)