0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-17 23:44:39 -05:00

Trying out moving the date dropdown

no issue

- seeing if this feels better up above than it is when inside the anchor
This commit is contained in:
James Morris 2022-05-11 14:03:48 +01:00
parent dc14b9943f
commit cd9ec81006
5 changed files with 54 additions and 46 deletions

View file

@ -32,6 +32,22 @@
<Dashboard::V5::Resources::Community /> <Dashboard::V5::Resources::Community />
</div> </div>
{{/if}} {{/if}}
<div class="gh-dashboard5-select">
<PowerSelect
@selected={{this.selectedDaysOption}}
@options={{this.daysOptions}}
@searchEnabled={{false}}
@onChange={{this.onDaysChange}}
@triggerComponent="gh-power-select/trigger"
@triggerClass="gh-contentfilter-menu-trigger"
@dropdownClass="gh-contentfilter-menu-dropdown is-narrow"
@matchTriggerWidth={{false}}
as |option|
>
{{#if option.name}}{{option.name}}{{else}}<span class="red">Unknown option</span>{{/if}}
</PowerSelect>
</div>
</section> </section>
{{#if (enable-developer-experiments)}} {{#if (enable-developer-experiments)}}

View file

@ -2,14 +2,45 @@ import Component from '@glimmer/component';
import {action} from '@ember/object'; import {action} from '@ember/object';
import {inject as service} from '@ember/service'; import {inject as service} from '@ember/service';
// Options 30 and 90 need an extra day to be able to distribute ticks/gridlines evenly
const DAYS_OPTIONS = [{
name: '7 Days',
value: 7
}, {
name: '30 Days',
value: 30 + 1
}, {
name: '90 Days',
value: 90 + 1
}];
export default class DashboardDashboardV5Component extends Component { export default class DashboardDashboardV5Component extends Component {
@service dashboardStats; @service dashboardStats;
daysOptions = DAYS_OPTIONS;
@action @action
onInsert() { onInsert() {
this.dashboardStats.loadSiteStatus(); this.dashboardStats.loadSiteStatus();
} }
@action
onDaysChange(selected) {
this.days = selected.value;
}
get days() {
return this.dashboardStats.chartDays;
}
set days(days) {
this.dashboardStats.chartDays = days;
}
get selectedDaysOption() {
return this.daysOptions.find(d => d.value === this.days);
}
get isLoading() { get isLoading() {
return this.dashboardStats.siteStatus === null; return this.dashboardStats.siteStatus === null;
} }

View file

@ -67,21 +67,5 @@
{{/if}} {{/if}}
</div> </div>
<div class="gh-dashboard5-select">
<PowerSelect
@selected={{this.selectedDaysOption}}
@options={{this.daysOptions}}
@searchEnabled={{false}}
@onChange={{this.onDaysChange}}
@triggerComponent="gh-power-select/trigger"
@triggerClass="gh-contentfilter-menu-trigger"
@dropdownClass="gh-contentfilter-menu-dropdown is-narrow"
@matchTriggerWidth={{false}}
as |option|
>
{{#if option.name}}{{option.name}}{{else}}<span class="red">Unknown option</span>{{/if}}
</PowerSelect>
</div>
</article> </article>
</section> </section>

View file

@ -9,18 +9,6 @@ import {tracked} from '@glimmer/tracking';
const DATE_FORMAT = 'D MMM, YYYY'; const DATE_FORMAT = 'D MMM, YYYY';
// Options 30 and 90 need an extra day to be able to distribute ticks/gridlines evenly
const DAYS_OPTIONS = [{
name: '7 Days',
value: 7
}, {
name: '30 Days',
value: 30 + 1
}, {
name: '90 Days',
value: 90 + 1
}];
const DISPLAY_OPTIONS = [{ const DISPLAY_OPTIONS = [{
name: 'Total members', name: 'Total members',
value: 'total' value: 'total'
@ -64,17 +52,8 @@ export default class Anchor extends Component {
@service feature; @service feature;
@tracked chartDisplay = 'total'; @tracked chartDisplay = 'total';
daysOptions = DAYS_OPTIONS;
displayOptions = DISPLAY_OPTIONS; displayOptions = DISPLAY_OPTIONS;
get days() {
return this.dashboardStats.chartDays;
}
set days(days) {
this.dashboardStats.chartDays = days;
}
@action @action
loadCharts() { loadCharts() {
this.dashboardStats.loadMemberCountStats(); this.dashboardStats.loadMemberCountStats();
@ -89,15 +68,6 @@ export default class Anchor extends Component {
this.chartDisplay = selected.value; this.chartDisplay = selected.value;
} }
@action
onDaysChange(selected) {
this.days = selected.value;
}
get selectedDaysOption() {
return this.daysOptions.find(d => d.value === this.days);
}
get selectedDisplayOption() { get selectedDisplayOption() {
return this.displayOptions.find(d => d.value === this.chartDisplay) ?? this.displayOptions[0]; return this.displayOptions.find(d => d.value === this.chartDisplay) ?? this.displayOptions[0];
} }

View file

@ -66,6 +66,7 @@ Dashboard v5 Layout */
} }
.gh-dashboard5-layout { .gh-dashboard5-layout {
position: relative;
max-width: 1230px; max-width: 1230px;
margin: 0 auto; margin: 0 auto;
} }
@ -398,6 +399,12 @@ Dashboard v5 Layout */
transition: none; transition: none;
} }
.gh-dashboard5-layout > .gh-dashboard5-select {
top: -62px;
right: -8px;
z-index: 999;
}
.gh-dashboard5-triple { .gh-dashboard5-triple {
display: flex; display: flex;
flex-direction: column; flex-direction: column;