Skip to content

Commit 68af21b

Browse files
authored
Merge pull request #2944 from appwrite/fix-tooltips-and-webhook-flows
fix: tooltips across the console and webhooks flow
2 parents 692c13d + 4e7e438 commit 68af21b

17 files changed

Lines changed: 117 additions & 45 deletions

File tree

src/lib/elements/forms/inputURL.svelte

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
export let autocomplete = false;
1616
export let maxlength: number = null;
1717
export let leadingIcon: ComponentType | undefined = undefined;
18+
export let helper: string = undefined;
1819
1920
let error: string;
2021
@@ -52,7 +53,7 @@
5253
type="url"
5354
autofocus={autofocus || undefined}
5455
autocomplete={autocomplete ? 'on' : 'off'}
55-
helper={error}
56+
helper={error || helper}
5657
state={error ? 'error' : 'default'}
5758
on:invalid={handleInvalid}
5859
on:input

src/lib/helpers/tooltipContent.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export const BODY_TOOLTIP_MAX_WIDTH = 'min(22rem, calc(100vw - 2rem))';
2+
3+
export const BODY_TOOLTIP_WRAPPER_STYLE =
4+
'min-width: 0; max-width: 100%; overflow-wrap: break-word; white-space: normal';
5+
6+
export const BODY_TOOLTIP_WRAPPER_STYLE_PRELINE =
7+
'min-width: 0; max-width: 100%; overflow-wrap: break-word; white-space: pre-line';

src/lib/layout/containerButton.svelte

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
<script lang="ts">
22
import { Button } from '$lib/elements/forms';
3+
import {
4+
BODY_TOOLTIP_MAX_WIDTH,
5+
BODY_TOOLTIP_WRAPPER_STYLE
6+
} from '$lib/helpers/tooltipContent';
37
import { organization } from '$lib/stores/organization';
48
import { Tooltip } from '@appwrite.io/pink-svelte';
59
import { BillingPlanGroup } from '@appwrite.io/console';
@@ -23,7 +27,7 @@
2327
export let buttonType: 'primary' | 'secondary' | 'text' = 'primary';
2428
</script>
2529

26-
<Tooltip disabled={!disabled}>
30+
<Tooltip disabled={!disabled} maxWidth={BODY_TOOLTIP_MAX_WIDTH}>
2731
<Button
2832
size="s"
2933
text={buttonType === 'text'}
@@ -38,5 +42,5 @@
3842
{/if}
3943
<span class="text">{buttonText}</span>
4044
</Button>
41-
<div slot="tooltip">{tooltipContent}</div>
45+
<div slot="tooltip" style={BODY_TOOLTIP_WRAPPER_STYLE}>{tooltipContent}</div>
4246
</Tooltip>

src/routes/(console)/account/organizations/+page.svelte

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717
import type { Models } from '@appwrite.io/console';
1818
import { daysLeftInTrial, billingIdToPlan } from '$lib/stores/billing';
1919
import { toLocaleDate } from '$lib/helpers/date';
20+
import {
21+
BODY_TOOLTIP_MAX_WIDTH,
22+
BODY_TOOLTIP_WRAPPER_STYLE
23+
} from '$lib/helpers/tooltipContent';
2024
import { goto } from '$app/navigation';
2125
import { Icon, Tooltip, Typography } from '@appwrite.io/pink-svelte';
2226
import { IconPlus } from '@appwrite.io/pink-icons-svelte';
@@ -132,29 +136,30 @@
132136
{#await planName}
133137
<Skeleton width={30} height={20} variant="line" />
134138
{:then name}
135-
<Tooltip>
139+
<Tooltip maxWidth={BODY_TOOLTIP_MAX_WIDTH}>
136140
<Badge size="xs" variant="secondary" content={name} />
137141

138-
<span slot="tooltip">
142+
<div slot="tooltip" style={BODY_TOOLTIP_WRAPPER_STYLE}>
139143
You are limited to 1 free organization per account
140-
</span>
144+
</div>
141145
</Tooltip>
142146
{/await}
143147
{/if}
144148
{/if}
145149

146150
{#if isOrganizationOnTrial(organization)}
147-
<Tooltip>
151+
<Tooltip maxWidth={BODY_TOOLTIP_MAX_WIDTH}>
148152
<div class="u-flex u-cross-center">
149153
<Badge
150154
class="eyebrow-heading-3"
151155
variant="secondary"
152156
content="TRIAL" />
153157
</div>
154-
<span slot="tooltip"
155-
>{`Your trial ends on ${toLocaleDate(
158+
<div slot="tooltip" style={BODY_TOOLTIP_WRAPPER_STYLE}>
159+
{`Your trial ends on ${toLocaleDate(
156160
organization.billingStartDate
157-
)}. ${$daysLeftInTrial} days remaining.`}</span>
161+
)}. ${$daysLeftInTrial} days remaining.`}
162+
</div>
158163
</Tooltip>
159164
{/if}
160165

src/routes/(console)/organization-[organization]/+page.svelte

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,10 @@
3535
} from '@appwrite.io/pink-icons-svelte';
3636
import type { PageProps } from './$types';
3737
import { getPlatformInfo } from '$lib/helpers/platform';
38+
import {
39+
BODY_TOOLTIP_MAX_WIDTH,
40+
BODY_TOOLTIP_WRAPPER_STYLE
41+
} from '$lib/helpers/tooltipContent';
3842
import CreateProjectCloud from './createProjectCloud.svelte';
3943
import { regions as regionsStore } from '$lib/stores/organization';
4044
@@ -147,16 +151,16 @@
147151

148152
{#if $canWriteProjects}
149153
{#if projectCreationDisabled && reachedProjectLimit}
150-
<Tooltip placement="bottom">
154+
<Tooltip placement="bottom" maxWidth={BODY_TOOLTIP_MAX_WIDTH}>
151155
<div>
152156
<Button event="create_project" disabled>
153157
<Icon icon={IconPlus} slot="start" size="s" />
154158
Create project
155159
</Button>
156160
</div>
157-
<span slot="tooltip">
161+
<div slot="tooltip" style={BODY_TOOLTIP_WRAPPER_STYLE}>
158162
You have reached your limit of {projectsLimit} projects.
159-
</span>
163+
</div>
160164
</Tooltip>
161165
{:else}
162166
<Button

src/routes/(console)/organization-[organization]/domains/domain-[domain]/createRecordModal.svelte

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import { IconInfo } from '@appwrite.io/pink-icons-svelte';
1212
import { addNotification } from '$lib/stores/notifications';
1313
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
14+
import { BODY_TOOLTIP_WRAPPER_STYLE_PRELINE } from '$lib/helpers/tooltipContent';
1415
import { page } from '$app/state';
1516
import { recordTypes } from './store';
1617
import { Dependencies } from '$lib/constants';
@@ -99,7 +100,7 @@
99100
</Layout.Stack>
100101

101102
<InputText id="value" label="Value" {placeholder} bind:value required>
102-
<Tooltip slot="info">
103+
<Tooltip slot="info" maxWidth="fit-content">
103104
<Icon icon={IconInfo} size="s" />
104105
<span slot="tooltip">
105106
Enter the target or destination for this DNS record (e.g., IP address, hostname,
@@ -111,10 +112,10 @@
111112
<InputNumber id="ttl" label="TTL" placeholder="Enter number" bind:value={ttl}>
112113
<Tooltip slot="info">
113114
<Icon icon={IconInfo} size="s" />
114-
<span slot="tooltip">
115+
<div style={BODY_TOOLTIP_WRAPPER_STYLE_PRELINE} slot="tooltip">
115116
TTL defines how long DNS information is cached. Lower values update faster;
116117
higher values reduce server load.
117-
</span>
118+
</div>
118119
</Tooltip>
119120
</InputNumber>
120121
{#if showPriority(type)}

src/routes/(console)/organization-[organization]/header.svelte

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
import { AvatarGroup, Tab, Tabs } from '$lib/components';
66
import { Button } from '$lib/elements/forms';
77
import { toLocaleDate } from '$lib/helpers/date';
8+
import {
9+
BODY_TOOLTIP_MAX_WIDTH,
10+
BODY_TOOLTIP_WRAPPER_STYLE
11+
} from '$lib/helpers/tooltipContent';
812
import { isTabSelected } from '$lib/helpers/load';
913
import { Cover } from '$lib/layout';
1014
import { daysLeftInTrial, getServiceLimit, readOnly } from '$lib/stores/billing';
@@ -110,12 +114,14 @@
110114
{/if}
111115

112116
{#if organization?.billingTrialStartDate && $daysLeftInTrial > 0 && organization.billingPlanDetails.trial && organization?.billingTrialDays}
113-
<Tooltip>
117+
<Tooltip maxWidth={BODY_TOOLTIP_MAX_WIDTH}>
114118
<Badge variant="secondary" content="Trial" />
115119
<svelte:fragment slot="tooltip">
116-
{`Your trial ends on ${toLocaleDate(
117-
organization.billingStartDate
118-
)}. ${$daysLeftInTrial} days remaining.`}
120+
<div style={BODY_TOOLTIP_WRAPPER_STYLE}>
121+
{`Your trial ends on ${toLocaleDate(
122+
organization.billingStartDate
123+
)}. ${$daysLeftInTrial} days remaining.`}
124+
</div>
119125
</svelte:fragment>
120126
</Tooltip>
121127
{/if}
@@ -139,7 +145,10 @@
139145
{/if}
140146

141147
{#if $isOwner}
142-
<Tooltip disabled={!areMembersLimited} placement="bottom-end">
148+
<Tooltip
149+
disabled={!areMembersLimited}
150+
placement="bottom-end"
151+
maxWidth={BODY_TOOLTIP_MAX_WIDTH}>
143152
<div>
144153
<Button
145154
secondary
@@ -150,7 +159,7 @@
150159
Invite
151160
</Button>
152161
</div>
153-
<div slot="tooltip">
162+
<div slot="tooltip" style={BODY_TOOLTIP_WRAPPER_STYLE}>
154163
{!(
155164
organization?.billingPlanDetails?.addons?.seats?.supported ??
156165
true

src/routes/(console)/organization-[organization]/members/+page.svelte

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@
77
import { Submit, trackError, trackEvent } from '$lib/actions/analytics';
88
import Upgrade from '$lib/components/roles/upgrade.svelte';
99
import { getServiceLimit, readOnly, getRoleLabel } from '$lib/stores/billing';
10+
import {
11+
BODY_TOOLTIP_MAX_WIDTH,
12+
BODY_TOOLTIP_WRAPPER_STYLE
13+
} from '$lib/helpers/tooltipContent';
1014
import { addNotification } from '$lib/stores/notifications';
1115
import { currentPlan, newMemberModal, organization } from '$lib/stores/organization';
1216
import { isOwner } from '$lib/stores/roles';
@@ -78,7 +82,10 @@
7882
<Container>
7983
<Layout.Stack direction="row" justifyContent="space-between">
8084
<Typography.Title>Members</Typography.Title>
81-
<Tooltip disabled={!isButtonDisabled} placement="bottom-end">
85+
<Tooltip
86+
disabled={!isButtonDisabled}
87+
placement="bottom-end"
88+
maxWidth={BODY_TOOLTIP_MAX_WIDTH}>
8289
<div>
8390
<ConsoleButton
8491
size="s"
@@ -89,7 +96,7 @@
8996
<span class="text">Invite</span>
9097
</ConsoleButton>
9198
</div>
92-
<div slot="tooltip">
99+
<div slot="tooltip" style={BODY_TOOLTIP_WRAPPER_STYLE}>
93100
{!supportsMembers
94101
? 'Upgrade to add more members'
95102
: `You've reached the members limit for the ${$organization?.billingPlanDetails.name} plan`}

src/routes/(console)/project-[region]-[project]/databases/+page.svelte

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@
1818
import EmptySearch from '$lib/components/emptySearch.svelte';
1919
import { isServiceLimited } from '$lib/stores/billing';
2020
import { organization } from '$lib/stores/organization';
21+
import {
22+
BODY_TOOLTIP_MAX_WIDTH,
23+
BODY_TOOLTIP_WRAPPER_STYLE_PRELINE
24+
} from '$lib/helpers/tooltipContent';
2125
2226
import { resolveRoute } from '$lib/stores/navigation';
2327
@@ -61,7 +65,7 @@
6165
view={data.view}
6266
searchPlaceholder="Search by name or ID">
6367
{#if $canWriteDatabases}
64-
<Tooltip disabled={!isLimited}>
68+
<Tooltip disabled={!isLimited} maxWidth={BODY_TOOLTIP_MAX_WIDTH}>
6569
<div>
6670
<Button
6771
disabled={isLimited}
@@ -72,7 +76,7 @@
7276
</Button>
7377
</div>
7478
<svelte:fragment slot="tooltip">
75-
<div style="white-space: pre-line;">
79+
<div style={BODY_TOOLTIP_WRAPPER_STYLE_PRELINE}>
7680
You have reached the maximum number of databases for your plan.
7781
</div>
7882
</svelte:fragment>

src/routes/(console)/project-[region]-[project]/functions/+page.svelte

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@
1616
import { isServiceLimited } from '$lib/stores/billing';
1717
import { organization } from '$lib/stores/organization';
1818
import { wizard } from '$lib/stores/wizard';
19+
import {
20+
BODY_TOOLTIP_MAX_WIDTH,
21+
BODY_TOOLTIP_WRAPPER_STYLE_PRELINE
22+
} from '$lib/helpers/tooltipContent';
1923
2024
import { parseExpression } from 'cron-parser';
2125
import { onMount } from 'svelte';
@@ -101,15 +105,15 @@
101105
<Layout.Stack direction="row" justifyContent="space-between">
102106
<SearchQuery placeholder="Search by name or ID" />
103107

104-
<Tooltip disabled={!isLimited}>
108+
<Tooltip disabled={!isLimited} maxWidth={BODY_TOOLTIP_MAX_WIDTH}>
105109
<div>
106110
<Button disabled={isLimited} href={createFunctionsUrl}>
107111
<Icon icon={IconPlus} slot="start" />
108112
Create function
109113
</Button>
110114
</div>
111115
<svelte:fragment slot="tooltip">
112-
<div style="white-space: pre-line;">
116+
<div style={BODY_TOOLTIP_WRAPPER_STYLE_PRELINE}>
113117
You have reached the maximum number of functions for your plan.
114118
</div>
115119
</svelte:fragment>

0 commit comments

Comments
 (0)