Skip to content

Commit

Permalink
fix: rename the Icon component to IconifyIcon to prevent name conflic…
Browse files Browse the repository at this point in the history
…ts and fix type issues (#4704)
  • Loading branch information
anncwb authored Oct 21, 2024
1 parent 88d2b3e commit 1b172b0
Show file tree
Hide file tree
Showing 16 changed files with 74 additions and 54 deletions.
1 change: 1 addition & 0 deletions apps/web-ele/src/views/demos/element/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ const tableData = [
<ElCard class="mb-5">
<template #header> 按钮 </template>
<ElSpace>
<ElButton text>Text</ElButton>
<ElButton>Default</ElButton>
<ElButton type="primary"> Primary </ElButton>
<ElButton type="info"> Info </ElButton>
Expand Down
2 changes: 1 addition & 1 deletion apps/web-naive/src/adapter/component/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ async function initComponentAdapter() {
DatePicker: NDatePicker,
// 自定义默认按钮
DefaultButton: (props, { attrs, slots }) => {
return h(NButton, { ...props, attrs, type: 'info' }, slots);
return h(NButton, { ...props, attrs, type: 'default' }, slots);
},
// 自定义主要按钮
PrimaryButton: (props, { attrs, slots }) => {
Expand Down
2 changes: 2 additions & 0 deletions docs/src/components/common-ui/vben-form.md
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,8 @@ export interface ActionButtonOptions {
show?: boolean;
/** 按钮文本 */
text?: string;
/** 任意属性 */
[key: string]: any;
}
```

Expand Down
4 changes: 2 additions & 2 deletions internal/vite-config/src/config/application.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ function defineApplicationConfig(userConfigPromise?: DefineApplicationOptions) {
rollupOptions: {
output: {
assetFileNames: '[ext]/[name]-[hash].[ext]',
chunkFileNames: 'js/[name]-[hash].mjs',
entryFileNames: 'jse/index-[name]-[hash].mjs',
chunkFileNames: 'js/[name]-[hash].js',
entryFileNames: 'jse/index-[name]-[hash].js',
},
},
target: 'es2015',
Expand Down
2 changes: 1 addition & 1 deletion packages/@core/base/design/src/design-tokens/dark.css
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

/* Used for accents such as hover effects on <DropdownMenuItem>, <SelectItem>...etc */
--accent: 216 5% 19%;
--accent-lighter: 216 5% 11%;
--accent-lighter: 216 5% 12%;
--accent-hover: 216 5% 24%;
--accent-foreground: 0 0% 98%;

Expand Down
4 changes: 3 additions & 1 deletion packages/@core/base/icons/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ export { default as EmptyIcon } from './components/empty.vue';
export * from './create-icon';

export * from './lucide';
export * from '@iconify/vue';

export type { IconifyIcon as IconifyIconStructure } from '@iconify/vue';
export { addCollection, addIcon, Icon as IconifyIcon } from '@iconify/vue';
9 changes: 9 additions & 0 deletions packages/@core/base/shared/src/color/color.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { TinyColor } from '@ctrl/tinycolor';

export function isDarkColor(color: string) {
return new TinyColor(color).isDark();
}

export function isLightColor(color: string) {
return new TinyColor(color).isLight();
}
1 change: 1 addition & 0 deletions packages/@core/base/shared/src/color/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './color';
export * from './convert';
export * from './generator';
1 change: 1 addition & 0 deletions packages/@core/ui-kit/form-ui/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ export interface FormRenderProps<
}

export interface ActionButtonOptions extends VbenButtonProps {
[key: string]: any;
content?: string;
show?: boolean;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/@core/ui-kit/shadcn-ui/src/components/icon/icon.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { type Component, computed } from 'vue';
import { Icon, IconDefault } from '@vben-core/icons';
import { IconDefault, IconifyIcon } from '@vben-core/icons';
import {
isFunction,
isHttpUrl,
Expand All @@ -28,6 +28,6 @@ const isComponent = computed(() => {
<template>
<component :is="icon as Component" v-if="isComponent" v-bind="$attrs" />
<img v-else-if="isRemoteIcon" :src="icon as string" v-bind="$attrs" />
<Icon v-else-if="icon" v-bind="$attrs" :icon="icon as string" />
<IconifyIcon v-else-if="icon" v-bind="$attrs" :icon="icon as string" />
<IconDefault v-else-if="fallback" v-bind="$attrs" />
</template>
6 changes: 4 additions & 2 deletions packages/effects/hooks/src/use-design-tokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,12 +217,13 @@ export function useElementPlusDesignTokens() {

'--el-color-info-light-8': border,
'--el-color-info-light-9': getCssVariableValue('--info'), // getCssVariableValue('--secondary'),

'--el-color-primary': getCssVariableValue('--primary-500'),
'--el-color-primary-dark-2': getCssVariableValue('--primary'),
'--el-color-primary-light-3': getCssVariableValue('--primary-400'),
'--el-color-primary-light-5': getCssVariableValue('--primary-300'),
'--el-color-primary-light-7': getCssVariableValue('--primary-200'),
'--el-color-primary-light-7': isDark.value
? border
: getCssVariableValue('--primary-200'),
'--el-color-primary-light-8': isDark.value
? border
: getCssVariableValue('--primary-100'),
Expand Down Expand Up @@ -268,6 +269,7 @@ export function useElementPlusDesignTokens() {

'--el-text-color-regular': getCssVariableValue('--foreground'),
};

updateCSSVariables(variables, `__vben_design_styles__`);
},
{ immediate: true },
Expand Down
4 changes: 2 additions & 2 deletions packages/icons/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './iconify/index';
export * from './svg/index';
export * from './iconify/index.js';
export * from './svg/index.js';
2 changes: 1 addition & 1 deletion packages/icons/src/svg/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createIconifyIcon } from '@vben-core/icons';

import './load';
import './load.js';

const SvgAvatar1Icon = createIconifyIcon('svg:avatar-1');
const SvgAvatar2Icon = createIconifyIcon('svg:avatar-2');
Expand Down
6 changes: 4 additions & 2 deletions packages/icons/src/svg/load.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { addIcon, type IconifyIcon } from '@vben-core/icons';
import type { IconifyIconStructure } from '@vben-core/icons';

import { addIcon } from '@vben-core/icons';

let loaded = false;
if (!loaded) {
loadSvgIcons();
loaded = true;
}

function parseSvg(svgData: string): IconifyIcon {
function parseSvg(svgData: string): IconifyIconStructure {
const parser = new DOMParser();
const xmlDoc = parser.parseFromString(svgData, 'image/svg+xml');
const svgElement = xmlDoc.documentElement;
Expand Down
66 changes: 33 additions & 33 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 1b172b0

Please sign in to comment.