Skip to content

Commit

Permalink
feat(PDYE-809): code review
Browse files Browse the repository at this point in the history
  • Loading branch information
Javiera Munita authored and Javiera Munita committed Jul 9, 2024
1 parent a6dc155 commit e5b1a1d
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 21 deletions.
9 changes: 3 additions & 6 deletions src/molecules/Buttons/Btn.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ interface colorScheme {

export interface propsBaseBtns {
ariaLabel?: string
ariaPressed?: boolean
children?: React.ReactNode
disabled?: boolean
isFullWidth?: boolean
Expand All @@ -24,7 +23,6 @@ export interface propsBaseBtns {
type?: 'button' | 'submit' | 'reset'
tabIndex?: number
id?: string
role?: string
}
interface props extends propsBaseBtns {
bg?: colorScheme
Expand All @@ -46,7 +44,6 @@ interface props extends propsBaseBtns {
*/
export function Btn({
ariaLabel,
ariaPressed,
bg,
borderColorActive = [vars('colors-main-deepSkyBlue'), vars('colors-neutral-white')],
children,
Expand All @@ -64,7 +61,7 @@ export function Btn({
size = 'regular',
touchDark = false,
type = 'button',
tabIndex,
tabIndex = 0,
}: props): JSX.Element {
let showChildren = children ?? null
if (!children && !rightIcon && !leftIcon) {
Expand All @@ -90,8 +87,8 @@ export function Btn({
<Ripples color={touchColor}>
<Button
aria-label={ariaLabel}
aria-pressed={ariaPressed}
id={id}
role="button"
bg={colorMain}
borderRadius={borderRadius}
color={color}
Expand Down Expand Up @@ -124,7 +121,7 @@ export function Btn({
type={type}
size={size === 'regular' ? 'md' : 'sm'}
spinner={<Loader fill={fillLoader} />}
tabIndex={tabIndex}
tabIndex={disabled || isLoading ? -1 : tabIndex}
_active={{
bg: bg?.main ?? vars('colors-main-azureRadiance'),
}}
Expand Down
5 changes: 1 addition & 4 deletions src/molecules/Buttons/BtnLink.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { Box } from '@chakra-ui/react'
export interface props {
as?: 'button' | 'a'
ariaLabel?: string
ariaPressed?: boolean
children?: React.ReactNode
fontSize?: string | '0.875rem'
href?: string
Expand All @@ -18,7 +17,6 @@ export interface props {
export function BtnLink({
as = 'button',
ariaLabel,
ariaPressed,
children,
fontSize = '0.875rem',
href = '',
Expand All @@ -42,9 +40,7 @@ export function BtnLink({
<Box
as={as}
aria-label={ariaLabel}
aria-pressed={ariaPressed}
id={id}
onClick={onClick}
role="button"
backgroundColor="transparent"
borderStyle="none"
Expand All @@ -55,6 +51,7 @@ export function BtnLink({
fontWeight="500"
fontSize={fontSize}
lineHeight="1rem"
onClick={onClick}
padding=".25em"
tabIndex={tabIndex}
textDecorationLine={textDecorationLine ? 'underline' : 'none'}
Expand Down
7 changes: 3 additions & 4 deletions src/molecules/Buttons/BtnPrimary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ import { Btn, propsBaseBtns } from './Btn'
* @example <BtnPrimary>Lorem</BtnPrimary>
*/

type XOR<T, U> = (T | U) extends object ? (T extends U ? never : T) | (U extends T ? never : U) : T | U
type XOR<T, U> = T | U extends object
? (T extends U ? never : T) | (U extends T ? never : U)
: T | U
interface ButtonWithTextProps extends propsBaseBtns {
children: React.ReactNode
ariaLabel?: string
Expand All @@ -22,7 +24,6 @@ interface ButtonWithoutTextProps extends propsBaseBtns {
type PrimaryButtonProps = XOR<ButtonWithTextProps, ButtonWithoutTextProps>
export function BtnPrimary({
ariaLabel,
ariaPressed,
children,
disabled = false,
isFullWidth = false,
Expand All @@ -36,11 +37,9 @@ export function BtnPrimary({
tabIndex,
id,
}: PrimaryButtonProps): JSX.Element {

return (
<Btn
ariaLabel={ariaLabel}
ariaPressed={ariaPressed}
id={id}
disabled={disabled}
isFullWidth={isFullWidth}
Expand Down
19 changes: 16 additions & 3 deletions src/molecules/Buttons/BtnSecondary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,23 @@ import { vars } from '@theme'
*
* @example <BtnSecondary>Lorem</BtnSecondary>
*/

type XOR<T, U> = T | U extends object
? (T extends U ? never : T) | (U extends T ? never : U)
: T | U
interface ButtonWithTextProps extends propsBaseBtns {
children: React.ReactNode
ariaLabel?: string
}

interface ButtonWithoutTextProps extends propsBaseBtns {
children?: React.ReactNode
ariaLabel: string
}

type SecondaryButtonProps = XOR<ButtonWithTextProps, ButtonWithoutTextProps>
export function BtnSecondary({
ariaLabel,
ariaPressed,
children,
disabled = false,
isFullWidth = false,
Expand All @@ -23,11 +37,10 @@ export function BtnSecondary({
type = 'button',
tabIndex,
id,
}: propsBaseBtns): JSX.Element {
}: SecondaryButtonProps): JSX.Element {
return (
<Btn
ariaLabel={ariaLabel}
ariaPressed={ariaPressed}
id={id}
bg={{
main: vars('colors-main-veryLightBlue'),
Expand Down
7 changes: 3 additions & 4 deletions src/molecules/Buttons/BtnTertiary.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@ import {
Download,
} from '@/atoms/Icons'

type XOR<T, U> = (T | U) extends object ? (T extends U ? never : T) | (U extends T ? never : U) : T | U
type XOR<T, U> = T | U extends object
? (T extends U ? never : T) | (U extends T ? never : U)
: T | U
export interface propsTertiaryBtn {
ariaPressed?: boolean
activeWhenPress?: boolean
id?: string
iconCustom?: JSX.Element
Expand Down Expand Up @@ -55,7 +56,6 @@ type ButtonProps = XOR<ButtonWithTextProps, ButtonWithoutTextProps>

export function BtnTertiary({
ariaLabel,
ariaPressed,
activeWhenPress = false,
children,
id,
Expand Down Expand Up @@ -103,7 +103,6 @@ export function BtnTertiary({
return (
<Button
aria-label={ariaLabel}
aria-pressed={ariaPressed}
id={id}
role="button"
type={type}
Expand Down

0 comments on commit e5b1a1d

Please sign in to comment.