@westpac/ui 0.16.0 → 0.17.0

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 (67) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/component-type.json +1 -1
  3. package/dist/components/badge/badge.component.js +3 -1
  4. package/dist/components/badge/badge.styles.js +1 -1
  5. package/dist/components/bottom-sheet/bottom-sheet.component.d.ts +1 -1
  6. package/dist/components/bottom-sheet/bottom-sheet.component.js +7 -2
  7. package/dist/components/bottom-sheet/bottom-sheet.types.d.ts +20 -0
  8. package/dist/components/bottom-sheet/components/bottom-sheet-dialog/bottom-sheet-dialog.component.d.ts +1 -1
  9. package/dist/components/bottom-sheet/components/bottom-sheet-dialog/bottom-sheet-dialog.component.js +26 -11
  10. package/dist/components/bottom-sheet/components/bottom-sheet-dialog/bottom-sheet-dialog.styles.d.ts +47 -0
  11. package/dist/components/bottom-sheet/components/bottom-sheet-dialog/bottom-sheet-dialog.styles.js +20 -0
  12. package/dist/components/bottom-sheet/components/bottom-sheet-dialog/bottom-sheet-dialog.types.d.ts +17 -1
  13. package/dist/components/bottom-sheet/components/bottom-sheet-modal/bottom-sheet-modal.component.d.ts +1 -1
  14. package/dist/components/bottom-sheet/components/bottom-sheet-modal/bottom-sheet-modal.component.js +6 -13
  15. package/dist/components/bottom-sheet/components/bottom-sheet-modal/bottom-sheet-modal.styles.d.ts +11 -0
  16. package/dist/components/bottom-sheet/components/bottom-sheet-modal/bottom-sheet-modal.styles.js +17 -0
  17. package/dist/components/bottom-sheet/components/bottom-sheet-modal/bottom-sheet-modal.types.d.ts +0 -5
  18. package/dist/components/icon/components/x-icon.d.ts +2 -0
  19. package/dist/components/icon/components/x-icon.js +40 -0
  20. package/dist/components/icon/index.d.ts +1 -1
  21. package/dist/components/icon/index.js +1 -1
  22. package/dist/components/modal/components/modal-backdrop/modal-backdrop.component.js +2 -1
  23. package/dist/components/modal/components/modal-backdrop/modal-backdrop.styles.d.ts +10 -0
  24. package/dist/components/modal/components/modal-backdrop/modal-backdrop.styles.js +7 -2
  25. package/dist/components/modal/components/modal-dialog/components/modal-dialog-body/modal-dialog-body.component.js +7 -2
  26. package/dist/components/modal/components/modal-dialog/components/modal-dialog-body/modal-dialog-body.styles.d.ts +43 -5
  27. package/dist/components/modal/components/modal-dialog/components/modal-dialog-body/modal-dialog-body.styles.js +30 -1
  28. package/dist/components/modal/components/modal-dialog/components/modal-dialog-footer/modal-dialog-footer.component.d.ts +1 -1
  29. package/dist/components/modal/components/modal-dialog/components/modal-dialog-footer/modal-dialog-footer.component.js +21 -4
  30. package/dist/components/modal/components/modal-dialog/components/modal-dialog-footer/modal-dialog-footer.styles.d.ts +47 -5
  31. package/dist/components/modal/components/modal-dialog/components/modal-dialog-footer/modal-dialog-footer.styles.js +32 -1
  32. package/dist/components/modal/components/modal-dialog/components/modal-dialog-footer/modal-dialog-footer.types.d.ts +16 -0
  33. package/dist/components/modal/components/modal-dialog/modal-dialog.component.d.ts +2 -1
  34. package/dist/components/modal/components/modal-dialog/modal-dialog.component.js +11 -2
  35. package/dist/components/modal/components/modal-dialog/modal-dialog.styles.d.ts +18 -0
  36. package/dist/components/modal/components/modal-dialog/modal-dialog.styles.js +15 -6
  37. package/dist/components/modal/components/modal-dialog/modal-dialog.types.d.ts +6 -0
  38. package/dist/components/repeater/repeater.component.js +4 -2
  39. package/dist/css/westpac-ui.css +192 -100
  40. package/dist/css/westpac-ui.min.css +192 -100
  41. package/package.json +1 -1
  42. package/src/components/badge/badge.component.tsx +2 -1
  43. package/src/components/badge/badge.styles.ts +1 -1
  44. package/src/components/bottom-sheet/bottom-sheet.component.tsx +20 -2
  45. package/src/components/bottom-sheet/bottom-sheet.types.ts +20 -0
  46. package/src/components/bottom-sheet/components/bottom-sheet-dialog/bottom-sheet-dialog.component.tsx +33 -14
  47. package/src/components/bottom-sheet/components/bottom-sheet-dialog/bottom-sheet-dialog.styles.ts +16 -0
  48. package/src/components/bottom-sheet/components/bottom-sheet-dialog/bottom-sheet-dialog.types.ts +17 -1
  49. package/src/components/bottom-sheet/components/bottom-sheet-modal/bottom-sheet-modal.component.tsx +7 -25
  50. package/src/components/bottom-sheet/components/bottom-sheet-modal/bottom-sheet-modal.styles.ts +14 -0
  51. package/src/components/bottom-sheet/components/bottom-sheet-modal/bottom-sheet-modal.types.ts +0 -5
  52. package/src/components/icon/components/x-icon.tsx +37 -0
  53. package/src/components/icon/index.ts +1 -1
  54. package/src/components/modal/components/modal-backdrop/modal-backdrop.component.tsx +1 -1
  55. package/src/components/modal/components/modal-backdrop/modal-backdrop.styles.ts +7 -2
  56. package/src/components/modal/components/modal-dialog/components/modal-dialog-body/modal-dialog-body.component.tsx +6 -2
  57. package/src/components/modal/components/modal-dialog/components/modal-dialog-body/modal-dialog-body.styles.ts +15 -3
  58. package/src/components/modal/components/modal-dialog/components/modal-dialog-footer/modal-dialog-footer.component.tsx +25 -4
  59. package/src/components/modal/components/modal-dialog/components/modal-dialog-footer/modal-dialog-footer.styles.ts +15 -3
  60. package/src/components/modal/components/modal-dialog/components/modal-dialog-footer/modal-dialog-footer.types.ts +16 -0
  61. package/src/components/modal/components/modal-dialog/modal-dialog.component.tsx +10 -3
  62. package/src/components/modal/components/modal-dialog/modal-dialog.styles.ts +13 -4
  63. package/src/components/modal/components/modal-dialog/modal-dialog.types.ts +7 -0
  64. package/src/components/repeater/repeater.component.tsx +2 -0
  65. package/dist/components/icon/components/twitter-icon.d.ts +0 -2
  66. package/dist/components/icon/components/twitter-icon.js +0 -35
  67. package/src/components/icon/components/twitter-icon.tsx +0 -37
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@westpac/ui",
3
- "version": "0.16.0",
3
+ "version": "0.17.0",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "type": "module",
@@ -11,7 +11,8 @@ export function BaseBadge(
11
11
  ) {
12
12
  return (
13
13
  <Tag {...({ ref } as any)} className={styles({ className, color, type, soft })} {...props}>
14
- {children}
14
+ {/* styling vertically aligns text in the middle */}
15
+ <div className="relative bottom-[1px]">{children}</div>
15
16
  </Tag>
16
17
  );
17
18
  }
@@ -25,7 +25,7 @@ export const styles = tv(
25
25
  },
26
26
  type: {
27
27
  pill: 'typography-body-10 rounded-xl px-[0.4375rem] py-[0.25rem] font-medium leading-none',
28
- default: 'rounded-sm px-1 py-0.5 pb-[0.125rem] text-[0.75rem] leading-none',
28
+ default: 'rounded-sm px-1 py-[0.125rem] text-[0.75rem] leading-none',
29
29
  },
30
30
  soft: {
31
31
  true: 'bg-white',
@@ -9,10 +9,28 @@ import { BottomSheetModal } from './components/bottom-sheet-modal/bottom-sheet-m
9
9
  /**
10
10
  * Bottom sheet component
11
11
  */
12
- export function BottomSheet({ children, state, ...props }: BottomSheetProps) {
12
+ export function BottomSheet({
13
+ children,
14
+ state,
15
+ title,
16
+ primaryLabel,
17
+ secondaryLabel,
18
+ primaryOnClick,
19
+ secondaryOnClick,
20
+ ...props
21
+ }: BottomSheetProps) {
13
22
  return (
14
23
  <BottomSheetModal state={state} {...props}>
15
- <BottomSheetDialog onClose={state.close}>{children}</BottomSheetDialog>
24
+ <BottomSheetDialog
25
+ primaryLabel={primaryLabel}
26
+ secondaryLabel={secondaryLabel}
27
+ primaryOnClick={primaryOnClick}
28
+ secondaryOnClick={secondaryOnClick}
29
+ onClose={state.close}
30
+ title={title}
31
+ >
32
+ {children}
33
+ </BottomSheetDialog>
16
34
  </BottomSheetModal>
17
35
  );
18
36
  }
@@ -8,8 +8,28 @@ export type BottomSheetProps = ModalProps & {
8
8
  * Body content of Bottom Sheet
9
9
  */
10
10
  children: ReactNode;
11
+ /**
12
+ * Label for primary button
13
+ */
14
+ primaryLabel?: string;
15
+ /**
16
+ * onClick for primary button
17
+ */
18
+ primaryOnClick?: () => void;
19
+ /**
20
+ * Label for secondary button
21
+ */
22
+ secondaryLabel?: string;
23
+ /**
24
+ * onClick for secondary button
25
+ */
26
+ secondaryOnClick?: () => void;
11
27
  /**
12
28
  * The Bottom Sheet opening and closing state, should use OverlayTriggerState from react-stately
13
29
  */
14
30
  state: OverlayTriggerState;
31
+ /**
32
+ * Title for bottom sheet
33
+ */
34
+ title?: string;
15
35
  };
@@ -5,32 +5,51 @@ import { useDialog } from 'react-aria';
5
5
  import { CloseIcon } from '../../../../components/icon/index.js';
6
6
  import { Button } from '../../../../components/index.js';
7
7
 
8
+ import { styles as bottomSheetDialogStyles } from './bottom-sheet-dialog.styles.js';
8
9
  import { DialogProps } from './bottom-sheet-dialog.types.js';
9
10
 
10
- export function BottomSheetDialog({ children, title, className, onClose, ...props }: DialogProps) {
11
+ export function BottomSheetDialog({
12
+ children,
13
+ title,
14
+ className,
15
+ onClose,
16
+ primaryLabel,
17
+ primaryOnClick,
18
+ secondaryLabel,
19
+ secondaryOnClick,
20
+ ...props
21
+ }: DialogProps) {
11
22
  const ref = useRef(null);
12
23
  const { dialogProps, titleProps } = useDialog({ ...props, role: 'dialog' }, ref);
24
+ const styles = bottomSheetDialogStyles({});
13
25
 
14
26
  return (
15
- <div
16
- {...dialogProps}
17
- className={clsx(
18
- className,
19
- 'flex max-h-screen max-w-full flex-1 flex-col overflow-hidden rounded-t-md bg-white shadow-sm md:rounded-md',
20
- )}
21
- ref={ref}
22
- >
23
- <header className="flex flex-row justify-between px-4 py-5 md:px-15 md:py-5">
24
- <h3 className="typography-body-3 m-0 md:typography-body-2" {...titleProps}>
27
+ <div {...dialogProps} className={styles.base({ className })} ref={ref}>
28
+ <header>
29
+ <h3 className={styles.title()} {...titleProps}>
25
30
  {title}
26
31
  </h3>
27
32
  {onClose && (
28
- <Button size="small" look="link" onClick={onClose} aria-label="close">
29
- <CloseIcon color="primary" />
33
+ <Button size="small" look="link" onClick={onClose} aria-label="close" className={styles.closeBtn()}>
34
+ <CloseIcon color="muted" size="small" />
30
35
  </Button>
31
36
  )}
32
37
  </header>
33
- <div className="flex-1 overflow-auto px-4 pb-10 md:px-15">{children}</div>
38
+ <div className={styles.body()}>{children}</div>
39
+ {(primaryLabel || secondaryLabel) && (
40
+ <div className={styles.buttonWrapper()}>
41
+ {primaryLabel && (
42
+ <Button look="primary" size="large" className={styles.primaryBtn()} onClick={primaryOnClick}>
43
+ {primaryLabel}
44
+ </Button>
45
+ )}
46
+ {secondaryLabel && (
47
+ <Button look="link" size="large" className={styles.secondaryBtn()} onClick={secondaryOnClick}>
48
+ {secondaryLabel}
49
+ </Button>
50
+ )}
51
+ </div>
52
+ )}
34
53
  </div>
35
54
  );
36
55
  }
@@ -0,0 +1,16 @@
1
+ import { tv } from 'tailwind-variants';
2
+
3
+ export const styles = tv(
4
+ {
5
+ slots: {
6
+ base: 'flex max-h-screen max-w-full flex-1 flex-col overflow-hidden rounded-t-md bg-white shadow-sm md:w-[37.5rem] md:rounded-md',
7
+ title: 'typography-body-7 p-7 pb-4 pt-9 font-bold max-md:px-5',
8
+ body: 'flex-1 overflow-auto px-7 pb-7 max-md:px-5',
9
+ closeBtn: 'absolute right-3 top-3 p-0',
10
+ buttonWrapper: '-mt-2 flex gap-1 px-7 pb-7 max-md:flex-col max-md:px-5 max-md:pb-5',
11
+ primaryBtn: '',
12
+ secondaryBtn: 'no-underline hover:underline',
13
+ },
14
+ },
15
+ { responsiveVariants: ['xsl', 'sm', 'md', 'lg', 'xl'] },
16
+ );
@@ -4,5 +4,21 @@ import { AriaDialogProps } from 'react-aria';
4
4
  export type DialogProps = AriaDialogProps & {
5
5
  children: ReactNode;
6
6
  onClose?: () => unknown;
7
- title?: ReactNode;
7
+ /**
8
+ * Label for primary button
9
+ */
10
+ primaryLabel?: string;
11
+ /**
12
+ * onClick for primary button
13
+ */
14
+ primaryOnClick?: () => void;
15
+ /**
16
+ * Label for secondary button
17
+ */
18
+ secondaryLabel?: string;
19
+ /**
20
+ * onClick for secondary button
21
+ */
22
+ secondaryOnClick?: () => void;
23
+ title?: string;
8
24
  } & HTMLAttributes<HTMLDivElement>;
@@ -5,7 +5,8 @@ import { Overlay, useModalOverlay } from 'react-aria';
5
5
 
6
6
  import { BREAKPOINTS } from '../../../../tailwind/constants/index.js';
7
7
 
8
- import { ModalProps, Sizes } from './bottom-sheet-modal.types.js';
8
+ import { styles as bottomSheetModalStyles } from './bottom-sheet-modal.styles.js';
9
+ import { ModalProps } from './bottom-sheet-modal.types.js';
9
10
 
10
11
  const isBrowser = typeof window !== 'undefined';
11
12
 
@@ -18,27 +19,11 @@ function checkIfItIsMobile(breakpoint: number) {
18
19
  }
19
20
  }
20
21
 
21
- const SIZES: Record<Sizes, string> = {
22
- xs: 'md:w-[20rem]',
23
- sm: 'md:w-[32.25rem]',
24
- md: 'md:w-[44.5rem]',
25
- lg: 'md:w-[56.75rem]',
26
- xl: 'md:w-[79rem]',
27
- full: 'md:h-full md:w-full',
28
- };
29
-
30
22
  const MEDIUM_BREAKPOINT_AS_NUMBER = +BREAKPOINTS.md.replace('px', '');
31
23
 
32
24
  // TODO: discuss about the animation
33
- export function BottomSheetModal({
34
- state,
35
- height,
36
- width,
37
- children,
38
- size = 'md',
39
- portalContainer,
40
- ...props
41
- }: ModalProps) {
25
+ export function BottomSheetModal({ state, height, width, children, portalContainer, ...props }: ModalProps) {
26
+ const styles = bottomSheetModalStyles({});
42
27
  const ref = useRef(null);
43
28
  const { modalProps, underlayProps } = useModalOverlay(props, state, ref);
44
29
  const controls = useAnimation();
@@ -81,10 +66,7 @@ export function BottomSheetModal({
81
66
 
82
67
  return (
83
68
  <Overlay portalContainer={portalContainer}>
84
- <div
85
- className="fixed inset-0 z-10 flex animate-fadeIn flex-col justify-end bg-black/50 transition-all md:items-center md:justify-center"
86
- {...underlayProps}
87
- >
69
+ <div className={styles.underlay()} {...underlayProps}>
88
70
  <motion.div
89
71
  animate={controls}
90
72
  dragElastic={0}
@@ -103,9 +85,9 @@ export function BottomSheetModal({
103
85
  visible: { y: 0 },
104
86
  hidden: { y: '100%' },
105
87
  }}
106
- className={clsx('flex flex-col', SIZES[size])}
88
+ className={styles.motionWrapper()}
107
89
  >
108
- <div className="flex w-full flex-col" {...modalProps} ref={ref} style={{ height, width }}>
90
+ <div className={styles.modal()} {...modalProps} ref={ref} style={{ height, width }}>
109
91
  {children}
110
92
  </div>
111
93
  </motion.div>
@@ -0,0 +1,14 @@
1
+ import { tv } from 'tailwind-variants';
2
+
3
+ export const styles = tv(
4
+ {
5
+ slots: {
6
+ underlay:
7
+ 'fixed inset-0 z-10 flex animate-fadeIn flex-col justify-end bg-black/50 transition-all md:items-center md:justify-center',
8
+ motionWrapper: 'flex flex-col',
9
+ modal: 'flex w-full flex-col',
10
+ },
11
+ variants: {},
12
+ },
13
+ { responsiveVariants: ['xsl', 'sm', 'md', 'lg', 'xl'] },
14
+ );
@@ -2,7 +2,6 @@ import { CSSProperties, ReactNode } from 'react';
2
2
  import { AriaModalOverlayProps } from 'react-aria';
3
3
  import { OverlayTriggerState } from 'react-stately';
4
4
 
5
- export type Sizes = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'full';
6
5
  export type ModalProps = AriaModalOverlayProps & {
7
6
  /**
8
7
  * Body content of Modal
@@ -16,10 +15,6 @@ export type ModalProps = AriaModalOverlayProps & {
16
15
  * Element where the modal will be rendered, by default it will be into the body
17
16
  */
18
17
  portalContainer?: Element;
19
- /**
20
- * Size of the Modal
21
- */
22
- size?: Sizes;
23
18
  /**
24
19
  * The modal opening and closing state, should use OverlayTriggerState from react-stately
25
20
  */
@@ -0,0 +1,37 @@
1
+ import React, { Fragment } from 'react';
2
+
3
+ import { Icon } from '../icon.component.js';
4
+ import { type IconProps } from '../icon.types.js';
5
+
6
+ export function XIcon({ look = 'filled', 'aria-label': ariaLabel = 'X', copyrightYear = '2024', ...props }: IconProps) {
7
+ return (
8
+ <Icon aria-label={ariaLabel} copyrightYear={copyrightYear} {...props}>
9
+ {look === 'filled' ? (
10
+ <Fragment>
11
+ <path fill="currentColor" d="M15.815 19.008h2.12L8.178 5.04h-2.12l9.757 13.968Z" />
12
+ <path
13
+ fill="currentColor"
14
+ fill-rule="evenodd"
15
+ d="M2 0a2 2 0 0 0-2 2v20a2 2 0 0 0 2 2h20a2 2 0 0 0 2-2V2a2 2 0 0 0-2-2H2Zm17.315 4-5.824 6.775L19.825 20h-4.659l-4.265-6.212L5.56 20H4.18l6.107-7.104L4.18 4H8.84l4.039 5.883L17.935 4h1.38Z"
16
+ clip-rule="evenodd"
17
+ />
18
+ </Fragment>
19
+ ) : (
20
+ <Fragment>
21
+ <path
22
+ fill="currentColor"
23
+ fill-rule="evenodd"
24
+ d="m19.315 4-5.824 6.775L19.825 20h-4.659l-4.265-6.212L5.56 20H4.18l6.107-7.104L4.18 4H8.84l4.039 5.883L17.935 4h1.38Zm-3.5 15.008h2.12L8.178 5.04h-2.12l9.757 13.968Z"
25
+ clip-rule="evenodd"
26
+ />
27
+ <path
28
+ fill="currentColor"
29
+ fill-rule="evenodd"
30
+ d="M0 2a2 2 0 0 1 2-2h20a2 2 0 0 1 2 2v20a2 2 0 0 1-2 2H2a2 2 0 0 1-2-2V2Zm2 0h20v20H2V2Z"
31
+ clip-rule="evenodd"
32
+ />
33
+ </Fragment>
34
+ )}
35
+ </Icon>
36
+ );
37
+ }
@@ -211,7 +211,6 @@ export { TransferIcon } from './components/transfer-icon.js';
211
211
  export { TransportIcon } from './components/transport-icon.js';
212
212
  export { TravelExploreIcon } from './components/travel-explore-icon.js';
213
213
  export { TuneIcon } from './components/tune-icon.js';
214
- export { TwitterIcon } from './components/twitter-icon.js';
215
214
  export { UmbrellaIcon } from './components/umbrella-icon.js';
216
215
  export { UploadIcon } from './components/upload-icon.js';
217
216
  export { VerifiedIcon } from './components/verified-icon.js';
@@ -229,6 +228,7 @@ export { WindowsNewIcon } from './components/windows-new-icon.js';
229
228
  export { WineGlassIcon } from './components/wine-glass-icon.js';
230
229
  export { WordFileIcon } from './components/word-file-icon.js';
231
230
  export { WriteIcon } from './components/write-icon.js';
231
+ export { XIcon } from './components/x-icon.js';
232
232
  export { YammerIcon } from './components/yammer-icon.js';
233
233
  export { YoutubeIcon } from './components/youtube-icon.js';
234
234
  export { ZipFileIcon } from './components/zip-file-icon.js';
@@ -11,7 +11,7 @@ export function ModalBackdrop({ zIndex = 100, portalContainer, size, ...props }:
11
11
  const { children, state, className } = props;
12
12
 
13
13
  const ref = useRef(null);
14
- const styles = backdropStyles({ className, fullscreen: size === 'full' });
14
+ const styles = backdropStyles({ className, fullscreen: size === 'full', fluid: size === 'fluid' });
15
15
 
16
16
  const { modalProps, underlayProps } = useModalOverlay(props, state, ref);
17
17
 
@@ -2,8 +2,8 @@ import { tv } from 'tailwind-variants';
2
2
 
3
3
  export const styles = tv({
4
4
  slots: {
5
- base: 'fixed inset-0 z-50 flex animate-fadeIn justify-center overflow-y-auto bg-black/50 p-2',
6
- modal: 'relative top-5 z-10 h-fit w-full animate-fadeInDown',
5
+ base: 'fixed inset-0 z-50 flex animate-fadeIn items-center justify-center overflow-y-auto bg-black/50 p-2',
6
+ modal: 'relative top-3 z-10 h-fit w-full animate-fadeInDown',
7
7
  },
8
8
  variants: {
9
9
  fullscreen: {
@@ -12,5 +12,10 @@ export const styles = tv({
12
12
  base: 'flex flex-col p-0',
13
13
  },
14
14
  },
15
+ fluid: {
16
+ true: {
17
+ modal: 'px-2',
18
+ },
19
+ },
15
20
  },
16
21
  });
@@ -1,11 +1,15 @@
1
1
  import React from 'react';
2
2
 
3
- import { styles } from './modal-dialog-body.styles.js';
3
+ import { useModalDialogContext } from '../../modal-dialog.component.js';
4
+
5
+ import { styles as modalBodyStyles } from './modal-dialog-body.styles.js';
4
6
  import { type ModalDialogBodyProps } from './modal-dialog-body.types.js';
5
7
 
6
8
  export function ModalDialogBody({ className, children, ...props }: ModalDialogBodyProps) {
9
+ const { size } = useModalDialogContext();
10
+ const styles = modalBodyStyles({ size });
7
11
  return (
8
- <div className={styles({ className })} {...props}>
12
+ <div className={styles.base({ className })} {...props}>
9
13
  {children}
10
14
  </div>
11
15
  );
@@ -1,5 +1,17 @@
1
1
  import { tv } from 'tailwind-variants';
2
2
 
3
- export const styles = tv({
4
- base: 'flex-1 overflow-auto px-4 py-3',
5
- });
3
+ export const styles = tv(
4
+ {
5
+ slots: { base: 'flex-1 overflow-auto' },
6
+ variants: {
7
+ size: {
8
+ full: { base: 'px-4 py-3' },
9
+ lg: { base: 'px-12 pb-12' },
10
+ md: { base: 'px-7 pb-7' },
11
+ sm: { base: 'px-5 pb-7' },
12
+ fluid: { base: 'px-5 pb-7' },
13
+ },
14
+ },
15
+ },
16
+ { responsiveVariants: ['xsl', 'sm', 'md', 'lg', 'xl'] },
17
+ );
@@ -1,12 +1,33 @@
1
+ 'use client';
2
+
1
3
  import React from 'react';
2
4
 
3
- import { styles } from './modal-dialog-footer.styles.js';
5
+ import { Button } from '../../../../../button/index.js';
6
+ import { useModalDialogContext } from '../../modal-dialog.component.js';
7
+
8
+ import { styles as modalFooterStyles } from './modal-dialog-footer.styles.js';
4
9
  import { type ModalDialogFooterProps } from './modal-dialog-footer.types.js';
5
10
 
6
- export function ModalDialogFooter({ className, children, ...props }: ModalDialogFooterProps) {
11
+ export function ModalDialogFooter({
12
+ className,
13
+ primaryLabel,
14
+ primaryOnClick,
15
+ secondaryLabel,
16
+ secondaryOnClick,
17
+ ...props
18
+ }: ModalDialogFooterProps) {
19
+ const { size } = useModalDialogContext();
20
+ const styles = modalFooterStyles({ size });
7
21
  return (
8
- <div className={styles({ className })} {...props}>
9
- {children}
22
+ <div className={styles.base({ className })} {...props}>
23
+ <Button look="primary" size="large" className={styles.primaryBtn()} onClick={primaryOnClick}>
24
+ {primaryLabel}
25
+ </Button>
26
+ {secondaryLabel && (
27
+ <Button look="link" size="large" className={styles.secondaryBtn()} onClick={secondaryOnClick}>
28
+ {secondaryLabel}
29
+ </Button>
30
+ )}
10
31
  </div>
11
32
  );
12
33
  }
@@ -1,5 +1,17 @@
1
1
  import { tv } from 'tailwind-variants';
2
2
 
3
- export const styles = tv({
4
- base: 'border-t border-t-border bg-background px-3 py-2',
5
- });
3
+ export const styles = tv(
4
+ {
5
+ slots: { base: 'flex gap-1', primaryBtn: '', secondaryBtn: 'no-underline hover:underline' },
6
+ variants: {
7
+ size: {
8
+ full: { base: 'px-4 py-3' },
9
+ lg: { base: '-mt-6 px-12 pb-12' },
10
+ md: { base: '-mt-2 px-7 pb-7' },
11
+ sm: { base: '-mt-2 flex-col px-5 pb-5' },
12
+ fluid: { base: '-mt-2 px-5 pb-5 max-md:flex-col' },
13
+ },
14
+ },
15
+ },
16
+ { responsiveVariants: ['xsl', 'sm', 'md', 'lg', 'xl'] },
17
+ );
@@ -5,4 +5,20 @@ export type ModalDialogFooterProps = {
5
5
  * Footer content
6
6
  */
7
7
  children?: ReactNode;
8
+ /**
9
+ * Label for primary button
10
+ */
11
+ primaryLabel: string;
12
+ /**
13
+ * onClick for primary button
14
+ */
15
+ primaryOnClick: () => void;
16
+ /**
17
+ * Label for secondary button
18
+ */
19
+ secondaryLabel?: string;
20
+ /**
21
+ * onClick for secondary button
22
+ */
23
+ secondaryOnClick?: () => void;
8
24
  } & HTMLAttributes<HTMLElement>;
@@ -1,4 +1,6 @@
1
- import React, { useRef } from 'react';
1
+ 'use client';
2
+
3
+ import React, { createContext, useContext, useRef } from 'react';
2
4
  import { useDialog, useFocusRing } from 'react-aria';
3
5
 
4
6
  import { CloseIcon } from '../../../../components/icon/index.js';
@@ -6,8 +8,11 @@ import { CloseIcon } from '../../../../components/icon/index.js';
6
8
  import { ModalDialogBody } from './components/modal-dialog-body/index.js';
7
9
  import { ModalDialogFooter } from './components/modal-dialog-footer/index.js';
8
10
  import { styles as dialogStyles } from './modal-dialog.styles.js';
9
- import { type ModalDialogProps } from './modal-dialog.types.js';
11
+ import { ModalDialogContextValue, type ModalDialogProps } from './modal-dialog.types.js';
12
+
13
+ const ModalDialogContext = createContext<ModalDialogContextValue>({ size: 'md' });
10
14
 
15
+ export const useModalDialogContext = () => useContext(ModalDialogContext);
11
16
  /**
12
17
  * @private
13
18
  */
@@ -32,7 +37,9 @@ export function ModalDialog({ className, body, onClose, size = 'md', ...props }:
32
37
  {props.title}
33
38
  </h3>
34
39
  )}
35
- {body ? <ModalDialogBody>{children}</ModalDialogBody> : children}
40
+ <ModalDialogContext.Provider value={{ size }}>
41
+ {body ? <ModalDialogBody>{children}</ModalDialogBody> : children}
42
+ </ModalDialogContext.Provider>
36
43
  </div>
37
44
  );
38
45
  }
@@ -4,22 +4,31 @@ export const styles = tv(
4
4
  {
5
5
  slots: {
6
6
  base: 'relative mx-auto flex max-w-full flex-col overflow-hidden rounded bg-white outline-none',
7
- title: 'border-b border-b-heading pb-2 pl-4 pr-5 pt-3 text-lg font-medium',
8
- close: 'absolute right-1 top-1 block p-1',
7
+ title: 'typography-body-7 pb-4 pt-9 font-bold',
8
+ close: 'absolute right-0 top-0 block p-3',
9
9
  },
10
10
  variants: {
11
11
  size: {
12
12
  full: {
13
13
  base: 'max-h-screen w-full flex-1',
14
+ close: 'p-2',
15
+ title: 'px-4 py-3',
14
16
  },
15
17
  lg: {
16
- base: 'w-[56.25rem]',
18
+ base: 'w-[50rem]',
19
+ title: 'px-12 pt-12',
17
20
  },
18
21
  md: {
19
22
  base: 'w-[37.5rem]',
23
+ title: 'px-7 ',
20
24
  },
21
25
  sm: {
22
- base: 'w-[18.75rem]',
26
+ base: 'w-[25rem]',
27
+ title: 'px-5',
28
+ },
29
+ fluid: {
30
+ base: 'w-full',
31
+ title: 'px-5',
23
32
  },
24
33
  },
25
34
  isFocusVisible: {
@@ -35,3 +35,10 @@ export type ModalDialogProps = {
35
35
  */
36
36
  title?: string;
37
37
  } & AriaDialogProps;
38
+
39
+ export type ModalDialogContextValue = {
40
+ /**
41
+ * Size of dialog
42
+ */
43
+ size?: Variants['size'];
44
+ };
@@ -99,6 +99,7 @@ export function Repeater({
99
99
  size="small"
100
100
  soft
101
101
  onClick={() => handleRemove(item.id, index)}
102
+ type="button"
102
103
  >
103
104
  Remove
104
105
  </Button>
@@ -118,6 +119,7 @@ export function Repeater({
118
119
  size="small"
119
120
  soft
120
121
  onClick={() => handleAdd()}
122
+ type="button"
121
123
  >
122
124
  {addText}
123
125
  </Button>
@@ -1,2 +0,0 @@
1
- import { type IconProps } from '../icon.types.js';
2
- export declare function TwitterIcon({ look, 'aria-label': ariaLabel, copyrightYear, ...props }: IconProps): import("react/jsx-runtime").JSX.Element;
@@ -1,35 +0,0 @@
1
- function _extends() {
2
- _extends = Object.assign || function(target) {
3
- for(var i = 1; i < arguments.length; i++){
4
- var source = arguments[i];
5
- for(var key in source){
6
- if (Object.prototype.hasOwnProperty.call(source, key)) {
7
- target[key] = source[key];
8
- }
9
- }
10
- }
11
- return target;
12
- };
13
- return _extends.apply(this, arguments);
14
- }
15
- import React, { Fragment } from 'react';
16
- import { Icon } from '../icon.component.js';
17
- export function TwitterIcon({ look ='filled' , 'aria-label': ariaLabel = 'Twitter' , copyrightYear ='2024' , ...props }) {
18
- return React.createElement(Icon, _extends({
19
- "aria-label": ariaLabel,
20
- copyrightYear: copyrightYear
21
- }, props), look === 'filled' ? React.createElement("path", {
22
- fillRule: "evenodd",
23
- clipRule: "evenodd",
24
- d: "M2 0C0.895431 0 0 0.89543 0 2V22C0 23.1046 0.89543 24 2 24H22C23.1046 24 24 23.1046 24 22V2C24 0.895431 23.1046 0 22 0H2ZM18.1146 7.34209C18.7788 7.26155 19.4119 7.08237 20 6.81641C19.5605 7.48568 19.003 8.07379 18.3618 8.54452C18.368 8.68749 18.3712 8.83233 18.3712 8.97655C18.3712 13.3898 15.0691 18.4799 9.032 18.4799C7.1784 18.4799 5.45216 17.9261 4 16.9784C4.25597 17.0096 4.51506 17.0259 4.7804 17.0259C6.31809 17.0259 7.72905 16.4921 8.85219 15.5962C7.41626 15.5693 6.19572 14.6035 5.77743 13.2768C5.97846 13.3156 6.167 13.3362 6.37802 13.3362C6.6777 13.3362 6.93429 13.2956 7.20899 13.2194C5.70813 12.9122 4.50944 11.5625 4.50944 9.94487V9.90241C5.13376 10.1534 5.52583 10.3032 6.06337 10.3207C5.18308 9.72198 4.67052 8.69935 4.67052 7.54062C4.67052 6.92879 4.83221 6.35504 5.11503 5.86183C6.73451 7.88212 9.15249 9.21192 11.8801 9.35114C11.8239 9.10641 11.7952 8.85169 11.7952 8.58947C11.7952 6.74586 13.2655 5.25 15.0773 5.25C16.0219 5.25 16.8747 5.65581 17.4734 6.30447C18.2213 6.15401 18.9237 5.87681 19.558 5.49473C19.312 6.27388 18.7919 6.92879 18.1146 7.34209Z",
25
- fill: "currentColor"
26
- }) : React.createElement(Fragment, null, React.createElement("path", {
27
- d: "M18.1146 7.34209C18.7788 7.26155 19.4119 7.08237 20 6.81641C19.5605 7.48568 19.003 8.07379 18.3618 8.54452C18.368 8.68749 18.3712 8.83233 18.3712 8.97655C18.3712 13.3898 15.0691 18.4799 9.032 18.4799C7.1784 18.4799 5.45216 17.9261 4 16.9784C4.25597 17.0096 4.51506 17.0259 4.7804 17.0259C6.31809 17.0259 7.72905 16.4921 8.85219 15.5962C7.41626 15.5693 6.19572 14.6035 5.77743 13.2768C5.97846 13.3156 6.167 13.3362 6.37802 13.3362C6.6777 13.3362 6.93429 13.2956 7.20899 13.2194C5.70813 12.9122 4.50944 11.5625 4.50944 9.94487V9.90241C5.13376 10.1534 5.52583 10.3032 6.06337 10.3207C5.18308 9.72198 4.67052 8.69935 4.67052 7.54062C4.67052 6.92879 4.83221 6.35504 5.11503 5.86183C6.73451 7.88212 9.15249 9.21192 11.8801 9.35114C11.8239 9.10641 11.7952 8.85169 11.7952 8.58947C11.7952 6.74586 13.2655 5.25 15.0773 5.25C16.0219 5.25 16.8747 5.65581 17.4734 6.30447C18.2213 6.15401 18.9237 5.87681 19.558 5.49473C19.312 6.27388 18.7919 6.92879 18.1146 7.34209Z",
28
- fill: "currentColor"
29
- }), React.createElement("path", {
30
- fillRule: "evenodd",
31
- clipRule: "evenodd",
32
- d: "M0 2C0 0.89543 0.895431 0 2 0H22C23.1046 0 24 0.895431 24 2V22C24 23.1046 23.1046 24 22 24H2C0.89543 24 0 23.1046 0 22V2ZM2 2H22V22H2V2Z",
33
- fill: "currentColor"
34
- })));
35
- }