|
| 1 | +import { Component, For } from 'solid-js'; |
| 2 | +import windowStore from './store/windowStore'; |
| 3 | +import WindowIcon from './WindowIcon'; |
| 4 | + |
| 5 | +const Taskbar: Component = (props) => { |
| 6 | + const [store, actions] = windowStore(); |
| 7 | + const openedWindows = () => Object.keys(store.windows); |
| 8 | + return ( |
| 9 | + <> |
| 10 | + <div class="window-manager-taskbar-placeholder"></div> |
| 11 | + <div class="window-manager-taskbar"> |
| 12 | + <div class="window-manager-taskbar-wrapper"> |
| 13 | + <For each={openedWindows()}> |
| 14 | + {(item, index) => { |
| 15 | + const windowProps = store.windows[item]; |
| 16 | + return ( |
| 17 | + <div |
| 18 | + class={`${'window-manager-taskbar-item'} ${windowProps?.attrs?.zIndex == 1 ? 'is-active' : ''}`} |
| 19 | + onClick={() => { |
| 20 | + actions.focusWindow(windowProps?.attrs?.key); |
| 21 | + }} |
| 22 | + > |
| 23 | + <div class="window-manager-taskbar-icon"> |
| 24 | + <WindowIcon icon={windowProps?.attrs?.icon} name={windowProps?.component} /> |
| 25 | + </div> |
| 26 | + <div class="window-manager-taskbar-name"> |
| 27 | + {windowProps?.attrs?.state?.title || windowProps?.component || ''} |
| 28 | + </div> |
| 29 | + <button |
| 30 | + class="window-manager-taskbar-btn" |
| 31 | + onClick={(e) => { |
| 32 | + e.stopPropagation(); |
| 33 | + actions.closeWindow(windowProps?.attrs?.key); |
| 34 | + }} |
| 35 | + > |
| 36 | + X |
| 37 | + </button> |
| 38 | + </div> |
| 39 | + ); |
| 40 | + }} |
| 41 | + </For> |
| 42 | + </div> |
| 43 | + </div> |
| 44 | + <style>{` |
| 45 | + .window-manager-taskbar-placeholder { |
| 46 | + width: 100%; |
| 47 | + height: 60px; |
| 48 | + } |
| 49 | + .window-manager-taskbar { |
| 50 | + position: fixed; |
| 51 | + top: 0; |
| 52 | + left: 0; |
| 53 | + right: 0; |
| 54 | + width: 100%; |
| 55 | + height: 60px; |
| 56 | + z-index: 100; |
| 57 | + background: rgba(255, 255, 255, 0.6); |
| 58 | + backdrop-filter: blur(5px); |
| 59 | + padding: 10px; |
| 60 | + } |
| 61 | + .window-manager-taskbar-wrapper { |
| 62 | + display: flex; |
| 63 | + flex-direction: row; |
| 64 | + flex-wrap: wrap; |
| 65 | + align-items: stretch; |
| 66 | + height: 100%; |
| 67 | + gap: 10px; |
| 68 | + } |
| 69 | + .window-manager-taskbar-item { |
| 70 | + display: flex; |
| 71 | + flex-direction: row; |
| 72 | + align-items: center; |
| 73 | + height: 40px; |
| 74 | + width: 200px; |
| 75 | + border-radius: 6px; |
| 76 | + cursor: pointer; |
| 77 | + background: rgba(0, 0, 0, 0.1); |
| 78 | + border: 1px solid rgba(0, 0, 0, 0.1); |
| 79 | + backdrop-filter: blur(5px); |
| 80 | + transition: all 150ms ease-in-out; |
| 81 | + } |
| 82 | + .window-manager-taskbar-item:hover { |
| 83 | + background: rgba(255, 255, 255, 0.1); |
| 84 | + border-color: rgba(255, 255, 255, 0.6); |
| 85 | + } |
| 86 | + .window-manager-taskbar-item.is-active { |
| 87 | + background: rgba(255, 255, 255, 0.6); |
| 88 | + } |
| 89 | + .window-manager-taskbar-icon { |
| 90 | + flex-shrink: 0; |
| 91 | + } |
| 92 | + .window-manager-taskbar-name { |
| 93 | + flex-grow: 1; |
| 94 | + font-size: 13px; |
| 95 | + overflow: hidden; |
| 96 | + text-overflow: ellipsis; |
| 97 | + max-height: 1.9rem; |
| 98 | + word-break: break-all; |
| 99 | + } |
| 100 | + .window-manager-taskbar-btn { |
| 101 | + flex-shrink: 0; |
| 102 | + margin: 10px; |
| 103 | + appearance: none; |
| 104 | + cursor: pointer; |
| 105 | + display: flex; |
| 106 | + flex-direction: row; |
| 107 | + align-items: center; |
| 108 | + justify-content: center; |
| 109 | + font-size: 11px; |
| 110 | + color: rgba(0, 0, 0, 0.3); |
| 111 | + font-family: sans-serif; |
| 112 | + font-weight: 600; |
| 113 | + text-transform: uppercase; |
| 114 | + background: rgba(204, 204, 204, 1); |
| 115 | + border-radius: 100%; |
| 116 | + width: 18px; |
| 117 | + height: 18px; |
| 118 | + border: none; |
| 119 | + outline: none; |
| 120 | + transition: all 150ms ease-in-out; |
| 121 | + } |
| 122 | + .window-manager-taskbar-btn:hover { |
| 123 | + color: rgba(0, 0, 0, 0.6); |
| 124 | + } |
| 125 | + `}</style> |
| 126 | + </> |
| 127 | + ); |
| 128 | +}; |
| 129 | +export default Taskbar; |
0 commit comments