Skip to content

Commit 35418ef

Browse files
committed
add: suggestions on mobile.
1 parent 28d7f26 commit 35418ef

2 files changed

Lines changed: 54 additions & 25 deletions

File tree

  • src/routes/(console)/project-[region]-[project]/databases/database-[database]/collection-[collection]/(components)

src/routes/(console)/project-[region]-[project]/databases/database-[database]/collection-[collection]/(components)/editor/view.svelte

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1336,8 +1336,13 @@
13361336

13371337
<div bind:this={editorContainer} class="cm-editor-wrapper" class:loading></div>
13381338

1339-
{#if showSuggestions && hasStartedEditing}
1340-
<Suggestions show={showSuggestions} />
1339+
{#if ($isSmallViewport && showSuggestions) || (showSuggestions && hasStartedEditing)}
1340+
<Suggestions
1341+
show={showSuggestions}
1342+
onMobileClick={() => {
1343+
showSuggestions = false;
1344+
applySuggestedAttributes();
1345+
}} />
13411346
{/if}
13421347
</div>
13431348

Original file line numberDiff line numberDiff line change
@@ -1,34 +1,45 @@
11
<script lang="ts">
2-
import { Badge, Layout, Typography } from '@appwrite.io/pink-svelte';
2+
import { Badge, FloatingActionBar, Layout, Typography } from '@appwrite.io/pink-svelte';
33
import { isSmallViewport } from '$lib/stores/viewport';
44
55
let {
6-
show = true
6+
show = true,
7+
onMobileClick
78
}: {
89
show?: boolean;
10+
onMobileClick: () => Promise<void> | void;
911
} = $props();
1012
</script>
1113

12-
{#if show && !$isSmallViewport}
13-
<div class="suggestions-wrapper">
14-
<div class="popover-content">
15-
<Layout.Stack inline gap="xs" direction="row" alignItems="center">
16-
<Typography.Caption variant="400" color="--fgcolor-neutral-secondary">
17-
Press
18-
</Typography.Caption>
14+
{#if show}
15+
{#if $isSmallViewport}
16+
<button type="button" class="floating-action-bar" onclick={onMobileClick}>
17+
<FloatingActionBar>
18+
<svelte:fragment slot="start">
19+
<Typography.Text variant="m-500">Tap to apply suggestions</Typography.Text>
20+
</svelte:fragment>
21+
</FloatingActionBar>
22+
</button>
23+
{:else}
24+
<div class="suggestions-wrapper">
25+
<div class="popover-content">
26+
<Layout.Stack inline gap="xs" direction="row" alignContent="center">
27+
<Typography.Caption variant="400" color="--fgcolor-neutral-secondary">
28+
Press
29+
</Typography.Caption>
1930

20-
<Layout.Stack direction="row" inline gap="xxxs" style="height: fit-content">
21-
<Badge content="" variant="secondary" size="xs" />
31+
<Layout.Stack direction="row" inline gap="xxxs" style="height: fit-content">
32+
<Badge content="" variant="secondary" size="xs" />
33+
<Badge content="A" variant="secondary" size="xs" />
34+
</Layout.Stack>
2235

23-
<Badge content="A" variant="secondary" size="xs" />
36+
<Typography.Caption variant="400" color="--fgcolor-neutral-secondary">
37+
for suggestions
38+
</Typography.Caption>
2439
</Layout.Stack>
25-
26-
<Typography.Caption variant="400" color="--fgcolor-neutral-secondary">
27-
for suggestions
28-
</Typography.Caption>
29-
</Layout.Stack>
40+
</div>
3041
</div>
31-
</div>
42+
{/if}
3243
{/if}
3344

3445
<style lang="scss">
@@ -38,11 +49,6 @@
3849
position: absolute;
3950
pointer-events: none;
4051
transform: translateX(40%);
41-
42-
@media (max-width: 768px) {
43-
top: auto;
44-
bottom: var(--space-12);
45-
}
4652
}
4753
4854
.popover-content {
@@ -60,4 +66,22 @@
6066
0 1px 3px 0 rgba(0, 0, 0, 0.03),
6167
0 4px 4px 0 rgba(0, 0, 0, 0.04);
6268
}
69+
70+
.floating-action-bar {
71+
left: 50%;
72+
bottom: 5%;
73+
width: 100%;
74+
max-width: 320px;
75+
position: fixed;
76+
transform: translateX(-50%);
77+
78+
& > :global:first-child {
79+
display: unset; /* stack with flex-start in FAB */
80+
81+
& > :global:first-child {
82+
width: 100%;
83+
justify-content: center;
84+
}
85+
}
86+
}
6387
</style>

0 commit comments

Comments
 (0)