Skip to content

Commit

Permalink
refactor: add DesignPageTitle
Browse files Browse the repository at this point in the history
  • Loading branch information
ludchieng committed Jan 24, 2023
1 parent 2aa7aa4 commit b18be8c
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 25 deletions.
34 changes: 13 additions & 21 deletions src/components/Stop/StopHeader.vue
Original file line number Diff line number Diff line change
@@ -1,48 +1,40 @@
<template>
<div class="title">
<h1>
{{ stop.displayName }}
</h1>
<span class="line-connections">
<router-link v-for="conn in stop.lineConnections"
:key="`${conn.line}/${conn.slugName}`"
:to="`/timetables/${$route.params.tab}/${conn.line}/${conn.slugName}`"
<DesignPageTitle :text="stop.displayName">
<div class="line-connections">
<router-link
v-for="conn in stop.lineConnections"
:key="`${conn.line}/${conn.slugName}`"
:to="`/timetables/${$route.params.tab}/${conn.line}/${conn.slugName}`"
>
<LineIcon
:lineSlugName="conn.line"
color="dark"
size="md"
/>
</router-link>
</span>
</div>
</div>
</DesignPageTitle>
</template>

<script lang="ts">
import Vue, { PropType } from 'vue'
import { StopType } from '@/utils/parser'
import LineIcon from '@/components/LineIcon.vue'
import DesignPageTitle from '@/components/design/DesignPageTitle.vue'
export default Vue.extend({
name: 'StopHeader',
components: { LineIcon },
components: {
LineIcon,
DesignPageTitle,
},
props: {
stop: {} as PropType<StopType>,
},
})
</script>

<style scoped>
.title {
min-height: 2.8rem;
}
h1 {
font-size: 1.5rem;
display: inline-block;
margin: 0.5rem 1rem 0 0;
}
.line-connections {
display: inline-block;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import Vue from 'vue'
export default Vue.extend({
name: 'DesignTitle',
name: 'DesignContentTitle',
})
</script>

Expand Down
27 changes: 27 additions & 0 deletions src/components/design/DesignPageTitle.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<template>
<div>
<h1>
{{ text }}
</h1>
<slot />
</div>
</template>

<script lang="ts">
import Vue from 'vue'
export default Vue.extend({
name: 'DesignContentTitle',
props: {
text: String,
},
})
</script>

<style scoped>
h1 {
font-size: 1.5rem;
display: inline-block;
margin: 0.5rem 1rem 0 0;
}
</style>
6 changes: 3 additions & 3 deletions src/pages/TimetablesHubPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
v-for="category in linesByCategory"
:key="category.name"
>
<DesignTitle>{{ category.name }}</DesignTitle>
<DesignContentTitle>{{ category.name }}</DesignContentTitle>
<router-link
v-for="line in category.lines"
:key="line.slugName"
Expand All @@ -26,13 +26,13 @@
import Vue from 'vue'
import LineIcon from '@/components/LineIcon.vue'
import { getLinesByCategory } from '@/utils/localstore/lines'
import DesignTitle from '@/components/design/DesignTitle.vue'
import DesignContentTitle from '@/components/design/DesignContentTitle.vue'
export default Vue.extend({
name: 'TimetablesHubPage',
components: {
LineIcon,
DesignTitle,
DesignContentTitle,
},
computed: {
linesByCategory () {
Expand Down

0 comments on commit b18be8c

Please sign in to comment.