Skip to content

Commit

Permalink
Merge pull request #831 from oslokommune/period-selector-facelift
Browse files Browse the repository at this point in the history
Period selector facelift
  • Loading branch information
petterhj authored Aug 25, 2023
2 parents a80c6ad + 90584ed commit e156f46
Show file tree
Hide file tree
Showing 10 changed files with 290 additions and 203 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ All notable changes to this project will be documented in this file. The format
- Upgraded to Firebase 9.
- Progression values are now required to be positive on entry, both from the web
interface and from the API.
- The design of the period selector has been refreshed.

### Removed

Expand Down
28 changes: 14 additions & 14 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"node": "18"
},
"dependencies": {
"@oslokommune/punkt-vue2": "^5.0.8",
"@oslokommune/punkt-vue2": "^5.1.21",
"d3": "^7.6.1",
"d3-array": "^3.1.1",
"d3-axis": "^3.0.0",
Expand Down Expand Up @@ -66,7 +66,7 @@
"devDependencies": {
"@babel/eslint-parser": "7.16.5",
"@babel/preset-env": "^7.16.5",
"@oslokommune/punkt-css": "^5.0.8",
"@oslokommune/punkt-css": "^5.1.19",
"@vitejs/plugin-vue2": "^2.2.0",
"env-cmd": "^10.1.0",
"esbuild": "^0.15.14",
Expand Down
8 changes: 4 additions & 4 deletions src/components/Navigation/SiteHeader.vue
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<nav-menu-item dropdown>
<template #text>
<pkt-icon class="nav-menu-item__icon" name="bullseye" />
<span class="pkt-show-phablet-up">{{ siteMenuLabel }}</span>
<span class="pkt-show-tablet-up">{{ siteMenuLabel }}</span>
</template>
<template #default="{ close }">
<site-menu-dropdown :handle-navigation="close" />
Expand Down Expand Up @@ -40,7 +40,7 @@
</nav>
<nav v-if="showToolbar" class="nav-bar site-navigation__toolbar">
<period-selector />
<period-selector-menu />
<view-toggle />
</nav>
</header>
Expand All @@ -53,7 +53,7 @@ import SiteMenuDropdown from '@/components/Navigation/SiteMenuDropdown.vue';
import getActiveItemType from '@/util/getActiveItemType';
import NavMenuItem from '@/components/Navigation/navbar/NavMenuItem.vue';
import NavMenu from '@/components/Navigation/navbar/NavMenu.vue';
import PeriodSelector from '@/components/Navigation/toolbar/PeriodSelector.vue';
import PeriodSelectorMenu from '@/components/Navigation/toolbar/PeriodSelectorMenu.vue';
import ViewToggle from '@/components/Navigation/toolbar/ViewToggle.vue';
import UserMenuDropdown from '@/components/Navigation/UserMenuDropdown.vue';
Expand All @@ -65,7 +65,7 @@ export default {
NavMenuItem,
SiteMenuDropdown,
UserMenuDropdown,
PeriodSelector,
PeriodSelectorMenu,
ViewToggle,
},
Expand Down
181 changes: 0 additions & 181 deletions src/components/Navigation/toolbar/PeriodSelector.vue

This file was deleted.

87 changes: 87 additions & 0 deletions src/components/Navigation/toolbar/PeriodSelectorMenu.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
<template>
<nav-menu class="period-selector-menu">
<nav-menu-text
:text="`${$t('general.period')}:`"
strong
class="period-selector-menu__label pkt-show-tablet-up"
/>
<nav-menu-item v-slot="{ close }" :text="periodLabel" dropdown>
<period-selector
v-model="period"
:options="_predefinedPeriods"
:max-months="3"
class="period-selector-menu__dropdown"
@input="close"
/>
</nav-menu-item>
</nav-menu>
</template>

<script>
import { mapState, mapActions } from 'vuex';
import { getPeriods } from '@/config/periods';
import NavMenu from '@/components/Navigation/navbar/NavMenu.vue';
import NavMenuItem from '@/components/Navigation/navbar/NavMenuItem.vue';
import NavMenuText from '@/components/Navigation/navbar/NavMenuText.vue';
import PeriodSelector from '@/components/period/PeriodSelector.vue';
export default {
name: 'PeriodSelectorMenu',
components: {
NavMenu,
NavMenuItem,
NavMenuText,
PeriodSelector,
},
computed: {
...mapState(['selectedPeriod']),
period: {
get() {
return this.selectedPeriod;
},
set(value) {
this.setSelectedPeriod(value);
},
},
periodLabel() {
if (this.selectedPeriod) {
return this.selectedPeriod.label;
}
return this.$t('period.choosePeriod');
},
_predefinedPeriods() {
return Object.values(getPeriods());
},
},
methods: {
...mapActions(['setSelectedPeriod']),
},
};
</script>

<style lang="scss" scoped>
@use '@oslokommune/punkt-css/dist/scss/abstracts/mixins/breakpoints' as *;
.period-selector-menu {
&__dropdown {
width: 100vw;
@include bp('tablet-up') {
width: unset;
min-width: 10rem;
}
}
&__label {
::v-deep .nav-menu-text__inner {
padding-right: 0;
}
}
}
</style>
Loading

0 comments on commit e156f46

Please sign in to comment.