Skip to content

Commit

Permalink
refactor: enhance floor display format
Browse files Browse the repository at this point in the history
  • Loading branch information
leftstick committed Mar 14, 2019
1 parent 000238a commit 7367f18
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 16 deletions.
14 changes: 7 additions & 7 deletions example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
"license": "MIT",
"private": true,
"dependencies": {
"antd": "^3.12.1",
"antd": "^3.15.0",
"classnames": "^2.2.6",
"dva": "^2.4.1",
"fengmap": "^2.2.0",
"lodash": "^4.17.11",
"path-to-regexp": "^2.4.0",
"react": "^16.7.0",
"react-syntax-highlighter": "^10.1.2",
"react-dom": "^16.7.0",
"react": "^16.8.4",
"react-syntax-highlighter": "^10.2.0",
"react-dom": "^16.8.4",
"react-fengmap": "file:.."
},
"scripts": {
Expand All @@ -23,9 +23,9 @@
"devDependencies": {
"babel-eslint": "^9.0.0",
"less-vars-to-js": "^1.3.0",
"prettier": "^1.15.3",
"prettier": "^1.16.4",
"redbox-react": "^1.6.0",
"umi": "^2.4.2",
"umi-plugin-react": "^1.4.0"
"umi": "^2.6.1",
"umi-plugin-react": "^1.6.0"
}
}
14 changes: 6 additions & 8 deletions example/src/pages/api/fengmap-floorcontrol/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class FengmapFloorControlDoc extends Component {
<Highlight language="jsx">
{`// 只能配合基础地图
<FengmapBase mapId={MapId} style={Style} fengmapSDK={SDK} mapOptions={MapOptions} >
<FengmapFloorControl ctrlOptions={CtrlOptions} onFloorChange={OnFloorChange} />
<FengmapFloorControl ctrlOptions={CtrlOptions} labelFormater={LabelFormater} />
</FengmapBase>
`}
</Highlight>
Expand All @@ -47,9 +47,9 @@ class FengmapFloorControlDoc extends Component {
)
},
{
prop: 'onFloorChange',
type: 'Function',
description: '楼层切换时的回调函数'
prop: 'labelFormater',
type: '(floor: Number) => String',
description: '自定义楼层标签'
}
]}
/>
Expand Down Expand Up @@ -84,9 +84,7 @@ class FengmapFloorControlDoc extends Component {
position: fengmapSDK.controlPositon.RIGHT_BOTTOM,
showBtnCount: 4
}}
onFloorChange={floor => {
console.log(`Changed floor to: `, floor)
}}
labelFormater={v => v + 'F'}
/>
</FengmapBase>

Expand Down Expand Up @@ -123,7 +121,7 @@ export default function Example(props) {
position: fengmapSDK.controlPositon.RIGHT_BOTTOM,
showBtnCount: 7
}}
onFloorChange={props.changeFloor}
labelFormater={v => v + 'F'}
/>
</FengmapBase>
)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-fengmap",
"version": "2.7.6",
"version": "2.7.7",
"description": "",
"author": "leftstick",
"typings": "typings/index.d.ts",
Expand Down
5 changes: 5 additions & 0 deletions src/components/HorizontalButtonGroupsControl/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ class HorizontalButtonGroupsControl extends React.Component {

_getFloorName = floorLevel => {
const { labelFormater } = this.props

if (!floorLevel || Number.isNaN(floorLevel)) {
return ''
}

if (labelFormater) {
return `${labelFormater(floorLevel)}`
}
Expand Down
4 changes: 4 additions & 0 deletions src/components/VerticalButtonGroupsControl/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ class VerticalButtonGroupsControl extends React.Component {

_getFloorName = floorLevel => {
const { labelFormater } = this.props
if (!floorLevel || Number.isNaN(floorLevel)) {
return ''
}

if (labelFormater) {
return `${labelFormater(floorLevel)}`
}
Expand Down

0 comments on commit 7367f18

Please sign in to comment.