Skip to content

Commit

Permalink
removed deprecated defaultProps
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrikMatiasko committed Apr 30, 2024
1 parent 0ba88a3 commit f1f9aaa
Show file tree
Hide file tree
Showing 11 changed files with 96 additions and 36 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
],
"scripts": {
"test": "jest -c ./config/jest.config.js",
"test:watch": "jest -c ./config/jest.config.js --watchAll",
"test:uwatch": "jest -c ./config/jest.config.js --watchAll",
"build": "npm-run-all prebuild build:legacy build:modern build:node build:stable build:copy-files",
"build:legacy": "node ./scripts/build legacy",
"build:modern": "node ./scripts/build modern",
Expand Down
22 changes: 20 additions & 2 deletions src/components/Atomic/Button/__snapshots__/Button.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,24 @@ exports[`<Button> render correctly - loading 1`] = `
margin-right: 8px;
}
.emotion-21 {
width: 20px;
height: 20px;
overflow: hidden;
display: block;
-webkit-animation: 0.75s linear 0s infinite normal both running animation-0;
animation: 0.75s linear 0s infinite normal both running animation-0;
display: -webkit-box;
display: -webkit-flex;
display: -ms-flexbox;
display: flex;
-webkit-align-items: center;
-webkit-box-align: center;
-ms-flex-align: center;
align-items: center;
margin-right: 8px;
}
<div>
<button
class="emotion-0"
Expand Down Expand Up @@ -332,7 +350,7 @@ exports[`<Button> render correctly - loading 1`] = `
class="emotion-2"
>
<span
class="emotion-3"
class="emotion-21"
>
<svg
fill="none"
Expand All @@ -354,7 +372,7 @@ exports[`<Button> render correctly - loading 1`] = `
class="emotion-4"
>
<span
class="emotion-3"
class="emotion-21"
>
<svg
fill="none"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ exports[`<ConfirmModal> renders without crashing 1`] = `
<div
class="emotion-1"
role="dialog"
style="opacity: 1; transform: translateY(0) translateZ(0);"
style="opacity: 1; transform: none;"
>
<div
class="emotion-2"
Expand Down
5 changes: 2 additions & 3 deletions src/components/Atomic/ContentMenu/ContentMenu.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ export const activeArrow = css`
`

export const subItems = css`
max-height: 0;
// max-height: 0;
overflow: hidden;
transition: all 0.45s;
//transition: all 0.45s;
`

export const subItemsList = css`
Expand All @@ -155,7 +155,6 @@ export const subItemLink = (theme: ThemeType) => css`
position: relative;
padding: 8px 8px 8px 20px;
white-space: nowrap;
margin: 4px 0 4px 0;
color: ${get(theme, `ContentMenu.subItem.color`)};
&:hover {
Expand Down
12 changes: 8 additions & 4 deletions src/components/Atomic/ContentMenu/ContentMenu.test.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { render, fireEvent } from '@testing-library/react'
import { render, fireEvent, waitFor } from '@testing-library/react'
import ContentMenu from './ContentMenu'

describe('<ContentMenu>', () => {
Expand Down Expand Up @@ -53,10 +53,14 @@ describe('<ContentMenu>', () => {
expect(mockHandleSubItemClick).not.toHaveBeenCalled()
})

it('filters menu items based on search input', () => {
it('filters menu items based on search input', async () => {
window.scrollTo = jest.fn()
const { getByText, getByRole } = render(<ContentMenu {...defaultProps} menuSearch />)
fireEvent.change(getByRole('search'), { target: { value: 'Item 2' } })
expect(getByText('Item 2')).toBeInTheDocument()
expect(() => getByText('Item 1')).toThrow()

await waitFor(() => {
expect(getByText('Item 2')).toBeInTheDocument()
expect(() => getByText('Item 1')).toThrow()
})
})
})
25 changes: 18 additions & 7 deletions src/components/Atomic/ContentMenu/ContentMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { cloneElement, FC, ReactElement, useEffect, useState } from 'react'
import { CSSTransition } from 'react-transition-group'
import { AnimatePresence, motion } from 'framer-motion'
import isFunction from 'lodash/isFunction'

import * as styles from './ContentMenu.styles'
Expand Down Expand Up @@ -74,9 +74,20 @@ const ContentMenu: FC<Props> = (props) => {
</span>
)}
</a>
{item.children && isItemActive && (
<CSSTransition appear={true} classNames='item' in={isItemActive} key={item.id} timeout={0}>
<div css={styles.subItems}>
<AnimatePresence initial={false}>
{item.children && isItemActive && (
<motion.section
animate='open'
css={styles.subItems}
exit='collapsed'
initial='collapsed'
key='content'
transition={{ duration: 0.8, ease: [0.04, 0.62, 0.23, 0.98] }}
variants={{
open: { opacity: 1, height: 'auto' },
collapsed: { opacity: 0, height: 0 },
}}
>
<ul css={styles.subItemsList}>
{item.children?.map((subItem, key) => (
<li key={key}>
Expand All @@ -97,9 +108,9 @@ const ContentMenu: FC<Props> = (props) => {
</li>
))}
</ul>
</div>
</CSSTransition>
)}
</motion.section>
)}
</AnimatePresence>
</li>
)
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,7 @@ exports[`<ContentMenu> renders without crashing 1`] = `
}
.emotion-5 {
max-height: 0;
overflow: hidden;
-webkit-transition: all 0.45s;
transition: all 0.45s;
}
.emotion-6 {
Expand All @@ -128,7 +125,6 @@ exports[`<ContentMenu> renders without crashing 1`] = `
position: relative;
padding: 8px 8px 8px 20px;
white-space: nowrap;
margin: 4px 0 4px 0;
}
.emotion-8 {
Expand Down Expand Up @@ -203,8 +199,9 @@ exports[`<ContentMenu> renders without crashing 1`] = `
</svg>
</span>
</a>
<div
class="emotion-5 item-appear item-appear-active"
<section
class="emotion-5"
style="opacity: 1; height: auto;"
>
<ul
class="emotion-6"
Expand All @@ -223,7 +220,7 @@ exports[`<ContentMenu> renders without crashing 1`] = `
</a>
</li>
</ul>
</div>
</section>
</li>
<li>
<a
Expand Down
5 changes: 5 additions & 0 deletions src/components/Atomic/Icon/__snapshots__/Icon.test.tsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,11 @@ exports[`<Icon> render correctly - snapshot 1`] = `
data-icon=""
style="width: 16px; height: 16px;"
/>
<div
class="emotion-0"
data-icon=""
style="width: 16px; height: 16px;"
/>
</div>
</DocumentFragment>
`;
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ exports[`<Modal> render correctly - snapshot 1`] = `
<div
class="emotion-1"
role="dialog"
style="opacity: 1; transform: translateY(0) translateZ(0);"
style="opacity: 1; transform: none;"
>
<div
class="emotion-2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,9 @@ exports[`<SimpleStripTable> render correctly - snapshot 1`] = `
tabindex="1"
type="submit"
>
<div>
<div
style="transform: none;"
>
<svg
fill="none"
height="16"
Expand Down Expand Up @@ -268,7 +270,9 @@ exports[`<SimpleStripTable> render correctly - snapshot 1`] = `
tabindex="1"
type="submit"
>
<div>
<div
style="transform: none;"
>
<svg
fill="none"
height="16"
Expand Down Expand Up @@ -301,7 +305,9 @@ exports[`<SimpleStripTable> render correctly - snapshot 1`] = `
tabindex="1"
type="submit"
>
<div>
<div
style="transform: none;"
>
<svg
fill="none"
height="16"
Expand Down Expand Up @@ -334,7 +340,9 @@ exports[`<SimpleStripTable> render correctly - snapshot 1`] = `
tabindex="1"
type="submit"
>
<div>
<div
style="transform: none;"
>
<svg
fill="none"
height="16"
Expand Down Expand Up @@ -383,7 +391,9 @@ exports[`<SimpleStripTable> render correctly - snapshot 1`] = `
tabindex="1"
type="submit"
>
<div>
<div
style="transform: none;"
>
<svg
fill="none"
height="16"
Expand Down Expand Up @@ -432,7 +442,9 @@ exports[`<SimpleStripTable> render correctly - snapshot 1`] = `
tabindex="1"
type="submit"
>
<div>
<div
style="transform: none;"
>
<svg
fill="none"
height="16"
Expand Down Expand Up @@ -482,7 +494,9 @@ exports[`<SimpleStripTable> render correctly - snapshot 1`] = `
tabindex="1"
type="submit"
>
<div>
<div
style="transform: none;"
>
<svg
fill="none"
height="16"
Expand Down Expand Up @@ -532,7 +546,9 @@ exports[`<SimpleStripTable> render correctly - snapshot 1`] = `
tabindex="1"
type="submit"
>
<div>
<div
style="transform: none;"
>
<svg
fill="none"
height="16"
Expand Down
14 changes: 12 additions & 2 deletions src/components/Atomic/TreeTable/TreeTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,12 +75,13 @@ const TreeTable: FC<Props> = (props) => {
<table {...getTableProps()} className={className} css={styles.table}>
<thead>
{headerGroups.map((headerGroup: any) => (
<tr {...headerGroup.getHeaderGroupProps()}>
<tr {...headerGroup.getHeaderGroupProps()} key={headerGroup.getHeaderGroupProps().key}>
{headerGroup.headers.map((column: any, key: number) => (
<th
{...column.getHeaderProps(column.getSortByToggleProps())}
className={classNames(column.getHeaderProps(column.getSortByToggleProps()).className, column.className)}
css={tableStyles.headerTh}
key={column.getHeaderProps(column.getSortByToggleProps()).key}
style={{
...column.getHeaderProps().style,
...column.style,
Expand Down Expand Up @@ -122,9 +123,10 @@ const TreeTable: FC<Props> = (props) => {
{rows.map((row: any, key: number) => {
prepareRow(row)
const _isLastFromExpanded = isLastFromExpanded(row)
const rowProps = row.getRowProps(getRowProps!(row))

return (
<tr {...row.getRowProps(getRowProps!(row))} css={[tableStyles.row, styles.row]}>
<tr {...rowProps} css={[tableStyles.row, styles.row]} key={rowProps.key}>
{row.cells.map((cell: any, cellKey: number) => (
<td
{...cell.getCellProps([
Expand All @@ -134,6 +136,14 @@ const TreeTable: FC<Props> = (props) => {
},
])}
data-row={row.id}
key={
cell.getCellProps([
{
className: cell.column.className,
style: cell.column.style,
},
]).key
}
>
<Cell
css={(theme) => [
Expand Down

0 comments on commit f1f9aaa

Please sign in to comment.