@aurora-ds/components 0.6.6 → 0.6.8

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.
@@ -24,4 +24,5 @@ export type ButtonProps = {
24
24
  export type ButtonStyleParams = {
25
25
  variant?: ButtonVariants;
26
26
  active?: boolean;
27
+ textColor?: keyof Theme['colors'];
27
28
  };
@@ -1,6 +1,6 @@
1
1
  import { Theme } from '@aurora-ds/theme';
2
2
  import { ReactNode } from 'react';
3
- import { ButtonVariants } from '@/interfaces';
3
+ import { ButtonVariants, IconButtonSizes } from '@/interfaces';
4
4
  export type IconButtonProps = {
5
5
  /** IconButton icon */
6
6
  icon?: ReactNode;
@@ -16,13 +16,12 @@ export type IconButtonProps = {
16
16
  disabled?: boolean;
17
17
  /** Custom text/icon color (overrides variant color) */
18
18
  textColor?: keyof Theme['colors'];
19
- /** Custom text/icon color (overrides variant color) */
20
- padding?: keyof Theme['spacing'];
21
- /** Custom text/icon color (overrides variant color) */
22
- iconSize?: keyof Theme['fontSize'];
19
+ /** Size of the icon button */
20
+ size?: IconButtonSizes;
23
21
  };
24
22
  export type IconButtonStyleParams = {
25
23
  variant?: ButtonVariants;
26
24
  active?: boolean;
27
- padding?: keyof Theme['spacing'];
25
+ size?: IconButtonSizes;
26
+ textColor?: keyof Theme['colors'];
28
27
  };
@@ -14,6 +14,7 @@ import { TextProps } from '@components/layout/text/Text.props.ts';
14
14
  * - Theme-aware colors
15
15
  * - Text truncation with `maxLines`
16
16
  * - Underline support
17
+ * - Preserve whitespace with `preserveWhitespace` prop
17
18
  * - Bold text with **double asterisks** syntax
18
19
  */
19
20
  declare const Text: FC<TextProps>;
@@ -14,6 +14,8 @@ export type TextProps = PropsWithChildren<{
14
14
  maxLines?: number;
15
15
  /** Add underline text decoration */
16
16
  underline?: boolean;
17
+ /** Preserve whitespace and line breaks */
18
+ preserveWhitespace?: boolean;
17
19
  }>;
18
20
  export type TextStyleParams = {
19
21
  variant?: TextVariants;
@@ -22,4 +24,5 @@ export type TextStyleParams = {
22
24
  fontFamily?: string;
23
25
  maxLines?: number;
24
26
  underline?: boolean;
27
+ preserveWhitespace?: boolean;
25
28
  };
package/dist/cjs/index.js CHANGED
@@ -296,14 +296,15 @@ const getTruncateTextStyles = (maxLines) => (maxLines === 1
296
296
  const TEXT_STYLES = theme.createStyles((theme) => {
297
297
  const variantStyles = getTextVariantStyles(theme);
298
298
  return {
299
- root: ({ variant = 'span', color, fontSize, fontFamily, maxLines, underline }) => ({
299
+ root: ({ variant = 'span', color, fontSize, fontFamily, maxLines, underline, preserveWhitespace, }) => ({
300
300
  margin: 0,
301
301
  fontSize: fontSize ? theme.fontSize[fontSize] : variantStyles[variant].fontSize,
302
302
  fontWeight: variantStyles[variant].fontWeight,
303
303
  lineHeight: variantStyles[variant].lineHeight,
304
304
  color: color ? theme.colors[color] : 'inherit',
305
305
  cursor: 'inherit',
306
- ...(fontFamily && { fontFamily }),
306
+ fontFamily,
307
+ ...(preserveWhitespace && { whiteSpace: 'pre-wrap' }),
307
308
  ...(underline && {
308
309
  textDecoration: 'underline',
309
310
  textUnderlineOffset: '3px',
@@ -356,14 +357,15 @@ const parseTextWithBold = (children) => {
356
357
  * - Theme-aware colors
357
358
  * - Text truncation with `maxLines`
358
359
  * - Underline support
360
+ * - Preserve whitespace with `preserveWhitespace` prop
359
361
  * - Bold text with **double asterisks** syntax
360
362
  */
361
- const Text = ({ children, variant = 'span', color, fontSize, fontFamily, maxLines, underline, }) => {
363
+ const Text = ({ children, variant = 'span', color, fontSize, fontFamily, maxLines, underline, preserveWhitespace, }) => {
362
364
  const theme$1 = theme.useTheme();
363
365
  const variantStyles = react.useMemo(() => getTextVariantStyles(theme$1), [theme$1]);
364
366
  const tag = variantStyles[variant].tag;
365
367
  const parsedChildren = react.useMemo(() => parseTextWithBold(children), [children]);
366
- return react.createElement(tag, { className: TEXT_STYLES.root({ variant, color, fontSize, fontFamily, maxLines, underline }) }, parsedChildren);
368
+ return react.createElement(tag, { className: TEXT_STYLES.root({ variant, color, fontSize, fontFamily, maxLines, underline, preserveWhitespace }) }, parsedChildren);
367
369
  };
368
370
  Text.displayName = 'Text';
369
371
 
@@ -477,25 +479,32 @@ const getButtonVariantStyles = (theme$1) => {
477
479
  const BUTTON_STYLES = theme.createStyles((theme) => {
478
480
  const variantStyles = getButtonVariantStyles(theme);
479
481
  return {
480
- root: ({ variant = 'contained', active = false }) => ({
481
- display: 'inline-flex',
482
- alignItems: 'center',
483
- justifyContent: 'center',
484
- boxSizing: 'border-box',
485
- gap: theme.spacing.sm,
486
- padding: `${theme.spacing.sm} ${theme.spacing.md}`,
487
- borderRadius: theme.radius.md,
488
- cursor: 'pointer',
489
- transition: `background-color ${theme.transition.fast}, color ${theme.transition.fast}`,
490
- minHeight: BUTTON_SIZE,
491
- maxHeight: BUTTON_SIZE,
492
- fontFamily: 'inherit',
493
- ...variantStyles[variant].default,
494
- ...(active && variantStyles[variant].pressed),
495
- ':hover': variantStyles[variant].hover,
496
- ':active': variantStyles[variant].pressed,
497
- ':disabled': variantStyles[variant].disabled,
498
- }),
482
+ root: ({ variant = 'contained', active = false, textColor }) => {
483
+ const overrides = textColor ? {
484
+ ...(variant !== 'contained' && { color: theme.colors[textColor] }),
485
+ ...(variant === 'outlined' && { border: `1px solid ${theme.colors[textColor]}` }),
486
+ } : {};
487
+ return {
488
+ display: 'inline-flex',
489
+ alignItems: 'center',
490
+ justifyContent: 'center',
491
+ boxSizing: 'border-box',
492
+ gap: theme.spacing.sm,
493
+ padding: `${theme.spacing.sm} ${theme.spacing.md}`,
494
+ borderRadius: theme.radius.md,
495
+ cursor: 'pointer',
496
+ transition: `background-color ${theme.transition.fast}, color ${theme.transition.fast}`,
497
+ minHeight: BUTTON_SIZE,
498
+ maxHeight: BUTTON_SIZE,
499
+ fontFamily: 'inherit',
500
+ ...variantStyles[variant].default,
501
+ ...(active && variantStyles[variant].pressed),
502
+ ':hover': variantStyles[variant].hover,
503
+ ':active': variantStyles[variant].pressed,
504
+ ':disabled': variantStyles[variant].disabled,
505
+ ...overrides,
506
+ };
507
+ },
499
508
  };
500
509
  });
501
510
 
@@ -511,42 +520,70 @@ const Button = ({ label, startIcon, endIcon, variant = 'contained', active = fal
511
520
  const theme$1 = theme.useTheme();
512
521
  const variantStyles = getButtonVariantStyles(theme$1);
513
522
  const textColor = disabled ? 'disabledText' : (customTextColor ?? variantStyles[variant].textColor);
514
- return (jsxRuntime.jsxs("button", { onClick: onClick, disabled: disabled, type: type, className: BUTTON_STYLES.root({ variant, active }), children: [startIcon && (jsxRuntime.jsx(Icon, { color: textColor, children: startIcon })), jsxRuntime.jsx(Text, { variant: 'label', color: textColor, children: label }), endIcon && (jsxRuntime.jsx(Icon, { color: textColor, children: endIcon }))] }));
523
+ return (jsxRuntime.jsxs("button", { onClick: onClick, disabled: disabled, type: type, className: BUTTON_STYLES.root({ variant, active, textColor: customTextColor }), children: [startIcon && (jsxRuntime.jsx(Icon, { color: textColor, children: startIcon })), jsxRuntime.jsx(Text, { variant: 'label', color: textColor, children: label }), endIcon && (jsxRuntime.jsx(Icon, { color: textColor, children: endIcon }))] }));
515
524
  };
516
525
  Button.displayName = 'Button';
517
526
 
527
+ const getIconButtonSizeStyles = () => ({
528
+ small: {
529
+ size: BUTTON_SIZE - 8,
530
+ padding: 'xs',
531
+ iconSize: 'md'
532
+ },
533
+ medium: {
534
+ size: BUTTON_SIZE,
535
+ padding: 'sm',
536
+ iconSize: 'lg'
537
+ },
538
+ large: {
539
+ size: BUTTON_SIZE + 8,
540
+ padding: 'sm',
541
+ iconSize: 'xl'
542
+ }
543
+ });
544
+
518
545
  const ICON_BUTTON_STYLES = theme.createStyles((theme) => {
519
546
  const variantStyles = getButtonVariantStyles(theme);
547
+ const sizeStyles = getIconButtonSizeStyles();
520
548
  return {
521
- root: ({ variant = 'contained', active = false, padding }) => ({
522
- display: 'inline-flex',
523
- alignItems: 'center',
524
- justifyContent: 'center',
525
- boxSizing: 'border-box',
526
- gap: theme.spacing.sm,
527
- padding: padding ? theme.spacing[padding] : `${theme.spacing.sm} ${theme.spacing.md}`,
528
- borderRadius: theme.radius.md,
529
- cursor: 'pointer',
530
- transition: `background-color ${theme.transition.fast}, color ${theme.transition.fast}`,
531
- minHeight: BUTTON_SIZE,
532
- maxHeight: BUTTON_SIZE,
533
- minWidth: BUTTON_SIZE,
534
- maxWidth: BUTTON_SIZE,
535
- fontFamily: 'inherit',
536
- ...variantStyles[variant].default,
537
- ...(active && variantStyles[variant].pressed),
538
- ':hover': variantStyles[variant].hover,
539
- ':active': variantStyles[variant].pressed,
540
- ':disabled': variantStyles[variant].disabled,
541
- }),
549
+ root: ({ variant = 'contained', active = false, size = 'medium', textColor }) => {
550
+ const sizeConfig = sizeStyles[size];
551
+ const overrides = textColor ? {
552
+ ...(variant !== 'contained' && { color: theme.colors[textColor] }),
553
+ ...(variant === 'outlined' && { border: `1px solid ${theme.colors[textColor]}` }),
554
+ } : {};
555
+ return {
556
+ display: 'inline-flex',
557
+ alignItems: 'center',
558
+ justifyContent: 'center',
559
+ boxSizing: 'border-box',
560
+ gap: theme.spacing.sm,
561
+ padding: theme.spacing[sizeConfig.padding],
562
+ borderRadius: theme.radius.md,
563
+ cursor: 'pointer',
564
+ transition: `background-color ${theme.transition.fast}, color ${theme.transition.fast}`,
565
+ minHeight: sizeConfig.size,
566
+ maxHeight: sizeConfig.size,
567
+ minWidth: sizeConfig.size,
568
+ maxWidth: sizeConfig.size,
569
+ fontFamily: 'inherit',
570
+ ...variantStyles[variant].default,
571
+ ...(active && variantStyles[variant].pressed),
572
+ ':hover': variantStyles[variant].hover,
573
+ ':active': variantStyles[variant].pressed,
574
+ ':disabled': variantStyles[variant].disabled,
575
+ ...overrides,
576
+ };
577
+ },
542
578
  };
543
579
  });
544
580
 
545
- const IconButton = ({ icon, variant = 'contained', active = false, type = 'button', onClick, disabled, textColor: customTextColor, padding, iconSize }) => {
581
+ const IconButton = ({ icon, variant = 'contained', active = false, type = 'button', onClick, disabled, textColor: customTextColor, size = 'medium' }) => {
546
582
  const theme$1 = theme.useTheme();
547
583
  const variantStyles = getButtonVariantStyles(theme$1);
548
584
  const textColor = disabled ? 'disabledText' : (customTextColor ?? variantStyles[variant].textColor);
549
- return (jsxRuntime.jsx("button", { onClick: onClick, disabled: disabled, type: type, className: ICON_BUTTON_STYLES.root({ variant, active, padding }), children: jsxRuntime.jsx(Icon, { color: textColor, size: iconSize, children: icon }) }));
585
+ const iconSize = getIconButtonSizeStyles()[size].iconSize;
586
+ return (jsxRuntime.jsx("button", { onClick: onClick, disabled: disabled, type: type, className: ICON_BUTTON_STYLES.root({ variant, active, size, textColor: customTextColor }), children: jsxRuntime.jsx(Icon, { color: textColor, size: iconSize, children: icon }) }));
550
587
  };
551
588
  IconButton.displayName = 'IconButton';
552
589