Skip to content

Commit

Permalink
Merge pull request #5 from liuxian496/developer
Browse files Browse the repository at this point in the history
Developer
  • Loading branch information
liuxian496 authored Apr 24, 2024
2 parents da625e0 + 9be540a commit 6dc7ef6
Show file tree
Hide file tree
Showing 8 changed files with 132 additions and 30 deletions.
1 change: 1 addition & 0 deletions .storybook/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const config: StorybookConfig = {
...coverageConfig,
},
},
"@storybook/addon-mdx-gfm"
],
framework: {
name: "@storybook/react-vite",
Expand Down
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
# [0.2.0](https://github.com/liuxian496/cyndi/compare/v0.1.3...v0.2.0) (2024-04-24)


### Features

* defaultPrefix支持设置默认前缀(defaultPrefix) ([a7a7fb8](https://github.com/liuxian496/cyndi/commit/a7a7fb8be589c50290e2b66118027793665c896c))



## [0.1.3](https://github.com/liuxian496/cyndi/compare/v0.1.2...v0.1.3) (2024-04-22)


Expand Down
40 changes: 33 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,49 @@
### 1. 安装cyndi
npm i cyndi

### 2. litten依赖的库
### 2. cyndi依赖的库
cyndi,依赖下面的库。
1. [react](https://github.com/facebook/react)
2. [lodash](https://github.com/lodash/lodash)
1. [lodash](https://github.com/lodash/lodash)

## 功能

### getPrefixNs
获取控件css前缀
```
/**
* 获取控件css前缀
* @param componentName 控件名称 {string}
* @param customizePrefix 用户自定义前缀 {string}
* @param defaultPrefix 默认前缀 {string}
* @returns prefix 控件css类前缀 {string}
*/
export declare function getPrefixNs(componentName: string, customizePrefix?: string, defaultPrefix?: string): string;
```
### isEmptyString
检测是否是空字符串

```
/**
* 检测是否是空字符串
* @param 需要判断的值 {any}
* @returns isString 是否是空字符串 {boolean}
*/
export declare function isEmptyString(str: unknown): boolean;
```

### printArrayItem
遍历对象数组,将对的每个属性输出成字符串,不递归遍历对象属性的子属性
```
/**
* 遍历对象数组,将对象的每个属性输出成字符串,不递归遍历对象属性的子属性
* @param list 待遍历的数组
* @returns 遍历后拼装的字符串
*/
export declare function printArrayItem(list?: object[]): string;
```


## 如果你想请我喝一杯蜜雪冰城(Buy Me a Mixue Ice Cream & Tea
## 如果你想请我喝一杯咖啡(Buy Me a Coffee
<img src=".\\public\\wechat.jpg" height="360">
<img src=".\\public\\alipay.jpg" height="360">
29 changes: 15 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "cyndi",
"private": false,
"version": "0.1.3",
"version": "0.2.0",
"type": "module",
"module": "dist/index.js",
"types": "dist/index.d.ts",
Expand All @@ -27,23 +27,22 @@
"prepare": "husky"
},
"dependencies": {
"lodash": "^4.17.21",
"react": "^18.2.0",
"react-dom": "^18.2.0"
"lodash": "^4.17.21"
},
"devDependencies": {
"@chromatic-com/storybook": "^1.3.3",
"@commitlint/cli": "^19.2.2",
"@commitlint/config-conventional": "^19.2.2",
"@storybook/addon-coverage": "^1.0.1",
"@storybook/addon-essentials": "^8.0.8",
"@storybook/addon-interactions": "^8.0.8",
"@storybook/addon-links": "^8.0.8",
"@storybook/addon-onboarding": "^8.0.8",
"@storybook/blocks": "^8.0.8",
"@storybook/react": "^8.0.8",
"@storybook/react-vite": "^8.0.8",
"@storybook/test": "^8.0.8",
"@storybook/addon-essentials": "^8.0.9",
"@storybook/addon-interactions": "^8.0.9",
"@storybook/addon-links": "^8.0.9",
"@storybook/addon-mdx-gfm": "^8.0.9",
"@storybook/addon-onboarding": "^8.0.9",
"@storybook/blocks": "^8.0.9",
"@storybook/react": "^8.0.9",
"@storybook/react-vite": "^8.0.9",
"@storybook/test": "^8.0.9",
"@storybook/test-runner": "^0.17.0",
"@types/react": "^18.2.66",
"@types/react-dom": "^18.2.22",
Expand All @@ -57,8 +56,10 @@
"eslint-plugin-react-refresh": "^0.4.6",
"eslint-plugin-storybook": "^0.8.0",
"husky": "^9.0.11",
"litten": "^0.9.1",
"storybook": "^8.0.8",
"litten": "^0.9.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"storybook": "^8.0.9",
"typescript": "^5.2.2",
"vite": "^5.2.0",
"vite-plugin-dts": "^3.8.3"
Expand Down
61 changes: 61 additions & 0 deletions src/stories/util.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import "litten/dist/assets/summary.css";

import {
Meta,
Source,
} from "@storybook/blocks";

import * as Stories from "./util.stories.tsx";

import { Summary } from "litten/dist/summary";
import { Color } from "litten/dist/global";

<Meta of={Stories} />

# Util

## getPrefixNs
<Summary>
<Source code={
`
/**
* 获取控件css前缀
* @param componentName 控件名称 {string}
* @param customizePrefix 用户自定义前缀 {string}
* @param defaultPrefix 默认前缀 {string}
* @returns prefix 控件css类前缀 {string}
*/
export declare function getPrefixNs(componentName: string, customizePrefix?: string, defaultPrefix?: string): string;
`
} language="tsx" />
</Summary>

## isEmptyString
<Summary>
<Source code={
`
/**
* 检测是否是空字符串
* @param 需要判断的值 {any}
* @returns isString 是否是空字符串 {boolean}
*/
export declare function isEmptyString(str: unknown): boolean;
`
} language="tsx" />
</Summary>

## printArrayItem
<Summary>
<Source code={
`
/**
* 遍历对象数组,将对象的每个属性输出成字符串,不递归遍历对象属性的子属性
* @param list 待遍历的数组
* @returns 遍历后拼装的字符串
*/
export declare function printArrayItem(list?: object[]): string;
`
} language="tsx" />
</Summary>
2 changes: 1 addition & 1 deletion src/stories/util.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { IsEmptyStringTest } from "../test/util/isEmptyStringTest";
import { PrintArrayItemTest } from "../test/util/printArrayItemTest";

export default {
title: "Example/Util",
title: "Example/Util"
} as Meta;

export type UtilStory = StoryObj;
Expand Down
16 changes: 9 additions & 7 deletions src/util/getPrefixNs.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import isString from "lodash/isString";
import isString from "lodash/isString";
import { isEmptyString } from "./isEmptyString";

/**
* 获取控件css前缀
* @param componentName 控件名称 {string}
* @param customizePrefix 用户自定义前缀 {string}
* @param defaultPrefix 默认前缀 {string}
* @returns prefix 控件css类前缀 {string}
*/
export function getPrefixNs(
componentName: string,
customizePrefix?: string
componentName: string,
customizePrefix?: string,
defaultPrefix = "cyndi"
): string {
return isString(customizePrefix) && !isEmptyString(customizePrefix)
? customizePrefix + "-" + componentName
: `cyndi-${componentName}`;
}
return isString(customizePrefix) && !isEmptyString(customizePrefix)
? customizePrefix + "-" + componentName
: `${defaultPrefix}-${componentName}`;
}
4 changes: 3 additions & 1 deletion src/util/printArrayItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import isArray from "lodash/isArray";
import forOwn from "lodash/forOwn";

/**
* 遍历对象数组,将对的每个属性输出成字符串,不递归遍历对象属性的子属性
* 遍历对象数组,将对象的每个属性输出成字符串,不递归遍历对象属性的子属性
* @param list 待遍历的数组
* @returns 遍历后拼装的字符串
*/
export function printArrayItem(list?: object[]) {
const log: string[] = [];
Expand Down

0 comments on commit 6dc7ef6

Please sign in to comment.