Skip to content

Commit 4b1ef87

Browse files
authored
feat: Mobile friendly (#86)
* Add prereqs to build vue app, resolve npm audit * Many changes to make this a responsive page * Revert "Add prereqs to build vue app, resolve npm audit" This reverts commit bdfbc86. * Cleanup to closer-match original * Many changes - now in line w/discussion on PR #86 Shrank container min-width to allow more flexibility with content shrinking. Now set to 160px, but including padding the minimum page width before the browser just starts shrinking content is about 220px. Allowed cards to grow to fit space, so now if one of the 4 little data points drops to the next line it'll show as centered and look nice. Also increased card min width and matched units to the font unit - so, essentially, the data points can show up to 8 or 9 large characters across before content will overflow. Imported the Menu icon from vue-material-design so it can be used for the page view/event selector. Added names to page and event in the router so the names can be displayed. Modified the demo banner to work better at small screen widths. Components will not encroach on the close button. The close button and right side of the box are scooted away from the right wall a little. The github links can now flex to a top line and push the text down below when there's not enough room for both of them on one line. The bar charts in view and events have overflow and width set on them as constraints. I'm honestly not sure why that makes them perform more consistently at smaller sizes in Firefox. The 300 px width is not a magic number - the important part is that it's smaller than expected chart width at screen widths larger than 700 px. This random fix only makes a difference at screen widths larger than 700 px... Tested in Firefox and Chromium. Site selector and date selector are now in a flexbox just by themselves, so when the screen gets too small for both then they can split across two lines and take up the full line. Looks nice I think. There's a new flexbox for the settings buttons and refresh button. Views/Event content setting is in there (when visible), refresh button, and theme settings (cog) button is in there. It's separate from the site/date selector so the site/date selectors flow nicer, and to allow this one to flow up in narrow mode. 700 pixels wide is the point at which the display switches mode. The normal left side views/events bar becomes invisible when the screen is narrower than 700 px now. The views/event "Content" selector hamburger button becomes visible when the screen is narrower than 700 px. This has an el-drawer implementing the popout window. The worst part about this is that this code is similar across two files now, instead of just being implemented in one place: views/stats/index.vue and vies/app.vue The settings button flexbox (content, refresh, cog button) moves up a line, above the site/date selector, and takes up the whole width, when screen is narrower than 700px. The map now pushes down below the location stats listing so they can both take the full width. I think the map is a really cool feature, and easy enough to scroll past if you don't want to see it. * Fix prettier output * Improve vis of page views chart at smaller size * Revert scroll overflow to hidden. * Change top/bottom/side padding back to 15px I rejiggered how this padding layout worked... I believe the goal with the original large screen layout was to have 15px on top, bottom, and sides, and good space between elements sideways. With the flexbox layout, and the possibility of multiple rows of stats, just putting 15px on the cards makes 30px between cards vertically. I think that looks slightly less balanced than intended. So - now the gap (flexbox thing) manages space between elements at only 15px, and the padding is applied to the outer element (totals) to handle the top/bottom/sides padding. * Put gap between settings rows at any screen size * Alignment fixes on settings bar - also moves gear Vertically centers the page/event button, refresh, and gear buttons, and slightly changes how separator is calculated to reflect local size instead of root (rem to em) so it'll hopefully stay centered better in future changes. Also moves the gear right to the edge... Not sure if you'll like this @rehanvdm, when I was aligning the hamburger button I realized there's no reason it shouldn't go all the way left to the edge, there's padding to keep it away from the screen edge... Then I realized the gear should work the same on the other side. * Time on page column slightly wider * Shift to element plus hiding/page break scheme Also - make the page break on the map simpler by just changing to one flex column, instead of switching layout mode to flex. * Fix text vert align in Firefox * Fix JS error about num/vs/string & fix 'else' typo * Site/date sel back to orig sizes when widescreen To do this without negatively affecting responsiveness, I added an additional media break at 900px. When the screen is less wide than 900px (max-width 899px) then the site and date selector are allowed to take up the full width and flex their sizes more, so they can take a good view size regardless of width. * Fix backlight on gear & page/event setting buttons
1 parent cdbe8ce commit 4b1ef87

File tree

14 files changed

+208
-78
lines changed

14 files changed

+208
-78
lines changed

application/src/frontend/src/assets/main.css

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,16 @@ p {
7979
width: 100%;
8080
padding: 0 15px;
8181
min-height: 470px;
82+
min-width: 200px;
83+
flex: 1 1;
84+
}
85+
86+
.main-row {
87+
display: flex; width: 100%; margin-top: 10px; column-gap: 10px; flex-flow: row wrap;
88+
}
89+
90+
.filter-tag {
91+
margin: 5px 5px 0 0;
8292
}
8393

8494
.demo > .el-alert__content > .el-alert__description {

application/src/frontend/src/components/ChartLocation.vue

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,11 +87,11 @@ onMounted(() => {
8787

8888
<template>
8989
<div style="height: 470px;">
90-
<div v-show="!loading" class="chart" ref="chartRef" style="height: 100%; width: 870px;"></div>
90+
<div v-show="!loading" class="chart" ref="chartRef" style="height: 100%; width: 100%;"></div>
9191
<el-skeleton v-show="loading" :loading="true" animated style="height: 100%">
9292
<template #template>
9393
<div style="display: flex; height: 100%; width: 100%; margin-top: 10px; column-gap: 10px;">
94-
<div class="chart" style="height: 100%; width: 900px; ">
94+
<div class="chart" style="height: 100%; width: 100%; ">
9595
<el-skeleton-item variant="image" style="height: 85%; margin: 20px;" />
9696
</div>
9797
</div>

application/src/frontend/src/components/TableData.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ const hover = reactive<Record<any, boolean>>({});
105105
<div class="row" :style="rowGridColumnCss" v-for="(row, rowIndex) in pageData">
106106
<template v-for="col of columns">
107107
<template v-if="col.type === 'string'">
108-
<el-tooltip :show-after="1000" :content="row[col.index] != undefined ? row[col.index] : '-'">
108+
<el-tooltip :show-after="1000" :content="row[col.index] != undefined ? String(row[col.index]) : '-'">
109109
<div v-if="col.canFilter" class="column column--overflow">
110110

111111
<div style="display: flex;"
@@ -123,13 +123,13 @@ const hover = reactive<Record<any, boolean>>({});
123123
</div>
124124

125125
</div>
126-
<div v-lese class="column column--overflow">
126+
<div v-else class="column column--overflow">
127127
{{ row[col.index] != undefined ? row[col.index] : "-" }}
128128
</div>
129129
</el-tooltip>
130130
</template>
131131
<template v-if="col.type === 'number'">
132-
<el-tooltip :show-after="1000" :content="row[col.index] != undefined ? row[col.index] : '-'">
132+
<el-tooltip :show-after="1000" :content="row[col.index] != undefined ? String(row[col.index]) : '-'">
133133
<div class="column">{{ humanizeNumber(row[col.index]) }}</div>
134134
</el-tooltip>
135135
</template>

application/src/frontend/src/components/TotalsData.vue

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,20 +79,22 @@ function tooltipContent(value: number, from: string, to: string, prevValue: numb
7979
8080
.totals {
8181
display: flex;
82+
flex-flow: row wrap;
8283
justify-content: space-between;
8384
box-shadow: var(--el-box-shadow-lighter);
8485
border-radius: 10px;
8586
min-height: inherit;
87+
padding: 15px;
88+
gap: 15px;
8689
}
8790
8891
.card {
92+
flex: 1 1;
8993
display: flex;
9094
flex-direction: column;
9195
justify-content: center;
9296
align-items: center;
93-
padding: 15px;
94-
width: 25%;
95-
min-width: 100px;
97+
min-width: 9rem;
9698
}
9799
.card__skeleton {
98100
margin-top: 5px;

application/src/frontend/src/components/vue-material-design-icons.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
import { App } from 'vue';
22
import 'vue-material-design-icons/styles.css';
33
import Cog from 'vue-material-design-icons/Cog.vue';
4+
import Menu from 'vue-material-design-icons/Menu.vue';
45
import InboxMultiple from 'vue-material-design-icons/InboxMultiple.vue';
56
import ChevronDown from 'vue-material-design-icons/ChevronDown.vue';
67
import Refresh from 'vue-material-design-icons/Refresh.vue';
78
import OpenInNew from 'vue-material-design-icons/OpenInNew.vue';
89

910
export function registerIconComponents(app: App<Element>) {
1011
app.component('mdi-cog', Cog);
12+
app.component('mdi-menu', Menu);
1113
app.component('mdi-inbox-multiple', InboxMultiple);
1214
app.component('mdi-chevron-down', ChevronDown);
1315
app.component('mdi-refresh', Refresh);

application/src/frontend/src/main.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import ElementPlus from 'element-plus';
22
import 'element-plus/dist/index.css';
33
import 'element-plus/theme-chalk/dark/css-vars.css';
4+
import 'element-plus/theme-chalk/display.css';
45
import '@fontsource/nunito/latin.css';
56

67
import { createApp, ref, watch } from 'vue';

application/src/frontend/src/router/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,12 @@ const router = createRouter({
1313
{
1414
path: '/stats/page',
1515
component: stats,
16+
name: 'Page Views',
1617
},
1718
{
1819
path: '/stats/event',
1920
component: stats,
21+
name: 'Events',
2022
},
2123
// {
2224
// path: '/',

application/src/frontend/src/views/app.vue

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<script setup lang="ts">
22
3-
import {computed} from "vue";
3+
import {computed, ref} from "vue";
44
import {getSystemStore} from "@frontend/src/stores/system";
55
import {trackLinkClick, trackRouterClick} from "@frontend/src/lib/track";
66
@@ -13,10 +13,10 @@ const showDemoBanner = computed(() => {
1313

1414
<template>
1515

16-
<el-container class="h100" style="display: flex; justify-content: center">
17-
<div style="width: 1280px;">
18-
<div style="display: flex;">
19-
<div style="width: 140px">
16+
<el-container class="h100" style="">
17+
<div style="max-width: 1280px; width: 100%; margin: auto;">
18+
<div style="display: flex; flex-flow: row nowrap;">
19+
<div class="hidden-xs-only" style="width: 140px; flex: 0 0;">
2020
<el-menu :default-active="$route.path" style="margin-top: 10px; border-right: none;">
2121
<el-menu-item index="/stats/page" @click="trackRouterClick('menu_page', '/stats/page')">
2222
<template #title>Page Views</template>
@@ -27,14 +27,14 @@ const showDemoBanner = computed(() => {
2727
</el-menu>
2828
</div>
2929

30-
<div style="width: 100%">
31-
<el-alert v-if="showDemoBanner" class="demo" type="warning" style="margin-top: 10px; margin-left: 10px; width: 100%" >
32-
<div style="display: flex; justify-content: space-between; width: 100%">
33-
<div>
30+
<div style="width: 100%; flex: 1 1;">
31+
<el-alert v-if="showDemoBanner" class="demo" type="warning" style="margin-top: 10px; margin-left: 10px; width: 97%;" >
32+
<div style="display: flex; flex-flow: row wrap-reverse; justify-content: space-between; width: 100%;">
33+
<div style="flex: 1 1; min-width: 200px;">
3434
This is the open source CDK <a style="font-weight: bold; color: inherit" href="https://github.com/rehanvdm/serverless-website-analytics" target="_blank">serverless-website-analytics</a>
3535
demo page, it tracks this page and some <a style="font-weight: bold; color: inherit" href="https://github.com/rehanvdm/serverless-website-analytics/blob/main/docs/DEMO-TRAFFIC.md" target="_blank">simulated traffic.</a>.
3636
</div>
37-
<div>
37+
<div style="flex: 0 1; padding-right: 25px; margin-left: auto;">
3838
<a style="margin-left: 20px" class="link-explicit"
3939
@click="trackLinkClick('github', 'https://github.com/rehanvdm/serverless-website-analytics')">
4040
<img alt="GitHub Repo stars" src="https://img.shields.io/github/stars/rehanvdm/serverless-website-analytics?label=Github&style=social">
@@ -57,9 +57,6 @@ const showDemoBanner = computed(() => {
5757
</template>
5858

5959
<style scoped>
60-
.el-menu {
61-
height: 50px;
62-
}
6360
.el-menu-item {
6461
border-radius: 5px;
6562
font-size: large;

application/src/frontend/src/views/stats/event/components/chart_locations.vue

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -136,16 +136,39 @@ function rowClick(cell: Record<string, any>) {
136136
</script>
137137

138138
<template>
139-
<div class="container" style="height: 470px;">
140-
141-
<div style="display: grid; grid-template-columns: 6fr 2fr; height: 100%;">
142-
<ChartLocation v-bind:graphs="chartProps.graphs!" v-bind:loading="loading"></ChartLocation>
143-
<TableData :columns="columns" :rows="chartLocations || []" :loading="loading" :page-size="16"
139+
<div class="container chart-data-outer">
140+
<div class="chart-data" style="height: 100%;">
141+
<ChartLocation v-bind:graphs="chartProps.graphs!" v-bind:loading="loading" style="overflow: hidden; width: 100%;"></ChartLocation>
142+
<TableData class="table-data" :columns="columns" :rows="chartLocations || []" :loading="loading" :page-size="16"
144143
@click="rowClick"></TableData>
145144
</div>
146-
147145
</div>
148146
</template>
149147

150148
<style scoped>
149+
.chart-data {
150+
display: grid;
151+
grid-template-columns: 6fr 2fr;
152+
padding: 10px;
153+
}
154+
.table-data {
155+
min-width: 140px;
156+
margin-left: 10px;
157+
}
158+
.chart-data-outer {
159+
min-height: 490px;
160+
}
161+
@media all and (max-width: 767px) {
162+
.chart-data {
163+
grid-template-columns: 1fr;
164+
}
165+
.table-data {
166+
order: -1;
167+
width: 100%;
168+
margin-bottom: 10px;
169+
}
170+
.chart-data-outer {
171+
height: fit-content;
172+
}
173+
}
151174
</style>

application/src/frontend/src/views/stats/event/index.vue

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ watch([filter], () => {
204204
<ChartEvents ref="componentChartEvents" :sites="sites" :from-date="fromDate" :to-date="toDate"
205205
@loading="(val) => loadingChartEvents = val"
206206
:filter="filter"
207+
style="overflow: hidden; width: 300px;"
207208
></ChartEvents>
208209
</div>
209210

@@ -242,12 +243,5 @@ watch([filter], () => {
242243

243244
<style scoped>
244245
245-
.main-row {
246-
display: flex; width: 100%; margin-top: 10px; column-gap: 10px;
247-
}
248-
.filter-tag {
249-
margin: 5px 5px 0 0;
250-
}
251-
252246
</style>
253247

0 commit comments

Comments
 (0)