Skip to content

Commit

Permalink
Merge branch 'yihong0618:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
jujimeizuo committed Nov 28, 2023
2 parents e418044 + 3f9584a commit 5c913a5
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 7 deletions.
10 changes: 7 additions & 3 deletions src/components/RunTable/RunRow.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from 'react';
import { formatPace, titleForRun, formatRunTime, Activity } from '@/utils/utils';
import { formatPace, titleForRun, formatRunTime, Activity, RunIds } from '@/utils/utils';
import styles from './style.module.scss';

interface IRunRowProperties {
elementIndex: number;
locateActivity: (_date: string) => void;
locateActivity: (_runIds: RunIds) => void;
run: Activity;
runIndex: number;
setRunIndex: (_ndex: number) => void;
Expand All @@ -16,7 +16,11 @@ const RunRow = ({ elementIndex, locateActivity, run, runIndex, setRunIndex }: IR
const heartRate = run.average_heartrate;
const runTime = formatRunTime(run.moving_time);
const handleClick = () => {
if (runIndex === elementIndex) return;
if (runIndex === elementIndex) {
setRunIndex(-1);
locateActivity([]);
return
};
setRunIndex(elementIndex);
locateActivity([run.run_id]);
};
Expand Down
3 changes: 2 additions & 1 deletion src/components/RunTable/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import {
sortDateFuncReverse,
convertMovingTime2Sec,
Activity,
RunIds,
} from '@/utils/utils';
import RunRow from './RunRow';
import styles from './style.module.scss';

interface IRunTableProperties {
runs: Activity[];
locateActivity: (_date: string) => void;
locateActivity: (_runIds: RunIds) => void;
setActivity: (_runs: Activity[]) => void;
runIndex: number;
setRunIndex: (_index: number) => void;
Expand Down
3 changes: 2 additions & 1 deletion src/components/RunTable/style.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
}

.runRow {
cursor: pointer;
td {
padding: 0.5rem;
border: 0;
Expand All @@ -47,7 +48,7 @@

.tableContainer {
width: 100%;
overflow-x: scroll;
overflow-x: auto;
}

.runDate {
Expand Down
7 changes: 5 additions & 2 deletions src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
scrollToMap,
sortDateFunc,
titleForShow,
RunIds,
} from '@/utils/utils';

const Index = () => {
Expand Down Expand Up @@ -74,10 +75,12 @@ const Index = () => {
changeByItem(title, 'Title', filterTitleRuns);
};

const locateActivity = (runIds: [Number]) => {
const locateActivity = (runIds: RunIds) => {
const ids = new Set(runIds);

const selectedRuns = runs.filter((r) => ids.has(r.run_id));
const selectedRuns = !runIds.length
? runs
: runs.filter((r: any) => ids.has(r.run_id));

if (!selectedRuns.length) {
return;
Expand Down
2 changes: 2 additions & 0 deletions src/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { FeatureCollection, LineString } from 'geojson';

export type Coordinate = [number, number];

export type RunIds = Array<number> | [];

export interface Activity {
run_id: number;
name: string;
Expand Down
9 changes: 9 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,14 @@ export default defineConfig({
build: {
manifest: true,
outDir: './dist', // for user easy to use, vercel use default dir -> dist
rollupOptions: {
output: {
manualChunks: (id: string) => {
if (id.includes('activities')) {
return 'activities'
}
},
}
},
},
});

0 comments on commit 5c913a5

Please sign in to comment.