Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(stepper): add tooltip in stepper #81

Merged
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 2.1.14

- Add tooltip hint in stepper and make stepper responsive

## 2.1.11

- Fix general issues
Expand Down
2 changes: 1 addition & 1 deletion DEPENDENCIES
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ npm/npmjs/-/csso/4.2.0, MIT, approved, clearlydefined
npm/npmjs/-/cssom/0.3.8, MIT, approved, clearlydefined
npm/npmjs/-/cssom/0.5.0, MIT, approved, clearlydefined
npm/npmjs/-/cssstyle/2.3.0, MIT, approved, clearlydefined
npm/npmjs/-/csstype/3.1.2, MIT, approved, clearlydefined
npm/npmjs/-/csstype/3.1.2, MIT, approved, #11847
npm/npmjs/-/data-urls/3.0.2, MIT, approved, clearlydefined
npm/npmjs/-/date-fns/2.30.0, MIT, approved, clearlydefined
npm/npmjs/-/debug/2.6.9, MIT, approved, clearlydefined
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@catena-x/portal-shared-components",
"version": "2.1.11",
"name": "@nidhi.garg/portal-shared-components",
Copy link
Contributor

Choose a reason for hiding this comment

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

pls change this back to catena-x

"version": "2.1.14",
Copy link
Contributor

Choose a reason for hiding this comment

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

why not 2.1.12?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Made the change. And yes I ran the linter command already.

"description": "Catena-X Portal Shared Components",
"author": "Catena-X Contributors",
"license": "Apache-2.0",
Expand Down
116 changes: 116 additions & 0 deletions src/components/basic/Stepper/Stepper.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
/********************************************************************************
* Copyright (c) 2021, 2023 BMW Group AG
Copy link
Contributor

Choose a reason for hiding this comment

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

remove 1st line. i.e line number 2

* Copyright (c) 2021, 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
********************************************************************************/

.stepperMain {
display: flex;

.stepperStep {
-webkit-flex: 1 0 0%;
-ms-flex: 1 0 0%;
flex: 1 0 0%;
width: 100%;
max-width: 100%;

.stepHead {
text-align: center;
height: 100%;

.hintStepMain {
.hintStepMobile {
display: none;
}
}

.stepHeadline {
width: 95px;
margin: 0px auto 24px auto;
min-height: 56px;
}
}
}
}

.stepperHint {
display: flex;

.hintStep {
-webkit-flex: 1 0 0%;
-ms-flex: 1 0 0%;
flex: 1 0 0%;
width: 100%;
max-width: 100%;
}
}



@media only screen and (max-width: 767px) {

.stepperMain {
display: inline-block;
width: 100%;

.stepperStep {
margin-bottom: 12px;

.stepHead {
text-align: left;
height: auto;

.hintStepMain {
display: flex;
align-items: center;

.hintStepMobile {
display: inline-block;

a {
display: inline-flex;
border-radius: 12px;
padding: 6px 12px;
background: var(--Interactive-Secondary, #EAF1FE);
box-shadow: 0px 20px 40px 0px rgba(80, 80, 80, 0.30);
margin-left: 10px;

span {
padding-bottom: 0;
}
}
}
}

.stepIcon {
margin: 0;
}

.stepHeadline {
width: 100%;
margin: 10px auto 12px auto;
min-height: auto;
line-height: normal;
}
}
}
}

.stepperHint {
display: none;
}
}
2 changes: 2 additions & 0 deletions src/components/basic/Stepper/Stepper.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,6 @@ Stepper.args = {
list: stepperElements,
showSteps: 6,
activeStep: 3,
tooltipText: "Continue where you left",
tooltipLink: "/registration/form"
}
164 changes: 95 additions & 69 deletions src/components/basic/Stepper/StepperItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@
* SPDX-License-Identifier: Apache-2.0
********************************************************************************/

import { Box } from '@mui/material'
import { useEffect, useState } from 'react'
import { Box, Link } from '@mui/material'
import { Typography } from '../Typography'
import { theme } from '../../../theme'
import { useEffect, useState } from 'react'

interface StepperItemProps {
step: number
Expand All @@ -31,6 +31,8 @@ interface StepperItemProps {
activeStep: number
index: number
totalSteps?: number
tooltipText?: string
tooltipLink?: string
}

export const StepperItem = ({
Expand All @@ -41,6 +43,8 @@ export const StepperItem = ({
activeStep,
index,
totalSteps = 6,
tooltipText,
tooltipLink,
}: StepperItemProps) => {
const [backgroundColor, setBackgroundColor] = useState(
color || theme.palette.stepper.stepUpcoming
Expand All @@ -59,78 +63,100 @@ export const StepperItem = ({
setDone(false)
}
}, [index, activeStep])
const width = 100 / totalSteps

return (
<Box
sx={{
width: `${width}%`,
margin: '0px',
borderBottom: `2px solid ${backgroundColor}`,
textAlign: 'center',
}}
>
<Box
<Box className="stepperStep">
<Box className="stepHead"
sx={{
backgroundColor: `${backgroundColor}`,
borderRadius: `${text ? '20px' : '50%'}`,
margin: '12px auto 16px auto',
width: `${text ? 'auto' : '28px'}`,
height: `${text ? 'auto' : '28px'}`,
color: '#fff',
display: `${text ? 'inline-block' : 'flex'}`,
padding: '3px 15px',
justifyContent: 'center',
alignItems: 'center',
borderBottom: `2px solid ${backgroundColor}`,
}}
>
<Typography
variant="body1"
fontSize="14px"
color="#fff"
sx={{
margin: 'auto',
width: 'fit-content',
}}
>
{done &&
(text || (
<svg
width="14"
height="13"
viewBox="0 0 14 13"
fill="none"
xmlns="http://www.w3.org/2000/svg"
<Box className="hintStepMain">
<Box
className="stepIcon"
sx={{
margin: '12px 0 16px 0',
}}
>
<Typography
variant="body1"
fontSize="14px"
color="#fff"
sx={{
backgroundColor: `${backgroundColor}`,
borderRadius: `${text ? '20px' : '50%'}`,
margin: '0 auto',
width: `${text ? 'auto' : '28px'}`,
height: `${text ? 'auto' : '28px'}`,
color: '#fff',
display: `${text ? 'inline-block' : 'flex'}`,
padding: `${text ? '3px 15px' : '0'}`,
justifyContent: 'center',
alignItems: 'center',
}}
>
{done &&
(text || (
<svg
width="14"
height="13"
viewBox="0 0 14 13"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M13.8078 1.24939L5.09535 12.1399L0.305542 7.15056L1.74832 5.7655L4.95851 9.10944L12.2461 0L13.8078 1.24939Z"
fill="white"
/>
</svg>
))}
{!done && step}
</Typography>
</Box>
<Box className="hintStepMobile" >
{
index === activeStep &&
<Link
href={tooltipLink}
target="_blank"
sx={{
color: '#111111 !important',
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
}}
>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M13.8078 1.24939L5.09535 12.1399L0.305542 7.15056L1.74832 5.7655L4.95851 9.10944L12.2461 0L13.8078 1.24939Z"
fill="white"
/>
</svg>
))}
{!done && step}
</Typography>
</Box>
<Box
sx={{
width: '95px',
margin: '0px auto 24px auto',
textAlign: 'center',
}}
>
<Typography
variant="label3"
fontSize="14px"
fontWeight="500"
sx={{
margin: 'auto',
height: 'fit-contetn',
}}
>
{headline}
</Typography>
<Typography
variant="label3"
fontSize="12px"
sx={{
paddingBottom: '5px',
textAlign: 'center'
}}
>
{tooltipText}
</Typography>
</Link>
}
</Box>
</Box>

<Box className="stepHeadline">
<Typography
variant="label3"
fontSize="14px"
fontWeight="500"
sx={{
margin: 'auto',
height: 'fit-contetn',
}}
>
{headline}
</Typography>
</Box>
</Box>
</Box>
)
}
}
Loading
Loading