Skip to content

Commit 6e4e926

Browse files
feat(tooltip): agregamos booleano de open a tooltip y pressed a btntertiary (#612)
1 parent 41eaec9 commit 6e4e926

File tree

4 files changed

+43
-2
lines changed

4 files changed

+43
-2
lines changed

src/documentation/pages/Molecules/Buttons.tsx

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,17 @@ export const Buttons = (): JSX.Element => {
101101
<BtnTertiary iconCustom={<GoAhead />}>custom</BtnTertiary>
102102
</ListComponent>
103103
<Code text="<BtnTertiary iconCustom={<GoAhead />} >custom</BtnTertiary>" />
104+
<MyTittle>Activo al presionar</MyTittle>
105+
<MyText>
106+
El <code>BtnTertiary</code> puede tener una propiedad <code>activeWhenPress</code> booleano
107+
el cual indica que al presionar o mantener focus queda azul brillante o activo:
108+
</MyText>
109+
<ListComponent>
110+
<BtnTertiary activeWhenPress iconCustom={<GoAhead />}>
111+
custom
112+
</BtnTertiary>
113+
</ListComponent>
114+
<Code text="<BtnTertiary activeWhenPress iconCustom={<GoAhead />} >custom</BtnTertiary>" />
104115
</>
105116
)
106117
}

src/documentation/pages/Molecules/Tooltip.tsx

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
import { ListComponent, MyHeading, MyText, MyTittle, Code } from '@/documentation/components'
22
import { NewTooltip } from '../../../molecules/Tooltip/NewTooltip'
33
import { BtnPrimary } from '@/molecules'
4+
import { useDisclosure } from '@chakra-ui/react'
45

56
export const ViewTooltip = (): JSX.Element => {
7+
const { isOpen, onToggle } = useDisclosure()
8+
69
return (
710
<>
811
<MyHeading>Tooltip</MyHeading>
@@ -60,6 +63,24 @@ export const ViewTooltip = (): JSX.Element => {
6063
<BtnPrimary>Left</BtnPrimary>
6164
</NewTooltip>`}
6265
/>
66+
<MyTittle>Activar al Click</MyTittle>
67+
<MyText>
68+
El componente tiene un prop booleano <code>isOpen</code> que se utiliza para mantener
69+
abierto o cerrado el tooltip en caso de utilizar <code>onClick</code>, usando el hook{' '}
70+
<code>useDisclosure()</code>
71+
</MyText>
72+
<ListComponent>
73+
<NewTooltip label="Default" isOpen={isOpen}>
74+
<BtnPrimary onClick={onToggle}>Presionar para mostrar</BtnPrimary>
75+
</NewTooltip>
76+
</ListComponent>
77+
<Code
78+
text={`
79+
const { isOpen, onToggle } = useDisclosure()
80+
<NewTooltip label="Default" isOpen={isOpen}>
81+
<BtnPrimary onClick={onToggle}>Presionar para mostrar</BtnPrimary>
82+
</NewTooltip>`}
83+
/>
6384
</>
6485
)
6586
}

src/molecules/Buttons/BtnTertiary.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ export interface propsTertiaryBtn {
3434
type?: 'button' | 'submit' | 'reset'
3535
tabIndex?: number
3636
id?: string
37-
37+
activeWhenPress?: boolean
3838
onClick?: (e: React.MouseEvent<HTMLElement>) => void
3939
}
4040

@@ -48,7 +48,7 @@ export function BtnTertiary({
4848
type = 'button',
4949
tabIndex,
5050
id,
51-
51+
activeWhenPress = false,
5252
onClick,
5353
}: propsTertiaryBtn): JSX.Element {
5454
const gray = vars('colors-neutral-gray')
@@ -107,6 +107,7 @@ export function BtnTertiary({
107107
boxShadow: `inset 0 0 0 2px ${blue}, inset 0 0 0 4px ${white}`,
108108
}}
109109
_focus={{
110+
color: activeWhenPress ? `${blue}` : 'inherit',
110111
boxShadow: 'none',
111112
}}
112113
_active={{
@@ -124,6 +125,11 @@ export function BtnTertiary({
124125
},
125126
},
126127
},
128+
'&:focus': {
129+
'svg path': {
130+
fill: activeWhenPress ? `${blue}` : '',
131+
},
132+
},
127133
}}
128134
>
129135
{children}

src/molecules/Tooltip/NewTooltip.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ interface TooltipProps {
99
m?: string
1010
maxWidth?: string
1111
placement?: PlacementWithLogical
12+
isOpen?: boolean | undefined
1213
}
1314

1415
export const NewTooltip: FC<TooltipProps> = ({
@@ -19,9 +20,11 @@ export const NewTooltip: FC<TooltipProps> = ({
1920
m,
2021
maxWidth = '200px',
2122
placement = 'bottom',
23+
isOpen,
2224
}) => {
2325
return (
2426
<Tooltip
27+
isOpen={isOpen}
2528
sx={{
2629
bg: vars('colors-neutral-darkCharcoal'),
2730
borderRadius: '10px',

0 commit comments

Comments
 (0)