geido commented on code in PR #32905: URL: https://github.com/apache/superset/pull/32905#discussion_r2024546515
########## superset-frontend/src/components/Breadcrumb/Breadcrumb.stories.tsx: ########## @@ -0,0 +1,57 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import type { Meta, StoryObj } from '@storybook/react'; +import { Breadcrumb } from '.'; + +const meta: Meta<typeof Breadcrumb> = { + title: 'Breadcrumb', + component: Breadcrumb, + tags: ['autodocs'], + argTypes: { + separator: { + control: 'text', + description: 'Custom separator between items', + defaultValue: '/', + }, + items: { + control: 'object', Review Comment: Let's use `false` here for the control as it is not really convenient to pass array of items in Storybook and let's use the Storybook table info and summary to provide an example for this prop. ########## superset-frontend/src/components/Breadcrumb/index.tsx: ########## @@ -0,0 +1,21 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import { Breadcrumb as antdBreadcrumb } from 'antd-v5'; + +export const Breadcrumb = antdBreadcrumb; Review Comment: ```suggestion export const Breadcrumb = AntdBreadcrumb; ``` ########## superset-frontend/src/components/Breadcrumb/index.tsx: ########## @@ -0,0 +1,21 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import { Breadcrumb as antdBreadcrumb } from 'antd-v5'; Review Comment: ```suggestion import { Breadcrumb as AntdBreadcrumb } from 'antd-v5'; ``` ########## superset-frontend/src/components/Breadcrumb/Breadcrumb.stories.tsx: ########## @@ -0,0 +1,57 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import type { Meta, StoryObj } from '@storybook/react'; +import { Breadcrumb } from '.'; + +const meta: Meta<typeof Breadcrumb> = { + title: 'Breadcrumb', + component: Breadcrumb, + tags: ['autodocs'], + argTypes: { + separator: { + control: 'text', + description: 'Custom separator between items', + defaultValue: '/', + }, + items: { + control: 'object', + description: 'List of breadcrumb items', + defaultValue: [ + { title: 'Home', href: '/' }, + { title: 'Library', href: '/library' }, + { title: 'Data' }, + ], + }, + }, +}; + +export default meta; +type Story = StoryObj<typeof Breadcrumb>; + +export const Default: Story = { Review Comment: I see that the component has a bunch of [different abilities](https://ant.design/components/breadcrumb), such as showing a dropdown. It would be nice to have a gallery here of these different abilities. Something like https://superset-storybook.netlify.app/?path=/story/buttongroup--interactive-button-group where we can see multiple components in one view. ########## superset-frontend/src/components/Breadcrumb/Breadcrumb.test.tsx: ########## @@ -0,0 +1,37 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import { render, screen } from '@testing-library/react'; +import '@testing-library/jest-dom'; +import { Breadcrumb } from '.'; + +describe('Breadcrumb Component', () => { + test('renders breadcrumb items correctly', () => { + render( + <Breadcrumb> + <Breadcrumb.Item>Home</Breadcrumb.Item> + <Breadcrumb.Item>Library</Breadcrumb.Item> + <Breadcrumb.Item>Data</Breadcrumb.Item> + </Breadcrumb>, + ); + + expect(screen.getByText('Home')).toBeInTheDocument(); Review Comment: Can we test that also a _**custom**_ divider is present -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
