@xswap-link/sdk 0.15.0 → 0.15.1

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 (38) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/index.global.js +86 -80
  3. package/dist/index.js +1117 -976
  4. package/dist/index.js.map +1 -1
  5. package/dist/index.mjs +809 -668
  6. package/dist/index.mjs.map +1 -1
  7. package/package.json +2 -1
  8. package/postcss.config.js +2 -0
  9. package/src/assets/icons/ChevronRightThinIcon.tsx +23 -0
  10. package/src/assets/icons/InfoThinIcon.tsx +33 -0
  11. package/src/assets/icons/RedirectThinIcon.tsx +15 -0
  12. package/src/assets/icons/index.ts +3 -0
  13. package/src/components/Swap/Header/index.tsx +3 -1
  14. package/src/components/Swap/HistoryView/ActivityCard/index.tsx +2 -2
  15. package/src/components/Swap/ReorderButton/ReorderButton.tsx +4 -1
  16. package/src/components/Swap/SettingsView/Delivery/index.tsx +3 -3
  17. package/src/components/Swap/SettingsView/InfiniteApproval/index.tsx +3 -3
  18. package/src/components/Swap/SettingsView/Slippage/index.tsx +5 -3
  19. package/src/components/Swap/SwapView/ConfirmationView/TokenTiles/index.tsx +5 -2
  20. package/src/components/Swap/SwapView/ConfirmationView/TxOverview/Header/index.tsx +1 -1
  21. package/src/components/Swap/SwapView/ConfirmationView/TxResult/index.tsx +19 -18
  22. package/src/components/Swap/SwapView/FeesPanel/Fees/index.tsx +1 -1
  23. package/src/components/Swap/SwapView/FeesPanel/index.tsx +3 -1
  24. package/src/components/Swap/SwapView/SwapPanel/AmountPanel/index.tsx +9 -0
  25. package/src/components/Swap/SwapView/SwapPanel/TokenPanel/ChainPicker/index.tsx +1 -1
  26. package/src/components/Swap/SwapView/SwapPanel/TokenPanel/TokenPicker/NetworkFilter/index.tsx +52 -42
  27. package/src/components/Swap/SwapView/SwapPanel/TokenPanel/TokenPicker/TokenItem/index.tsx +1 -1
  28. package/src/components/Swap/SwapView/SwapPanel/TokenPanel/TokenPicker/index.tsx +5 -5
  29. package/src/components/Swap/SwapView/SwapPanel/TokenPanel/index.tsx +24 -2
  30. package/src/components/Swap/SwapView/SwapPanel/WalletPanel/index.tsx +14 -3
  31. package/src/components/Swap/SwapView/SwapPanel/index.tsx +14 -2
  32. package/src/components/Swap/SwapView/WalletPicker/index.tsx +1 -1
  33. package/src/components/ToggleButton/index.tsx +5 -3
  34. package/src/components/TxModal/index.tsx +2 -6
  35. package/src/components/global.css +85 -0
  36. package/src/config/fonts.ts +15 -2
  37. package/src/context/TxUIWrapper.tsx +0 -1
  38. package/tailwind.config.js +3 -9
@@ -1,5 +1,5 @@
1
1
  import { useSwapContext } from "@src/context";
2
- import { useMemo } from "react";
2
+ import { MouseEvent, useMemo } from "react";
3
3
  import { SwapPanelType } from "../index";
4
4
  import { AmountPanel } from "./AmountPanel";
5
5
  import { Balance } from "./AmountPanel/Balance";
@@ -23,11 +23,23 @@ export const SwapPanel = ({ type }: Props) => {
23
23
  [type, srcChain, dstChain],
24
24
  );
25
25
 
26
+ // The whole source card acts as the amount input's hit area; clicks on the
27
+ // nested buttons (wallet, MAX, token picker) must keep their own actions.
28
+ const focusAmountInput = (event: MouseEvent<HTMLDivElement>) => {
29
+ if (type !== "source" || (event.target as HTMLElement).closest("button")) {
30
+ return;
31
+ }
32
+ event.currentTarget
33
+ .querySelector<HTMLInputElement>("#swap-amount-input")
34
+ ?.focus();
35
+ };
36
+
26
37
  return (
27
38
  <div
39
+ onClick={focusAmountInput}
28
40
  className={`flex flex-col gap-2 px-4 sm:px-6 py-4 rounded-2xl backdrop-blur-[12px] ${
29
41
  type === "source"
30
- ? "bg-gradient-to-r from-t_bg_tertiary/5 to-t_bg_tertiary/5 border border-solid border-t_text_primary border-opacity-25"
42
+ ? "bg-gradient-to-r from-t_bg_tertiary/5 to-t_bg_tertiary/5 swap-panel-gradient-border cursor-text"
31
43
  : "bg-gradient-to-r from-t_bg_tertiary/[0.03] to-t_bg_tertiary/[0.03]"
32
44
  }`}
33
45
  >
@@ -167,7 +167,7 @@ export const WalletPicker: FC<{
167
167
  return (
168
168
  <div className={`flex flex-col h-full min-h-0 ${className || ""}`}>
169
169
  <div className="flex justify-between items-center mb-6">
170
- <div className="text-2xl leading-8 tracking-[0.01em] text-t_text_primary">
170
+ <div className="text-2xl font-medium leading-8 tracking-[0.01em] text-t_text_primary">
171
171
  Select Wallet
172
172
  </div>
173
173
  <button
@@ -12,13 +12,15 @@ const ToggleButton = ({ checked, onClick }: Props) => {
12
12
  onClick={onClick}
13
13
  className={`relative inline-flex items-center w-10 h-5 p-0.5 rounded-full cursor-pointer transition-opacity border-none bg-gradient-to-r ${
14
14
  checked
15
- ? "from-t_main_accent_light/25 to-t_main_accent_dark/25"
15
+ ? "from-x_blue_light/25 to-x_blue_dark/25"
16
16
  : "from-t_main_accent_light/20 to-t_main_accent_dark/20 opacity-50"
17
17
  }`}
18
18
  >
19
19
  <span
20
- className={`w-4 h-4 rounded-full transition-transform bg-gradient-to-r from-t_main_accent_light to-t_main_accent_dark ${
21
- checked ? "translate-x-5" : "translate-x-0"
20
+ className={`w-4 h-4 rounded-full transition-transform bg-gradient-to-r ${
21
+ checked
22
+ ? "translate-x-5 from-x_blue_light to-x_blue_dark"
23
+ : "translate-x-0 from-t_main_accent_light to-t_main_accent_dark"
22
24
  }`}
23
25
  ></span>
24
26
  </button>
@@ -38,12 +38,8 @@ export const TxModal = ({
38
38
  onMouseDown={onBackdropClick}
39
39
  >
40
40
  <div
41
- className={`relative rounded-[32px] p-6 sm:p-8 w-full min-w-[340px] overflow-auto max-w-x_modal backdrop-blur-[32px] bg-t_bg_secondary bg-opacity-75 border border-solid ${
42
- type === "error"
43
- ? "border-[#F44336]"
44
- : type === "success"
45
- ? "border-[#6AE89B]"
46
- : type === "warning"
41
+ className={`relative rounded-[32px] p-6 sm:p-8 w-full min-w-[340px] overflow-auto max-w-[var(--modal-width,588px)] backdrop-blur-[32px] bg-t_bg_secondary bg-opacity-75 border border-solid ${
42
+ type === "warning"
47
43
  ? "border-t_warning_dark"
48
44
  : type === "waiting"
49
45
  ? "border-t_main_accent_dark"
@@ -43,6 +43,91 @@
43
43
  @apply border border-solid border-t_text_primary border-opacity-10;
44
44
  }
45
45
 
46
+ /* 1px gradient stroke of the source swap panel (Figma 1762:39085): the
47
+ design's stroke is white 25%->50% stops under a 10% paint opacity, so the
48
+ effective colors are 2.5%->5% (hover: 50%->75% stops, i.e. 5%->7.5%).
49
+ Border-image can't round corners, hence the masked-pseudo-element ring;
50
+ the two pseudo-elements crossfade because gradients don't interpolate. */
51
+ .swap-panel-gradient-border {
52
+ position: relative;
53
+ }
54
+
55
+ .swap-panel-gradient-border::before,
56
+ .swap-panel-gradient-border::after {
57
+ content: "";
58
+ position: absolute;
59
+ inset: 0;
60
+ border-radius: inherit;
61
+ padding: 1px;
62
+ -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
63
+ -webkit-mask-composite: xor;
64
+ mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
65
+ mask-composite: exclude;
66
+ pointer-events: none;
67
+ }
68
+
69
+ .swap-panel-gradient-border::before {
70
+ background: linear-gradient(
71
+ 90deg,
72
+ color-mix(in srgb, var(--text-primary) 2.5%, transparent),
73
+ color-mix(in srgb, var(--text-primary) 5%, transparent)
74
+ );
75
+ }
76
+
77
+ .swap-panel-gradient-border::after {
78
+ background: linear-gradient(
79
+ 90deg,
80
+ color-mix(in srgb, var(--text-primary) 5%, transparent),
81
+ color-mix(in srgb, var(--text-primary) 7.5%, transparent)
82
+ );
83
+ opacity: 0;
84
+ transition: opacity 0.15s ease;
85
+ }
86
+
87
+ .swap-panel-gradient-border:hover::after {
88
+ opacity: 1;
89
+ }
90
+
91
+ /* Surface of the network filter dropdown (Figma 1770:15593): a 20% black
92
+ wash over a subtle vertical sheen (white 4% -> 2% -> 4%).
93
+ The design carries those over a 72px background blur, but Chromium
94
+ ignores backdrop-filter nested inside the widget's own backdrop-blur,
95
+ so the translucent stack alone would let the token list read through.
96
+ Hence the opaque base underneath — it lands on the same near-black the
97
+ blurred design resolves to. */
98
+ .network-dropdown-surface {
99
+ background:
100
+ linear-gradient(
101
+ 90deg,
102
+ color-mix(in srgb, var(--bg-primary) 20%, transparent) 0%,
103
+ color-mix(in srgb, var(--bg-primary) 20%, transparent) 100%
104
+ ),
105
+ linear-gradient(
106
+ 180deg,
107
+ color-mix(in srgb, var(--bg-tertiary) 4%, transparent) 0%,
108
+ color-mix(in srgb, var(--bg-tertiary) 2%, transparent) 49.5%,
109
+ color-mix(in srgb, var(--bg-tertiary) 4%, transparent) 100%
110
+ ),
111
+ var(--bg-secondary);
112
+ }
113
+
114
+ /* Hover/selected pill of a network row ("Active Fill", Figma 1770:15599):
115
+ a horizontal sheen peaking in the middle and fading out at both ends.
116
+ The design's stops are white 0 -> 10% -> 50% -> 10% -> 0 under a 5% layer
117
+ opacity, so the effective values are the ones below. Gradients don't
118
+ interpolate, hence no transition. */
119
+ .network-dropdown-row:hover,
120
+ .network-dropdown-row-active {
121
+ background: linear-gradient(
122
+ 90deg,
123
+ transparent 0%,
124
+ color-mix(in srgb, var(--bg-tertiary) 0.5%, transparent) 15%,
125
+ color-mix(in srgb, var(--bg-tertiary) 2.5%, transparent) 50%,
126
+ color-mix(in srgb, var(--bg-tertiary) 0.5%, transparent) 85%,
127
+ transparent 100%
128
+ );
129
+ }
130
+
46
131
  /* Corner glow of the transaction result modal, fading towards the center */
47
132
  .tx-modal-glow-success {
48
133
  background: radial-gradient(
@@ -52,9 +52,18 @@
52
52
  // font-style: italic;
53
53
  // }`;
54
54
 
55
+ import SatoshiRegularWOFF2 from "../fonts/Satoshi-Regular.woff2";
56
+ const SatoshiRegular = `@font-face {
57
+ font-family: "Satoshi";
58
+ src: url(${SatoshiRegularWOFF2}) format("woff2");
59
+ font-weight: 400;
60
+ font-display: swap;
61
+ font-style: normal;
62
+ }`;
63
+
55
64
  import SatoshiMediumWOFF2 from "../fonts/Satoshi-Medium.woff2";
56
65
  const SatoshiMedium = `@font-face {
57
- font-family: "Satoshi-Medium";
66
+ font-family: "Satoshi";
58
67
  src: url(${SatoshiMediumWOFF2}) format("woff2");
59
68
  font-weight: 500;
60
69
  font-display: swap;
@@ -109,6 +118,10 @@ const SatoshiMedium = `@font-face {
109
118
  // Fonts are inlined into JS bundle when we import them and they are added into DOM when we add them to this array.
110
119
  // Use only fonts that you need.
111
120
  // We don't want to increase the bundle size unnecessarily.
112
- const enabledFonts = [SatoshiMedium];
121
+ //
122
+ // Regular and Medium are registered under one "Satoshi" family so that
123
+ // `font-weight` picks a face. With a single face loaded every weight renders
124
+ // as that face, which is why `font-medium` used to be a no-op.
125
+ const enabledFonts = [SatoshiRegular, SatoshiMedium];
113
126
 
114
127
  export const fontDefinitions = enabledFonts.join("\n");
@@ -487,7 +487,6 @@ export const TxUIWrapper = ({ children }: Props) => {
487
487
  {isTxModalOpen && (
488
488
  <TxModal
489
489
  id="tx_modal"
490
- className="max-w-x_modal"
491
490
  type={modalType}
492
491
  onCloseClick={closeTxModal}
493
492
  >
@@ -6,15 +6,9 @@ export default {
6
6
  content: ["src/components/**/*.{ts,tsx}", "src/context/**/*.{ts,tsx}"],
7
7
  theme: {
8
8
  fontFamily: {
9
- body: [
10
- withFontVariable("'Satoshi-Medium', Tahoma, Verdana, ui-sans-serif"),
11
- ],
12
- sans: [
13
- withFontVariable("'Satoshi-Medium', Tahoma, Verdana, ui-sans-serif"),
14
- ],
15
- "sans-bold": [
16
- withFontVariable("'Satoshi-Bold', Tahoma, Verdana, ui-sans-serif"),
17
- ],
9
+ // One family with Regular (400) and Medium (500) faces, see config/fonts.ts.
10
+ // Weight is selected with `font-normal` / `font-medium`, not by family.
11
+ sans: [withFontVariable("'Satoshi', Tahoma, Verdana, ui-sans-serif")],
18
12
  },
19
13
  extend: {
20
14
  colors: {