Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion ai/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Componentes React de eClass sobre Chakra UI 1.8. Funcionan desde React 16.8. Tod
desde el paquete:

```tsx
import { ModalMultiple, ModalContent, ModalButtons, BtnPrimary, vars } from '@eclass/ui-kit'
import { ModalMultiple, ModalContent, ModalButtons, BtnPrimary, BoxLearningPath, vars } from '@eclass/ui-kit'
```

## Reglas rápidas
Expand All @@ -28,6 +28,8 @@ cómo reconocerlo en un diseño.
| `BtnTertiary` | Acción de baja jerarquía: texto gris subrayado con ícono azul | [botones](components/botones.md) |
| `BtnLink` | Acción con aspecto de enlace | [botones](components/botones.md) |
| `Btn` | Botón base; preferir las variantes de arriba | [botones](components/botones.md) |
| `BoxLearningPath` | Caja para rutas de aprendizaje. |
[ruta-aprendizaje](components/ruta-aprendizaje.md) |
| `Modal` | Modal con cabecera azul, título, contenido y botones | [modales](components/modales.md) |
| `ModalMultiple` | Un solo modal que cambia entre contenido, alerta y carga | [modales](components/modales.md) |
| `ModalContent` | Cuerpo de `Modal`/`ModalMultiple` | [modales](components/modales.md) |
Expand Down
55 changes: 55 additions & 0 deletions ai/components/ruta-aprendizaje.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# BoxLearningPath

Exports: `BoxLearningPath`.
Tipos: `dist/organisms/CourseList/Boxes/BoxLearningPath.tsx` (`IBoxLearningPath`, no
exportado).

## Cuándo usarlo

Casos en que hay rutas de aprendizaje.

## Ejemplo

```tsx
import { BoxLearningPath } from '@eclass/ui-kit'

export function RutaAprendizaje({ learningPath }: { courses: any[] }): JSX.Element {
return (
<>
{learningPath.map((path, index) => (
<BoxLearningPath
headerImage={path.headerImg}
title={path.title}
coursesCount={path.count}
progress={path.progress}
pathHref={path.href}
buttonLabel={path.btnLabel}
start={{
level: 'Nivel 1 - Aplica',
courseTitle: 'Fundamentos de IA generativa y prompting',
courseHref: 'www.google.com',
thumbnail: '/img/curso-1.png',
}}
/>
))}
</>
)
}
```

## Props clave

- `headerImage`, `title` y `coursesCount` (obligatorios): imagen, nombre y cantidad de cursos de la ruta.
- `progress`: porcentaje de avance (0-100).
- `start`: información sobre curso inicial o curso con última actividad.
- `buttonLabel`: texto del botón, por defecto: "Ver ruta de aprendizaje".
- `pathHref`: href para navegar a vista de ruta.
- `hasFinished`: valor booleano que indica si la ruta ha finalizado.


## Cómo se ve (para reconocerlo en un diseño)

- Caja parecida a caja curso tradicional.
- Header con imagen y texto sobrepuesto con título de la ruta.
- Barra de progreso que muestra porcentaje de avance.
- Sección con fondo gris que indica curso por el cual comenzar o retomar, o alerta info de curso finalizado.
23 changes: 23 additions & 0 deletions src/atoms/Icons/LearningPath.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { Base, BaseProps } from './Base'

export function LearningPath(props: BaseProps): JSX.Element {
return (
<Base {...props} title="path">
<svg width={16} height={16} viewBox="0 0 16 16" fill="none" {...props}>
<g clipPath="url(#clip0_7045_4904)">
<path
d="M12.9714 6.04018C12.2814 6.04018 11.6734 5.8394 11.1474 5.43785C10.6214 5.03631 10.2651 4.51882 10.0785 3.88539H5.88759C5.74054 4.36612 5.48887 4.78181 5.13256 5.13245C4.77625 5.4831 4.36055 5.73477 3.88547 5.88748V10.0783C4.51326 10.2592 5.02793 10.6156 5.42948 11.1472C5.83104 11.6788 6.03181 12.284 6.03181 12.9626C6.03181 13.8053 5.73772 14.5179 5.14952 15.1004C4.56133 15.683 3.85154 15.9771 3.02015 15.9827C2.17179 15.9827 1.45634 15.6915 0.873807 15.1089C0.291269 14.5264 0 13.8138 0 12.9711C0 12.2924 0.200778 11.6873 0.602333 11.1557C1.00389 10.624 1.52139 10.2649 2.15482 10.0783V5.88748C1.52704 5.7065 1.01237 5.35585 0.610817 4.83553C0.209261 4.31522 0.00565571 3.71007 0 3.02009C0 2.1774 0.291269 1.4648 0.873807 0.882273C1.45634 0.299747 2.17179 0.0056556 3.02015 0C3.70449 0 4.30965 0.200774 4.83563 0.602321C5.36161 1.00387 5.71227 1.52136 5.88759 2.15478H10.0785C10.2595 1.52701 10.6129 1.01235 11.1389 0.610804C11.6649 0.209257 12.2729 0.00848338 12.9629 0.00848338C13.8056 0.00848338 14.5182 0.299747 15.1007 0.882273C15.6833 1.4648 15.9774 2.1774 15.983 3.02009C15.9887 3.86277 15.6974 4.5782 15.1092 5.16639C14.521 5.75457 13.8084 6.04583 12.9714 6.04018ZM3.01167 14.2521C3.36797 14.2521 3.67338 14.1277 3.92789 13.8788C4.1824 13.63 4.30965 13.3274 4.30965 12.9711C4.30965 12.6148 4.1824 12.3151 3.92789 12.0719C3.67338 11.8287 3.36797 11.7014 3.01167 11.6901C2.6497 11.6901 2.34712 11.8145 2.10392 12.0634C1.86073 12.3122 1.73913 12.6176 1.73913 12.9796C1.73913 13.3359 1.86356 13.6385 2.11241 13.8873C2.36126 14.1362 2.66384 14.2578 3.02015 14.2521H3.01167ZM3.01167 4.30956C3.36797 4.30956 3.67338 4.18231 3.92789 3.92781C4.1824 3.67331 4.30682 3.36508 4.30117 3.00312C4.30117 2.65247 4.17391 2.35273 3.91941 2.10388C3.6649 1.85504 3.36232 1.73344 3.01167 1.7391C2.6497 1.7391 2.34712 1.86352 2.10392 2.11237C1.86073 2.36121 1.73913 2.66379 1.73913 3.02009C1.73913 3.37639 1.86073 3.67896 2.10392 3.92781C2.34712 4.17666 2.6497 4.30108 3.01167 4.30108V4.30956ZM12.9799 15.9997C12.1428 15.9997 11.4302 15.7112 10.842 15.1344C10.2538 14.5575 9.9597 13.8477 9.9597 13.005C9.9597 12.1624 10.2538 11.4469 10.842 10.8587C11.4302 10.2706 12.1428 9.97364 12.9799 9.96799C13.8169 9.96233 14.5295 10.2592 15.1177 10.8587C15.7059 11.4582 16 12.1737 16 13.005C16 13.8364 15.7059 14.5462 15.1177 15.1344C14.5295 15.7226 13.8169 16.011 12.9799 15.9997ZM12.9968 14.2691C13.3475 14.2691 13.6472 14.1446 13.8961 13.8958C14.1449 13.647 14.2694 13.3444 14.2694 12.9881C14.2694 12.6318 14.1449 12.3292 13.8961 12.0804C13.6472 11.8315 13.3446 11.7043 12.9883 11.6986C12.632 11.6929 12.3294 11.8202 12.0806 12.0804C11.8317 12.3405 11.7045 12.6459 11.6988 12.9966C11.6988 13.3585 11.8261 13.6611 12.0806 13.9043C12.3351 14.1475 12.6405 14.2691 12.9968 14.2691ZM12.9799 4.30108C13.3305 4.30108 13.6303 4.17383 13.8791 3.91933C14.128 3.66483 14.2524 3.35942 14.2524 3.00312C14.2524 2.65247 14.128 2.35273 13.8791 2.10388C13.6303 1.85504 13.3277 1.73344 12.9714 1.7391C12.6151 1.74475 12.3125 1.86917 12.0636 2.11237C11.8148 2.35556 11.6875 2.65813 11.6819 3.02009C11.6762 3.38205 11.8035 3.68462 12.0636 3.92781C12.3238 4.171 12.6292 4.29825 12.9799 4.30956V4.30108Z"
fill="#B0CFE0"
/>
</g>
<defs>
<clipPath id="clip0_7045_4904">
<rect width={16} height={16} fill="white" />
</clipPath>
</defs>
</svg>
</Base>
)
}

LearningPath.displayName = 'LearningPath'
1 change: 1 addition & 0 deletions src/atoms/Icons/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export * from './GoBack'
export * from './Loader'
export * from './MapIndicator'
export * from './Multimedia'
export * from './LearningPath'
export * from './Profile'
export * from './Remote'
export * from './Schedule'
Expand Down
9 changes: 8 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@ export { UserWay } from './molecules/UserWay/UserWay'
export { UserWayCookie } from './molecules/UserWay/UserWayCookie'

// Organismos
export { CourseList, CourseStatus, dataFake, maxWidthCoursesList } from './organisms/CourseList'
export {
BoxLearningPath,
CourseList,
CourseStatus,
dataFake,
maxWidthCoursesList,
} from './organisms/CourseList'
export type { IBoxLearningPath, LearningPathStart } from './organisms/CourseList'
export { Alert, FlashNotification, useFlashNotification } from './organisms/Alerts'
export {
Modal,
Expand Down
188 changes: 188 additions & 0 deletions src/organisms/CourseList/Boxes/BoxLearningPath.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
import {
Box,
keyframes,
LinkBox,
LinkBoxProps,
LinkOverlay,
LinkOverlayProps,
} from '@chakra-ui/react'
import { useState } from 'react'

import { vars } from '@theme'
import { PathHeader } from '../components/LearningPath/PathHeader'
import { PathProgress } from '../components/LearningPath/PathProgress'
import { PathCourseLink } from '../components/LearningPath/PathCourseLink'
import { IBoxLearningPath } from '../types'

const StyledLinkBox = LinkBox as React.FC<LinkBoxProps>
const StyledLinkOverlay = LinkOverlay as React.FC<LinkOverlayProps>

// Desplazamiento de las tarjetas apiladas al bajar y al subir (atrás y adelante)
const BACK_PEEK = 8
const FRONT_PEEK = 4

/**
* Subida de las tarjetas apiladas al hacer hover: bajan `peek` px y suben hasta
* `peek` px por sobre su posición inicial. Con `both`, la tarjeta de atrás espera su
* retraso en la posición inicial y al terminar ambas se quedan arriba.
*/
const stackBounce = (peek: number): string => keyframes`
0% { transform: translateY(0); }
40% { transform: translateY(${peek}px); }
100% { transform: translateY(-${peek}px); }
`

/** Bajada de las tarjetas apiladas a su posición inicial al salir el cursor */
const stackDrop = (peek: number): string => keyframes`
from { transform: translateY(-${peek}px); }
to { transform: translateY(0); }
`

const stackAnimations = {
back: {
rise: `${stackBounce(BACK_PEEK)} 680ms ease-in-out 90ms both`,
drop: `${stackDrop(BACK_PEEK)} 300ms ease-in-out both`,
},
front: {
rise: `${stackBounce(FRONT_PEEK)} 680ms ease-in-out both`,
drop: `${stackDrop(FRONT_PEEK)} 300ms ease-in-out both`,
},
}

/**
* Fases de las tarjetas apiladas:
* - `rest`: en su posición inicial (sin animación).
* - `rising`: animación de subida en curso; siempre se completa, aunque el cursor salga.
* - `raised`: subida terminada y el cursor sigue en la caja; se quedan arriba.
* - `dropping`: bajando o ya abajo tras salir el cursor.
*/
type StackPhase = 'rest' | 'rising' | 'raised' | 'dropping'

/** Animación CSS de una tarjeta apilada según la fase */
const stackAnimation = (
phase: StackPhase,
animations: { rise: string; drop: string }
): string | undefined => {
if (phase === 'rising' || phase === 'raised') return animations.rise
if (phase === 'dropping') return animations.drop
return undefined
}

export const BoxLearningPath = ({
headerImage,
title,
coursesCount,
progress = 0,
start,
buttonLabel = 'Ver ruta de aprendizaje',
pathHref,
hasFinished = false,
}: IBoxLearningPath): JSX.Element => {
const safeProgress = Math.min(100, Math.max(0, progress))
const [isHovered, setIsHovered] = useState(false)
const [stackPhase, setStackPhase] = useState<StackPhase>('rest')

return (
<Box
as="article"
position="relative"
w="100%"
pt="10px"
onMouseEnter={() => {
setIsHovered(true)
if (stackPhase === 'rest' || stackPhase === 'dropping') setStackPhase('rising')
}}
onMouseLeave={() => {
setIsHovered(false)
// Si la subida sigue en curso, la bajada parte en onAnimationEnd
if (stackPhase === 'raised') setStackPhase('dropping')
}}
>
{/* Efecto de tarjetas apiladas detrás; rebotan al pasar el mouse por la caja */}
<Box
aria-hidden="true"
position="absolute"
top="-3px"
left="24px"
right="24px"
h="28px"
w="calc(100% - 48px)"
border={`1px solid ${vars('colors-neutral-silverSand')}`}
borderBottom="none"
borderTopRadius={vars('radii-big')}
bg={vars('colors-neutral-cultured2')}
animation={stackAnimation(stackPhase, stackAnimations.back)}
onAnimationEnd={() => {
if (stackPhase === 'rising') setStackPhase(isHovered ? 'raised' : 'dropping')
}}
/>
<Box
aria-hidden="true"
position="absolute"
top="4px"
left="12px"
right="12px"
h="18px"
w="calc(100% - 24px)"
border={`1px solid ${vars('colors-neutral-silverSand')}`}
borderBottom="none"
borderTopRadius={vars('radii-big')}
bg={vars('colors-neutral-cultured2')}
animation={stackAnimation(stackPhase, stackAnimations.front)}
/>

{/* position relative: la caja queda por encima de las tarjetas cuando bajan */}
<StyledLinkBox
position="relative"
display="flex"
flexDir="column"
border={`1px solid ${vars('colors-neutral-platinum')}`}
borderRadius={vars('radii-big')}
h="100%"
overflow="hidden"
_hover={{
boxShadow: `0 2px 7px 0 ${vars('colors-neutral-silverSand')}`,
cursor: 'pointer',
}}
>
{/* Header */}
<PathHeader headerImage={headerImage} title={title} coursesCount={coursesCount} />

{/* Progreso */}
<PathProgress progress={safeProgress} />

{/* Comenzar/Continuar con */}
<PathCourseLink
title="Comenzar con:"
start={start}
progress={safeProgress}
finished={hasFinished}
/>

{/* Botón para ver ruta */}
<StyledLinkOverlay
href={pathHref}
w="100%"
h="53px"
minH="53px"
alignContent="center"
textAlign="center"
bg={vars('colors-neutral-white')}
borderRadius="0"
borderTop={vars('borders-light')}
fontSize="16px"
fontWeight="500"
color={vars('colors-icon-deepSkyBlue')}
_hover={{
bg: 'none',
}}
_focusVisible={{
boxShadow: `0 0 0 3px ${vars('colors-alert-deepSkyBlue')} inset`,
}}
>
{buttonLabel}
</StyledLinkOverlay>
</StyledLinkBox>
</Box>
)
}
Loading
Loading