@mezo-org/passport 0.16.0-dev.1 → 0.16.0-dev.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/dist/src/hooks/useAuthenticateWithWallet.d.ts +11 -11
  2. package/dist/src/hooks/useSignInWithWallet.d.ts +11 -11
  3. package/dist/src/hooks/useSignUpWithWallet.d.ts +11 -11
  4. package/dist/src/index.d.ts +0 -1
  5. package/dist/src/index.d.ts.map +1 -1
  6. package/dist/src/index.js +0 -1
  7. package/dist/src/index.js.map +1 -1
  8. package/package.json +1 -2
  9. package/src/index.ts +0 -1
  10. package/dist/src/assets/DefaultAvatar.d.ts +0 -5
  11. package/dist/src/assets/DefaultAvatar.d.ts.map +0 -1
  12. package/dist/src/assets/DefaultAvatar.js +0 -21
  13. package/dist/src/assets/DefaultAvatar.js.map +0 -1
  14. package/dist/src/assets/EditIcon.d.ts +0 -5
  15. package/dist/src/assets/EditIcon.d.ts.map +0 -1
  16. package/dist/src/assets/EditIcon.js +0 -10
  17. package/dist/src/assets/EditIcon.js.map +0 -1
  18. package/dist/src/components/Dropdown/ConnectedTrigger.d.ts +0 -8
  19. package/dist/src/components/Dropdown/ConnectedTrigger.d.ts.map +0 -1
  20. package/dist/src/components/Dropdown/ConnectedTrigger.js +0 -39
  21. package/dist/src/components/Dropdown/ConnectedTrigger.js.map +0 -1
  22. package/dist/src/components/Dropdown/Content.d.ts +0 -8
  23. package/dist/src/components/Dropdown/Content.d.ts.map +0 -1
  24. package/dist/src/components/Dropdown/Content.js +0 -29
  25. package/dist/src/components/Dropdown/Content.js.map +0 -1
  26. package/dist/src/components/Dropdown/DisconnectedTrigger.d.ts +0 -7
  27. package/dist/src/components/Dropdown/DisconnectedTrigger.d.ts.map +0 -1
  28. package/dist/src/components/Dropdown/DisconnectedTrigger.js +0 -13
  29. package/dist/src/components/Dropdown/DisconnectedTrigger.js.map +0 -1
  30. package/dist/src/components/Dropdown/Dropdown.d.ts +0 -23
  31. package/dist/src/components/Dropdown/Dropdown.d.ts.map +0 -1
  32. package/dist/src/components/Dropdown/Dropdown.js +0 -45
  33. package/dist/src/components/Dropdown/Dropdown.js.map +0 -1
  34. package/dist/src/components/Dropdown/ListingItem.d.ts +0 -14
  35. package/dist/src/components/Dropdown/ListingItem.d.ts.map +0 -1
  36. package/dist/src/components/Dropdown/ListingItem.js +0 -42
  37. package/dist/src/components/Dropdown/ListingItem.js.map +0 -1
  38. package/dist/src/components/Dropdown/NestedViewLayout.d.ts +0 -8
  39. package/dist/src/components/Dropdown/NestedViewLayout.d.ts.map +0 -1
  40. package/dist/src/components/Dropdown/NestedViewLayout.js +0 -33
  41. package/dist/src/components/Dropdown/NestedViewLayout.js.map +0 -1
  42. package/dist/src/components/Dropdown/Receive/Receive.d.ts +0 -4
  43. package/dist/src/components/Dropdown/Receive/Receive.d.ts.map +0 -1
  44. package/dist/src/components/Dropdown/Receive/Receive.js +0 -64
  45. package/dist/src/components/Dropdown/Receive/Receive.js.map +0 -1
  46. package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts +0 -4
  47. package/dist/src/components/Dropdown/Root/AccountAddressActions.d.ts.map +0 -1
  48. package/dist/src/components/Dropdown/Root/AccountAddressActions.js +0 -49
  49. package/dist/src/components/Dropdown/Root/AccountAddressActions.js.map +0 -1
  50. package/dist/src/components/Dropdown/Root/AccountBalance.d.ts +0 -6
  51. package/dist/src/components/Dropdown/Root/AccountBalance.d.ts.map +0 -1
  52. package/dist/src/components/Dropdown/Root/AccountBalance.js +0 -32
  53. package/dist/src/components/Dropdown/Root/AccountBalance.js.map +0 -1
  54. package/dist/src/components/Dropdown/Root/AccountBtcListing.d.ts +0 -6
  55. package/dist/src/components/Dropdown/Root/AccountBtcListing.d.ts.map +0 -1
  56. package/dist/src/components/Dropdown/Root/AccountBtcListing.js +0 -28
  57. package/dist/src/components/Dropdown/Root/AccountBtcListing.js.map +0 -1
  58. package/dist/src/components/Dropdown/Root/AccountError.d.ts +0 -8
  59. package/dist/src/components/Dropdown/Root/AccountError.d.ts.map +0 -1
  60. package/dist/src/components/Dropdown/Root/AccountError.js +0 -17
  61. package/dist/src/components/Dropdown/Root/AccountError.js.map +0 -1
  62. package/dist/src/components/Dropdown/Root/AccountMusdListing.d.ts +0 -4
  63. package/dist/src/components/Dropdown/Root/AccountMusdListing.d.ts.map +0 -1
  64. package/dist/src/components/Dropdown/Root/AccountMusdListing.js +0 -21
  65. package/dist/src/components/Dropdown/Root/AccountMusdListing.js.map +0 -1
  66. package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts +0 -8
  67. package/dist/src/components/Dropdown/Root/AccountOtherAssets.d.ts.map +0 -1
  68. package/dist/src/components/Dropdown/Root/AccountOtherAssets.js +0 -43
  69. package/dist/src/components/Dropdown/Root/AccountOtherAssets.js.map +0 -1
  70. package/dist/src/components/Dropdown/Root/Root.d.ts +0 -8
  71. package/dist/src/components/Dropdown/Root/Root.d.ts.map +0 -1
  72. package/dist/src/components/Dropdown/Root/Root.js +0 -49
  73. package/dist/src/components/Dropdown/Root/Root.js.map +0 -1
  74. package/dist/src/components/Dropdown/Root/WalletAddress.d.ts +0 -4
  75. package/dist/src/components/Dropdown/Root/WalletAddress.d.ts.map +0 -1
  76. package/dist/src/components/Dropdown/Root/WalletAddress.js +0 -66
  77. package/dist/src/components/Dropdown/Root/WalletAddress.js.map +0 -1
  78. package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts +0 -6
  79. package/dist/src/components/Dropdown/Root/WelcomeBlock.d.ts.map +0 -1
  80. package/dist/src/components/Dropdown/Root/WelcomeBlock.js +0 -88
  81. package/dist/src/components/Dropdown/Root/WelcomeBlock.js.map +0 -1
  82. package/dist/src/components/Dropdown/Settings/InlineEditField.d.ts +0 -12
  83. package/dist/src/components/Dropdown/Settings/InlineEditField.d.ts.map +0 -1
  84. package/dist/src/components/Dropdown/Settings/InlineEditField.js +0 -95
  85. package/dist/src/components/Dropdown/Settings/InlineEditField.js.map +0 -1
  86. package/dist/src/components/Dropdown/Settings/Settings.d.ts +0 -4
  87. package/dist/src/components/Dropdown/Settings/Settings.d.ts.map +0 -1
  88. package/dist/src/components/Dropdown/Settings/Settings.js +0 -36
  89. package/dist/src/components/Dropdown/Settings/Settings.js.map +0 -1
  90. package/dist/src/components/Dropdown/SlotNumber.d.ts +0 -19
  91. package/dist/src/components/Dropdown/SlotNumber.d.ts.map +0 -1
  92. package/dist/src/components/Dropdown/SlotNumber.js +0 -67
  93. package/dist/src/components/Dropdown/SlotNumber.js.map +0 -1
  94. package/dist/src/components/Dropdown/TestnetTopBanner.d.ts +0 -3
  95. package/dist/src/components/Dropdown/TestnetTopBanner.d.ts.map +0 -1
  96. package/dist/src/components/Dropdown/TestnetTopBanner.js +0 -14
  97. package/dist/src/components/Dropdown/TestnetTopBanner.js.map +0 -1
  98. package/dist/src/components/Dropdown/index.d.ts +0 -3
  99. package/dist/src/components/Dropdown/index.d.ts.map +0 -1
  100. package/dist/src/components/Dropdown/index.js +0 -2
  101. package/dist/src/components/Dropdown/index.js.map +0 -1
  102. package/dist/src/components/index.d.ts +0 -2
  103. package/dist/src/components/index.d.ts.map +0 -1
  104. package/dist/src/components/index.js +0 -2
  105. package/dist/src/components/index.js.map +0 -1
  106. package/src/assets/DefaultAvatar.tsx +0 -74
  107. package/src/assets/EditIcon.tsx +0 -33
  108. package/src/components/Dropdown/ConnectedTrigger.tsx +0 -76
  109. package/src/components/Dropdown/Content.tsx +0 -56
  110. package/src/components/Dropdown/DisconnectedTrigger.tsx +0 -36
  111. package/src/components/Dropdown/Dropdown.tsx +0 -100
  112. package/src/components/Dropdown/ListingItem.tsx +0 -176
  113. package/src/components/Dropdown/NestedViewLayout.tsx +0 -88
  114. package/src/components/Dropdown/README.md +0 -41
  115. package/src/components/Dropdown/Receive/Receive.tsx +0 -144
  116. package/src/components/Dropdown/Root/AccountAddressActions.tsx +0 -99
  117. package/src/components/Dropdown/Root/AccountBalance.tsx +0 -69
  118. package/src/components/Dropdown/Root/AccountBtcListing.tsx +0 -53
  119. package/src/components/Dropdown/Root/AccountError.tsx +0 -34
  120. package/src/components/Dropdown/Root/AccountMusdListing.tsx +0 -45
  121. package/src/components/Dropdown/Root/AccountOtherAssets.tsx +0 -85
  122. package/src/components/Dropdown/Root/Root.tsx +0 -104
  123. package/src/components/Dropdown/Root/WalletAddress.tsx +0 -123
  124. package/src/components/Dropdown/Root/WelcomeBlock.tsx +0 -173
  125. package/src/components/Dropdown/Settings/InlineEditField.tsx +0 -212
  126. package/src/components/Dropdown/Settings/Settings.tsx +0 -87
  127. package/src/components/Dropdown/SlotNumber.tsx +0 -131
  128. package/src/components/Dropdown/TestnetTopBanner.tsx +0 -32
  129. package/src/components/Dropdown/index.ts +0 -2
  130. package/src/components/index.ts +0 -1
@@ -1,173 +0,0 @@
1
- import {
2
- Block,
3
- BlockProps,
4
- HeadingMedium,
5
- LabelLarge,
6
- Mats,
7
- mergeOverrides,
8
- Skeleton,
9
- useStyletron,
10
- } from "@mezo-org/mezo-clay"
11
- import React from "react"
12
- import DefaultAvatar from "../../../assets/DefaultAvatar"
13
- import { useGetCurrentAccount } from "../../../hooks"
14
- import { formatNumberToCompactString } from "../../../utils/numbers"
15
- import AccountError from "./AccountError"
16
- import { usePassportContext } from "../../../hooks/usePassportContext"
17
- import SlotNumber from "../SlotNumber"
18
-
19
- const DOT_DELIMITER_REGEX = /(?=\.)/
20
-
21
- function WelcomeBlockSkeleton() {
22
- const [, theme] = useStyletron()
23
-
24
- return (
25
- <Block
26
- display="flex"
27
- alignItems="center"
28
- padding={theme.sizing.scale600}
29
- paddingTop={theme.sizing.scale900}
30
- paddingBottom={theme.sizing.scale800}
31
- overrides={{
32
- Block: {
33
- style: {
34
- gap: theme.sizing.scale600,
35
- },
36
- },
37
- }}
38
- >
39
- <Skeleton
40
- animation
41
- width={theme.sizing.scale1200}
42
- height={theme.sizing.scale1200}
43
- overrides={{
44
- Root: {
45
- style: {
46
- borderRadius: "100%",
47
- },
48
- },
49
- }}
50
- />
51
-
52
- <Block
53
- display="flex"
54
- flexDirection="column"
55
- flex={1}
56
- overrides={{
57
- Block: {
58
- style: {
59
- gap: theme.sizing.scale100,
60
- },
61
- },
62
- }}
63
- >
64
- <Skeleton animation width="60%" height={theme.sizing.scale900} />
65
- <Skeleton animation width="40%" height={theme.sizing.scale800} />
66
- </Block>
67
- </Block>
68
- )
69
- }
70
-
71
- type WelcomeBlockProps = BlockProps
72
-
73
- export default function WelcomeBlock(props: WelcomeBlockProps) {
74
- const { overrides, ...restProps } = props
75
- const { accountDataRefetchInterval } = usePassportContext()
76
-
77
- const { data, isError, isPending } = useGetCurrentAccount({
78
- staleTime: accountDataRefetchInterval,
79
- refetchInterval: accountDataRefetchInterval,
80
- })
81
- const [, theme] = useStyletron()
82
-
83
- if (isError) {
84
- return (
85
- <AccountError
86
- padding={theme.sizing.scale600}
87
- paddingTop={theme.sizing.scale900}
88
- paddingBottom={theme.sizing.scale800}
89
- marginBottom={theme.sizing.scale300}
90
- topic="account information"
91
- />
92
- )
93
- }
94
-
95
- if (isPending) {
96
- return <WelcomeBlockSkeleton />
97
- }
98
-
99
- const [mezoId, mezoIdSuffix] = (data.mezoId ?? "").split(DOT_DELIMITER_REGEX)
100
-
101
- return (
102
- <Block
103
- display="flex"
104
- alignItems="center"
105
- paddingLeft={theme.sizing.scale600}
106
- paddingRight={theme.sizing.scale600}
107
- paddingTop={theme.sizing.scale900}
108
- paddingBottom={theme.sizing.scale800}
109
- overrides={mergeOverrides(overrides, {
110
- Block: {
111
- style: {
112
- gap: theme.sizing.scale600,
113
- },
114
- },
115
- })}
116
- {...restProps}
117
- >
118
- <Block
119
- as={DefaultAvatar}
120
- width={theme.sizing.scale1200}
121
- height={theme.sizing.scale1200}
122
- overrides={{
123
- Block: {
124
- style: {
125
- borderRadius: "100%",
126
- },
127
- },
128
- }}
129
- />
130
-
131
- <Block display="flex" flexDirection="column">
132
- {mezoId && mezoIdSuffix && (
133
- <HeadingMedium as="span">
134
- <Block as="span">{mezoId}</Block>
135
- <Block as="span" color={theme.colors.contentSecondary}>
136
- {mezoIdSuffix}
137
- </Block>
138
- </HeadingMedium>
139
- )}
140
-
141
- <Block
142
- display="flex"
143
- alignItems="center"
144
- overrides={{
145
- Block: {
146
- style: {
147
- gap: theme.sizing.scale100,
148
- },
149
- },
150
- }}
151
- >
152
- <Mats
153
- size={theme.sizing.scale600}
154
- overrides={{
155
- Svg: {
156
- style: {
157
- margin: theme.sizing.scale100, // To reduce gap
158
- },
159
- },
160
- }}
161
- />
162
-
163
- <LabelLarge color={theme.colors.contentPrimary}>
164
- <SlotNumber formatFunction={formatNumberToCompactString}>
165
- {data.totalMats}
166
- </SlotNumber>{" "}
167
- mats
168
- </LabelLarge>
169
- </Block>
170
- </Block>
171
- </Block>
172
- )
173
- }
@@ -1,212 +0,0 @@
1
- import {
2
- Block,
3
- ButtonIcon,
4
- Check,
5
- Close,
6
- Input,
7
- LabelSmall,
8
- ParagraphSmall,
9
- Spinner,
10
- useStyletron,
11
- } from "@mezo-org/mezo-clay"
12
- import React, { useCallback, useEffect, useState } from "react"
13
- import EditIcon from "../../../assets/EditIcon"
14
-
15
- type InlineEditFieldProps = {
16
- label: string
17
- value: string
18
- placeholder?: string
19
- onSave: (value: string) => Promise<void>
20
- validate?: (value: string) => string | null
21
- isLoading?: boolean
22
- }
23
-
24
- type InlineFieldWrapperProps = {
25
- label: string
26
- children: React.ReactNode
27
- }
28
-
29
- function InlineFieldWrapper({ label, children }: InlineFieldWrapperProps) {
30
- const [, theme] = useStyletron()
31
-
32
- return (
33
- <Block
34
- display="flex"
35
- flexDirection="column"
36
- overrides={{
37
- Block: {
38
- style: {
39
- gap: theme.sizing.scale200,
40
- },
41
- },
42
- }}
43
- >
44
- <LabelSmall color={theme.colors.contentSecondary}>{label}</LabelSmall>
45
- {children}
46
- </Block>
47
- )
48
- }
49
-
50
- export default function InlineEditField(props: InlineEditFieldProps) {
51
- const { label, value, placeholder, onSave, validate, isLoading } = props
52
-
53
- const [, theme] = useStyletron()
54
- const [isEditing, setIsEditing] = useState(false)
55
- const [editValue, setEditValue] = useState(value)
56
- const [error, setError] = useState<string | null>(null)
57
- const [isSaving, setIsSaving] = useState(false)
58
-
59
- useEffect(() => {
60
- setEditValue(value)
61
- }, [value])
62
-
63
- const handleEdit = useCallback(() => {
64
- setIsEditing(true)
65
- setEditValue(value)
66
- setError(null)
67
- }, [value])
68
-
69
- const handleCancel = useCallback(() => {
70
- setIsEditing(false)
71
- setEditValue(value)
72
- setError(null)
73
- }, [value])
74
-
75
- const handleSave = useCallback(async () => {
76
- if (validate) {
77
- const validationError = validate(editValue)
78
- if (validationError) {
79
- setError(validationError)
80
- return
81
- }
82
- }
83
-
84
- setIsSaving(true)
85
- try {
86
- await onSave(editValue)
87
- setIsEditing(false)
88
- setError(null)
89
- } catch (err) {
90
- setError(err instanceof Error ? err.message : "Failed to save")
91
- } finally {
92
- setIsSaving(false)
93
- }
94
- }, [editValue, onSave, validate])
95
-
96
- const handleKeyDown = useCallback(
97
- (e: React.KeyboardEvent) => {
98
- if (e.key === "Enter") {
99
- handleSave()
100
- } else if (e.key === "Escape") {
101
- handleCancel()
102
- }
103
- },
104
- [handleSave, handleCancel],
105
- )
106
-
107
- if (isLoading) {
108
- return (
109
- <InlineFieldWrapper label={label}>
110
- <Block
111
- display="flex"
112
- alignItems="center"
113
- height={theme.sizing.scale950}
114
- >
115
- <Spinner $size={theme.sizing.scale600} />
116
- </Block>
117
- </InlineFieldWrapper>
118
- )
119
- }
120
-
121
- if (isEditing) {
122
- return (
123
- <InlineFieldWrapper label={label}>
124
- <Block
125
- display="flex"
126
- alignItems="center"
127
- width="100%"
128
- gridGap="scale300"
129
- >
130
- <Block flex={1}>
131
- <Input
132
- value={editValue}
133
- onChange={(e) => {
134
- setEditValue(e.currentTarget.value)
135
- setError(null)
136
- }}
137
- onKeyDown={handleKeyDown}
138
- placeholder={placeholder}
139
- size="small"
140
- error={!!error}
141
- disabled={isSaving}
142
- autoFocus
143
- />
144
- </Block>
145
- <ButtonIcon
146
- onClick={handleSave}
147
- size="small"
148
- shape="circle"
149
- kind="secondary"
150
- disabled={isSaving}
151
- aria-label="Save"
152
- >
153
- {isSaving ? (
154
- <Spinner $size={theme.sizing.scale500} />
155
- ) : (
156
- <Check size={14} color="currentColor" />
157
- )}
158
- </ButtonIcon>
159
- <ButtonIcon
160
- onClick={handleCancel}
161
- size="small"
162
- shape="circle"
163
- kind="tertiary"
164
- disabled={isSaving}
165
- aria-label="Cancel"
166
- >
167
- <Close size={14} color="currentColor" />
168
- </ButtonIcon>
169
- </Block>
170
- {error && (
171
- <ParagraphSmall
172
- color={theme.colors.contentNegative}
173
- marginTop={0}
174
- marginBottom={0}
175
- >
176
- {error}
177
- </ParagraphSmall>
178
- )}
179
- </InlineFieldWrapper>
180
- )
181
- }
182
-
183
- return (
184
- <InlineFieldWrapper label={label}>
185
- <Block
186
- display="flex"
187
- alignItems="center"
188
- justifyContent="space-between"
189
- onClick={handleEdit}
190
- overrides={{
191
- Block: {
192
- style: {
193
- cursor: "pointer",
194
- minHeight: theme.sizing.scale950,
195
- },
196
- },
197
- }}
198
- >
199
- <ParagraphSmall
200
- marginTop={0}
201
- marginBottom={0}
202
- color={
203
- value ? theme.colors.contentPrimary : theme.colors.contentTertiary
204
- }
205
- >
206
- {value || placeholder}
207
- </ParagraphSmall>
208
- <EditIcon size={16} color={theme.colors.contentTertiary} />
209
- </Block>
210
- </InlineFieldWrapper>
211
- )
212
- }
@@ -1,87 +0,0 @@
1
- import { Block, ParagraphSmall, Link, useStyletron } from "@mezo-org/mezo-clay"
2
- import React, { useCallback } from "react"
3
- import NestedViewLayout from "../NestedViewLayout"
4
- import InlineEditField from "./InlineEditField"
5
- import { useGetCurrentAccount, useUpdateUserProfile } from "../../../hooks"
6
- import { validateEmail, validateTelegram } from "../../../utils/validation"
7
-
8
- function Settings() {
9
- const [, theme] = useStyletron()
10
-
11
- const { data: account, isPending: isCurrentAccountPending } =
12
- useGetCurrentAccount()
13
- const { updateProfileAsync } = useUpdateUserProfile()
14
-
15
- const handleSaveEmail = useCallback(
16
- async (value: string) => {
17
- await updateProfileAsync({ email: value || "" })
18
- },
19
- [updateProfileAsync],
20
- )
21
-
22
- const handleSaveTelegram = useCallback(
23
- async (value: string) => {
24
- const handle = value.startsWith("@") ? value.slice(1) : value
25
- await updateProfileAsync({ telegram: handle || "" })
26
- },
27
- [updateProfileAsync],
28
- )
29
-
30
- return (
31
- <NestedViewLayout>
32
- <ParagraphSmall
33
- marginTop={0}
34
- marginBottom={theme.sizing.scale800}
35
- color={theme.colors.contentSecondary}
36
- >
37
- Update your contact information to stay connected.
38
- </ParagraphSmall>
39
-
40
- <Block
41
- display="flex"
42
- flexDirection="column"
43
- overrides={{
44
- Block: {
45
- style: {
46
- gap: theme.sizing.scale600,
47
- },
48
- },
49
- }}
50
- >
51
- <InlineEditField
52
- label="Email"
53
- value={account?.email || ""}
54
- placeholder="Enter your email"
55
- onSave={handleSaveEmail}
56
- validate={validateEmail}
57
- isLoading={isCurrentAccountPending}
58
- />
59
-
60
- <InlineEditField
61
- label="Telegram"
62
- value={account?.telegram || ""}
63
- placeholder="Enter your Telegram handle"
64
- onSave={handleSaveTelegram}
65
- validate={validateTelegram}
66
- isLoading={isCurrentAccountPending}
67
- />
68
- </Block>
69
-
70
- <ParagraphSmall
71
- marginTop={theme.sizing.scale800}
72
- marginBottom={0}
73
- color={theme.colors.contentTertiary}
74
- >
75
- By providing your contact information, you agree to receive service
76
- notifications and occasional promotional messages. Promotional messages
77
- will always include an opt out link. The Privacy Policy is available{" "}
78
- <Link href="https://mezo.org/privacy" target="_blank">
79
- here
80
- </Link>
81
- .
82
- </ParagraphSmall>
83
- </NestedViewLayout>
84
- )
85
- }
86
-
87
- export default Settings
@@ -1,131 +0,0 @@
1
- /* eslint-disable react/no-array-index-key */
2
- import React, { useMemo } from "react"
3
- import { AnimatePresence, motion } from "motion/react"
4
- import { Block, useStyletron } from "@mezo-org/mezo-clay"
5
-
6
- type SlotNumberProps = {
7
- className?: string
8
- children: number
9
- formatFunction?: (value: number) => string
10
- }
11
-
12
- type SlotNumberDigitProps = {
13
- className?: string
14
- children: number
15
- }
16
-
17
- function SlotNumberDigit(props: SlotNumberDigitProps) {
18
- const { children: value, ...restProps } = props
19
-
20
- const [css] = useStyletron()
21
-
22
- const digits = [...Array(10).keys()]
23
-
24
- return (
25
- <AnimatePresence initial={false}>
26
- <motion.div
27
- initial={{
28
- y: "100%",
29
- }}
30
- animate={{
31
- y: "0%",
32
- }}
33
- layout="position"
34
- className={css({
35
- position: "relative",
36
- })}
37
- {...restProps}
38
- >
39
- <Block
40
- overrides={{
41
- Block: {
42
- style: {
43
- visibility: "hidden",
44
- },
45
- },
46
- }}
47
- >
48
- {value}
49
- </Block>
50
-
51
- <motion.div
52
- className={css({
53
- display: "flex",
54
- flexDirection: "column",
55
- position: "absolute",
56
- inset: 0,
57
- height: "fit-content",
58
- })}
59
- initial={false}
60
- animate={{ y: `${(value / 10) * -100}%` }}
61
- transition={{
62
- type: "spring",
63
- damping: 16,
64
- stiffness: 220,
65
- }}
66
- >
67
- {digits.map((digit) => (
68
- <Block as="span" key={digit}>
69
- {digit}
70
- </Block>
71
- ))}
72
- </motion.div>
73
- </motion.div>
74
- </AnimatePresence>
75
- )
76
- }
77
-
78
- /**
79
- * SlotNumber component displays a number with animated digits.
80
- *
81
- * @typedef {object} SlotNumberProps
82
- * @property {number} children - The number to display.
83
- * @property {function} [formatFunction] - Optional function to format the number.
84
- * @property {BlockProps} [restProps] - Additional properties for the Block component.
85
- * @see https://pyszkowski.dev/writings/slot-number
86
- * @returns {JSX.Element} The rendered SlotNumber component.
87
- */
88
- function SlotNumber(props: SlotNumberProps) {
89
- const { children: value, formatFunction, ...restProps } = props
90
-
91
- const [css] = useStyletron()
92
-
93
- const characters = useMemo(() => {
94
- const formattedValue = formatFunction
95
- ? formatFunction(value)
96
- : value.toString()
97
-
98
- return formattedValue
99
- .split("")
100
- .map((character) => (/^[0-9]$/.test(character) ? +character : character))
101
- .reverse()
102
- }, [formatFunction, value])
103
-
104
- return (
105
- <motion.div
106
- layout
107
- className={css({
108
- display: "inline-flex",
109
- flexDirection: "row-reverse",
110
- justifyContent: "flex-end",
111
- overflow: "hidden",
112
- userSelect: "none",
113
- })}
114
- {...restProps}
115
- >
116
- {characters.map((character, index) =>
117
- typeof character === "number" ? (
118
- <SlotNumberDigit key={`slot-number-character-${index}`}>
119
- {character}
120
- </SlotNumberDigit>
121
- ) : (
122
- <motion.span layout key={`slot-number-character-${index}`}>
123
- {character}
124
- </motion.span>
125
- ),
126
- )}
127
- </motion.div>
128
- )
129
- }
130
-
131
- export default SlotNumber
@@ -1,32 +0,0 @@
1
- import React from "react"
2
- import {
3
- Block,
4
- InfoCircle,
5
- LabelSmall,
6
- useStyletron,
7
- } from "@mezo-org/mezo-clay"
8
- import { usePassportContext } from "../../hooks/usePassportContext"
9
-
10
- export default function TestnetTopBanner() {
11
- const [, theme] = useStyletron()
12
-
13
- const { environment } = usePassportContext()
14
-
15
- if (environment !== "testnet") {
16
- return null
17
- }
18
-
19
- return (
20
- <Block
21
- display="flex"
22
- alignItems="center"
23
- padding={`${theme.sizing.scale700} ${theme.sizing.scale600}`}
24
- backgroundColor={theme.colors.warning}
25
- >
26
- <InfoCircle size={theme.sizing.scale550} />
27
- <LabelSmall marginLeft={theme.sizing.scale500}>
28
- You are using testnet funds.
29
- </LabelSmall>
30
- </Block>
31
- )
32
- }
@@ -1,2 +0,0 @@
1
- export { Dropdown } from "./Dropdown"
2
- export type { DropdownProps } from "./Dropdown"
@@ -1 +0,0 @@
1
- export { Dropdown, DropdownProps } from "./Dropdown"