Skip to content

Commit

Permalink
Merge pull request #94 from MargoMarm/fix/background
Browse files Browse the repository at this point in the history
Fix/background
  • Loading branch information
MargoMarm committed Sep 27, 2023
2 parents 0b43bdf + ff2002b commit af2d833
Show file tree
Hide file tree
Showing 6 changed files with 333 additions and 374 deletions.
73 changes: 52 additions & 21 deletions src/components/ParamsBar/ParamsBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,36 +2,67 @@ import { ProgressBar, BarItem } from './ParamsBar.styled';
import PropTypes from 'prop-types';
import { colors as palette } from '../../utils';

const ParamsBar = ({ steps }) => {
return (
<ProgressBar>
<BarItem
const ParamsBar = ({ steps, setSteps }) => {
const Btn = ({ steps, step, setSteps, children }) => {
return (
<button
style={{
background: steps >= 1 && `${palette.orangeSecondary}`,
boxShadow: steps >= 1 && '0px 1px 10px 0px rgba(230, 83, 60, 0.8)',
margin: '0',
padding: '30px 0px',
border: 'none',
backgroundColor: ' rgba(0, 0, 0, 0)',
cursor: 'pointer',
}}
></BarItem>
<BarItem
style={{
background: steps >= 2 && steps > 1 && `${palette.orangeSecondary}`,
boxShadow:
steps >= 2 &&
steps > 1 &&
'0px 1px 10px 0px rgba(230, 83, 60, 0.8)',
}}
></BarItem>
<BarItem
style={{
background: steps === 3 && `${palette.orangeSecondary}`,
boxShadow: steps === 3 && '0px 1px 10px 0px rgba(230, 83, 60, 0.8)',
onClick={() => {
if (steps > 1) {
setSteps(step);
}
}}
></BarItem>
>
{children}
</button>
);
};

return (
<ProgressBar>
<Btn step={1} setSteps={setSteps} steps={steps}>
<BarItem
style={{
background: steps >= 1 && `${palette.orangeSecondary}`,
boxShadow: steps >= 1 && '0px 1px 10px 0px rgba(230, 83, 60, 0.8)',
}}
></BarItem>
</Btn>

<Btn step={2} setSteps={setSteps} steps={steps}>
<BarItem
style={{
background: steps >= 2 && steps > 1 && `${palette.orangeSecondary}`,
boxShadow:
steps >= 2 &&
steps > 1 &&
'0px 1px 10px 0px rgba(230, 83, 60, 0.8)',
}}
></BarItem>
</Btn>
<Btn>
<BarItem
style={{
background: steps === 3 && `${palette.orangeSecondary}`,
boxShadow: steps === 3 && '0px 1px 10px 0px rgba(230, 83, 60, 0.8)',
}}
></BarItem>
</Btn>
</ProgressBar>
);
};

ParamsBar.propTypes = {
steps: PropTypes.number.isRequired,
step: PropTypes.number,
setSteps: PropTypes.func.isRequired,
children: PropTypes.any,
};

export default ParamsBar;
27 changes: 25 additions & 2 deletions src/components/ParamsBtn/ParamsBtn.jsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,34 @@
import PropTypes from 'prop-types';
import { BtnNav, Svg } from './ParamsBtn.styled';
import Notiflix from 'notiflix';

const ParamsBtn = ({ setSteps, type, step }) => {
const ParamsBtn = ({ setSteps, type, step, values }) => {
if (type === 'next') {
return (
<BtnNav
type="button"
onClick={() => {
setSteps(step);
if (
step === 2 &&
values.height !== '' &&
values.currentWeight !== '' &&
values.desiredWeight !== ''
) {
setSteps(step);
return;
}

if (
step === 3 &&
values.blood !== '' &&
values.sex !== '' &&
values.levelActivity !== ''
) {
setSteps(step);
return;
}

Notiflix.Notify.warning('pls fill all fields');
}}
>
Next
Expand Down Expand Up @@ -39,6 +60,8 @@ ParamsBtn.propTypes = {
setSteps: PropTypes.func.isRequired,
type: PropTypes.string,
step: PropTypes.number.isRequired,
validate: PropTypes.func,
values: PropTypes.object,
};

export default ParamsBtn;
Loading

0 comments on commit af2d833

Please sign in to comment.