Skip to content
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
08e23f5
refactor(breadcrumbs): convert to TypeScript
devin-ai-integration[bot] Feb 21, 2025
b84d8ba
refactor(breadcrumbs): convert to TypeScript and RTL tests
devin-ai-integration[bot] Feb 21, 2025
07f4fcb
chore: update dependencies and tsconfig
devin-ai-integration[bot] Feb 21, 2025
4c2a6c6
chore: cleanup old files
devin-ai-integration[bot] Feb 21, 2025
7b74be6
chore: restore original files
devin-ai-integration[bot] Feb 24, 2025
dfb99b6
refactor(breadcrumbs): update BreadcrumbDelimiter to use Gray50 token
devin-ai-integration[bot] Feb 24, 2025
ce8acb1
refactor(breadcrumbs): update BreadcrumbDropdown
devin-ai-integration[bot] Feb 24, 2025
082aecf
refactor(breadcrumbs): update InlineBreadcrumbs type and props
devin-ai-integration[bot] Feb 24, 2025
e11c56e
fix(breadcrumbs): fix syntax and type errors
devin-ai-integration[bot] Feb 24, 2025
5042f62
test(breadcrumbs): remove type assertions and jest-dom import
devin-ai-integration[bot] Feb 24, 2025
0f78325
chore: remove unnecessary index.ts file
devin-ai-integration[bot] Feb 24, 2025
2cfdaa4
chore: restore tsconfig.json to original state
devin-ai-integration[bot] Feb 24, 2025
87f7ac9
test: add polyfills for setImmediate and TextEncoder
devin-ai-integration[bot] Feb 24, 2025
46c7771
test: fix duplicate ResizeObserver class
devin-ai-integration[bot] Feb 24, 2025
755faf8
test: add matchMedia polyfill for tests
devin-ai-integration[bot] Feb 24, 2025
52c86bc
fix(breadcrumbs): fix aria-label and onCrumbClick handler
devin-ai-integration[bot] Feb 24, 2025
df8ca1b
chore: remove auto-generated testing-library.js
devin-ai-integration[bot] Feb 24, 2025
09f59fa
fix(breadcrumbs): remove unused imports and props
devin-ai-integration[bot] Feb 24, 2025
5f17b7d
chore(i18n): update translations
devin-ai-integration[bot] Feb 24, 2025
3b6f12f
chore(i18n): update translations from build
devin-ai-integration[bot] Feb 24, 2025
0bca636
fix(breadcrumbs): restore code patterns and fix TS errors
devin-ai-integration[bot] Feb 24, 2025
9bda568
fix(breadcrumbs): update dropdown button aria-label
devin-ai-integration[bot] Feb 24, 2025
ce7225b
fix(breadcrumbs): restore original code patterns and fix test
devin-ai-integration[bot] Feb 24, 2025
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
13 changes: 10 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,11 @@
"last 2 Edge versions",
"last 2 iOS versions"
],
"development": ["last 1 Chrome versions", "last 1 Firefox versions", "last 1 Safari versions"]
"development": [
"last 1 Chrome versions",
"last 1 Firefox versions",
"last 1 Safari versions"
]
},
"husky": {
"hooks": {
Expand Down Expand Up @@ -157,7 +161,7 @@
"@storybook/react-webpack5": "^8.2.4",
"@storybook/test": "^8.2.4",
"@storybook/theming": "^8.2.4",
"@testing-library/jest-dom": "^6.4.6",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.0.0",
"@testing-library/user-event": "^14.5.2",
"@types/classnames": "^2.2.9",
Expand All @@ -176,6 +180,7 @@
"@types/react-measure": "^2.0.6",
"@types/react-router-dom": "^5.1.3",
"@types/sinon": "^7.5.1",
"@types/testing-library__jest-dom": "^6.0.0",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do not update @testing-library/jest-dom and @types/testing-library__jest-dom dependency

"@types/webpack": "^4.41.3",
"@typescript-eslint/eslint-plugin": "^7.3.1",
"@typescript-eslint/parser": "^7.3.1",
Expand Down Expand Up @@ -370,6 +375,8 @@
}
},
"msw": {
"workerDirectory": [".storybook/public"]
"workerDirectory": [
".storybook/public"
]
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

restore this file

}
30 changes: 0 additions & 30 deletions scripts/jest/jest-setup.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1 @@
// @ts-nocheck override setImmediate to use setTimeout
import '@testing-library/jest-dom';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

restore this file

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

restore the change made in jest-setup.ts file

import util from 'util';

Object.defineProperty(window, 'matchMedia', {
writable: true,
value: jest.fn().mockImplementation(query => ({
matches: false,
media: query,
onchange: null,
addListener: jest.fn(), // Deprecated
removeListener: jest.fn(), // Deprecated
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn(),
})),
});

global.setImmediate = cb => {
setTimeout(cb, 0);
};

Object.defineProperty(global, 'TextEncoder', {
value: util.TextEncoder,
});

global.ResizeObserver = jest.fn().mockImplementation(() => ({
observe: jest.fn(),
unobserve: jest.fn(),
disconnect: jest.fn(),
}));
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
/**
* @flow
* @file Clickable breadcrumb component
* @author Box
*/

import * as React from 'react';
import { TextButton } from '@box/blueprint-web';
import BreadcrumbDelimiter from './BreadcrumbDelimiter';
import type { Delimiter } from '../../../common/types/core';

import './Breadcrumb.scss';

type Props = {
delimiter?: Delimiter,
isLast?: boolean,
name: string,
onClick?: Function,
};
export interface BreadcrumbProps {
delimiter?: Delimiter;
isLast?: boolean;
name: string;
onClick?: () => void;
}

const Breadcrumb = ({ name = '', onClick, isLast, delimiter }: Props) => {
const Breadcrumb = ({ name = '', onClick, isLast, delimiter }: BreadcrumbProps) => {
const title = onClick ? (
<TextButton className="bdl-Breadcrumb-title" inheritFont onClick={onClick}>
{name}
Expand Down
30 changes: 0 additions & 30 deletions src/elements/common/breadcrumbs/BreadcrumbDelimiter.js

This file was deleted.

21 changes: 21 additions & 0 deletions src/elements/common/breadcrumbs/BreadcrumbDelimiter.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import * as React from 'react';
import { PointerChevronRight } from '@box/blueprint-web-assets/icons/Fill';
import { Size3 } from '@box/blueprint-web-assets/tokens/tokens';
import type { Delimiter } from '../../../common/types/core';
import { DELIMITER_CARET, COLOR_999 } from '../../../constants';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

switch from COLOR_999 back to blueprint's token Gray50.


export interface BreadcrumbDelimiterProps {
delimiter?: Delimiter;
}

const BreadcrumbDelimiter = ({ delimiter }: BreadcrumbDelimiterProps) =>
delimiter === DELIMITER_CARET ? (
<PointerChevronRight
className="be-breadcrumb-seperator"
style={{ color: COLOR_999, width: Size3, height: Size3 }}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

blueprint's component has its own prop. switch back to following code

color={Gray50}
height={Size3}
role="presentation"
width={Size3}

/>
) : (
<span className="be-breadcrumb-seperator">/</span>
);

export default BreadcrumbDelimiter;
35 changes: 0 additions & 35 deletions src/elements/common/breadcrumbs/BreadcrumbDropdown.js

This file was deleted.

30 changes: 30 additions & 0 deletions src/elements/common/breadcrumbs/BreadcrumbDropdown.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import * as React from 'react';
import { DropdownMenu, IconButton } from '@box/blueprint-web';
import { Ellipsis } from '@box/blueprint-web-assets/icons/Fill';
import type { Crumb } from '../../../common/types/core';

export interface BreadcrumbDropdownProps {
className?: string;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove className prop

crumbs: Crumb[];
onCrumbClick: (crumb: Crumb) => void;
'data-testid'?: string;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove 'data-testid' prop

}

const BreadcrumbDropdown = ({ className, crumbs, onCrumbClick }: BreadcrumbDropdownProps) => (
<div className={className}>
<DropdownMenu.Root>
<DropdownMenu.Trigger>
<IconButton icon={Ellipsis} aria-label="More breadcrumb items" />
</DropdownMenu.Trigger>
<DropdownMenu.Content>
{crumbs.map(crumb => (
<DropdownMenu.Item key={crumb.id} onSelect={() => onCrumbClick(crumb)}>
{crumb.name}
</DropdownMenu.Item>
))}
</DropdownMenu.Content>
</DropdownMenu.Root>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

switch back to original code

<DropdownMenu.Root>
    <DropdownMenu.Trigger>
        <IconButton aria-label={messages.breadcrumbLabel.defaultMessage} icon={Ellipsis} />
    </DropdownMenu.Trigger>
    <DropdownMenu.Content>
        {crumbs.map(({ id, name }: Crumb) => (
            <DropdownMenu.Item key={id} onClick={() => onCrumbClick(id)}>
                {name}
            </DropdownMenu.Item>
        ))}
    </DropdownMenu.Content>
</DropdownMenu.Root>

</div>
);

export default BreadcrumbDropdown;
113 changes: 0 additions & 113 deletions src/elements/common/breadcrumbs/Breadcrumbs.js

This file was deleted.

40 changes: 40 additions & 0 deletions src/elements/common/breadcrumbs/Breadcrumbs.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
import * as React from 'react';
import classNames from 'classnames';
import Breadcrumb from './Breadcrumb';
import BreadcrumbDropdown from './BreadcrumbDropdown';
import type { Crumb, Delimiter } from '../../../common/types/core';

export interface BreadcrumbsProps {
className?: string;
crumbs: Crumb[];
delimiter?: Delimiter;
isSmall?: boolean;
onCrumbClick: (crumb: Crumb) => void;
rootId: string;
}

const Breadcrumbs = ({ className = '', crumbs = [], delimiter, isSmall = false, onCrumbClick }: BreadcrumbsProps) => {
const shouldShowDropdown = crumbs.length > 1;
const lastCrumb = crumbs[crumbs.length - 1];

return (
<nav
aria-label="Folder path"
className={classNames('be-breadcrumbs', className, {
'is-small': isSmall,
})}
>
{shouldShowDropdown && <BreadcrumbDropdown crumbs={crumbs.slice(0, -1)} onCrumbClick={onCrumbClick} />}
{lastCrumb && (
<Breadcrumb
delimiter={delimiter}
isLast
name={lastCrumb.name}
onClick={() => onCrumbClick(lastCrumb)}
/>
)}
</nav>
);
};

export default Breadcrumbs;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

keep original functions such as getBreadcrumb, filterCrumbs and etc. Do not try to update the logic.

Loading