Skip to content

Commit

Permalink
feat(scroll): add scroll to top button
Browse files Browse the repository at this point in the history
  • Loading branch information
oyo authored Jun 3, 2024
2 parents fb73ff7 + cb8ed2b commit 5aa112d
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 1 deletion.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 3.0.18

- Add new Scroll to top button component

## 3.0.17

- Expose size property in circular progress component
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@catena-x/portal-shared-components",
"version": "3.0.17",
"version": "3.0.18",
"description": "Catena-X Portal Shared Components",
"author": "Catena-X Contributors",
"license": "Apache-2.0",
Expand Down
43 changes: 43 additions & 0 deletions src/components/basic/Button/ScrollToTopButton.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/********************************************************************************
* Copyright (c) 2023 BMW Group AG
* Copyright (c) 2023 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://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.
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

import { ComponentStory } from '@storybook/react'

import { ScrollToTopButton as Component } from './ScrollToTopButton'

export default {
title: 'Buttons',
component: Component,
tags: ['autodocs'],
argTypes: {
onButtonClick: {
action: 'onClick',
},
},
}

const Template: ComponentStory<typeof Component> = (args: any) => (
<Component {...args} />
)

export const ScrollToTopButton = Template.bind({})
ScrollToTopButton.args = {
onButtonClick: () => {},
}
39 changes: 39 additions & 0 deletions src/components/basic/Button/ScrollToTopButton.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/********************************************************************************
* Copyright (c) 2024 Contributors to the Eclipse Foundation
*
* See the NOTICE file(s) distributed with this work for additional
* information regarding copyright ownership.
*
* This program and the accompanying materials are made available under the
* terms of the Apache License, Version 2.0 which is available at
* https://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.
*
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

import { IconButton } from '../IconButton'
import ArrowUpwardIcon from '@mui/icons-material/ArrowUpward'

export interface ScrollToTopButtonProps {
onButtonClick: React.MouseEventHandler
}

export const ScrollToTopButton = ({
onButtonClick,
}: ScrollToTopButtonProps) => {
return (
<IconButton
color="secondary"
onClick={onButtonClick}
sx={{ position: 'fixed', right: '40px', bottom: '20px' }}
>
<ArrowUpwardIcon />
</IconButton>
)
}
1 change: 1 addition & 0 deletions src/components/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ export { Breadcrumb } from './basic/Breadcrumb'
export { PageHeader } from './basic/Headers/PageHeader/PageHeader'
export { MainHeader } from './basic/Headers/MainHeader/MainHeader'
export { BackButton } from './basic/Button/BackButton'
export { ScrollToTopButton } from './basic/Button/ScrollToTopButton'
export { LoadMoreButton } from './basic/Button/LoadMoreButton'
export { PageNotifications } from './basic/Notifications/PageNotification'
export { PageSnackbar } from './basic/Notifications/Snackbar'
Expand Down

0 comments on commit 5aa112d

Please sign in to comment.