|
1 | 1 | <script lang="ts">
|
2 | 2 | // UI5 Components
|
3 |
| - import { setTheme } from "@ui5/webcomponents-base/dist/config/Theme"; |
| 3 | + import { setTheme } from "@ui5/webcomponents-base/dist/config/Theme.js"; |
4 | 4 | import "@ui5/webcomponents-base/dist/features/F6Navigation";
|
5 |
| - import applyDirection from "@ui5/webcomponents-base/dist/locale/applyDirection.js"; |
6 | 5 |
|
7 | 6 | import "@ui5/webcomponents/dist/Button";
|
8 | 7 | import "@ui5/webcomponents/dist/Input";
|
|
13 | 12 | import "@ui5/webcomponents/dist/Popover";
|
14 | 13 | import "@ui5/webcomponents/dist/Tab";
|
15 | 14 | import "@ui5/webcomponents/dist/TabContainer";
|
16 |
| - import "@ui5/webcomponents-fiori/dist/ShellBar"; |
17 |
| - import "@ui5/webcomponents-fiori/dist/ShellBarItem"; |
18 | 15 | import "@ui5/webcomponents-fiori/dist/Assets.js";
|
19 | 16 | import "@ui5/webcomponents/dist/Switch";
|
20 | 17 | import "@ui5/webcomponents-icons/dist/palette.js";
|
|
27 | 24 | import "@ui5/webcomponents-icons/dist/globe.js";
|
28 | 25 | import TodoList from "./lib/TodoList.svelte";
|
29 | 26 | import { todos, doneTodos } from "./stores/stores";
|
30 |
| - import logo from "./assets/imgs/UI5-orange-pheonix-logo.png"; |
31 | 27 | import type { TodoItemT } from "./types/TodoItem.type";
|
32 |
| - import { references } from "./stores/stores.svelte"; |
33 | 28 | import Dialog from "@ui5/webcomponents/dist/Dialog.js";
|
34 |
| - import Popover from "@ui5/webcomponents/dist/Popover.js"; |
| 29 | + import Header from "./lib/Header.svelte"; |
35 | 30 |
|
36 | 31 | setTheme("sap_horizon");
|
37 | 32 |
|
38 |
| - const shellBarTitle: string = "UI5 Web Components Svelte Sample Application"; |
39 | 33 | const dialogHeaderText: string = "Edit Todo";
|
40 | 34 |
|
41 | 35 | // Elements
|
42 | 36 | let dialog = $state<Dialog | null>();
|
43 | 37 | let dialogTextArea = $state();
|
44 | 38 | let dialogDatePicker = $state();
|
45 |
| - let themeSettingsPopover = $state<Popover | null>(null); |
46 |
| - let profileSettingsPopover = $state<Popover | null>(null); |
47 | 39 |
|
48 | 40 | // Create ToDo Fields
|
49 | 41 | let itemInputValue;
|
|
56 | 48 |
|
57 | 49 | // Event Handlers
|
58 | 50 |
|
59 |
| - const handleThemeSettingsToggle = (event) => { |
60 |
| - if (themeSettingsPopover) { |
61 |
| - themeSettingsPopover.opener = event.detail.targetRef; |
62 |
| - themeSettingsPopover.open = !themeSettingsPopover.open; |
63 |
| - } |
64 |
| - }; |
65 |
| -
|
66 |
| - const handleThemeChange = (event) => { |
67 |
| - setTheme(event.detail.selectedItems[0].getAttribute("data-theme")); |
68 |
| - if (themeSettingsPopover) { |
69 |
| - themeSettingsPopover.open = false; |
70 |
| - } |
71 |
| - }; |
72 |
| -
|
73 |
| - const handleProfileClick = (event) => { |
74 |
| - if (profileSettingsPopover) { |
75 |
| - profileSettingsPopover.opener = event.detail.targetRef; |
76 |
| - profileSettingsPopover.open = !profileSettingsPopover.open; |
77 |
| - } |
78 |
| - }; |
79 |
| -
|
80 |
| - const handleProfileSettingsSelect = (event) => { |
81 |
| - const selectedKey = event.detail.item.getAttribute("data-key"); |
82 |
| - if (selectedKey === "settings") { |
83 |
| - if (references.dialog.settings) { |
84 |
| - references.dialog.settings.open = true; |
85 |
| - } |
86 |
| - } else if (selectedKey === "help") { |
87 |
| - if (references.dialog.help) { |
88 |
| - references.dialog.help.open = true; |
89 |
| - } |
90 |
| - } |
91 |
| - }; |
92 |
| -
|
93 |
| - const handleRtlSwitchChange = (event) => { |
94 |
| - document.body.dir = event.target.checked ? "rtl" : "ltr"; |
95 |
| - applyDirection(); |
96 |
| - }; |
97 |
| -
|
98 |
| - const handleContentDensitySwitchChange = (event) => { |
99 |
| - if (event.target.checked) { |
100 |
| - document.body.classList.add("ui5-content-density-compact"); |
101 |
| - } else { |
102 |
| - document.body.classList.remove("ui5-content-density-compact"); |
103 |
| - } |
104 |
| - }; |
105 |
| -
|
106 |
| - const handleSettingsDialogCloseButtonClick = () => { |
107 |
| - if (references.dialog.settings) { |
108 |
| - references.dialog.settings.open = false; |
109 |
| - } |
110 |
| - }; |
111 |
| -
|
112 |
| - const handleHelpDialogCloseButtonClick = () => { |
113 |
| - if (references.dialog.help) { |
114 |
| - references.dialog.help.open = false; |
115 |
| - } |
116 |
| - }; |
117 |
| -
|
118 | 51 | const handleItemInput = (event) => {
|
119 | 52 | itemInputValue = event.target.value;
|
120 | 53 | };
|
|
237 | 170 | </script>
|
238 | 171 |
|
239 | 172 | <main class="app">
|
240 |
| - <header class="app-header"> |
241 |
| - <ui5-shellbar primary-title={shellBarTitle} show-notifications notifications-count="2" onprofile-click={handleProfileClick}> |
242 |
| - <img class="app-header-logo" slot="logo" src={logo} alt="ui5 orange pheonix logo" /> |
243 |
| - <ui5-shellbar-item icon="palette" text="Theme" onclick={handleThemeSettingsToggle}></ui5-shellbar-item> |
244 |
| - <ui5-avatar slot="profile" size="XS" initials="JD"></ui5-avatar> |
245 |
| - </ui5-shellbar> |
246 |
| - </header> |
| 173 | + <Header /> |
247 | 174 |
|
248 | 175 | <ui5-tabcontainer collapsed>
|
249 | 176 | <ui5-tab text="My Todos"></ui5-tab>
|
|
400 | 327 | width: calc(100% - 2rem);
|
401 | 328 | }
|
402 | 329 |
|
403 |
| - .app-header-logo { |
404 |
| - height: 2rem; |
405 |
| - max-height: 2rem; |
406 |
| - } |
407 |
| -
|
408 |
| - .app-bar-theming-popover { |
409 |
| - width: 250px; |
410 |
| - } |
411 |
| -
|
412 | 330 | .create-todo-wrapper {
|
413 | 331 | display: flex;
|
414 | 332 | align-items: center;
|
|
490 | 408 | width: 100%;
|
491 | 409 | }
|
492 | 410 | }
|
493 |
| - .app-bar-profile-popover { |
494 |
| - width: 250px; |
495 |
| - } |
496 |
| -
|
497 |
| - #settings-dialog { |
498 |
| - max-width: 300px; |
499 |
| - } |
500 |
| -
|
501 |
| - .dialog-button { |
502 |
| - display: flex; |
503 |
| - justify-content: flex-end; |
504 |
| - margin-top: 0.625rem; |
505 |
| - margin-bottom: -0.425rem; |
506 |
| - } |
507 |
| -
|
508 |
| - .profile-settings, |
509 |
| - .help-header { |
510 |
| - display: flex; |
511 |
| - flex-direction: row; |
512 |
| - justify-content: flex-start; |
513 |
| - } |
514 |
| -
|
515 |
| - .profile-text { |
516 |
| - display: flex; |
517 |
| - flex-direction: column; |
518 |
| - justify-content: center; |
519 |
| - margin-inline-start: 1rem; |
520 |
| - } |
521 |
| -
|
522 |
| - .app-header-logo { |
523 |
| - height: 2rem; |
524 |
| - } |
525 |
| -
|
526 |
| - .profile-settings-list { |
527 |
| - margin-top: 1.25rem; |
528 |
| - } |
529 |
| -
|
530 |
| - .help-dialog-text { |
531 |
| - font-size: 0.875rem; |
532 |
| - } |
533 |
| -
|
534 |
| - .profile-rtl-switch { |
535 |
| - width: 100%; |
536 |
| - display: flex; |
537 |
| - align-items: center; |
538 |
| - justify-content: space-between; |
539 |
| - } |
540 |
| -
|
541 |
| - #header-title-align { |
542 |
| - margin: 1rem 0; |
543 |
| - gap: 0.225rem; |
544 |
| - } |
545 |
| -
|
546 |
| - #header-logo-align { |
547 |
| - margin: 0.225rem 3.225rem 0.225rem 0; |
548 |
| - align-items: center; |
549 |
| - gap: 0.435rem; |
550 |
| - } |
551 |
| -
|
552 |
| - #help-dialog::part(header) { |
553 |
| - justify-content: flex-start; |
554 |
| - } |
555 | 411 | </style>
|
0 commit comments