How to use the @axa-fr/react-toolkit-core.withProps function in @axa-fr/react-toolkit-core

To help you get started, we’ve selected a few @axa-fr/react-toolkit-core examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github AxaGuilDEv / react-toolkit / packages / action / src / ActionCore.tsx View on Github external
};

const omitProperties = PropsManager.omit(['classModifier']);

const ActionCore: React.FC = ({ icon, ...otherProps }) => (
  <a>
    <i>
  </i></a><i>
);

ActionCore.defaultProps = defaultProps;

const enhance = compose(
  withClassDefault(defaultClassName),
  withClassModifier,
  withProps(({ onClick, href, role }: ActionCoreProps) =&gt; ({
    href: onClick ? '#' : href || undefined,
    role: onClick ? 'button' : role || undefined,
  }))
);

const Enhanced = enhance(ActionCore);
Enhanced.displayName = 'ActionCore';
export default Enhanced;
</i>
github AxaGuilDEv / react-toolkit / packages / alert / src / Alert.ts View on Github external
const defaultClassModifier = 'error';

type AlertProps = Pick&gt; &amp; {
  icon?: string;
};

const setWithProps = ({ icon, ...otherProps }: AlertProps): AlertCoreProps =&gt; {
  const firstModifier = otherProps.classModifier.split(' ')[0];
  return {
    ...otherProps,
    iconClassName: `glyphicon glyphicon-${icon || icons[firstModifier]}`,
  };
};

const Enhanced = compose(withProps(setWithProps))(AlertCore);

Enhanced.displayName = 'Alert';
Enhanced.defaultProps = {
  classModifier: defaultClassModifier,
};

export default Enhanced;
github AxaGuilDEv / react-toolkit / packages / tabs / src / Title.tsx View on Github external
export type TitleProps = TitleComponentProps &amp;
  TitleHandlerProps &amp;
  WithClassModifierOptions;

const setWithProps = (props: TitleComponentProps) =&gt; ({
  ...props,
  classModifier: (props.classModifier || '').concat(
    (props.enable === false ? ' disabled' : '').concat(
      props.active ? ' active' : ''
    )
  ),
});

const enchance = compose(
  withProps(setWithProps),
  withClickId({ event: [onChangeEvent] }),
  withClassDefault(DEFAULT_CLASSNAME),
  withClassModifier
)(Title);

enchance.displayName = 'Title';

export default enchance;
github AxaGuilDEv / react-toolkit / packages / alert / src / AlertWithType.ts View on Github external
}

export enum TypeIcons {
  error = 'glyphicon glyphicon-exclamation-sign',
  danger = 'glyphicon glyphicon-alert',
  info = 'glyphicon glyphicon-info-sign',
  success = 'glyphicon glyphicon-ok',
}

export const setWithProps = ({ type, classModifier, iconClassName, ...otherProps }: AlertWithTypeProps): AlertCoreProps =&gt; ({
  ...otherProps,
  classModifier: classnames(classModifier, type),
  iconClassName: iconClassName || TypeIcons[type as keyof typeof TypeIcons],
});

const enhance =  compose(withProps(setWithProps))(AlertCore);

enhance.defaultProps = {
  type: 'error',
};
enhance.displayName = 'AlertWithType';

export default enhance;
github AxaGuilDEv / react-toolkit / packages / Modal / default / src / Header.ts View on Github external
const onCancelEvent = 'onCancel';

export interface HeaderProps
  extends WithClickIdProps {
  title: string;
}

const setWithProps = (props: HeaderProps) =&gt; ({
  ...props,
  children: props.title,
});

const enchance = compose(
  withClickId({ event: [onCancelEvent] }),
  withProps(setWithProps),
)(HeaderCore);

enchance.displayName = 'Header';

export default enchance;
github AxaGuilDEv / react-toolkit / packages / Layout / footer / src / Footer.ts View on Github external
withProps,
  compose,
} from '@axa-fr/react-toolkit-core';

export interface FooterProps extends FooterCoreProps {
  copyright?: React.ReactNode;
}

export const setWithProps = ({
                        copyright,
                        ...otherProps
                      }: FooterProps): FooterCoreProps =&gt; ({
  ...otherProps,
  children: copyright,
});
const enhanced = compose(withProps(setWithProps))(FooterCore);

enhanced.displayName = 'Footer';

export default enhanced;