diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0c1266ac2766b594a6888010d412467894e72e49..33e9798a1c9e7b593c5bf91c7a3498f21f4f0666 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -20,9 +20,9 @@ 为了保证项目代码质量,我们指定了详细的编码风格指南。 为了你的PR可以顺利通过代码审查,请在编码前认真阅读以下**编码指南**: -- [Farris UI TypeScript 编码指南](./style-guid/typescript_style_guid.md) +- [Farris UI TypeScript 编码指南](./style-guide/typescript_style_guide.md) -- [Farris UI Vue 组件编码指南](./style-guid/vue_component_style_guid.md) +- [Farris UI Vue 组件编码指南](./style-guide/vue_component_style_guide.md) ## 提交Pull Request diff --git a/packages/ui-vue/components/input-group/src/composables/types.ts b/packages/ui-vue/components/input-group/src/composition/types.ts similarity index 100% rename from packages/ui-vue/components/input-group/src/composables/types.ts rename to packages/ui-vue/components/input-group/src/composition/types.ts diff --git a/packages/ui-vue/components/input-group/src/composables/use-append-button.ts b/packages/ui-vue/components/input-group/src/composition/use-append-button.ts similarity index 100% rename from packages/ui-vue/components/input-group/src/composables/use-append-button.ts rename to packages/ui-vue/components/input-group/src/composition/use-append-button.ts diff --git a/packages/ui-vue/components/input-group/src/composables/use-clear.ts b/packages/ui-vue/components/input-group/src/composition/use-clear.ts similarity index 100% rename from packages/ui-vue/components/input-group/src/composables/use-clear.ts rename to packages/ui-vue/components/input-group/src/composition/use-clear.ts diff --git a/packages/ui-vue/components/input-group/src/composables/use-text-box.ts b/packages/ui-vue/components/input-group/src/composition/use-text-box.ts similarity index 100% rename from packages/ui-vue/components/input-group/src/composables/use-text-box.ts rename to packages/ui-vue/components/input-group/src/composition/use-text-box.ts diff --git a/style-guid/typescript_style_guid.md b/style-guide/typescript_style_guide.md similarity index 100% rename from style-guid/typescript_style_guid.md rename to style-guide/typescript_style_guide.md diff --git a/style-guid/vue_component_style_guid.md b/style-guide/vue_component_style_guide.md similarity index 53% rename from style-guid/vue_component_style_guid.md rename to style-guide/vue_component_style_guide.md index bd9d643dde25144032b1e24a9d5d73c109c9e686..310671cf5cf1314e42a2e2def8230c78c901dea2 100644 --- a/style-guid/vue_component_style_guid.md +++ b/style-guide/vue_component_style_guide.md @@ -14,19 +14,18 @@ Farris UI Vue 的组件,都包含在`ui-vue`包的`components`目录下,每 以下是单个组件目录的结构 ``` -farris-component -├── specs // 单元测试 -| └── farris-component.spec.ts +input-group +├── test // 单元测试 +| └── input-group.spec.tsx ├── src // 组件源码 | ├── components // 子组件 -| | └── farris-child-component.ts -| ├── services // 组件的可复用逻辑 -| | ├── some-feature.service.ts -| | ├── some-feature.render.ts -| | ├── some-feature.template.ts -| | └── some-event.handler.ts -| ├── farris-component.types.ts // 组件类型 -| └── farris-component.tsx // 组件代码 +| | └── input-group-sub.component.tsx +| ├── composition // 组件的可复用逻辑 +| | ├── types.ts // 组合式Api返利值接口类型 +| | ├── use-append-button.ts // 实现组件特性1的组合式Api +| | └── use-clear.ts // 实现组件特性2的组合式Api +| ├── input-group.component.tsx // 组件代码 +| └── input-group.props.ts // 定义组件Api └── index.ts // 组件入口文件 ``` @@ -34,102 +33,107 @@ farris-component ```TypeScript import type { App } from 'vue'; -import FarrisComponent from './src/farris-component'; +import InputGroup from './src/input-group.component'; -export * from './src/farris-component.types'; +export * from './src/input-group.props'; -export { FarrisComponent }; +export { InputGroup }; export default { install(app: App): void { - app.component(FarrisComponent.name, FarrisComponent); + app.component(InputGroup.name, InputGroup); }, }; ``` -### 组件文件 `my-component.tsx` +### 组件文件 `input-group.component.tsx` ```TypeScript import { defineComponent, toRefs } from 'vue'; import type { SetupContext } from 'vue'; -import { someComponentProps, SomeComponentProps } from './farris-component.types'; -import { someFeatureService } from './services/some-feature.service'; +import { InputGroupProps, inputGroupProps } from './input-group.props'; +import { useClear } from './composition/use-clear'; export default defineComponent({ - name: 'f-some-component', - props: someComponentProps, + name: 'FInputGroup', + props: inputGroupProps, emits: ['update:modelValue'], - setup(props: SomeComponentProps, setupContext: SetupContext) { + setup(props: InputGroupProps, setupContext: SetupContext) { const { someProp } = toRefs(props); - const { someVarieble, someMethod } = someFeatureService(); + const { showClearButton, onClearValue } = useClear(); return () => { return ( -