From 4510816802ede4b0319b5ef125bb3cd2047bc2a5 Mon Sep 17 00:00:00 2001 From: Aex Date: Thu, 28 Oct 2021 23:37:26 +0800 Subject: [PATCH] refactor(componentes): deprecate the icon font of some components (#4067) * refactor(components): [el-breadcumb] icon * refactor(components): el-tabs icon * refactor(components): color picker icon * refactor(components): menus icon * refactor(components): loading spinner icon * fix(components): panel-data-pick elicon import * refactor(components): dropdown item icon * refactor(components): tabs plus icon * fix: message & tabs icon test * fix(components): breadcrumb docs * fix(components): colorPicker docs * fix(components): loading docs Co-authored-by: imswk --- docs/en-US/component/breadcrumb.md | 8 +++---- docs/en-US/component/color-picker.md | 18 +++++++-------- docs/en-US/component/loading.md | 14 ++++++------ .../breadcrumb/__tests__/breadcrumb.spec.ts | 22 ++++++++++++------- .../breadcrumb/src/breadcrumb-item.vue | 10 ++++----- .../components/breadcrumb/src/breadcrumb.ts | 12 +++++----- .../components/color-picker/src/index.vue | 21 +++++++++++++----- .../src/date-picker-com/panel-date-pick.vue | 2 ++ .../components/dropdown/src/dropdown-item.vue | 12 ++++++---- packages/components/dropdown/src/dropdown.vue | 2 +- .../loading/src/createLoadingComponent.ts | 3 ++- packages/components/menu/src/menu.ts | 12 +++++++--- packages/components/menu/src/sub-menu.ts | 18 ++++++++++----- .../message/__tests__/message.spec.ts | 12 +++++++++- .../components/tabs/__tests__/tabs.spec.ts | 6 ++--- packages/components/tabs/src/tab-nav.vue | 22 ++++++++++++------- packages/components/tabs/src/tabs.ts | 4 +++- packages/theme-chalk/src/breadcrumb.scss | 5 ++++- packages/theme-chalk/src/menu.scss | 6 ++--- packages/theme-chalk/src/tabs.scss | 16 ++++++++------ play/main.ts | 3 ++- 21 files changed, 143 insertions(+), 85 deletions(-) diff --git a/docs/en-US/component/breadcrumb.md b/docs/en-US/component/breadcrumb.md index 6933761ee6..c90a922333 100644 --- a/docs/en-US/component/breadcrumb.md +++ b/docs/en-US/component/breadcrumb.md @@ -25,10 +25,10 @@ breadcrumb/icon ## Breadcrumb Attributes -| Attribute | Description | Type | Accepted Values | Default | -| --------------- | ---------------------------- | ------ | --------------- | ------- | -| separator | separator character | string | — | / | -| separator-class | class name of icon separator | string | — | - | +| Attribute | Description | Type | Accepted Values | Default | +| --------------- | --------------------------------- | ------------------ | --------------- | ------- | +| separator | separator character | string | — | / | +| separator-class | icon compontent of icon separator | string / Component | — | - | ## Breadcrumb Slots diff --git a/docs/en-US/component/color-picker.md b/docs/en-US/component/color-picker.md index e1292571e2..6b41b7b6aa 100644 --- a/docs/en-US/component/color-picker.md +++ b/docs/en-US/component/color-picker.md @@ -41,15 +41,15 @@ color-picker/sizes ## Attributes -| Attribute | Description | Type | Accepted Values | Default | -| --------------------- | -------------------------------------------- | ------- | --------------------- | ------------------------------------------------------------- | -| model-value / v-model | binding value | string | — | — | -| disabled | whether to disable the ColorPicker | boolean | — | false | -| size | size of ColorPicker | string | medium / small / mini | — | -| show-alpha | whether to display the alpha slider | boolean | — | false | -| color-format | color format of v-model | string | hsl / hsv / hex / rgb | hex (when show-alpha is false)/ rgb (when show-alpha is true) | -| popper-class | custom class name for ColorPicker's dropdown | string | — | — | -| predefine | predefined color options | array | — | — | +| Attribute | Description | Type | Accepted Values | Default | +| --------------------- | ------------------------------------------------- | ------------------ | --------------------- | ------------------------------------------------------------- | +| model-value / v-model | binding value | string | — | — | +| disabled | whether to disable the ColorPicker | boolean | — | false | +| size | size of ColorPicker | string | medium / small / mini | — | +| show-alpha | whether to display the alpha slider | boolean | — | false | +| color-format | color format of v-model | string | hsl / hsv / hex / rgb | hex (when show-alpha is false)/ rgb (when show-alpha is true) | +| popper-class | custom icon compontent for ColorPicker's dropdown | string / Component | — | — | +| predefine | predefined color options | array | — | — | ## Events diff --git a/docs/en-US/component/loading.md b/docs/en-US/component/loading.md index 38fcb091b7..813e8ea783 100644 --- a/docs/en-US/component/loading.md +++ b/docs/en-US/component/loading.md @@ -21,7 +21,7 @@ loading/basic You can customize loading text, loading spinner and background color. -:::demo Add attribute `element-loading-text` to the element on which `v-loading` is bound, and its value will be displayed under the spinner. Similarly, the `element-loading-spinner`, `element-loading-background`, and `element-loading-svg` attributes are used to set the icon class name, background color value, and loading icon, respectively. +:::demo Add attribute `element-loading-text` to the element on which `v-loading` is bound, and its value will be displayed under the spinner. Similarly, the `element-loading-spinner`, `element-loading-background`, and `element-loading-svg` attributes are used to set the icon component, background color value, and loading icon, respectively. loading/customization @@ -94,9 +94,9 @@ If Element Plus is imported entirely, a globally method `$loading` will be regis ## Directives -| Name | Description | Type | -| -------------------------- | -------------------------------------------- | ------- | -| v-loading | show animation while loading data | boolean | -| element-loading-text | loading text that displays under the spinner | string | -| element-loading-spinner | class name of the custom spinner | string | -| element-loading-background | background color of the mask | string | +| Name | Description | Type | +| -------------------------- | -------------------------------------------- | ------------------ | +| v-loading | show animation while loading data | boolean | +| element-loading-text | loading text that displays under the spinner | string | +| element-loading-spinner | icon compontent of the custom spinner | string / Component | +| element-loading-background | background color of the mask | string | diff --git a/packages/components/breadcrumb/__tests__/breadcrumb.spec.ts b/packages/components/breadcrumb/__tests__/breadcrumb.spec.ts index cde1f700b9..67860ed986 100644 --- a/packages/components/breadcrumb/__tests__/breadcrumb.spec.ts +++ b/packages/components/breadcrumb/__tests__/breadcrumb.spec.ts @@ -1,4 +1,5 @@ import { mount } from '@vue/test-utils' +import { Check } from '@element-plus/icons' import Breadcrumb from '../src/breadcrumb.vue' import BreadcrumbItem from '../src/breadcrumb-item.vue' @@ -9,6 +10,11 @@ const _mount = (template: string) => 'el-breadcrumb': Breadcrumb, 'el-breadcrumb-item': BreadcrumbItem, }, + data() { + return { + Check, + } + }, template, }, { @@ -30,21 +36,21 @@ describe('Breadcrumb.vue', () => { expect(wrapper.find('.el-breadcrumb__separator').text()).toBe('?') }) - test('separatorClass', () => { - const wrapper = _mount(` - + test('separatorIcon', () => { + const wrapper = _mount( + ` + A - `) - expect(wrapper.find('.el-breadcrumb__separator').text()).toBe('') - expect(wrapper.find('.el-breadcrumb__separator').classes()).toContain( - 'test' + ` ) + expect(wrapper.find('.el-breadcrumb__separator').text()).toBe('') + expect(wrapper.findComponent(Check).exists()).toBe(true) }) test('to', () => { const wrapper = _mount(` - + A `) diff --git a/packages/components/breadcrumb/src/breadcrumb-item.vue b/packages/components/breadcrumb/src/breadcrumb-item.vue index 46c6a91d16..6f5b6521db 100644 --- a/packages/components/breadcrumb/src/breadcrumb-item.vue +++ b/packages/components/breadcrumb/src/breadcrumb-item.vue @@ -7,11 +7,9 @@ > - + + + {{ separator }} @@ -56,7 +54,7 @@ export default defineComponent({ return { link, separator: parent?.separator, - separatorClass: parent?.separatorClass, + separatorIcon: parent?.separatorIcon, } }, }) diff --git a/packages/components/breadcrumb/src/breadcrumb.ts b/packages/components/breadcrumb/src/breadcrumb.ts index c797627d02..47f2ce8341 100644 --- a/packages/components/breadcrumb/src/breadcrumb.ts +++ b/packages/components/breadcrumb/src/breadcrumb.ts @@ -1,13 +1,15 @@ -import type { ExtractPropTypes } from 'vue' +import { buildProps, definePropType } from '@element-plus/utils/props' -export const breadcrumbProps = { +import type { ExtractPropTypes, Component } from 'vue' + +export const breadcrumbProps = buildProps({ separator: { type: String, default: '/', }, - separatorClass: { - type: String, + separatorIcon: { + type: definePropType([String, Object]), default: '', }, -} as const +} as const) export type BreadcrumbProps = ExtractPropTypes diff --git a/packages/components/color-picker/src/index.vue b/packages/components/color-picker/src/index.vue index 4697a29ff3..0d8f5edd9f 100644 --- a/packages/components/color-picker/src/index.vue +++ b/packages/components/color-picker/src/index.vue @@ -75,15 +75,19 @@ backgroundColor: displayedColor, }" > - + class="el-color-picker__empty is-icon-close" + > + + - + class="el-color-picker__icon is-icon-arrow-down" + > + + @@ -104,6 +108,7 @@ import { } from 'vue' import debounce from 'lodash/debounce' import ElButton from '@element-plus/components/button' +import ElIcon from '@element-plus/components/icon' import { ClickOutside } from '@element-plus/directives' import { elFormItemKey, elFormKey } from '@element-plus/tokens' import { useLocaleInject } from '@element-plus/hooks' @@ -112,6 +117,7 @@ import ElInput from '@element-plus/components/input' import { UPDATE_MODEL_EVENT } from '@element-plus/utils/constants' import { useGlobalConfig } from '@element-plus/utils/util' import { isValidComponentSize } from '@element-plus/utils/validators' +import { Close, ArrowDown } from '@element-plus/icons' import AlphaSlider from './components/alpha-slider.vue' import HueSlider from './components/hue-slider.vue' import Predefine from './components/predefine.vue' @@ -130,6 +136,9 @@ export default defineComponent({ ElButton, ElPopper, ElInput, + ElIcon, + Close, + ArrowDown, SvPanel, HueSlider, AlphaSlider, diff --git a/packages/components/date-picker/src/date-picker-com/panel-date-pick.vue b/packages/components/date-picker/src/date-picker-com/panel-date-pick.vue index c1a3053ea6..77c4625b37 100644 --- a/packages/components/date-picker/src/date-picker-com/panel-date-pick.vue +++ b/packages/components/date-picker/src/date-picker-com/panel-date-pick.vue @@ -189,6 +189,7 @@ import { extractTimeFormat, TimePickPanel, } from '@element-plus/components/time-picker' +import { ElIcon } from '@element-plus/components/icon' import { EVENT_CODE } from '@element-plus/utils/aria' import { isValidDatePickType } from '@element-plus/utils/validators' import { @@ -214,6 +215,7 @@ export default defineComponent({ DateTable, ElInput, ElButton, + ElIcon, TimePickPanel, MonthTable, YearTable, diff --git a/packages/components/dropdown/src/dropdown-item.vue b/packages/components/dropdown/src/dropdown-item.vue index fc17e1fae7..efe49654df 100644 --- a/packages/components/dropdown/src/dropdown-item.vue +++ b/packages/components/dropdown/src/dropdown-item.vue @@ -9,25 +9,29 @@ :tabindex="disabled ? null : -1" @click="handleClick" > - +