Skip to content

Commit

Permalink
Display compared versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Damnae committed Apr 8, 2024
1 parent c1b8a00 commit 4e75449
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/common/datasource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,14 @@ export async function getLatestCommitId()
return commits[0]?.sha
}

export async function getCommitVersion(commitId:string) : Promise<string>
{
const commits = await retrieveCommits()
const entry = commits.find(c => c.sha == commitId)
const message = entry?.commit.message ?? 'missing'
return message.replace(/\s+/, ' ').split(' ')[0] ?? message
}

export interface DataSourceCompareFile
{
Path:string
Expand Down
19 changes: 19 additions & 0 deletions src/styles/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,25 @@ body
min-height: 100vh;
}

header
{
display:flex;
align-items:center;
justify-content:end;
gap:.5rem;
}
header .header-info
{
text-align:end;
order:-1;
color:#484848;
margin-bottom:.5rem;
}
header .header-info em
{
color:grey;
}

h1
{
font-weight: 100;
Expand Down
16 changes: 16 additions & 0 deletions src/views/pages/Changes.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script setup lang="ts">
import { ref, provide, } from 'vue';
import { getCommitVersion } from '@/common/datasource';
import { TaskContextType } from '@/sources/ability';
import NavTabs from '@/components/NavTabs.vue';
import Files from './changes/Files.vue';
Expand All @@ -9,6 +10,8 @@
import BattleEvents from './changes/BattleEvents.vue';
const props = defineProps<{fromCommitId:string, commitId:string}>()
const fromName = ref(await getCommitVersion(props.fromCommitId))
const toName = ref(await getCommitVersion(props.commitId))
const tabs:string[] = ['Files', 'Abilities', 'Modifiers', 'Statuses', 'Battle Events']
const tabsWithContext = ['Abilities', 'Modifiers']
Expand Down Expand Up @@ -37,6 +40,14 @@
<main class="panel">
<header>
<h1>Changes</h1>
<div class="header-info">
<div>
Comparing <em>{{ toName }}</em>&nbsp;<span class="code" :title="commitId">{{ commitId.slice(0, 6) }}</span>
</div>
<div>
since <em>{{ fromName }}</em>&nbsp;<span class="code" :title="fromCommitId">{{ fromCommitId.slice(0, 6) }}</span>
</div>
</div>
</header>
<div class="filters">
<NavTabs :tabs="tabs" v-model:selected="selectedTab" />
Expand All @@ -62,4 +73,9 @@
</template>

<style scoped>
.code
{
font-family: monospace;
font-size: 1rem;
}
</style>

0 comments on commit 4e75449

Please sign in to comment.