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

Different versions buttons #1758

Open
wants to merge 110 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
0221831
Add different styles
avanegasp Dec 26, 2024
b9b9474
Add variants in Log in button
avanegasp Dec 27, 2024
da04c05
Add variant primary in Join for free button
avanegasp Dec 27, 2024
66ce902
Add more variants in files
avanegasp Dec 28, 2024
a254ad6
Add variant in Sigup file
avanegasp Dec 28, 2024
0bfb3c4
Add ChakraButton
avanegasp Dec 28, 2024
f398a9a
fix variant in LogIn and ProfileForm
avanegasp Dec 28, 2024
4392761
Add variant in button
avanegasp Dec 28, 2024
9317381
Fix code errors
avanegasp Dec 30, 2024
d13a45f
Add variant in ModuleMap
avanegasp Dec 30, 2024
73ab523
Add variant in TableWithForm
avanegasp Dec 30, 2024
4afc1c1
Add hasLoading in defaultProps
avanegasp Dec 31, 2024
136a83a
Add variant in attendanceModal.jsx
avanegasp Dec 31, 2024
48c0f57
Add variant in PopoverTaskHandler.jsx Button
avanegasp Jan 1, 2025
5484304
Remove hex from file
avanegasp Jan 2, 2025
0b4fd0c
Add variant and refact code in ModalInfo and ChooseYourClass.jsx
avanegasp Jan 2, 2025
f5dcd81
Add variant in 404 and OnlyFor.jsx
avanegasp Jan 2, 2025
0f50ac8
Add variant primary
avanegasp Jan 7, 2025
60f917c
Update pricing.jsx
tommygonzaleza Dec 9, 2024
ac0d2f6
Update pricing.jsx
tommygonzaleza Dec 11, 2024
60b818f
Add heading to bootcamp landing
tomasgonzaleza Dec 12, 2024
0c6ced3
Update syllabus.json
tommygonzaleza Dec 12, 2024
0868609
Update [course_slug].jsx
tommygonzaleza Dec 12, 2024
a81c076
Update [course_slug].jsx
tommygonzaleza Dec 12, 2024
3bbac9b
Update syllabus.json
alesanchezr Dec 12, 2024
d2c38f7
Update signup.json
alesanchezr Dec 16, 2024
8a2d607
Allow getting the info from landing_variables
tomasgonzaleza Dec 16, 2024
f82d1d6
Allow getting the info from landing_variables
tomasgonzaleza Dec 16, 2024
32020b4
Allow getting the info from landing_variables
tomasgonzaleza Dec 16, 2024
7cd8c49
Fix deployment issues
tomasgonzaleza Dec 16, 2024
43f1813
Fix deployment issues
tomasgonzaleza Dec 16, 2024
a03d095
Fix deployment issues
tomasgonzaleza Dec 16, 2024
b2e6e84
Students enrolled translation bug
tomasgonzaleza Dec 16, 2024
01b86fd
Fix amount of exercises per program
tomasgonzaleza Dec 16, 2024
f2e25f8
Allow changing featured bullets
tomasgonzaleza Dec 16, 2024
23d6793
Allow changing featured bullets
tomasgonzaleza Dec 16, 2024
46ffc33
Remove trailling spaces
tomasgonzaleza Dec 16, 2024
ffe90f6
Update footer.json
tommygonzaleza Dec 17, 2024
4a0282b
Update footer.json
tommygonzaleza Dec 17, 2024
f8480e3
Update footer.json
tommygonzaleza Dec 17, 2024
9115e67
Update footer.json
tommygonzaleza Dec 17, 2024
7200c72
change algorithm to find currentTask
lumi-tip Dec 16, 2024
36749a8
small refactor
lumi-tip Dec 16, 2024
2f31276
small refactor
lumi-tip Dec 16, 2024
1485f06
refactor
lumi-tip Dec 17, 2024
f68eec8
set rigobot context in bootcamp page
gustavomm19 Dec 20, 2024
25e7031
Update completion-jobs.json
tommygonzaleza Dec 26, 2024
0ebe287
fixes bug with label
gustavomm19 Dec 27, 2024
cdb214f
fix bug when delivering projects
gustavomm19 Dec 23, 2024
fcb16c8
fix
gustavomm19 Dec 23, 2024
683c000
remove projects report query
gustavomm19 Dec 30, 2024
c0a0ab5
fix bug in bootcamp rigobot welcome message
gustavomm19 Dec 30, 2024
1b267df
add payment methods to rigobot context
gustavomm19 Dec 30, 2024
036b164
fix bug in mentorships modal
gustavomm19 Jan 2, 2025
764a79b
fix rigobot bug
gustavomm19 Jan 2, 2025
00e7886
adding new state in the modal for subtasks
lumi-tip Dec 2, 2024
c650763
small change
lumi-tip Dec 2, 2024
476b989
small changes
lumi-tip Dec 9, 2024
de8aaf2
♻️ refactor of subtasks
lumi-tip Dec 12, 2024
81f4455
adding logs
lumi-tip Dec 16, 2024
4dbe93d
refactor of the code
lumi-tip Dec 17, 2024
8dda49d
changes requested for subtasks
lumi-tip Dec 19, 2024
8a3599e
start
lumi-tip Dec 16, 2024
c7aaf7c
small refactor
lumi-tip Dec 26, 2024
acfa64d
adding external traslation in es
lumi-tip Dec 26, 2024
e9a8916
:recycle: refactor to avoid useless requests
lumi-tip Dec 27, 2024
2132f86
back to prev
lumi-tip Dec 27, 2024
3cc7e82
Update common.json
tommygonzaleza Jan 2, 2025
75d2c80
♻️ adding contact support text if payment issue
lumi-tip Dec 11, 2024
83fe2d5
remove logs
lumi-tip Dec 11, 2024
86a8be8
Update ButtonHandler.jsx
tommygonzaleza Dec 12, 2024
c8645f8
include epired courses
lumi-tip Dec 13, 2024
0f82d4d
small refactor
lumi-tip Dec 17, 2024
cf60642
changes for expired, paymentissue and error
lumi-tip Dec 25, 2024
89fe290
fix bug with syllabus
gustavomm19 Jan 2, 2025
846e087
:refactor: include correct version on ep
lumi-tip Jan 4, 2025
f861e09
change coupon top bar logic
gustavomm19 Jan 2, 2025
c150d20
:recycle: small refactor based to avoid useless request
lumi-tip Dec 27, 2024
d22683a
if there is no recommended course redirect to an asset
gustavomm19 Jan 6, 2025
1786752
Update pricing.jsx
tommygonzaleza Dec 9, 2024
3f70deb
Update pricing.jsx
tommygonzaleza Dec 11, 2024
b16ccc8
Add heading to bootcamp landing
tomasgonzaleza Dec 12, 2024
1f02614
Update syllabus.json
tommygonzaleza Dec 12, 2024
d166220
Update [course_slug].jsx
tommygonzaleza Dec 12, 2024
3180d09
Update [course_slug].jsx
tommygonzaleza Dec 12, 2024
8993f1a
Allow getting the info from landing_variables
tomasgonzaleza Dec 16, 2024
fba5817
Students enrolled translation bug
tomasgonzaleza Dec 16, 2024
ba82bfa
Allow changing featured bullets
tomasgonzaleza Dec 16, 2024
cd56f1e
Remove trailling spaces
tomasgonzaleza Dec 16, 2024
496b561
set rigobot context in bootcamp page
gustavomm19 Dec 20, 2024
6c6a768
fixes bug with label
gustavomm19 Dec 27, 2024
369dbed
fix bug in bootcamp rigobot welcome message
gustavomm19 Dec 30, 2024
461c133
adding logs
lumi-tip Dec 16, 2024
e5d5481
refactor of the code
lumi-tip Dec 17, 2024
27d2560
start
lumi-tip Dec 16, 2024
29e620e
small refactor
lumi-tip Dec 26, 2024
93154a8
back to prev
lumi-tip Dec 27, 2024
4f897f8
♻️ adding contact support text if payment issue
lumi-tip Dec 11, 2024
f309abc
remove logs
lumi-tip Dec 11, 2024
b016873
changes for expired, paymentissue and error
lumi-tip Dec 25, 2024
72a64a6
fix bug with syllabus
gustavomm19 Jan 2, 2025
3185df5
:recycle: small refactor based to avoid useless request
lumi-tip Dec 27, 2024
c128674
Merge branch 'development' into different_versions_buttons
avanegasp Jan 8, 2025
7d768c6
bun lockb
avanegasp Jan 8, 2025
ff5ed46
Fix imports
avanegasp Jan 24, 2025
92a3266
Add styles in link
avanegasp Jan 24, 2025
c21a3bc
Add more links styles
avanegasp Jan 24, 2025
e43edf6
Merge branch 'development' into different_versions_buttons
avanegasp Jan 24, 2025
1de55dc
Fix errors
avanegasp Jan 24, 2025
9d001bb
Button
avanegasp Jan 26, 2025
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
Binary file modified bun.lockb
Binary file not shown.
15 changes: 8 additions & 7 deletions src/common/components/AttendanceModal/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React, { useEffect, useState } from 'react';
import useTranslation from 'next-translate/useTranslation';
import PropTypes from 'prop-types';
import {
Modal, ModalOverlay, ModalContent, ModalHeader, ModalFooter, ModalBody, Button, Box,
Modal, ModalOverlay, ModalContent, ModalHeader, ModalFooter, ModalBody, Button as ChakraButton, Box,
NumberInput, NumberInputStepper, NumberDecrementStepper, NumberIncrementStepper, NumberInputField,
FormControl, FormLabel, Flex, Grid, useCheckbox, useCheckboxGroup, Avatar,
useColorMode, useToast, Select, ModalCloseButton,
Expand All @@ -15,6 +15,7 @@ import ModalInfo from '../../../js_modules/moduleMap/modalInfo';
import useStyle from '../../hooks/useStyle';
import useCohortHandler from '../../hooks/useCohortHandler';
import handlers from '../../handlers';
import Button from '../Button';

function AttendanceModal({
title, message, isOpen, onClose, students,
Expand Down Expand Up @@ -310,9 +311,9 @@ function AttendanceModal({
})}
</Grid>
</Box>
<Button variant="link" fontSize="13px" fontWeight={400} onClick={() => setChecked(students.map((l) => String(l?.user?.id)))}>
<ChakraButton variant="link" fontSize="13px" fontWeight={400} onClick={() => setChecked(students.map((l) => String(l?.user?.id)))}>
{t('common:select-all')}
</Button>
</ChakraButton>
</ModalBody>
<ModalFooter justifyContent="space-between">
<Text
Expand All @@ -328,9 +329,9 @@ function AttendanceModal({
textTransform="uppercase"
fontSize="13px"
isDisabled={checked.length < 1 || isLoading}
variant="default"
variant="primary"
onClick={handleAttendance}
rightIcon={<Icon icon="longArrowRight" width="15px" color={checked.length < 1 ? 'black' : 'white'} />}
rightIcon={<Icon icon="longArrowRight" width="15px" color={checked.length < 1 ? 'disable' : 'primary'} />}
>
{t('attendance-modal.apply-changes')}
</Button>
Expand Down Expand Up @@ -381,12 +382,12 @@ function AttendanceModal({
minWidth="173.4px"
textTransform="uppercase"
fontSize="13px"
variant="default"
variant="primary"
onClick={() => {
setOpenAttendanceTakenWarn(false);
updateCohortDay();
}}
rightIcon={<Icon icon="longArrowRight" width="15px" color={checked.length < 1 ? 'black' : 'white'} />}
rightIcon={<Icon icon="longArrowRight" width="15px" color={checked.length < 1 ? 'disabled' : 'primary'} />}
>
{t('attendance-modal.apply-changes')}
</Button>
Expand Down
77 changes: 72 additions & 5 deletions src/common/components/Button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,86 @@ import PropTypes from 'prop-types';
import { useRouter } from 'next/router';
import { useState } from 'react';

function Button({ to, onClick, children, ...rest }) {
function Button({ to, onClick, children, variant = 'primary', disabled = false, hasLoading = true, ...rest }) {
const router = useRouter();
const [isLoading, setIsLoading] = useState(false);
const existsHash = to.includes('#');

const clickHandler = () => {
if (!existsHash) {
if (!existsHash && hasLoading) {
setIsLoading(true);
}
if (to) {
router.push(to);
} else {
setIsLoading(true);
if (hasLoading) {
setIsLoading(true);
}
onClick();
}
};

const variants = {
primary: {
background: '#0097CF',
color: 'white',
borderRadius: '4px',
hover: { background: '#02A9EA', color: 'white' },
disabled: { background: '#DADADA', color: 'white', cursor: 'not-allowed' },
active: { background: '#0084FF', color: 'white' },
},
success: {
background: '#25BF6C',
color: 'white',
borderRadius: '4px',
hover: { background: '#2CE883', color: 'white' },
disabled: { background: '#A9A9A9', color: 'white', cursor: 'not-allowed' },
active: { background: '#06AB52', color: 'white' },
},
outline: {
background: '#FFFFFF',
color: '#0097CF',
borderColor: '#0097CF',
borderRadius: '4px',
hover: { background: '#EEF9FE', color: '#02A9EA', borderColor: '#02A9EA' },
disabled: { background: '#F9F9F9', color: '#DADADA', borderColor: '#F9F9F9', cursor: 'not-allowed' },
active: { background: '#EEF9FE', color: '#0084FF', borderColor: '#0084FF' },
},
ghost: {
background: 'transparent',
color: '#0097CF',
borderRadius: '4px',
hover: { background: '#FFFFFF', color: '#02A9EA' },
disabled: { background: 'transparent', color: '#DADADA', cursor: 'not-allowed' },
active: { background: '#EEF9FE', color: '#0084FF' },
},
outlineWhite: {
background: '#FFFFFF',
color: '#000000',
borderColor: 'transparent',
borderRadius: '4px',
disabled: { background: 'transparent', color: '#DADADA', cursor: 'not-allowed' },
},
unstyled: {},
};

const customStyles = variants[variant] || {};

return (
<ChakraButton isLoading={isLoading} onClick={clickHandler} {...rest}>
<ChakraButton
isLoading={isLoading}
onClick={clickHandler}
borderRadius={customStyles.borderRadius}
_hover={customStyles.hover}
_active={customStyles.active}
_disabled={customStyles.disabled}
backgroundColor={customStyles.background}
color={customStyles.color}
border={variant === 'outline' ? '1px solid' : undefined}
borderColor={customStyles.borderColor}
isDisabled={disabled}
variant={variant === 'unstyled' ? 'unstyled' : undefined}
{...rest}
>
{children}
</ChakraButton>
);
Expand All @@ -31,10 +92,16 @@ Button.propTypes = {
to: PropTypes.string,
onClick: PropTypes.func,
children: PropTypes.node.isRequired,
variant: PropTypes.oneOf(['primary', 'success', 'outline', 'ghost', 'unstyled']),
disabled: PropTypes.bool,
hasLoading: PropTypes.bool,
};
Button.defaultProps = {
to: '',
onClick: () => {},
variant: 'primary',
disabled: false,
hasLoading: true,
};

export default Button;
19 changes: 10 additions & 9 deletions src/common/components/CallToAction.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import {
Box, Heading, Button, Image,
Box, Heading, Button as ChakraButton, Image,
Popover,
PopoverTrigger,
PopoverContent,
Expand All @@ -12,6 +12,7 @@ import {
import PropTypes from 'prop-types';
import Text from './Text';
import Icon from './Icon';
import Button from './Button';

function CallToAction({
background, imageSrc, icon, href, styleContainer, isExternalLink, title, text,
Expand Down Expand Up @@ -87,7 +88,7 @@ function CallToAction({
{...buttonsContainerStyles}
>
{buttonText && !buttonsData?.length > 0 && (
<Button width="max-content" isLoading={isLoading} whiteSpace="wrap" as="a" style={buttonStyle} href={href} target={isExternalLink ? '_blank' : '_self'} padding="0.5rem 1rem" height="auto" marginY="auto" textTransform="uppercase" borderColor="white" color="white" variant="outline" onClick={onClick}>
<Button width="max-content" isLoading={isLoading} whiteSpace="wrap" as="a" border="1px solid" href={href} target={isExternalLink ? '_blank' : '_self'} padding="0.5rem 1rem" height="auto" marginY="auto" textTransform="uppercase" borderColor="white" variant="primary" onClick={onClick}>
{buttonText}
</Button>
)}
Expand All @@ -97,7 +98,7 @@ function CallToAction({

if (isButton) {
return (
<Button
<ChakraButton
style={buttonStyle}
isLoading={isLoading}
target={element.isExternalLink ? '_blank' : '_self'}
Expand All @@ -111,15 +112,15 @@ function CallToAction({
width="max-content"
>
{element.text}
</Button>
</ChakraButton>
);
}

if (isDropdown) {
return (
<Popover>
<PopoverTrigger>
<Button width="max-content" variant="default" textTransform="uppercase" background="blue.400">{element?.text}</Button>
<ChakraButton width="max-content" variant="default" textTransform="uppercase" background="blue.400">{element?.text}</ChakraButton>
</PopoverTrigger>
<PopoverContent width="min-content">
<PopoverArrow />
Expand All @@ -132,7 +133,7 @@ function CallToAction({
style={{ margin: 0 }}
/>
{element?.links?.length > 0 && element.links.map((link) => (
<Button
<ChakraButton
key={link.text}
as="a"
display="flex"
Expand All @@ -154,7 +155,7 @@ function CallToAction({
>
{link.title}
<Icon color="currentColor" icon="longArrowRight" />
</Button>
</ChakraButton>
))}
</PopoverBody>
</PopoverContent>
Expand All @@ -163,7 +164,7 @@ function CallToAction({
}

return (
<Button
<ChakraButton
style={buttonStyle}
key={element.text}
as="a"
Expand All @@ -179,7 +180,7 @@ function CallToAction({
variant="outline"
>
{element.text}
</Button>
</ChakraButton>
);
})}
</Box>
Expand Down
5 changes: 3 additions & 2 deletions src/common/components/FinalProject/Form.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Button, Flex, useToast, Box, Image } from '@chakra-ui/react';
import { Flex, useToast, Box, Image } from '@chakra-ui/react';
import { Form, Formik } from 'formik';
import PropTypes from 'prop-types';
import useTranslation from 'next-translate/useTranslation';
Expand All @@ -13,6 +13,7 @@ import useStyle from '../../hooks/useStyle';
import { isNumber } from '../../../utils';
import useFinalProjectProps from '../../store/actions/finalProjectAction';
import Icon from '../Icon';
import Button from '../Button';

function FinalProjectForm({ cohortData, studentsData, handleClose, defaultValues, refreshFinalProject }) {
const { t } = useTranslation('final-project');
Expand Down Expand Up @@ -334,7 +335,7 @@ function FinalProjectForm({ cohortData, studentsData, handleClose, defaultValues
/>
<Button
type="submit"
variant="default"
variant="primary"
isLoading={isSubmitting}
>
{t('common:submit-project')}
Expand Down
5 changes: 3 additions & 2 deletions src/common/components/FinalProject/Modal.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Box, Button, Flex, Image, Modal, ModalCloseButton, ModalContent, ModalOverlay } from '@chakra-ui/react';
import { Box, Flex, Image, Modal, ModalCloseButton, ModalContent, ModalOverlay } from '@chakra-ui/react';
import useTranslation from 'next-translate/useTranslation';
import PropTypes from 'prop-types';
import { useState } from 'react';
import useStyle from '../../hooks/useStyle';
import Heading from '../Heading';
import Text from '../Text';
import FinalProjectForm from './Form';
import Button from '../Button';

function FinalProjectModal({ isOpen, cohortData, studentsData, closeModal, closeOnOverlayClick }) {
const { t } = useTranslation('final-project');
Expand Down Expand Up @@ -41,7 +42,7 @@ function FinalProjectModal({ isOpen, cohortData, studentsData, closeModal, close
))}
</Flex>
<Button
variant="default"
variant="primary"
width="fit-content"
margin="auto 0 0 0"
padding="0 1.8rem"
Expand Down
14 changes: 7 additions & 7 deletions src/common/components/FinalProject/index.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/* eslint-disable no-unsafe-optional-chaining */
import { Box, Button, Link, Modal, ModalCloseButton, ModalContent, ModalOverlay } from '@chakra-ui/react';
import { Box, Button as ChakraButton, Link, Modal, ModalCloseButton, ModalContent, ModalOverlay } from '@chakra-ui/react';
import { useEffect, useState } from 'react';
import PropTypes from 'prop-types';
import { useRouter } from 'next/router';
Expand All @@ -14,6 +14,7 @@ import bc from '../../services/breathecode';
import FinalProjectForm from './Form';
import useStyle from '../../hooks/useStyle';
import useFinalProjectProps from '../../store/actions/finalProjectAction';
import Button from '../Button';

function FinalProject({ storyConfig, studentAndTeachers, tasks, isStudent }) {
const { t } = useTranslation('final-project');
Expand All @@ -24,7 +25,7 @@ function FinalProject({ storyConfig, studentAndTeachers, tasks, isStudent }) {
const { cohortSession } = state;

const router = useRouter();
const { modal, hexColor } = useStyle();
const { modal } = useStyle();
const { finalProjectData, setFinalProjectData } = useFinalProjectProps();
const storyConfigExists = Object.keys(storyConfig).length > 0;
const repoUrl = finalProjectData?.repo_url || finalProject?.currentProject?.repo_url;
Expand Down Expand Up @@ -132,7 +133,7 @@ function FinalProject({ storyConfig, studentAndTeachers, tasks, isStudent }) {
<Box display="flex" flexDirection="column" gridGap="20px" padding="0 24px" mt="2rem">
{isStudent ? (
<>
<Button
<ChakraButton
display="flex"
height="45px"
gridGap="10px"
Expand All @@ -149,7 +150,7 @@ function FinalProject({ storyConfig, studentAndTeachers, tasks, isStudent }) {
{repoUrl
? t('edit-final-project')
: t('add-final-project')}
</Button>
</ChakraButton>
<Box display="flex" flexDirection="column" gridGap="10px" borderColor="white" border="1px solid" padding="10px 22px" borderRadius="4px">
<Text size="l" fontWeight={700}>
{progressPercent === 100
Expand All @@ -176,9 +177,8 @@ function FinalProject({ storyConfig, studentAndTeachers, tasks, isStudent }) {
onClick={() => {
window.open(`/cohort/${cohortSlug}/assignments?academy=${cohortSession?.academy?.id}&view=2`, '_blank');
}}
variant="unstyled"
background={hexColor.blueDefault}
color="white"
hasLoading={false}
variant="primary"
padding="0 27px"
whiteSpace="normal"
>
Expand Down
Loading