|
2 | 2 | // UI5 Components |
3 | 3 | import { setTheme } from "@ui5/webcomponents-base/dist/config/Theme"; |
4 | 4 | import "@ui5/webcomponents-base/dist/features/F6Navigation"; |
| 5 | + import applyDirection from "@ui5/webcomponents-base/dist/locale/applyDirection.js"; |
5 | 6 |
|
6 | 7 | import "@ui5/webcomponents/dist/Button"; |
7 | 8 | import "@ui5/webcomponents/dist/Input"; |
|
14 | 15 | import "@ui5/webcomponents/dist/TabContainer"; |
15 | 16 | import "@ui5/webcomponents-fiori/dist/ShellBar"; |
16 | 17 | import "@ui5/webcomponents-fiori/dist/ShellBarItem"; |
17 | | - import "@ui5/webcomponents-icons/dist/palette.js"; |
18 | 18 | import "@ui5/webcomponents-fiori/dist/Assets.js"; |
19 | | -
|
| 19 | + import "@ui5/webcomponents/dist/Switch"; |
| 20 | + import "@ui5/webcomponents-icons/dist/palette.js"; |
| 21 | + import "@ui5/webcomponents-icons/dist/settings.js"; |
| 22 | + import "@ui5/webcomponents-icons/dist/sys-help.js"; |
| 23 | + import "@ui5/webcomponents-icons/dist/log.js"; |
| 24 | + import "@ui5/webcomponents-icons/dist/account.js"; |
| 25 | + import "@ui5/webcomponents-icons/dist/private.js"; |
| 26 | + import "@ui5/webcomponents-icons/dist/loan.js"; |
| 27 | + import "@ui5/webcomponents-icons/dist/globe.js"; |
20 | 28 | import TodoList from "./lib/TodoList.svelte"; |
21 | 29 | import { todos, doneTodos } from "./stores/stores"; |
22 | 30 | import logo from "./assets/imgs/UI5-orange-pheonix-logo.png"; |
|
32 | 40 | let dialogTextArea; |
33 | 41 | let dialogDatePicker; |
34 | 42 | let themeSettingsPopover; |
| 43 | + let profileSettingsPopover; |
35 | 44 |
|
36 | 45 | // Create ToDo Fields |
37 | 46 | let itemInputValue; |
|
53 | 62 | themeSettingsPopover.close(); |
54 | 63 | }; |
55 | 64 |
|
| 65 | + const handleProfileClick = (event) => { |
| 66 | + profileSettingsPopover.showAt(event.detail.targetRef); |
| 67 | + }; |
| 68 | +
|
| 69 | + const handleProfileSettingsSelect = (event) => { |
| 70 | + const selectedKey = event.detail.item.getAttribute("data-key"); |
| 71 | + if (selectedKey === "settings") { |
| 72 | + window["settings-dialog"].show(event.detail.targetRef); |
| 73 | + } else if (selectedKey === "help") { |
| 74 | + window["help-dialog"].show(event.detail.targetRef); |
| 75 | + } |
| 76 | + }; |
| 77 | +
|
| 78 | + const handleRtlSwitchChange = (event) => { |
| 79 | + document.body.dir = event.target.checked ? "rtl" : "ltr"; |
| 80 | + applyDirection(); |
| 81 | + }; |
| 82 | +
|
| 83 | + const handleContentDensitySwitchChange = (event) => { |
| 84 | + if (event.target.checked) { |
| 85 | + document.body.classList.add("ui5-content-density-compact"); |
| 86 | + } else { |
| 87 | + document.body.classList.remove("ui5-content-density-compact"); |
| 88 | + } |
| 89 | + }; |
| 90 | +
|
| 91 | + const handleSettingsDialogCloseButtonClick = (event) => { |
| 92 | + window["settings-dialog"].close(); |
| 93 | + }; |
| 94 | +
|
| 95 | + const handleHelpDialogCloseButtonClick = (event) => { |
| 96 | + window["help-dialog"].close(); |
| 97 | + }; |
| 98 | +
|
56 | 99 | const handleItemInput = (event) => { |
57 | 100 | itemInputValue = event.target.value; |
58 | 101 | }; |
|
170 | 213 |
|
171 | 214 | <main class="app"> |
172 | 215 | <header class="app-header"> |
173 | | - <ui5-shellbar primary-title={shellBarTitle} show-notifications notifications-count="2"> |
| 216 | + <ui5-shellbar primary-title={shellBarTitle} show-notifications notifications-count="2" on:profile-click={handleProfileClick}> |
174 | 217 | <img class="app-header-logo" slot="logo" src={logo} alt="ui5 orange pheonix logo" /> |
175 | 218 | <ui5-shellbar-item icon="palette" text="Theme" on:click={handleThemeSettingsToggle} /> |
176 | 219 | <ui5-avatar slot="profile" size="XS" initials="JD" /> |
|
230 | 273 | <ui5-li icon="palette" data-theme="sap_fiori_3_hcw">SAP Quartz HCW</ui5-li> |
231 | 274 | </ui5-list> |
232 | 275 | </ui5-popover> |
| 276 | + |
| 277 | + <ui5-popover bind:this={profileSettingsPopover} id="profile-pop" class="app-bar-profile-popover" placement-type="Bottom" horizontal-align="Right"> |
| 278 | + <div class="profile-settings"> |
| 279 | + <ui5-avatar size="M" initials="JD" /> |
| 280 | + <div class="profile-text"> |
| 281 | + <ui5-title level="H3">John Doe</ui5-title> |
| 282 | + <ui5-label>Svelte Developer</ui5-label> |
| 283 | + </div> |
| 284 | + </div> |
| 285 | + |
| 286 | + <div class="profile-settings-list"> |
| 287 | + <ui5-list mode="SingleSelect" separators="None" on:item-click={handleProfileSettingsSelect} bind:this={profileSettingsPopover}> |
| 288 | + <ui5-li icon="settings" data-key="settings">Settings</ui5-li> |
| 289 | + <ui5-li icon="sys-help" data-key="help">Help</ui5-li> |
| 290 | + <ui5-li icon="log" data-key="sign-out">Sign out</ui5-li> |
| 291 | + </ui5-list> |
| 292 | + </div> |
| 293 | + </ui5-popover> |
| 294 | + |
| 295 | + <ui5-dialog id="settings-dialog" header-text="Profile Settings" draggable> |
| 296 | + <div> |
| 297 | + <div class="profile-rtl-switch centered"> |
| 298 | + <div class="profile-rtl-switch-title"> |
| 299 | + <ui5-label class="profile-rtl-switch-text">RTL</ui5-label> |
| 300 | + </div> |
| 301 | + <ui5-switch on:change={handleRtlSwitchChange} /> |
| 302 | + </div> |
| 303 | + </div> |
| 304 | + |
| 305 | + <div class="profile-rtl-switch centered"> |
| 306 | + <div class="profile-rtl-switch-title"> |
| 307 | + <ui5-label class="profile-rtl-switch-text">Compact</ui5-label> |
| 308 | + </div> |
| 309 | + <ui5-switch on:change={handleContentDensitySwitchChange} /> |
| 310 | + </div> |
| 311 | + |
| 312 | + <div class="dialog-button"> |
| 313 | + <ui5-button on:click={handleSettingsDialogCloseButtonClick} design="Emphasized">Close</ui5-button> |
| 314 | + </div> |
| 315 | + </ui5-dialog> |
| 316 | + |
| 317 | + <ui5-dialog id="help-dialog"> |
| 318 | + <div slot="header" class="help-header" id="header-title-align"> |
| 319 | + <ui5-icon name="sys-help" /> |
| 320 | + Help |
| 321 | + </div> |
| 322 | + |
| 323 | + <div class="help-header" id="header-logo-align"> |
| 324 | + <img class="app-header-logo" alt="logo" slot="logo" src={logo} /> |
| 325 | + <ui5-title level="H5">UI5 Web Components Svelte Sample App</ui5-title> |
| 326 | + </div> |
| 327 | + |
| 328 | + <p class="help-dialog-text"> |
| 329 | + <b>Release</b>: b225.20220729335 <br /> |
| 330 | + <b>Server</b>: pk21443x3132 <br /> |
| 331 | + <b>Timestamp</b>: 2022-08-18T10:29:03.159+0200 <br /> |
| 332 | + <b>Company ID</b>: SAP <br /> |
| 333 | + <b>UI version</b>: SAP Fiori <br /> |
| 334 | + <b>Edition</b>: Enterprise <br /> |
| 335 | + <b>Admin version</b>: Svelte Admin <br /> |
| 336 | + </p> |
| 337 | + <hr /> |
| 338 | + <span class="help-dialog-text">For more information, please visit our <a href="https://github.com/SAP-samples/ui5-webcomponents-sample-svelte" target="_blank">documentation</a>.</span> |
| 339 | + <p /> |
| 340 | + <div class="dialog-button"> |
| 341 | + <ui5-button design="Emphasized" on:click={handleHelpDialogCloseButtonClick}>Close</ui5-button> |
| 342 | + </div> |
| 343 | + </ui5-dialog> |
233 | 344 | </main> |
234 | 345 |
|
235 | 346 | <style scoped> |
|
245 | 356 | margin: 0; |
246 | 357 | height: 100%; |
247 | 358 | background-color: var(--sapBackgroundColor); |
| 359 | + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif; |
| 360 | + -webkit-font-smoothing: antialiased; |
| 361 | + -moz-osx-font-smoothing: grayscale; |
248 | 362 | } |
249 | 363 |
|
250 | 364 | *:not(:defined) { |
|
337 | 451 |
|
338 | 452 | #add-input, |
339 | 453 | #date-picker { |
340 | | - margin-bottom: 1rem; |
| 454 | + margin-bottom: 0.5rem; |
341 | 455 | transition: ease-in-out 0.6s; |
342 | 456 | } |
343 | 457 |
|
|
351 | 465 | width: 100%; |
352 | 466 | } |
353 | 467 | } |
| 468 | + .app-bar-profile-popover { |
| 469 | + width: 250px; |
| 470 | + } |
| 471 | +
|
| 472 | + #settings-dialog { |
| 473 | + max-width: 300px; |
| 474 | + } |
| 475 | +
|
| 476 | + .dialog-button { |
| 477 | + display: flex; |
| 478 | + justify-content: flex-end; |
| 479 | + margin-top: 0.625rem; |
| 480 | + margin-bottom: -0.425rem; |
| 481 | + } |
| 482 | +
|
| 483 | + .profile-settings, |
| 484 | + .help-header { |
| 485 | + display: flex; |
| 486 | + flex-direction: row; |
| 487 | + justify-content: flex-start; |
| 488 | + } |
| 489 | +
|
| 490 | + .profile-text { |
| 491 | + display: flex; |
| 492 | + flex-direction: column; |
| 493 | + justify-content: center; |
| 494 | + margin-inline-start: 1rem; |
| 495 | + } |
| 496 | +
|
| 497 | + .app-header-logo { |
| 498 | + height: 2rem; |
| 499 | + } |
| 500 | +
|
| 501 | + .profile-settings-list { |
| 502 | + margin-top: 1.25rem; |
| 503 | + } |
| 504 | +
|
| 505 | + .help-dialog-text { |
| 506 | + font-size: 0.875rem; |
| 507 | + } |
| 508 | +
|
| 509 | + .profile-rtl-switch { |
| 510 | + width: 100%; |
| 511 | + display: flex; |
| 512 | + align-items: center; |
| 513 | + justify-content: space-between; |
| 514 | + } |
| 515 | +
|
| 516 | + #header-title-align { |
| 517 | + margin: 1rem 0; |
| 518 | + gap: 0.225rem; |
| 519 | + } |
| 520 | +
|
| 521 | + #header-logo-align { |
| 522 | + margin: 0.225rem 3.225rem 0.225rem 0; |
| 523 | + align-items: center; |
| 524 | + gap: 0.435rem; |
| 525 | + } |
| 526 | +
|
| 527 | + #help-dialog::part(header) { |
| 528 | + justify-content: flex-start; |
| 529 | + } |
354 | 530 | </style> |
0 commit comments