Skip to content

Commit

Permalink
added new button for social
Browse files Browse the repository at this point in the history
  • Loading branch information
okeino committed Jan 29, 2024
1 parent 9c16dc3 commit fa4667b
Show file tree
Hide file tree
Showing 3 changed files with 83 additions and 12 deletions.
16 changes: 5 additions & 11 deletions src/components/molecules/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,20 +50,14 @@ export default function Button({
};

const inner = (
<div className={IconLeft ? styles.spaceIcon : ''}>
{IconLeft && (
<div className={styles.leftIcon}>
<IconLeft className={clsx(text && styles.iconLeftOfText)} />
</div>
)}
<>
{IconLeft && <IconLeft className={clsx(text && styles.iconLeftOfText)} />}

<div className={styles.text}>{text}</div>
{text}
{IconRight && (
<div>
<IconRight className={clsx(text && styles.iconRightOfText)} />
</div>
<IconRight className={clsx(text && styles.iconRightOfText)} />
)}
</div>
</>
);
return href ? (
<Link href={href} legacyBehavior>
Expand Down
77 changes: 77 additions & 0 deletions src/components/molecules/buttonSocial.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
import clsx from 'clsx';
import Link from 'next/link';
import React, { MouseEvent } from 'react';

import styles from './button.module.scss';

export type IButtonType =
| 'super'
| 'primary'
| 'primaryInverse'
| 'secondary'
| 'secondaryInverse'
| 'none';
// | 'tertiary' someday

type Props = {
type: IButtonType;
text?: JSX.Element | string;
href?: string;
onClick?: (e: MouseEvent<HTMLElement>) => void;
IconLeft?: React.ElementType;
IconRight?: React.ElementType;
target?: '_blank';
className?: string;
'aria-label'?: string;
disabled?: boolean;
centered?: boolean;
};

export default function Button({
type,
text,
href,
IconLeft,
IconRight,
className,
centered,
disabled,
...props
}: Props): JSX.Element {
const _props = {
className: clsx(
styles.base,
styles[type],
centered && styles.centered,
disabled && styles.disabled,
className
),
...props,
};

const inner = (
<div className={IconLeft ? styles.spaceIcon : ''}>
{IconLeft && (
<div className={styles.leftIcon}>
<IconLeft className={clsx(text && styles.iconLeftOfText)} />
</div>
)}

<div className={styles.text}>{text}</div>
{IconRight && (
<div>
<IconRight className={clsx(text && styles.iconRightOfText)} />
</div>
)}
</div>
);
return href ? (
<Link href={href} legacyBehavior>
<a {..._props}>{inner}</a>
</Link>
) : (
<button disabled={disabled === true} {..._props}>
{inner}
</button>
);
}
2 changes: 1 addition & 1 deletion src/components/molecules/socialLogin.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { setSessionToken } from '~lib/cookies';
import useDidUnmount from '~lib/useDidUnmount';
import { UserSocialServiceName } from '~src/__generated__/graphql';

import Button from './button';
import Button from './buttonSocial';
import styles from './socialLogin.module.scss';

export default function SocialLogin({
Expand Down

0 comments on commit fa4667b

Please sign in to comment.