xref: /webtrees/app/Module/CloudsTheme.php (revision 4a52049613a3fd380896a97f74b94d45ccccc97c)
1<?php
2/**
3 * webtrees: online genealogy
4 * Copyright (C) 2019 webtrees development team
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
15 */
16declare(strict_types=1);
17
18namespace Fisharebest\Webtrees\Module;
19
20use Fisharebest\Webtrees\I18N;
21use Fisharebest\Webtrees\Menu;
22
23/**
24 * The clouds theme.
25 */
26class CloudsTheme extends AbstractModule implements ModuleThemeInterface
27{
28    use ModuleThemeTrait {
29        primaryMenu as basePrimaryMenu;
30    }
31
32    protected const PERSON_BOX_CLASSES = [
33        'M' => 'person_box',
34        'F' => 'person_boxF',
35        'U' => 'person_boxNN',
36    ];
37
38
39    /**
40     * How should this module be labelled on tabs, menus, etc.?
41     *
42     * @return string
43     */
44    public function title(): string
45    {
46        /* I18N: Name of a theme. */
47        return I18N::translate('clouds');
48    }
49
50    /**
51     * Misecellaneous dimensions, fonts, styles, etc.
52     *
53     * @param string $parameter_name
54     *
55     * @return string|int|float
56     */
57    public function parameter($parameter_name)
58    {
59        $parameters = [
60            'chart-background-f'             => 'e9daf1',
61            'chart-background-m'             => 'b1cff0',
62            'chart-background-u'             => 'eeeeee',
63            'chart-box-x'                    => 260,
64            'chart-box-y'                    => 85,
65            'chart-font-color'               => '000000',
66            'chart-spacing-x'                => 4,
67            'chart-spacing-y'                => 10,
68            'compact-chart-box-x'            => 240,
69            'compact-chart-box-y'            => 50,
70            'distribution-chart-high-values' => '95b8e0',
71            'distribution-chart-low-values'  => 'c8e7ff',
72            'distribution-chart-no-values'   => 'ffffff',
73        ];
74
75        return $parameters[$parameter_name];
76    }
77
78    /**
79     * Generate a list of items for the main menu.
80     *
81     * @return Menu[]
82     */
83    public function primaryMenu(): array
84    {
85        $primary_menu = $this->basePrimaryMenu();
86
87        foreach ($primary_menu as $menu) {
88            $submenus = $menu->getSubmenus();
89
90            if (!empty($submenus)) {
91                // Insert a dummy menu / label into the submenu
92                array_unshift($submenus, new Menu($menu->getLabel(), '#', '', ['onclick' => 'return false;']));
93                $menu->setSubmenus($submenus);
94            }
95        }
96
97        return $primary_menu;
98    }
99
100    /**
101     * A list of CSS files to include for this page.
102     *
103     * @return string[]
104     */
105    public function stylesheets(): array
106    {
107        return [
108            asset('css/clouds.min.css'),
109        ];
110    }
111}
112