Forráskód Böngészése

[stdf]Update Avatar compoent, demo and documents.

dufu1991 1 éve
szülő
commit
3085c3dee4

+ 22 - 22
doc/components/avatar/api.md

@@ -1,16 +1,16 @@
 ## Avatar Props
 
-| 属性     | 类型                                          | 默认值                                              | 必传 | 说明                                                                     |
-| -------- | --------------------------------------------- | --------------------------------------------------- | ---- | ------------------------------------------------------------------------ |
-| image    | `string`                                      | `''`                                                | N    | 图片路径。                                                               |
-| alt      | `string`                                      | `''`                                                | N    | 替换文本,建议单字。                                                     |
-| icon     | `Icon`                                        | `{ name: 'ri-user-3-line', theme: true, size: 32 }` | N    | 替换图标 [Icon Props](https://stdf.design/#/components?nav=icon&tab=1)。 |
-| altSize  | `'xs'\|'sm'\|'md'\|'lg'\|'xl'`                | `'md'`                                              | N    | 替换文本大小。                                                           |
-| radius   | `'none'\|'base'\|'xl'\|'2xl'\|'3xl'\|'full'`  | `'base'`                                            | N    | 圆角风格。                                                               |
-| size     | `'xs'\|'sm'\|'base'\|'md'\|'lg'\|'xl'\|'2xl'` | `'md'`                                              | N    | 头像框大小。                                                             |
-| imgSize  | `'s'\|'m'\|'l'`                               | `'l'`                                               | N    | 头像图片大小。                                                           |
-| line     | `'none'\|'solid'\|'dashed'\|'dotted'`         | `'none'`                                            | N    | 边框风格。                                                               |
-| injClass | `string`                                      | `''`                                                | N    | 注入 CSS 名称。                                                          |
+| 属性     | 类型                                                      | 默认值   | 必传 | 说明                 |
+| -------- | --------------------------------------------------------- | -------- | ---- | -------------------- |
+| image    | `string`                                                  | `''`     | N    | 图片路径。           |
+| alt      | `string`                                                  | `''`     | N    | 替换文本,建议单字。 |
+| icon     | [`Icon`](https://stdf.design/#/components?nav=icon&tab=1) | `{}`     | N    | 替换图标           |
+| altSize  | `'xs'\|'sm'\|'md'\|'lg'\|'xl'`                            | `'md'`   | N    | 替换文本大小。       |
+| radius   | `'none'\|'base'\|'xl'\|'2xl'\|'3xl'\|'full'`              | `'base'` | N    | 圆角风格。           |
+| size     | `'xs'\|'sm'\|'base'\|'md'\|'lg'\|'xl'\|'2xl'`             | `'md'`   | N    | 头像框大小。         |
+| imgSize  | `'s'\|'m'\|'l'`                                           | `'l'`    | N    | 头像图片大小。       |
+| line     | `'none'\|'solid'\|'dashed'\|'dotted'`                     | `'none'` | N    | 边框风格。           |
+| injClass | `string`                                                  | `''`     | N    | 注入 CSS 名称。      |
 
 ## Avatar Events
 
@@ -20,17 +20,17 @@
 
 ## Avatars Props
 
-| 属性      | 类型                                          | 默认值    | 必传 | 说明                                                                                   |
-| --------- | --------------------------------------------- | --------- | ---- | -------------------------------------------------------------------------------------- |
-| data      | `Avatar[]`                                    | `[]`      | N    | 由 Avatar Props 组成的头像数据。                                                       |
-| radius    | `'none'\|'base'\|'xl'\|'2xl'\|'3xl'\|'full'`  | `'full'`  | N    | 圆角风格。                                                                             |
-| size      | `'xs'\|'sm'\|'base'\|'md'\|'lg'\|'xl'\|'2xl'` | `'md'`    | N    | 头像框大小。                                                                           |
-| compact   | `number`                                      | `5`       | N    | 紧凑程度,越大越紧凑。                                                                 |
-| lineWidth | `'0'\|'1'\|'2'\|'3'\|'4'\|'8'`                | `'3'`     | N    | 边框粗细。                                                                             |
-| reverse   | `boolean`                                     | `false`   | N    | 是否反向。                                                                             |
-| max       | `number`                                      | `10`      | N    | 最大最大显示数量。                                                                     |
-| top       | `'totle'\|'add'\|null\|Snippet`               | `'totle'` | N    | 顶层内容,注:类型 [Snippet](https://svelte.dev/docs/svelte/snippet#Typing-snippets)。 |
-| injClass  | `string`                                      | `''`      | N    | 注入 CSS 名称。                                                                        |
+| 名称      | 类型                                                                                        | 默认值    | 必传 | 说明                             |
+| --------- | ------------------------------------------------------------------------------------------- | --------- | ---- | -------------------------------- |
+| data      | `Avatar[]`                                                                                  | `[]`      | N    | 由 Avatar Props 组成的头像数据。 |
+| radius    | `'none'\|'base'\|'xl'\|'2xl'\|'3xl'\|'full'`                                                | `'full'`  | N    | 圆角风格。                       |
+| size      | `'xs'\|'sm'\|'base'\|'md'\|'lg'\|'xl'\|'2xl'`                                               | `'md'`    | N    | 头像框大小。                     |
+| compact   | `number`                                                                                    | `5`       | N    | 紧凑程度,越大越紧凑。           |
+| lineWidth | `'0'\|'1'\|'2'\|'3'\|'4'\|'8'`                                                              | `'3'`     | N    | 边框粗细。                       |
+| reverse   | `boolean`                                                                                   | `false`   | N    | 是否反向。                       |
+| max       | `number`                                                                                    | `10`      | N    | 最大最大显示数量。               |
+| top       | `'totle'\|'add'\|null`\|[`Snippet`](https://svelte.dev/docs/svelte/snippet#Typing-snippets) | `'totle'` | N    | 顶层内容                       |
+| injClass  | `string`                                                                                    | `''`      | N    | 注入 CSS 名称。                  |
 
 ## Avatars Events
 

+ 28 - 28
doc/components/avatar/api_en.md

@@ -1,39 +1,39 @@
 ## Avatar Props
 
-| Name     | Type                                          | Default                                             | Required | Description                                                               |
-| -------- | --------------------------------------------- | --------------------------------------------------- | -------- | ------------------------------------------------------------------------- |
-| image    | `string`                                      | `''`                                                | N        | Image path.                                                               |
-| alt      | `string`                                      | `''`                                                | N        | Alternative text, single character recommended.                           |
-| icon     | `Icon`                                        | `{ name: 'ri-user-3-line', theme: true, size: 32 }` | N        | Icon props [Icon Props](https://stdf.design/#/components?nav=icon&tab=1). |
-| altSize  | `'xs'\|'sm'\|'md'\|'lg'\|'xl'`                | `'md'`                                              | N        | Alternative text size.                                                    |
-| radius   | `'none'\|'base'\|'xl'\|'2xl'\|'3xl'\|'full'`  | `'base'`                                            | N        | Border radius style.                                                      |
-| size     | `'xs'\|'sm'\|'base'\|'md'\|'lg'\|'xl'\|'2xl'` | `'md'`                                              | N        | Avatar frame size.                                                        |
-| imgSize  | `'s'\|'m'\|'l'`                               | `'l'`                                               | N        | Avatar image size.                                                        |
-| line     | `'none'\|'solid'\|'dashed'\|'dotted'`         | `'none'`                                            | N        | Border style.                                                             |
-| injClass | `string`                                      | `''`                                                | N        | Inject CSS class name.                                                    |
+| Property | Type                                                      | Default  | Required | Description                        |
+| -------- | --------------------------------------------------------- | -------- | -------- | ---------------------------------- |
+| image    | `string`                                                  | `''`     | N        | Image path.                        |
+| alt      | `string`                                                  | `''`     | N        | Alt text, single char recommended. |
+| icon     | [`Icon`](https://stdf.design/#/components?nav=icon&tab=1) | `{}`     | N        | Alternative icon.                  |
+| altSize  | `'xs'\|'sm'\|'md'\|'lg'\|'xl'`                            | `'md'`   | N        | Alt text size.                     |
+| radius   | `'none'\|'base'\|'xl'\|'2xl'\|'3xl'\|'full'`              | `'base'` | N        | Border radius style.               |
+| size     | `'xs'\|'sm'\|'base'\|'md'\|'lg'\|'xl'\|'2xl'`             | `'md'`   | N        | Avatar frame size.                 |
+| imgSize  | `'s'\|'m'\|'l'`                                           | `'l'`    | N        | Avatar image size.                 |
+| line     | `'none'\|'solid'\|'dashed'\|'dotted'`                     | `'none'` | N        | Border style.                      |
+| injClass | `string`                                                  | `''`     | N        | Injected CSS class name.           |
 
 ## Avatar Events
 
-| Name    | Type         | Parameters | Description         |
-| ------- | ------------ | ---------- | ------------------- |
-| onclick | `() => void` | -          | Triggered on click. |
+| Name    | Type         | Params | Description         |
+| ------- | ------------ | ------ | ------------------- |
+| onclick | `() => void` | -      | Triggered on click. |
 
 ## Avatars Props
 
-| Name      | Type                                          | Default   | Required | Description                                                                                |
-| --------- | --------------------------------------------- | --------- | -------- | ------------------------------------------------------------------------------------------ |
-| data      | `Avatar[]`                                    | `[]`      | N        | Avatar data array composed of Avatar Props.                                                |
-| radius    | `'none'\|'base'\|'xl'\|'2xl'\|'3xl'\|'full'`  | `'full'`  | N        | Border radius style.                                                                       |
-| size      | `'xs'\|'sm'\|'base'\|'md'\|'lg'\|'xl'\|'2xl'` | `'md'`    | N        | Avatar frame size.                                                                         |
-| compact   | `number`                                      | `5`       | N        | Compactness level, larger value means more compact.                                        |
-| lineWidth | `'0'\|'1'\|'2'\|'3'\|'4'\|'8'`                | `'3'`     | N        | Border width.                                                                              |
-| reverse   | `boolean`                                     | `false`   | N        | Whether to reverse the order.                                                              |
-| max       | `number`                                      | `10`      | N        | Maximum number of avatars to display.                                                      |
-| top       | `'totle'\|'add'\|null\|Snippet`               | `'totle'` | N        | Top content, Note: type [Snippet](https://svelte.dev/docs/svelte/snippet#Typing-snippets). |
-| injClass  | `string`                                      | `''`      | N        | Inject CSS class name.                                                                     |
+| Name      | Type                                                                                        | Default   | Required | Description                                   |
+| --------- | ------------------------------------------------------------------------------------------- | --------- | -------- | --------------------------------------------- |
+| data      | `Avatar[]`                                                                                  | `[]`      | N        | Array of Avatar Props data.                   |
+| radius    | `'none'\|'base'\|'xl'\|'2xl'\|'3xl'\|'full'`                                                | `'full'`  | N        | Border radius style.                          |
+| size      | `'xs'\|'sm'\|'base'\|'md'\|'lg'\|'xl'\|'2xl'`                                               | `'md'`    | N        | Avatar frame size.                            |
+| compact   | `number`                                                                                    | `5`       | N        | Compactness level, higher means more compact. |
+| lineWidth | `'0'\|'1'\|'2'\|'3'\|'4'\|'8'`                                                              | `'3'`     | N        | Border width.                                 |
+| reverse   | `boolean`                                                                                   | `false`   | N        | Whether to reverse the order.                 |
+| max       | `number`                                                                                    | `10`      | N        | Maximum number of avatars to display.         |
+| top       | `'totle'\|'add'\|null`\|[`Snippet`](https://svelte.dev/docs/svelte/snippet#Typing-snippets) | `'totle'` | N        | Top layer content.                            |
+| injClass  | `string`                                                                                    | `''`      | N        | Injected CSS class name.                      |
 
 ## Avatars Events
 
-| Name    | Type         | Parameters | Description                          |
-| ------- | ------------ | ---------- | ------------------------------------ |
-| onclick | `() => void` | -          | Triggered when avatar group clicked. |
+| Name    | Type         | Params | Description                          |
+| ------- | ------------ | ------ | ------------------------------------ |
+| onclick | `() => void` | -      | Triggered when avatar group clicked. |

+ 8 - 2
packages/stdf/components/avatar/Avatar.svelte

@@ -6,7 +6,7 @@
 	let {
 		image = '',
 		alt = '',
-		icon = { name: 'ri-user-3-line', theme: true },
+		icon = {},
 		altSize = 'md',
 		radius = 'base',
 		size = 'base',
@@ -68,7 +68,13 @@
 >
 	{#if image === '' && alt === ''}
 		<div class="m-auto">
-			<Icon size={iconSizeObj[size] || iconSizeObj.base} {...icon} injClass="text-primary-950 dark:text-dark-950" />
+			<Icon
+				size={iconSizeObj[size] || iconSizeObj.base}
+				name="ri-user-3-line"
+				theme
+				{...icon}
+				injClass="text-primary-950 dark:text-dark-950"
+			/>
 		</div>
 	{:else if image === '' && alt !== ''}
 		<div