|
1 | 1 | <script lang="ts"> |
2 | 2 | import { base } from '$app/paths'; |
3 | 3 | import { page } from '$app/state'; |
4 | | - import { showCreate } from './store'; |
| 4 | + import { showCreate, databaseSubNavigationItems } from './store'; |
5 | 5 | import type { PageData } from './$types'; |
6 | 6 | import { showSubNavigation } from '$lib/stores/layout'; |
7 | | - import { Icon, Sidebar, Navbar, Layout, Link, Typography } from '@appwrite.io/pink-svelte'; |
| 7 | + import { |
| 8 | + Icon, |
| 9 | + Sidebar, |
| 10 | + Navbar, |
| 11 | + Layout, |
| 12 | + Link, |
| 13 | + Typography, |
| 14 | + Divider |
| 15 | + } from '@appwrite.io/pink-svelte'; |
8 | 16 | import { |
9 | 17 | IconChevronDown, |
10 | 18 | IconDatabase, |
|
41 | 49 | sortedTables?.find((table: Models.Table) => table.$id === tableId) |
42 | 50 | ); |
43 | 51 |
|
| 52 | + const isTablesScreen = $derived(page.route.id.endsWith('table-[table]')); |
| 53 | +
|
| 54 | + const isMainDatabaseScreen = $derived(page.route.id.endsWith('database-[database]')); |
| 55 | +
|
44 | 56 | async function loadTables() { |
45 | 57 | tables = await sdk.forProject(region, project).tablesDB.listTables({ |
46 | 58 | databaseId: databaseId, |
|
66 | 78 | <Sidebar.Base state="open" resizable={false}> |
67 | 79 | <section class="list-container" slot="top" style:width="100%"> |
68 | 80 | <a |
| 81 | + class:is-selected={!isTablesScreen} |
69 | 82 | href={`${base}/project-${region}-${project}/databases/database-${databaseId}`} |
70 | | - class="database-name u-flex u-cross-center body-text-2 u-gap-8 is-not-mobile is-selected"> |
| 83 | + class="database-name u-flex u-cross-center body-text-2 u-gap-8 is-not-mobile u-padding-block-8 u-padding-inline-start-4"> |
71 | 84 | <Icon icon={IconDatabase} size="s" color="--fgcolor-neutral-weak" /> |
| 85 | + |
72 | 86 | {data.database?.name} |
73 | 87 | </a> |
74 | | - <div class="collection-content"> |
| 88 | + <div class="table-content"> |
75 | 89 | {#if tables?.total} |
76 | 90 | <ul class="drop-list u-margin-inline-start-8 u-margin-block-start-4"> |
77 | 91 | {#each sortedTables as table, index} |
|
94 | 108 | color={isSelected |
95 | 109 | ? '--fgcolor-neutral-tertiary' |
96 | 110 | : '--fgcolor-neutral-weak'} /> |
97 | | - <span class="text collection-name" data-private |
| 111 | + <span class="text table-name" data-private |
98 | 112 | >{table.name}</span> |
99 | 113 | </a> |
100 | 114 | </li> |
|
132 | 146 | </Button> |
133 | 147 | </Layout.Stack> |
134 | 148 | </div> |
| 149 | + |
| 150 | + <Layout.Stack direction="column" gap="xxs" style="bottom: 1rem; position: sticky;"> |
| 151 | + <div class="action-menu-divider"> |
| 152 | + <Divider /> |
| 153 | + </div> |
| 154 | + |
| 155 | + <ul |
| 156 | + style="margin-inline-start: -1.25rem" |
| 157 | + class="drop-list bottom-nav u-margin-block-start-4"> |
| 158 | + {#each databaseSubNavigationItems as action} |
| 159 | + {@const href = `${base}/project-${region}-${project}/databases/database-${databaseId}/${action.href}`} |
| 160 | + |
| 161 | + <Layout.Stack gap="s" direction="row" alignItems="center"> |
| 162 | + <li> |
| 163 | + <a |
| 164 | + {href} |
| 165 | + class="u-padding-block-8 u-padding-inline-end-4 u-padding-inline-start-8 u-flex u-cross-center u-gap-8"> |
| 166 | + <Icon |
| 167 | + size="s" |
| 168 | + icon={action.icon} |
| 169 | + color="--fgcolor-neutral-weak" /> |
| 170 | + <span class="text table-name">{action.title}</span> |
| 171 | + </a> |
| 172 | + </li> |
| 173 | + </Layout.Stack> |
| 174 | + {/each} |
| 175 | + </ul> |
| 176 | + </Layout.Stack> |
135 | 177 | </section> |
136 | 178 | </Sidebar.Base> |
137 | | -{:else if data?.database?.name} |
| 179 | +{:else if data?.database?.name && !isMainDatabaseScreen} |
138 | 180 | <Navbar.Base> |
139 | 181 | <div slot="left"> |
140 | 182 | <Layout.Stack direction="row" alignItems="center" gap="s"> |
|
194 | 236 | } |
195 | 237 |
|
196 | 238 | .database-name { |
197 | | - margin-block-end: 8px; |
| 239 | + margin-block-end: 4px; |
198 | 240 | font-size: var(--font-size-sm); |
199 | 241 | color: var(--fgcolor-neutral-secondary); |
| 242 | +
|
| 243 | + &:hover { |
| 244 | + color: var(--fgcolor-neutral-primary); |
| 245 | + border-radius: var(--border-radius-s, 6px); |
| 246 | + background: var(--bgcolor-neutral-secondary); |
| 247 | + } |
200 | 248 | } |
201 | 249 |
|
202 | | - .collection-content { |
| 250 | + .table-content { |
203 | 251 | flex: 1; |
204 | 252 | overflow-y: auto; |
205 | 253 | overflow-x: hidden; |
|
232 | 280 |
|
233 | 281 | .drop-list { |
234 | 282 | flex: 1; |
235 | | - gap: 8px; |
| 283 | + gap: 4px; |
236 | 284 | padding-left: 4px; |
237 | 285 | position: relative; |
238 | 286 | font-size: var(--font-size-sm); |
239 | 287 | color: var(--fgcolor-neutral-secondary); |
240 | 288 |
|
241 | | - &::before { |
| 289 | + &:not(.bottom-nav)::before { |
242 | 290 | content: ''; |
243 | 291 | right: 99%; |
244 | 292 | top: 0.2rem; |
|
248 | 296 | } |
249 | 297 |
|
250 | 298 | // first item |
251 | | - &:has(li.is-first)::before { |
| 299 | + &:not(.bottom-nav):has(li.is-first)::before { |
252 | 300 | top: 0.8rem; |
253 | 301 | } |
254 | 302 |
|
255 | 303 | // last item |
256 | | - &:has(li.is-last)::before { |
| 304 | + &:not(.bottom-nav):has(li.is-last)::before { |
257 | 305 | bottom: 0.85rem; |
258 | 306 | } |
259 | 307 |
|
260 | 308 | // the only item |
261 | | - &:has(li.is-first.is-last)::before { |
| 309 | + &:not(.bottom-nav):has(li.is-first.is-last)::before { |
262 | 310 | top: 0.6rem; |
263 | 311 | bottom: 0.6rem; |
264 | 312 | } |
265 | 313 |
|
266 | 314 | li { |
| 315 | + width: 100%; |
267 | 316 | overflow: hidden; |
268 | 317 | position: relative; |
269 | 318 | padding-inline-end: 0.5rem; |
270 | 319 | margin-inline-start: 0.5rem; |
271 | 320 | } |
272 | 321 |
|
273 | | - .is-selected, |
274 | 322 | li:hover { |
275 | | - width: 100%; |
276 | 323 | color: var(--fgcolor-neutral-primary); |
277 | | - border-radius: var(--border-radius-xs, 4px); |
| 324 | + border-radius: var(--border-radius-s, 6px); |
278 | 325 | background: var(--bgcolor-neutral-secondary); |
279 | 326 | } |
280 | 327 |
|
281 | | - .collection-name { |
| 328 | + .table-name { |
282 | 329 | white-space: nowrap; |
283 | 330 | overflow: hidden; |
284 | 331 | text-overflow: ellipsis; |
|
287 | 334 | } |
288 | 335 | } |
289 | 336 |
|
| 337 | + .is-selected { |
| 338 | + color: var(--fgcolor-neutral-primary); |
| 339 | + border-radius: var(--border-radius-s, 6px); |
| 340 | + background: var(--bgcolor-neutral-secondary); |
| 341 | + } |
| 342 | +
|
290 | 343 | :global(.sub-navigation header) { |
291 | 344 | top: 48px !important; |
292 | 345 | } |
|
310 | 363 | font-weight: 400; |
311 | 364 | line-height: 150%; /* 21px */ |
312 | 365 | } |
| 366 | +
|
| 367 | + .action-menu-divider { |
| 368 | + margin-inline: -1.2rem; |
| 369 | + padding-block-end: 0.25rem; |
| 370 | + } |
313 | 371 | </style> |
0 commit comments