@rango-dev/ui 0.27.0 → 0.27.1-next.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 (52) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/index.js +2 -2
  3. package/dist/index.js.map +4 -4
  4. package/dist/widget/ui/src/components/Alert/Alert.styles.d.ts +1 -0
  5. package/dist/widget/ui/src/components/Alert/Alert.styles.d.ts.map +1 -1
  6. package/dist/widget/ui/src/components/ChainToken/ChainToken.d.ts.map +1 -1
  7. package/dist/widget/ui/src/components/ChainToken/ChainToken.types.d.ts +1 -0
  8. package/dist/widget/ui/src/components/ChainToken/ChainToken.types.d.ts.map +1 -1
  9. package/dist/widget/ui/src/components/Toast/Toast.Provider.d.ts +6 -0
  10. package/dist/widget/ui/src/components/Toast/Toast.Provider.d.ts.map +1 -0
  11. package/dist/widget/ui/src/components/Toast/Toast.d.ts +4 -0
  12. package/dist/widget/ui/src/components/Toast/Toast.d.ts.map +1 -0
  13. package/dist/widget/ui/src/components/Toast/Toast.helpers.d.ts +2 -0
  14. package/dist/widget/ui/src/components/Toast/Toast.helpers.d.ts.map +1 -0
  15. package/dist/widget/ui/src/components/Toast/Toast.stories.d.ts +7 -0
  16. package/dist/widget/ui/src/components/Toast/Toast.stories.d.ts.map +1 -0
  17. package/dist/widget/ui/src/components/Toast/Toast.styles.d.ts +977 -0
  18. package/dist/widget/ui/src/components/Toast/Toast.styles.d.ts.map +1 -0
  19. package/dist/widget/ui/src/components/Toast/Toast.types.d.ts +31 -0
  20. package/dist/widget/ui/src/components/Toast/Toast.types.d.ts.map +1 -0
  21. package/dist/widget/ui/src/components/Toast/index.d.ts +3 -0
  22. package/dist/widget/ui/src/components/Toast/index.d.ts.map +1 -0
  23. package/dist/widget/ui/src/components/common/Image.d.ts +1 -0
  24. package/dist/widget/ui/src/components/common/Image.d.ts.map +1 -1
  25. package/dist/widget/ui/src/components/index.d.ts +1 -0
  26. package/dist/widget/ui/src/components/index.d.ts.map +1 -1
  27. package/dist/widget/ui/src/constants/index.d.ts +7 -0
  28. package/dist/widget/ui/src/constants/index.d.ts.map +1 -0
  29. package/dist/widget/ui/src/containers/SwapInput/SwapInput.d.ts.map +1 -1
  30. package/dist/widget/ui/src/containers/SwapInput/TokenSection.d.ts.map +1 -1
  31. package/dist/widget/ui/src/containers/SwapInput/TokenSection.types.d.ts +1 -0
  32. package/dist/widget/ui/src/containers/SwapInput/TokenSection.types.d.ts.map +1 -1
  33. package/dist/widget/ui/src/index.d.ts +1 -0
  34. package/dist/widget/ui/src/index.d.ts.map +1 -1
  35. package/package.json +2 -2
  36. package/src/components/Alert/Alert.styles.ts +5 -0
  37. package/src/components/ChainToken/ChainToken.tsx +9 -1
  38. package/src/components/ChainToken/ChainToken.types.ts +1 -0
  39. package/src/components/Toast/Toast.Provider.tsx +87 -0
  40. package/src/components/Toast/Toast.helpers.ts +7 -0
  41. package/src/components/Toast/Toast.stories.tsx +71 -0
  42. package/src/components/Toast/Toast.styles.ts +113 -0
  43. package/src/components/Toast/Toast.tsx +59 -0
  44. package/src/components/Toast/Toast.types.ts +31 -0
  45. package/src/components/Toast/index.ts +2 -0
  46. package/src/components/common/Image.tsx +1 -0
  47. package/src/components/index.ts +1 -0
  48. package/src/constants/index.ts +6 -0
  49. package/src/containers/SwapInput/SwapInput.tsx +13 -1
  50. package/src/containers/SwapInput/TokenSection.tsx +2 -0
  51. package/src/containers/SwapInput/TokenSection.types.ts +1 -0
  52. package/src/index.ts +1 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Toast.styles.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Toast/Toast.styles.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAO3C,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;+DAI9B,CAAC"}
@@ -0,0 +1,31 @@
1
+ /// <reference types="react" />
2
+ import type { Type } from '../Alert/Alert.types';
3
+ import type { CSSProperties } from '@stitches/react';
4
+ export interface ProviderPropTypes {
5
+ container: HTMLElement;
6
+ anchorOrigin?: {
7
+ horizontal: 'left' | 'right';
8
+ vertical: 'bottom' | 'top';
9
+ };
10
+ containerStyle?: CSSProperties;
11
+ }
12
+ export type ToastType = {
13
+ autoHideDuration?: number;
14
+ id?: number | string;
15
+ } & ({
16
+ title: string;
17
+ type: Type;
18
+ titleColor?: string;
19
+ style?: CSSProperties;
20
+ } | {
21
+ component: React.ReactNode;
22
+ });
23
+ export type ToastProps = ToastType & {
24
+ id: number | string;
25
+ horizontal: 'left' | 'right';
26
+ };
27
+ export type ProviderContext = {
28
+ addToast: (content: ToastType) => void;
29
+ removeToast: (id: number | string) => void;
30
+ };
31
+ //# sourceMappingURL=Toast.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Toast.types.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Toast/Toast.types.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAC;AACjD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,WAAW,CAAC;IACvB,YAAY,CAAC,EAAE;QACb,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC;QAC7B,QAAQ,EAAE,QAAQ,GAAG,KAAK,CAAC;KAC5B,CAAC;IACF,cAAc,CAAC,EAAE,aAAa,CAAC;CAChC;AAED,MAAM,MAAM,SAAS,GAAG;IAAE,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAAC,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;CAAE,GAAG,CAC1E;IACE,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,IAAI,CAAC;IACX,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,aAAa,CAAC;CACvB,GACD;IAAE,SAAS,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,CACjC,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG;IACnC,EAAE,EAAE,MAAM,GAAG,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC;CAC9B,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,QAAQ,EAAE,CAAC,OAAO,EAAE,SAAS,KAAK,IAAI,CAAC;IACvC,WAAW,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,KAAK,IAAI,CAAC;CAC5C,CAAC"}
@@ -0,0 +1,3 @@
1
+ export { Toast } from './Toast';
2
+ export { ToastProvider, useToast } from './Toast.Provider';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../src/components/Toast/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC"}
@@ -161,6 +161,7 @@ export declare const ImageContainer: import("@stitches/react/types/styled-compon
161
161
  transitions: {};
162
162
  }, import("@stitches/react/types/config").DefaultThemeMap, {}>>;
163
163
  type PropTypes = {
164
+ id?: string;
164
165
  size: number;
165
166
  useAsPlaceholder?: boolean;
166
167
  backgroundColor?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"Image.d.ts","sourceRoot":"","sources":["../../../../../../src/components/common/Image.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+DAYzB,CAAC;AAEH,KAAK,SAAS,GAAG;IACf,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,UAAU,GAAG,aAAa,CAAC;CACnC,GAAG,KAAK,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;AAE9C,wBAAgB,KAAK,CAAC,KAAK,EAAE,SAAS,qBA0BrC"}
1
+ {"version":3,"file":"Image.d.ts","sourceRoot":"","sources":["../../../../../../src/components/common/Image.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+DAYzB,CAAC;AAEH,KAAK,SAAS,GAAG;IACf,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,CAAC,EAAE,OAAO,CAAC;IAC3B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,UAAU,GAAG,aAAa,CAAC;CACnC,GAAG,KAAK,CAAC,iBAAiB,CAAC,gBAAgB,CAAC,CAAC;AAE9C,wBAAgB,KAAK,CAAC,KAAK,EAAE,SAAS,qBA0BrC"}
@@ -29,6 +29,7 @@ export * from './SwapListItem';
29
29
  export * from './SwapDetailsPlaceholder';
30
30
  export * from './Switch';
31
31
  export * from './TextField';
32
+ export * from './Toast';
32
33
  export * from './TokenList';
33
34
  export * from './TokenPreview';
34
35
  export * from './Tooltip';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/components/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,SAAS,CAAC;AACxB,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,cAAc,CAAC;AAC7B,cAAc,eAAe,CAAC;AAC9B,cAAc,wBAAwB,CAAC;AACvC,cAAc,YAAY,CAAC;AAC3B,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC;AAC7B,cAAc,oBAAoB,CAAC;AACnC,cAAc,cAAc,CAAC;AAC7B,cAAc,yBAAyB,CAAC;AACxC,cAAc,kBAAkB,CAAC;AACjC,cAAc,iBAAiB,CAAC;AAChC,cAAc,wBAAwB,CAAC;AACvC,cAAc,UAAU,CAAC;AACzB,cAAc,0BAA0B,CAAC;AACzC,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC;AACzC,cAAc,UAAU,CAAC;AACzB,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;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c,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,mBAAmB,CAAC;AAClC,cAAc,kBAAkB,CAAC;AACjC,cAAc,QAAQ,CAAC;AACvB,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC;AAC3B,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,aAAa,CAAC;AAC5B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,WAAW,CAAC;AAC1B,cAAc,SAAS,CAAC"}
@@ -0,0 +1,7 @@
1
+ export declare const UI_ID: {
2
+ SWAP_FROM_INPUT_CONTAINER_ID: string;
3
+ SWAP_TO_INPUT_CONTAINER_ID: string;
4
+ SWAP_FROM_CHAIN_IMAGE_ID: string;
5
+ SWAP_TO_CHAIN_IMAGE_ID: string;
6
+ };
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/constants/index.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,KAAK;;;;;CAKjB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"SwapInput.d.ts","sourceRoot":"","sources":["../../../../../../src/containers/SwapInput/SwapInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGxD,OAAO,KAAK,MAAM,OAAO,CAAC;AAyB1B,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,qBAuH9C"}
1
+ {"version":3,"file":"SwapInput.d.ts","sourceRoot":"","sources":["../../../../../../src/containers/SwapInput/SwapInput.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAGxD,OAAO,KAAK,MAAM,OAAO,CAAC;AA0B1B,wBAAgB,SAAS,CAAC,KAAK,EAAE,cAAc,qBAkI9C"}
@@ -1 +1 @@
1
- {"version":3,"file":"TokenSection.d.ts","sourceRoot":"","sources":["../../../../../../src/containers/SwapInput/TokenSection.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAG9D,OAAO,KAAK,MAAM,OAAO,CAAC;AAY1B,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,qBA8CpD"}
1
+ {"version":3,"file":"TokenSection.d.ts","sourceRoot":"","sources":["../../../../../../src/containers/SwapInput/TokenSection.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAG9D,OAAO,KAAK,MAAM,OAAO,CAAC;AAY1B,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,qBAgDpD"}
@@ -3,6 +3,7 @@ export type TokenSectionProps = {
3
3
  tokenImage: string;
4
4
  tokenSymbol: string;
5
5
  chain: string;
6
+ chianImageId?: string;
6
7
  error?: boolean;
7
8
  onClick: () => void;
8
9
  loading?: boolean;
@@ -1 +1 @@
1
- {"version":3,"file":"TokenSection.types.d.ts","sourceRoot":"","sources":["../../../../../../src/containers/SwapInput/TokenSection.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC"}
1
+ {"version":3,"file":"TokenSection.types.d.ts","sourceRoot":"","sources":["../../../../../../src/containers/SwapInput/TokenSection.types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC"}
@@ -4,4 +4,5 @@ export * from './theme';
4
4
  export * from './types';
5
5
  export * from './hooks';
6
6
  export * from './icons';
7
+ export * from './constants';
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rango-dev/ui",
3
- "version": "0.27.0",
3
+ "version": "0.27.1-next.1",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "source": "./src/index.ts",
@@ -77,4 +77,4 @@
77
77
  "publishConfig": {
78
78
  "access": "public"
79
79
  }
80
- }
80
+ }
@@ -153,6 +153,11 @@ export const IconHighlight = styled('div', {
153
153
  backgroundColor: '$$color',
154
154
  },
155
155
  },
156
+ align: {
157
+ center: {
158
+ alignSelf: 'center',
159
+ },
160
+ },
156
161
  },
157
162
  });
158
163
 
@@ -9,7 +9,14 @@ import { tokenChainSizeMap } from './ChainToken.constants';
9
9
  import { ChainImageContainer, Container } from './ChainToken.styles';
10
10
 
11
11
  export const ChainToken: React.FC<PropTypes> = (props) => {
12
- const { tokenImage, chainImage, size, useAsPlaceholder, loading } = props;
12
+ const {
13
+ tokenImage,
14
+ chainImage,
15
+ chianImageId,
16
+ size,
17
+ useAsPlaceholder,
18
+ loading,
19
+ } = props;
13
20
  return (
14
21
  <Container
15
22
  css={
@@ -43,6 +50,7 @@ export const ChainToken: React.FC<PropTypes> = (props) => {
43
50
  />
44
51
  ) : (
45
52
  <Image
53
+ id={chianImageId}
46
54
  size={tokenChainSizeMap[size].chain}
47
55
  src={chainImage}
48
56
  type="circular"
@@ -7,6 +7,7 @@ type BaseSizes = Exclude<BaseProps['size'], object>;
7
7
  export type PropTypes = {
8
8
  tokenImage: string;
9
9
  chainImage: string;
10
+ chianImageId?: string;
10
11
  size: NonNullable<BaseSizes>;
11
12
  useAsPlaceholder?: boolean;
12
13
  loading?: boolean;
@@ -0,0 +1,87 @@
1
+ import type {
2
+ ProviderContext,
3
+ ProviderPropTypes,
4
+ ToastProps,
5
+ ToastType,
6
+ } from './Toast.types';
7
+ import type { PropsWithChildren } from 'react';
8
+
9
+ import React, { createContext, useContext, useMemo, useState } from 'react';
10
+ import { createPortal } from 'react-dom';
11
+
12
+ import { Toast } from './Toast';
13
+ import { idGenerator } from './Toast.helpers';
14
+ import { ToastContainer } from './Toast.styles';
15
+
16
+ const ToastContext = createContext<ProviderContext | undefined>(undefined);
17
+
18
+ export const ToastProvider = (props: PropsWithChildren<ProviderPropTypes>) => {
19
+ const generateId = useMemo(() => idGenerator(), []);
20
+
21
+ const {
22
+ children,
23
+ anchorOrigin = {
24
+ horizontal: 'right',
25
+ vertical: 'bottom',
26
+ },
27
+ container,
28
+ containerStyle = {},
29
+ } = props;
30
+ const [toasts, setToasts] = useState<ToastProps[]>([]);
31
+
32
+ // eslint-disable-next-line react/jsx-no-constructed-context-values
33
+ const api: ProviderContext = {
34
+ addToast(content: ToastType) {
35
+ setToasts((toasts) => {
36
+ const isToastExistById = toasts.find(
37
+ (toast) => toast.id === content.id
38
+ );
39
+ if (isToastExistById) {
40
+ console.warn(
41
+ 'Trying to send a toast with an existing ID. Please update the toast ID or use it after the toast is hidden'
42
+ );
43
+ return toasts;
44
+ }
45
+ return [
46
+ ...toasts,
47
+ {
48
+ ...content,
49
+ id: content.id || generateId(),
50
+ horizontal: anchorOrigin.horizontal,
51
+ },
52
+ ];
53
+ });
54
+ },
55
+ removeToast(id: number | string) {
56
+ setToasts((toasts) => toasts.filter((t) => t.id !== id));
57
+ },
58
+ };
59
+
60
+ return (
61
+ <ToastContext.Provider value={api}>
62
+ {children}
63
+ {container &&
64
+ createPortal(
65
+ <ToastContainer
66
+ style={containerStyle}
67
+ horizontal={anchorOrigin.horizontal}
68
+ vertical={anchorOrigin.vertical}>
69
+ {toasts.map((toast) => (
70
+ <Toast {...toast} key={toast.id} />
71
+ ))}
72
+ </ToastContainer>,
73
+ container
74
+ )}
75
+ </ToastContext.Provider>
76
+ );
77
+ };
78
+
79
+ export function useToast(): ProviderContext {
80
+ const context = useContext(ToastContext);
81
+ if (!context) {
82
+ throw new Error(
83
+ 'useToast can only be used within the ToastProvider component'
84
+ );
85
+ }
86
+ return context;
87
+ }
@@ -0,0 +1,7 @@
1
+ export function idGenerator() {
2
+ let id = 1;
3
+ return () => {
4
+ id++;
5
+ return id;
6
+ };
7
+ }
@@ -0,0 +1,71 @@
1
+ import type { ToastProps } from './Toast.types';
2
+ import type { Meta } from '@storybook/react';
3
+
4
+ import React from 'react';
5
+
6
+ import { Button } from '../Button';
7
+
8
+ import { ToastStoryContainer } from './Toast.styles';
9
+
10
+ import { Toast, ToastProvider, useToast } from '.';
11
+
12
+ export default {
13
+ title: 'Components/Toast',
14
+ component: Toast,
15
+ args: {
16
+ type: 'success',
17
+ title: 'Please change your wallet network to Polygon',
18
+ autoHideDuration: 5_000,
19
+ horizontal: 'right',
20
+ },
21
+ argTypes: {
22
+ type: {
23
+ name: 'type',
24
+ control: {
25
+ type: 'select',
26
+ options: ['success', 'warning', 'error', 'info', 'loading'],
27
+ },
28
+ },
29
+ },
30
+ } as Meta<typeof Toast>;
31
+
32
+ export const TopToasts = (props: ToastProps) => {
33
+ return (
34
+ <ToastProvider
35
+ container={document.body}
36
+ anchorOrigin={{
37
+ horizontal: props.horizontal,
38
+ vertical: 'top',
39
+ }}>
40
+ <ToastComponent {...props} />
41
+ </ToastProvider>
42
+ );
43
+ };
44
+
45
+ export const BottomToasts = (props: ToastProps) => {
46
+ return (
47
+ <ToastProvider
48
+ container={document.body}
49
+ anchorOrigin={{
50
+ horizontal: props.horizontal,
51
+ vertical: 'bottom',
52
+ }}>
53
+ <ToastComponent {...props} />
54
+ </ToastProvider>
55
+ );
56
+ };
57
+
58
+ const ToastComponent = (props: ToastProps) => {
59
+ const { addToast } = useToast();
60
+
61
+ return (
62
+ <ToastStoryContainer>
63
+ <Button
64
+ variant="contained"
65
+ type="success"
66
+ onClick={() => addToast(props)}>
67
+ Show Toast
68
+ </Button>
69
+ </ToastStoryContainer>
70
+ );
71
+ };
@@ -0,0 +1,113 @@
1
+ import { darkTheme, keyframes, lightTheme, styled } from '../../theme';
2
+ import { Typography } from '../Typography';
3
+
4
+ const toastOpacity = keyframes({
5
+ from: { opacity: 0 },
6
+ to: { opacity: 1 },
7
+ });
8
+
9
+ export const ToastContentContainer = styled('div', {
10
+ variants: {
11
+ horizontal: {
12
+ right: {
13
+ right: 12,
14
+ animation: `${toastOpacity} .7s`,
15
+ },
16
+ left: {
17
+ left: 12,
18
+ animation: `${toastOpacity} .7s`,
19
+ },
20
+ },
21
+ },
22
+ });
23
+
24
+ export const ToastContainer = styled('div', {
25
+ position: 'absolute',
26
+ zIndex: 9999,
27
+ display: 'flex',
28
+ gap: '$4',
29
+ flexDirection: 'column',
30
+ variants: {
31
+ horizontal: {
32
+ right: {
33
+ right: 12,
34
+ },
35
+ left: {
36
+ left: 12,
37
+ },
38
+ },
39
+
40
+ vertical: {
41
+ top: {
42
+ top: 2,
43
+ },
44
+ bottom: {
45
+ bottom: 2,
46
+ },
47
+ },
48
+ },
49
+ });
50
+
51
+ export const AlertBox = styled('div', {
52
+ display: 'flex',
53
+ borderRadius: '$sm',
54
+ width: '292px',
55
+ minHeight: '52px',
56
+ backgroundColor: '$background',
57
+ borderRight: '1px solid',
58
+ [`.${darkTheme} &`]: {
59
+ backgroundColor: '#070917',
60
+ },
61
+ '&:hover': {
62
+ backgroundColor: '$info100',
63
+ [`.${darkTheme} &`]: {
64
+ backgroundColor: '#111733',
65
+ },
66
+ },
67
+ variants: {
68
+ type: {
69
+ error: {
70
+ borderRightColor: '$error500',
71
+ },
72
+ success: {
73
+ borderRightColor: '$success500',
74
+ },
75
+ warning: {
76
+ borderRightColor: '$warning500',
77
+ },
78
+ info: {
79
+ borderRightColor: '$info500',
80
+ },
81
+ loading: {
82
+ borderRightColor: '$info500',
83
+ },
84
+ },
85
+ },
86
+ });
87
+
88
+ export const AlertFlexContainer = styled('div', {
89
+ display: 'flex',
90
+ padding: '$10',
91
+ alignItems: 'center',
92
+ });
93
+
94
+ export const StyledTypography = styled(Typography, {
95
+ variants: {
96
+ hasColor: {
97
+ false: {
98
+ [`.${lightTheme} &`]: {
99
+ color: '$neutral700',
100
+ },
101
+ [`.${darkTheme} &`]: {
102
+ color: '$neutral900',
103
+ },
104
+ },
105
+ },
106
+ },
107
+ });
108
+
109
+ export const ToastStoryContainer = styled('div', {
110
+ display: 'flex',
111
+ justifyContent: 'center',
112
+ alignItems: 'center',
113
+ });
@@ -0,0 +1,59 @@
1
+ import type { ToastProps } from './Toast.types';
2
+
3
+ import React, { useEffect } from 'react';
4
+
5
+ import { IconHighlight } from '../Alert/Alert.styles';
6
+ import AlertIcon from '../Alert/AlertIcon';
7
+ import { Divider } from '../Divider';
8
+
9
+ import { useToast } from './Toast.Provider';
10
+ import {
11
+ AlertBox,
12
+ AlertFlexContainer,
13
+ StyledTypography,
14
+ ToastContentContainer,
15
+ } from './Toast.styles';
16
+
17
+ const DEFAULT_HIDE_DURATION = 3_000;
18
+
19
+ export const Toast = (props: ToastProps) => {
20
+ const { id, horizontal, autoHideDuration = DEFAULT_HIDE_DURATION } = props;
21
+ const { removeToast } = useToast();
22
+ useEffect(() => {
23
+ const timer = setTimeout(() => {
24
+ removeToast(id);
25
+ }, autoHideDuration);
26
+
27
+ return () => {
28
+ clearTimeout(timer);
29
+ };
30
+ }, [id]);
31
+
32
+ return (
33
+ <ToastContentContainer horizontal={horizontal}>
34
+ {'component' in props ? (
35
+ props.component
36
+ ) : (
37
+ <AlertBox
38
+ onClick={() => removeToast(id)}
39
+ type={props.type}
40
+ style={props.style}>
41
+ <AlertFlexContainer>
42
+ <IconHighlight type={props.type} align="center">
43
+ <AlertIcon type={props.type} />
44
+ </IconHighlight>
45
+ <Divider direction="horizontal" size={10} />
46
+ <StyledTypography
47
+ variant="body"
48
+ size="small"
49
+ color={props.titleColor}
50
+ hasColor={!!props.titleColor}
51
+ align="left">
52
+ {props.title}
53
+ </StyledTypography>
54
+ </AlertFlexContainer>
55
+ </AlertBox>
56
+ )}
57
+ </ToastContentContainer>
58
+ );
59
+ };
@@ -0,0 +1,31 @@
1
+ import type { Type } from '../Alert/Alert.types';
2
+ import type { CSSProperties } from '@stitches/react';
3
+
4
+ export interface ProviderPropTypes {
5
+ container: HTMLElement;
6
+ anchorOrigin?: {
7
+ horizontal: 'left' | 'right';
8
+ vertical: 'bottom' | 'top';
9
+ };
10
+ containerStyle?: CSSProperties;
11
+ }
12
+
13
+ export type ToastType = { autoHideDuration?: number; id?: number | string } & (
14
+ | {
15
+ title: string;
16
+ type: Type;
17
+ titleColor?: string;
18
+ style?: CSSProperties;
19
+ }
20
+ | { component: React.ReactNode }
21
+ );
22
+
23
+ export type ToastProps = ToastType & {
24
+ id: number | string;
25
+ horizontal: 'left' | 'right';
26
+ };
27
+
28
+ export type ProviderContext = {
29
+ addToast: (content: ToastType) => void;
30
+ removeToast: (id: number | string) => void;
31
+ };
@@ -0,0 +1,2 @@
1
+ export { Toast } from './Toast';
2
+ export { ToastProvider, useToast } from './Toast.Provider';
@@ -17,6 +17,7 @@ export const ImageContainer = styled('div', {
17
17
  });
18
18
 
19
19
  type PropTypes = {
20
+ id?: string;
20
21
  size: number;
21
22
  useAsPlaceholder?: boolean;
22
23
  backgroundColor?: string;
@@ -29,6 +29,7 @@ export * from './SwapListItem';
29
29
  export * from './SwapDetailsPlaceholder';
30
30
  export * from './Switch';
31
31
  export * from './TextField';
32
+ export * from './Toast';
32
33
  export * from './TokenList';
33
34
  export * from './TokenPreview';
34
35
  export * from './Tooltip';
@@ -0,0 +1,6 @@
1
+ export const UI_ID = {
2
+ SWAP_FROM_INPUT_CONTAINER_ID: 'rango-swap-from-input-container',
3
+ SWAP_TO_INPUT_CONTAINER_ID: 'rango-swap-to-input-container',
4
+ SWAP_FROM_CHAIN_IMAGE_ID: 'rango-swap-from-chain-image',
5
+ SWAP_TO_CHAIN_IMAGE_ID: 'rango-swap-to-chain-image',
6
+ };
@@ -10,6 +10,7 @@ import {
10
10
  Tooltip,
11
11
  Typography,
12
12
  } from '../../components';
13
+ import { UI_ID } from '../../constants';
13
14
 
14
15
  import {
15
16
  amountStyles,
@@ -32,7 +33,13 @@ export function SwapInput(props: SwapInputProps) {
32
33
  const showBalanceSkeleton =
33
34
  'balance' in props && (props.loading || props.loadingBalance);
34
35
  return (
35
- <Container sharpBottomStyle={props.sharpBottomStyle}>
36
+ <Container
37
+ id={
38
+ props.mode === 'To'
39
+ ? UI_ID.SWAP_TO_INPUT_CONTAINER_ID
40
+ : UI_ID.SWAP_FROM_INPUT_CONTAINER_ID
41
+ }
42
+ sharpBottomStyle={props.sharpBottomStyle}>
36
43
  <div className={labelContainerStyles()}>
37
44
  <div className={labelStyles()}>
38
45
  <Typography variant="body" size="small" className={textStyles()}>
@@ -67,6 +74,11 @@ export function SwapInput(props: SwapInputProps) {
67
74
  <div className={formStyles()}>
68
75
  <TokenSection
69
76
  chain={props.chain.displayName}
77
+ chianImageId={
78
+ props.mode === 'To'
79
+ ? UI_ID.SWAP_TO_CHAIN_IMAGE_ID
80
+ : UI_ID.SWAP_FROM_CHAIN_IMAGE_ID
81
+ }
70
82
  tokenSymbol={props.token.displayName}
71
83
  error={props.error}
72
84
  chainImage={props.chain.image}
@@ -20,6 +20,7 @@ export function TokenSection(props: TokenSectionProps) {
20
20
  tokenImage,
21
21
  tokenSymbol,
22
22
  chain,
23
+ chianImageId,
23
24
  onClick,
24
25
  loading,
25
26
  } = props;
@@ -27,6 +28,7 @@ export function TokenSection(props: TokenSectionProps) {
27
28
  <Container variant="default" disabled={error || loading} onClick={onClick}>
28
29
  <TokenSectionContainer>
29
30
  <ChainToken
31
+ chianImageId={chianImageId}
30
32
  size="large"
31
33
  useAsPlaceholder={error}
32
34
  chainImage={chainImage}
@@ -3,6 +3,7 @@ export type TokenSectionProps = {
3
3
  tokenImage: string;
4
4
  tokenSymbol: string;
5
5
  chain: string;
6
+ chianImageId?: string;
6
7
  error?: boolean;
7
8
  onClick: () => void;
8
9
  loading?: boolean;
package/src/index.ts CHANGED
@@ -4,3 +4,4 @@ export * from './theme';
4
4
  export * from './types';
5
5
  export * from './hooks';
6
6
  export * from './icons';
7
+ export * from './constants';