From c3602187c30df7fc83ee44c39dc55eaa48e4df3e Mon Sep 17 00:00:00 2001 From: yyyyaaa Date: Mon, 2 Sep 2024 13:34:23 +0700 Subject: [PATCH] fix --- compiler/plugins/vue.plugin.js | 10 +--- packages/vue/stories/core/Icon.stories.ts | 70 +++++++++++++++++++++++ src/ui/box/box.lite.tsx | 10 +--- src/ui/icon/icon.lite.tsx | 14 ++++- 4 files changed, 85 insertions(+), 19 deletions(-) create mode 100644 packages/vue/stories/core/Icon.stories.ts diff --git a/compiler/plugins/vue.plugin.js b/compiler/plugins/vue.plugin.js index bd5ef2f0..818660f9 100644 --- a/compiler/plugins/vue.plugin.js +++ b/compiler/plugins/vue.plugin.js @@ -26,8 +26,6 @@ module.exports = function vueCompilerPlugin() { function fixCleanupRefAst(ast) { if (ast.hooks && ast.hooks.onUnMount) { - console.log(ast.hooks); - const onUnMountCode = ast.hooks.onUnMount.code; let updatedCode = onUnMountCode; @@ -88,11 +86,5 @@ function fixCleanupRefAst(ast) { } function fixVueClassName(codeStr) { - return codeStr - .replace(/\.className/g, ".class") - .replace(/\bclassName\b/g, "class") - .replace( - /:class="boxStyles\.class"/g, - ':class="clsx(boxStyles.class, class)"', - ); + return codeStr.replace(/\bprops\.className\b/g, "props.class"); } diff --git a/packages/vue/stories/core/Icon.stories.ts b/packages/vue/stories/core/Icon.stories.ts new file mode 100644 index 00000000..97aa573b --- /dev/null +++ b/packages/vue/stories/core/Icon.stories.ts @@ -0,0 +1,70 @@ +import type { Meta, StoryObj } from "@storybook/vue3"; +import Icon from "../../src/ui/icon/icon.vue"; +import Box from "../../src/ui/box/box.vue"; +import Text from "../../src/ui/text/text.vue"; +import { ALL_ICON_NAMES } from "../../src/ui/icon/icon.types"; + +const meta: Meta = { + title: "Core/Icon", + component: Icon, + tags: ["autodocs"], + argTypes: { + name: { + control: "select", + options: ALL_ICON_NAMES, + }, + size: { + control: "text", + }, + color: { + control: "color", + }, + }, +}; + +export default meta; +type Story = StoryObj; + +export const Primary: Story = { + args: {}, + render: (args) => ({ + components: { Icon, Box, Text }, + setup() { + return { args, ALL_ICON_NAMES }; + }, + template: ` +
+ + + + {{ iconName }} + + +
+ `, + }), +}; diff --git a/src/ui/box/box.lite.tsx b/src/ui/box/box.lite.tsx index 200cb717..32559c4c 100644 --- a/src/ui/box/box.lite.tsx +++ b/src/ui/box/box.lite.tsx @@ -16,12 +16,11 @@ export default function Box(props: BoxProps) { const state = useStore<{ comp: string; boxStyles: { - className: string; + combinedClassName: string; style: Record; passThroughProps: Record; }; finalPassThroughProps: Record; - combinedClassName: string; }>({ get comp() { return props.as ?? DEFAULT_VALUES.as; @@ -29,9 +28,6 @@ export default function Box(props: BoxProps) { get finalPassThroughProps() { return state.boxStyles.passThroughProps; }, - get combinedClassName() { - return clsx(state.boxStyles.className, props.className); - }, get boxStyles() { const sprinklesObj = rainbowSprinkles({ ...omit(props, ["attributes", "as", "boxRef"]), @@ -39,7 +35,7 @@ export default function Box(props: BoxProps) { }); return { - className: clsx(sprinklesObj.className, props.className), + combinedClassName: clsx(sprinklesObj.className, props.className), style: sprinklesObj.style, passThroughProps: omit(sprinklesObj.otherProps, [ "attributes", @@ -53,7 +49,7 @@ export default function Box(props: BoxProps) { return ( {props.title}