Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
9 changes: 9 additions & 0 deletions src/plays/steps/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';

import StepsWrapper from './components/StepsWrapper';

const App = () => {
return <StepsWrapper />;
};

export default App;
27 changes: 27 additions & 0 deletions src/plays/steps/Readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# Steps

A web app with “next” and “previous” navigation buttons, where the “next” button helps users move forward through steps, similar to the flow in e-commerce applications, and the “previous” button allows them to step back.

## Play Demographic

- Language: ts
- Level: Beginner

## Creator Information

- User: aaqib605
- Gihub Link: https://github.com/aaqib605
- Blog: https://hashnode.com/@aaqib605
- Video:

## Implementation Details

Update your implementation idea and details here

## Consideration

Update all considerations(if any)

## Resources

Update external resources(if any)
20 changes: 20 additions & 0 deletions src/plays/steps/Steps.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import React from 'react';

import PlayHeader from 'common/playlists/PlayHeader';
import App from './App';
import './styles.css';

function Steps(props: any) {
return (
<>
<div className="play-details">
<PlayHeader play={props} />
<div className="play-details-body">
<App />
</div>
</div>
</>
);
}

export default Steps;
22 changes: 22 additions & 0 deletions src/plays/steps/components/Button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import React, { ReactNode, MouseEventHandler } from 'react';

interface ButtonProps {
bgColor: string;
textColor: string;
disable: boolean;
onClick: MouseEventHandler<HTMLButtonElement>;
children: ReactNode;
}

export default function Button({ textColor, bgColor, onClick, disable, children }: ButtonProps) {
const disabledStyles = { background: 'grey', color: 'white', cursor: 'not-allowed' };

return (
<button
style={disable ? disabledStyles : { backgroundColor: bgColor, color: textColor }}
onClick={onClick}
>
{children}
</button>
);
}
15 changes: 15 additions & 0 deletions src/plays/steps/components/StepMessage.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';

interface StepMessageProps {
step: number;
children: React.ReactNode;
}

export default function StepMessage({ step, children }: StepMessageProps) {
return (
<div className="steps_message">
<h3>Step {step}</h3>
{children}
</div>
);
}
44 changes: 44 additions & 0 deletions src/plays/steps/components/StepsWrapper.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React, { useState } from 'react';

import StepMessage from './StepMessage';
import Button from './Button';

export default function StepsWrapper() {
const [step, setStep] = useState(1);

const messages = ['Learn React ⚛️', 'Apply for jobs 💼', 'Invest your new income 🤑'];

function handlePrevious() {
if (step > 1) setStep((s) => s - 1);
}

function handleNext() {
if (step < 3) {
setStep((s) => s + 1);
}
}

return (
<div>
<div className="steps">
<div className="steps_numbers">
<div className={step >= 1 ? 'steps_active' : ''}>1</div>
<div className={step >= 2 ? 'steps_active' : ''}>2</div>
<div className={step >= 3 ? 'steps_active' : ''}>3</div>
</div>

<StepMessage step={step}>{messages[step - 1]}</StepMessage>

<div className="steps_buttons">
<Button bgColor="#7950f2" disable={step === 1} textColor="#fff" onClick={handlePrevious}>
<span>👈</span> Previous
</Button>

<Button bgColor="#7950f2" disable={step === 3} textColor="#fff" onClick={handleNext}>
Next <span>👉</span>
</Button>
</div>
</div>
</div>
);
}
Binary file added src/plays/steps/cover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
69 changes: 69 additions & 0 deletions src/plays/steps/styles.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
.steps {
width: 600px;
background-color: #f7f7f7;
border-radius: 7px;
padding: 25px 100px;
margin: 100px auto;
}

.steps_numbers {
display: flex;
justify-content: space-between;
}

.steps_numbers > div {
height: 40px;
aspect-ratio: 1;
background-color: #e7e7e7;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
font-size: 18px;
}

.steps_numbers .steps_active {
background-color: #7950f2;
color: #fff;
}

.steps_message {
text-align: center;
font-size: 20px;
margin: 40px 0;
font-weight: bold;

display: flex;
flex-direction: column;
align-items: center;
}

.steps_buttons {
display: flex;
justify-content: space-between;
}

.steps_buttons button {
border: none;
cursor: pointer;
padding: 10px 15px;
border-radius: 100px;
font-size: 14px;
font-weight: bold;

display: flex;
align-items: center;
justify-content: center;
gap: 10px;
min-width: 8rem;
}

.steps_buttons button span {
font-size: 16px;
line-height: 1;
}

.steps_message h3 {
margin: 0;
text-transform: uppercase;
}
Loading