Skip to content

Commit

Permalink
🏷️ feat: 优化配置结构
Browse files Browse the repository at this point in the history
BREAKING CHANGE: 配置中 `arrange` 字段 更名为 `sections`
  • Loading branch information
arvinxx committed Apr 10, 2021
1 parent 34deff8 commit a780bcd
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 23 deletions.
24 changes: 10 additions & 14 deletions packages/journey-map/schema/journey-map.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@
"Config": {
"description": "图表配置",
"properties": {
"arrange": {
"description": "section 的排序",
"color": {
"description": "主色",
"type": "string"
},
"height": {
"$ref": "#/definitions/Partial<Record<SectionType,number>>",
"description": "每个部分的高度"
},
"sections": {
"description": "待显示的区块\n默认为: ['stage', 'action', 'emotion','thought']",
"items": {
"enum": [
"action",
Expand All @@ -19,18 +27,6 @@
},
"type": "array"
},
"color": {
"description": "主色",
"type": "string"
},
"height": {
"$ref": "#/definitions/Partial<Record<SectionType,number>>",
"description": "每个部分的高度"
},
"section": {
"description": "显示左侧区域",
"type": "boolean"
},
"title": {
"description": "显示旅程图标题",
"type": "boolean"
Expand Down
4 changes: 2 additions & 2 deletions packages/journey-map/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ const JourneyMap: FC<JourneyMapProps> = ({
chance: () => <div />,
};

const arrange = store.config?.arrange || [
const list = store.config?.sections || [
'stage',
'action',
'emotion',
Expand All @@ -78,7 +78,7 @@ const JourneyMap: FC<JourneyMapProps> = ({
<div className="avx-journey-map-title">{store.title}</div>
) : null}
<div className="avx-journey-map-content">
{arrange.map((a) => {
{list.map((a) => {
const Section = sections[a];
return <Section key={a} />;
})}
Expand Down
11 changes: 4 additions & 7 deletions packages/journey-map/src/types/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,24 +79,21 @@ export type SectionType =
* 图表配置
*/
export interface Config {
/**
* 显示左侧区域
*/
section?: boolean;
/**
* 显示旅程图标题
*/
title?: boolean;
/**
* 主色
* 旅程图主色风格
*/
color?: string;
/**
* 每个部分的高度
*/
height?: Partial<Record<SectionType, number>>;
/**
* section 的排序
* 待显示的区块
* 默认为: ['stage', 'action', 'emotion','thought']
*/
arrange?: Partial<SectionType>[];
sections?: Partial<SectionType>[];
}

1 comment on commit a780bcd

@vercel
Copy link

@vercel vercel bot commented on a780bcd Apr 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.