Skip to content
This repository has been archived by the owner on Sep 16, 2024. It is now read-only.

feat: [BB-191] Feature** Fields and Soil Stage 2 #192

Merged
merged 35 commits into from
Jun 22, 2024
Merged
Show file tree
Hide file tree
Changes from 33 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
bb64299
primary changes
kcaparas1630 Jun 19, 2024
c428290
format
kcaparas1630 Jun 19, 2024
dce0470
configured button to accept children
kcaparas1630 Jun 19, 2024
fc6439d
format?
kcaparas1630 Jun 19, 2024
1880239
organized logic
kcaparas1630 Jun 19, 2024
047f28d
format
kcaparas1630 Jun 19, 2024
0c9ad08
last commit for the day, scratch again tomorrow
kcaparas1630 Jun 20, 2024
22035ea
ugh
kcaparas1630 Jun 20, 2024
314697c
scratched earlier work, simpler workflow with dividers
kcaparas1630 Jun 20, 2024
fd32941
Merge branch 'main' of https://github.com/bcgov/nr-sustainment-capsto…
kcaparas1630 Jun 20, 2024
f8f405c
removed fieldsInfo
kcaparas1630 Jun 20, 2024
cf0d66c
forgot to save
kcaparas1630 Jun 20, 2024
640bf4b
remoevd setField hook
kcaparas1630 Jun 20, 2024
262b861
fixed some bugs, finished styling
kcaparas1630 Jun 20, 2024
93986dc
Removed formik and values, don't need it anymore
kcaparas1630 Jun 20, 2024
edd5bd8
Added id for fields
kcaparas1630 Jun 20, 2024
401baa1
switched button types for add and next
kcaparas1630 Jun 21, 2024
d5f62c4
format
kcaparas1630 Jun 21, 2024
d0de5db
separated into components, formik stays the same
kcaparas1630 Jun 21, 2024
cd052bb
forgot to save
kcaparas1630 Jun 21, 2024
1460bb5
imported StyledButtonGroupContainer
kcaparas1630 Jun 21, 2024
eb90dda
changed h4 into h2
kcaparas1630 Jun 21, 2024
40c9d94
set initial values to empty for second adding new field
kcaparas1630 Jun 21, 2024
672eb64
format
kcaparas1630 Jun 21, 2024
79ea1d8
cleanup
kcaparas1630 Jun 21, 2024
8bfbbf1
deploy again
kcaparas1630 Jun 21, 2024
ca8d68d
removed comment deploy
kcaparas1630 Jun 21, 2024
6977baa
button styling consistency fixed
kcaparas1630 Jun 21, 2024
a899dc7
format
kcaparas1630 Jun 21, 2024
e431f2e
Created a function for buttonSizes using switch
kcaparas1630 Jun 21, 2024
5cdd646
format
kcaparas1630 Jun 21, 2024
19900e0
error message style defined
kcaparas1630 Jun 21, 2024
7fd80df
format
kcaparas1630 Jun 21, 2024
12f0263
minor revision done, ready for another review
kcaparas1630 Jun 22, 2024
46a63ee
format
kcaparas1630 Jun 22, 2024
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
1 change: 1 addition & 0 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"bootstrap": "^5.3.3",
"eslint-config-airbnb-base": "^15.0.0",
"formik": "^2.4.6",
"prop-types": "^15.8.1",
kcaparas1630 marked this conversation as resolved.
Show resolved Hide resolved
"react": "^18.2.0",
"react-bootstrap": "^2.10.2",
"react-dom": "^18.2.0",
Expand Down
31 changes: 18 additions & 13 deletions frontend/src/Commons/Button/Button.style.ts
kcaparas1630 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
import styled from '@emotion/styled';
import * as tokens from '@bcgov/design-tokens/js';
import screenSizes from '@Constants/ScreenSize';
import getButtonSize from './ButtonSizeConstant';
kcaparas1630 marked this conversation as resolved.
Show resolved Hide resolved

type StyledButtonProps = {
size: string;
type: string;
disabled: boolean;
radius: string;
actions: string;
};

const StyledButton = styled.button<StyledButtonProps>`
display: flex;
align-items: center;
justify-content: center;
max-height: ${(props) => (props.size === 'sm' ? '27px' : props.size === 'md' ? '25px' : '40px')};
max-height: 42px;
height: 100%;
width: 100%;
max-width: ${(props) => (props.size === 'sm' ? '52px' : props.size === 'md' ? '200px' : '300px')};
background-color: ${(props) => (props.type === 'button' || props.type === 'submit'
max-width: ${(props) => getButtonSize(props.size, false)};
background-color: ${(props) => (props.actions === 'primary'
? tokens.surfaceColorPrimaryButtonDefault
: tokens.surfaceColorSecondaryButtonDefault)};
color: ${(props) => (props.type === 'button' || props.type === 'submit'
color: ${(props) => (props.actions === 'primary'
? tokens.typographyColorPrimaryInvert
: tokens.typographyColorPrimary)};
border-radius: 8px;
border: ${(props) => (props.type === 'button' || props.type === 'submit'
? 0
: `1px solid ${tokens.surfaceColorBorderMedium}`)};
: tokens.typographyColorSecondary)};
border-radius: ${(props) => props.radius};
border: ${(props) => (props.actions === 'primary' ? 0 : `1px solid ${tokens.surfaceColorBorderMedium}`)};
padding: 20px 30px;
font-family: ${tokens.typographyFontFamiliesBcSans};
font-weight: ${tokens.typographyFontWeightsBold};
Expand All @@ -35,9 +35,14 @@ const StyledButton = styled.button<StyledButtonProps>`
}

@media (min-width: ${screenSizes.desktop}) {
max-height: ${(props) => (props.size === 'sm' ? '27px' : props.size === 'md' ? '25px' : '40px')};
max-width: ${(props) => (props.size === 'sm' ? '52px' : props.size === 'md' ? '200px' : '300px')};
max-width: ${(props) => getButtonSize(props.size, true)};
}
`;

export default StyledButton;
const StyledChildrenContainer = styled.div`
display: flex;
align-items: center;
gap: 5px;
`;

export { StyledButton, StyledChildrenContainer };
17 changes: 15 additions & 2 deletions frontend/src/Commons/Button/Button.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import StyledButton from './Button.style';
import React from 'react';
import { StyledButton, StyledChildrenContainer } from './Button.style';
kcaparas1630 marked this conversation as resolved.
Show resolved Hide resolved

type ButtonSizes = 'sm' | 'md' | 'lg';
type ButtonActions = 'primary' | 'secondary';
type ButtonTypes = 'button' | 'submit' | 'reset' | undefined;

type ButtonProps = {
Expand All @@ -9,14 +11,20 @@ type ButtonProps = {
size?: ButtonSizes;
disabled?: boolean;
type?: ButtonTypes;
radius?: string;
actions?: ButtonActions;
children?: React.ReactNode;
};

const Button = ({
handleClick,
text,
size = 'md',
disabled = false,
radius = '8px',
type = 'button',
actions = 'primary',
children,
}: ButtonProps) => {
kcaparas1630 marked this conversation as resolved.
Show resolved Hide resolved
const handleClickWrapper = () => {
if (handleClick) {
Expand All @@ -31,8 +39,13 @@ const Button = ({
onClick={handleClickWrapper}
value=""
type={type}
radius={radius}
actions={actions}
>
{text}
<StyledChildrenContainer>
{children}
{text}
</StyledChildrenContainer>
</StyledButton>
);
};
Expand Down
21 changes: 21 additions & 0 deletions frontend/src/Commons/Button/ButtonSizeConstant.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const getButtonSize = (size: string, isDesktop: boolean): string => {
let buttonSize;

switch (size) {
case 'sm':
buttonSize = '62px';
break;
case 'md':
buttonSize = '178px';
break;
case 'lg':
buttonSize = isDesktop ? '483px' : '327px';
break;
default:
buttonSize = '100%';
break;
}

return buttonSize;
};
export default getButtonSize;
kcaparas1630 marked this conversation as resolved.
Show resolved Hide resolved
14 changes: 9 additions & 5 deletions frontend/src/Commons/CustomLink/CustomLink.style.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import styled from '@emotion/styled';
import * as tokens from '@bcgov/design-tokens/js';
import screenSizes from '@Constants/ScreenSize';
import getButtonSize from '@Commons/Button/ButtonSizeConstant';

type StyledLinkProps = {
size: string;
Expand All @@ -10,18 +11,21 @@ const StyledLinkContainer = styled.div<StyledLinkProps>`
display: flex;
align-items: center;
justify-content: center;
height: ${(props) => (props.size === 'sm' ? '27px' : props.size === 'md' ? '25px' : '40px')};
width: ${(props) => (props.size === 'sm' ? '52px' : props.size === 'md' ? '200px' : '300px')};
height: 100%;
width: 100%;
max-height: 42px;
max-width: ${(props) => getButtonSize(props.size, false)};
kcaparas1630 marked this conversation as resolved.
Show resolved Hide resolved
background-color: ${tokens.surfaceColorPrimaryButtonDefault};
color: ${tokens.typographyColorPrimaryInvert};
border-radius: 8px;
border: ${`1px solid ${tokens.surfaceColorBorderMedium}`};
font-family: ${tokens.typographyFontFamiliesBcSans};
font-weight: ${tokens.typographyFontWeightsBold};

padding: 20px 30px;
@media (min-width: ${screenSizes.desktop}) {
max-height: ${(props) => (props.size === 'sm' ? '27px' : props.size === 'md' ? '25px' : '40px')};
max-width: ${(props) => (props.size === 'sm' ? '52px' : props.size === 'md' ? '200px' : '300px')};
height: 100%;
max-width: ${(props) => getButtonSize(props.size, true)};
width: 100%;
}
a {
display: flex;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
/**
*
* THIS IS A SKELETON!
* THIS IS STILL TO BE IMPLEMENTED!
*
* @desc Styling with BC Design Tokens and Emotion for
* Farm Information Input Module
* @author @GDamaso
* Field and Soil Input Module
* @author @Kcaparas
*/
import styled from '@emotion/styled';
import screenSizes from '@Constants/ScreenSize';
Expand Down Expand Up @@ -44,28 +40,4 @@ const StyledTextAreaContainer = styled.div`
}
`;

const StyledButtonGroupContainer = styled.div`
margin-top: -10px;
display: flex;
flex-direction: row;
gap: 20px;
`;

const StyledListContainer = styled.div`
display: flex;
flex-direction: row;
gap: 20px;
`;
const StyledListItem = styled.div`
display: flex;
flex-direction: column;
align-items: flex-start;
`;

export {
StyledFarmInfo,
StyledTextAreaContainer,
StyledButtonGroupContainer,
StyledListContainer,
StyledListItem,
};
export { StyledFarmInfo, StyledTextAreaContainer };
Loading
Loading