Skip to content

Commit

Permalink
add: sport type: Ski
Browse files Browse the repository at this point in the history
  • Loading branch information
ben-29 committed Sep 16, 2023
1 parent c9c0388 commit f3a3588
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
- 修改 `scripts/config.py`, `TYPE_DICT` 增加类型映射关系, `MAPPING_TYPE` 里增加运动类型
- 修改 `src/utils/const.js`, 增加类型标题,并加入到 `RUN_TITLES`
- 修改 `src/utils/util.js` 里的 `colorFromType`, 增加 case 指定颜色; `titleForRun` 增加 case 指定类型标题

- 参考这个 [commit](https://github.com/ben-29/workouts_page/commit/bfb6e9da4f72bdbdec669c42bdd10062558039cd)
-[留言](https://github.com/ben-29/workouts_page/issues/20)
---

### Codoon(咕咚)
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ This project is based on [running_page](https://github.com/yihong0618/running_pa
- Modify `TYPE_DICT` & `MAPPING_TYPE` in `scripts/config.py`
- Add Type Name and add it into `RUN_TITLES` in `src/utils/const.js`
- Modify `colorFromType` & `titleForRun` in `src/utils/util.js`

- see [commit](https://github.com/ben-29/workouts_page/commit/bfb6e9da4f72bdbdec669c42bdd10062558039cd)
- or comment [here](https://github.com/ben-29/workouts_page/issues/20)

---

Expand Down
2 changes: 2 additions & 0 deletions scripts/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def safeget(dct, *keys):
"flight": "Flight",
"kayaking": "Kayaking",
"Snowboard": "Snowboard",
"Ski": "Ski",
}

MAPPING_TYPE = [
Expand All @@ -81,6 +82,7 @@ def safeget(dct, *keys):
"RoadTrip",
"Kayaking",
"Snowboard",
"Ski",
]

STRAVA_GARMIN_TYPE_DICT = {
Expand Down
2 changes: 2 additions & 0 deletions src/utils/const.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ const HIKE_TITLE = IS_CHINESE ? '徒步' : 'Hike';
const ROWING_TITLE = IS_CHINESE ? '划船' : 'Rowing';
const KAYAKING_TITLE = IS_CHINESE ? '皮划艇' : 'Kayaking';
const SNOWBOARD_TITLE = IS_CHINESE ? '单板滑雪' : 'Snowboard';
const SKI_TITLE = IS_CHINESE ? '双板滑雪' : 'Ski';
const ROAD_TRIP_TITLE = IS_CHINESE ? '自驾' : 'RoadTrip';
const FLIGHT_TITLE = IS_CHINESE ? '飞行' : 'Flight';

Expand All @@ -78,6 +79,7 @@ const RUN_TITLES = {
ROAD_TRIP_TITLE,
FLIGHT_TITLE,
SNOWBOARD_TITLE,
SKI_TITLE,
};

export {
Expand Down
9 changes: 6 additions & 3 deletions src/utils/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,11 @@ const pattern = /([\u4e00-\u9fa5]{2,}(市|自治州))/g;
const extractLocations = (str) => {
const locations = [];
let match;

while ((match = pattern.exec(str)) !== null) {
locations.push(match[0]);
}

return locations;
};

Expand All @@ -96,7 +96,7 @@ const locationForRun = (run) => {
if (cityMatch) {
[city] = cityMatch;
city = cities.find(value => cityMatch.includes(value));

if (!city) {
city = '';
}
Expand Down Expand Up @@ -194,6 +194,8 @@ const titleForType = (type) => {
return RUN_TITLES.KAYAKING_TITLE;
case 'Snowboard':
return RUN_TITLES.SNOWBOARD_TITLE;
case 'Ski':
return RUN_TITLES.SKI_TITLE;
default:
return RUN_TITLES.RUN_TITLE;
}
Expand Down Expand Up @@ -235,6 +237,7 @@ const colorFromType = (workoutType) => {
case 'Kayaking':
return KAYAKING_COLOR;
case 'Snowboard':
case 'Ski':
return SNOWBOARD_COLOR;
default:
return MAIN_COLOR;
Expand Down

0 comments on commit f3a3588

Please sign in to comment.