Skip to content

Commit ff2f4dc

Browse files
feat(organisms): ajustes en comportamiento de flashNotification
- componente alert recibe string con elementos html inmersos, validando estos antes de montarlos - componentes reciben sx como props para modificarlos: label, tinyAlert, btn y sus variantes, alerts, newTooltip - optimizan los test, dejando mock globales
1 parent 7695619 commit ff2f4dc

27 files changed

+338
-48
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,5 @@ yarn-error.log
88
docs
99
.eslintcache
1010
tsconfig.tsbuildinfo
11-
*.env*
11+
*.env*
12+
.jest-cache

__mocks__/dompurify.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
const DOMPurify = {
2+
sanitize: (html: string) => html,
3+
}
4+
5+
export default DOMPurify

__mocks__/react-ripples.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import React from 'react'
2+
3+
const Ripples = ({ children }: { children: React.ReactNode }) => {
4+
return <>{children}</>
5+
}
6+
7+
export default Ripples

jest.config.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,14 @@ module.exports = {
1010
setupFilesAfterEnv: ['<rootDir>/src/test/jest-setup.ts'],
1111
watchPlugins: ['jest-watch-typeahead/filename', 'jest-watch-typeahead/testname'],
1212
roots: ['<rootDir>'],
13+
maxWorkers: '50%',
14+
cacheDirectory: '<rootDir>/.jest-cache',
15+
globals: {
16+
'ts-jest': {
17+
diagnostics: false,
18+
isolatedModules: true,
19+
},
20+
},
1321
modulePaths: tsConfig.compilerOptions ? [tsConfig.compilerOptions.baseUrl] : [],
1422
moduleNameMapper: {
1523
...(tsConfig.compilerOptions && tsConfig.compilerOptions.paths
@@ -18,4 +26,4 @@ module.exports = {
1826
'\\.(jpg|jpeg|png|gif|eot|otf|webp|svg|ttf|woff|woff2|mp4|webm|wav|mp3|m4a|aac|oga)$': '<rootDir>/__mocks__/fileMock.js',
1927
'\\.(css)$': 'identity-obj-proxy'
2028
}
21-
};
29+
};

package-lock.json

Lines changed: 116 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,9 @@
128128
"@emotion/react": "11.8.2",
129129
"@emotion/styled": "11.8.1",
130130
"date-fns": "^4.1.0",
131+
"dompurify": "^3.3.1",
131132
"framer-motion": "6.2.8",
133+
"html-react-parser": "^5.2.11",
132134
"react-hot-toast": "2.4.1",
133135
"react-ripples": "2.2.1"
134136
},
@@ -137,4 +139,4 @@
137139
"@types/react-dom": "17.0.2"
138140
},
139141
"sideEffects": false
140-
}
142+
}

src/atoms/Icons/Base.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export interface BaseProps {
1111
}
1212
interface IconProps extends BaseProps {
1313
viewBox?: string
14-
children: React.ReactChild | React.ReactChild[]
14+
children: React.ReactNode
1515
title?: string
1616
}
1717

src/atoms/Label/Label.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
import { Box } from '@chakra-ui/react'
1+
import { Box, CSSObject } from '@chakra-ui/react'
22

33
import { vars } from '@theme'
44

55
export interface LabelProps {
6-
children: React.ReactChild
6+
children: React.ReactNode
77
bg?: string
88
color?: string
99
size?: 'md' | 'sm'
1010
m?: string
11+
sx?: CSSObject
1112
}
1213

1314
/**
@@ -20,6 +21,7 @@ export function Label({
2021
color = vars('colors-neutral-darkCharcoal'),
2122
size = 'md',
2223
m = '0',
24+
sx,
2325
}: LabelProps): JSX.Element {
2426
const config = {
2527
md: {
@@ -45,6 +47,7 @@ export function Label({
4547
lineHeight=".875rem"
4648
m={m}
4749
p={config[size].p}
50+
sx={sx}
4851
>
4952
{children}
5053
</Box>

src/atoms/TinyAlert/TinyAlert.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Box } from '@chakra-ui/react'
1+
import { Box, CSSObject } from '@chakra-ui/react'
22
import { vars } from '@theme'
33

44
import { TinyAlertInfo, TinyAlertError, TinyAlertWarning, TinyAlertSuccess } from '../Icons'
@@ -7,6 +7,7 @@ export interface props {
77
status: 'success' | 'error' | 'info' | 'warning' | 'answered' | 'pending' | 'omitted' | 'new'
88
text?: string
99
margin?: string
10+
sx?: CSSObject
1011
}
1112

1213
/**
@@ -16,7 +17,7 @@ export interface props {
1617
* <TinyAlert status="info" />
1718
*/
1819

19-
export function TinyAlert({ status, text, margin = '0' }: props): JSX.Element | null {
20+
export function TinyAlert({ status, text, margin = '0', sx }: props): JSX.Element | null {
2021
const alerts = {
2122
success: {
2223
icon: <TinyAlertSuccess />,
@@ -84,6 +85,7 @@ export function TinyAlert({ status, text, margin = '0' }: props): JSX.Element |
8485
width="fit-content"
8586
borderRadius=".25rem"
8687
className="TinyAlert-Box"
88+
sx={sx}
8789
>
8890
{alerts[status].icon && (
8991
<Box

src/documentation/Documentation.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { routes } from './utils/routes'
55
import { Home, NoMatch } from './pages'
66
import { Layout } from './components'
77
import { Box } from '@chakra-ui/react'
8+
import { FlashNotificationGlobal } from '@/organisms/Alerts/FlashNotification'
89

910
export const Documentation = (): JSX.Element => {
1011
React.useEffect(() => {
@@ -16,6 +17,7 @@ export const Documentation = (): JSX.Element => {
1617

1718
return (
1819
<Box w="100%" overflowX="hidden">
20+
<FlashNotificationGlobal />
1921
<BrowserRouter>
2022
<Routes>
2123
<Route path="/" element={<Layout />}>

0 commit comments

Comments
 (0)