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

Add formatting, linting and CI #57

Merged
merged 2 commits into from
Jan 17, 2024
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
6 changes: 5 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
{
"extends": ["next/core-web-vitals", "plugin:mdx/recommended"]
"extends": ["next/core-web-vitals", "plugin:mdx/recommended", "prettier"],
"plugins": ["prettier"],
"rules": {
"prettier/prettier": "error"
}
}
30 changes: 30 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Continuous Integration

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

- uses: actions/setup-node@v4
with:
node-version: lts/*

- name: Install dependencies
run: yarn

- name: Lint
run: yarn lint

- name: Build
run: yarn build

# - name: Test
# run: yarn test
3 changes: 3 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"recommendations": ["esbenp.prettier-vscode", "dbaeumer.vscode-eslint"]
}
15 changes: 15 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"[javascript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[javascriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescript]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[typescriptreact]": {
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"editor.formatOnSave": true
}
35 changes: 20 additions & 15 deletions components/Footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,33 +19,38 @@
import React from "react";

// reactstrap components
import {
Container,
Row,
Col,
} from "reactstrap";
import { Container, Row, Col } from "reactstrap";

const Footer = () => {
return (
<>
<footer className="footer">
<Container>
<br></br>
<Row className="justify-content-center text-center">
<br></br>
<Row className="justify-content-center text-center">
<Col lg="8">
<div className="container">
<a className="footerLink" href="/Constitution.pdf">Constitution</a> | <a className="footerLink" href="/Grievance-Resolution-Policy-Procedure.pdf">Grievance Policy</a>
</div>
<div className="container">
<div className="container">
<a className="footerLink" href="/Constitution.pdf">
Constitution
</a>{" "}
|{" "}
<a
className="footerLink"
href="/Grievance-Resolution-Policy-Procedure.pdf"
>
Grievance Policy
</a>
</div>
<div className="container">
Copyright &copy; 2023 UNSW Co-op Society
</div>
<br></br>
</Col>
</div>
<br></br>
</Col>
</Row>
</Container>
</footer>
</>
);
}
};

export default Footer;
5 changes: 1 addition & 4 deletions components/Header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,7 @@ const Header = () => {
x="0"
y="0"
>
<polygon
className="fill-white"
points="4000 0 4000 100 0 100"
/>
<polygon className="fill-white" points="4000 0 4000 100 0 100" />
</svg>
</div>
</section>
Expand Down
11 changes: 3 additions & 8 deletions components/IndexHeader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,15 @@ const IndexHeader = () => {
<Typewriter
options={{ loop: false }}
onInit={(typewriter) => {
typewriter.typeString('UNSW CO-OP SOCIETY')
.start();
typewriter.typeString("UNSW CO-OP SOCIETY").start();
}}
/>
<p className="lead text-white" style={{ fontWeight: 'normal' }}>
<p className="lead text-white" style={{ fontWeight: "normal" }}>
A society for co-ops, by co-ops.
</p>
</Col>
</Row>
</div>

</Container>
{/* SVG separator */}
<div className="separator separator-bottom separator-skew">
Expand All @@ -49,10 +47,7 @@ const IndexHeader = () => {
x="0"
y="0"
>
<polygon
className="fill-white"
points="4000 0 4000 100 0 100"
/>
<polygon className="fill-white" points="4000 0 4000 100 0 100" />
</svg>
</div>
</section>
Expand Down
9 changes: 5 additions & 4 deletions components/Loader.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,14 @@ const Loader = ({ width, height, strokeColour }) => {
viewBox="0 0 13 14"
fill="none"
xmlns="http://www.w3.org/2000/svg"
className={styles['spinner']}>
className={styles["spinner"]}
>
<path
d="M4.38798 12.616C3.36313 12.2306 2.46328 11.5721 1.78592 10.7118C1.10856 9.85153 0.679515 8.82231 0.545268 7.73564C0.411022 6.64897 0.576691 5.54628 1.02433 4.54704C1.47197 3.54779 2.1845 2.69009 3.08475 2.06684C3.98499 1.4436 5.03862 1.07858 6.13148 1.01133C7.22435 0.944078 8.31478 1.17716 9.28464 1.68533C10.2545 2.19349 11.0668 2.95736 11.6336 3.89419C12.2004 4.83101 12.5 5.90507 12.5 7"
stroke={strokeColour}
/>
</svg>
)
}
);
};

export default Loader;
export default Loader;
20 changes: 14 additions & 6 deletions components/LoadingButton.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,20 @@ import React from "react";

import Loader from "components/Loader";

const LoadingButton = ({text, onClick, isLoading, disabled}) => {
const LoadingButton = ({ text, onClick, isLoading, disabled }) => {
return (
<button className="w-100 btn btn-primary btn-lg" onClick={onClick} disabled={disabled}>
{ !isLoading ? text : <Loader width={13} height={14} strokeColour="white"/> }
<button
className="w-100 btn btn-primary btn-lg"
onClick={onClick}
disabled={disabled}
>
{!isLoading ? (
text
) : (
<Loader width={13} height={14} strokeColour="white" />
)}
</button>
)
}
);
};

export default LoadingButton;
export default LoadingButton;
51 changes: 24 additions & 27 deletions components/Navigation.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,11 @@ import {
} from "reactstrap";

import { faEnvelope } from "@fortawesome/free-solid-svg-icons";
import { faFacebookSquare, faInstagram, faLinkedinIn } from "@fortawesome/free-brands-svg-icons";
import {
faFacebookSquare,
faInstagram,
faLinkedinIn,
} from "@fortawesome/free-brands-svg-icons";

import Logo from "public/img/brand/logo_white.png";
import LogoSmall from "public/img/brand/logo_small.png";
Expand All @@ -55,8 +59,10 @@ const Navigation = () => {
});

const getNavLinkClass = (path) => {
return router.pathname === path ? "active" : "navbar-hover navbar-nav-hover align-items-lg-center";
}
return router.pathname === path
? "active"
: "navbar-hover navbar-nav-hover align-items-lg-center";
};

return (
<>
Expand All @@ -81,17 +87,14 @@ const Navigation = () => {
<Col className="collapse-brand" xs="6">
<Link href="/">
<a>
<Image
alt="..."
src={LogoSmall}
/>
<Image alt="..." src={LogoSmall} />
</a>
</Link>
</Col>

<Col className="collapse-close" xs="6">
{/* Needs two spans to make "X" shape */}
<NavbarToggler onClick={() => setOpen(false)} >
<NavbarToggler onClick={() => setOpen(false)}>
<span />
<span />
</NavbarToggler>
Expand All @@ -117,72 +120,66 @@ const Navigation = () => {

<NavItem>
<Link href="/events" passHref>
<NextNavLink
className={getNavLinkClass("/events")}
>
<NextNavLink className={getNavLinkClass("/events")}>
<span className="nav-link-inner--text">Events</span>
</NextNavLink>
</Link>
</NavItem>

<NavItem>
<Link href="/publications" passHref>
<NextNavLink
className={getNavLinkClass("/publications")}
>
<NextNavLink className={getNavLinkClass("/publications")}>
<span className="nav-link-inner--text">Publications</span>
</NextNavLink>
</Link>
</NavItem>

<NavItem>
<Link href="/charity" passHref>
<NextNavLink
className={getNavLinkClass("/charity")}
>
<NextNavLink className={getNavLinkClass("/charity")}>
<span className="nav-link-inner--text">Charity</span>
</NextNavLink>
</Link>
</NavItem>

<NavItem>
<Link href="/calendar" passHref>
<NextNavLink
className={getNavLinkClass("/calendar")}
>
<NextNavLink className={getNavLinkClass("/calendar")}>
<span className="nav-link-inner--text">Calendar</span>
</NextNavLink>
</Link>
</NavItem>

</Nav>


<Nav className="align-items-lg-center ml-lg-auto" navbar>
<NavIcon
href="https://www.facebook.com/coopsoc.unsw/"
id="tooltip-facebook"
icon={faFacebookSquare}
collapseText="FACEBOOK"
tooltip="Like us on Facebook" />
tooltip="Like us on Facebook"
/>
<NavIcon
href="mailto: [email protected]"
id="tooltip-email"
icon={faEnvelope}
collapseText="EMAIL"
tooltip="Email us" />
tooltip="Email us"
/>
<NavIcon
href="https://www.instagram.com/coopsoc_unsw/"
id="tooltip-instagram"
icon={faInstagram}
collapseText="INSTAGRAM"
tooltip="Follow us on Instagram" />
tooltip="Follow us on Instagram"
/>
<NavIcon
href="https://www.linkedin.com/company/unsw-co-op-society/"
id="tooltip-linkedin"
icon={faLinkedinIn}
collapseText="LINKEDIN"
tooltip="Connect on LinkedIn" />
tooltip="Connect on LinkedIn"
/>
</Nav>
</Collapse>
</Container>
Expand Down
8 changes: 4 additions & 4 deletions components/YearSlider.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const YearSlider = ({ start, end, onChange }) => {
const updateSlider = (values, _) => {
const year = parseInt(values[0]);
onChange(year);
}
};

useEffect(() => {
const sliderNode = sliderRef.current;
Expand All @@ -21,8 +21,8 @@ const YearSlider = ({ start, end, onChange }) => {
step: 1,
range: { min: start, max: end },
format: wNumb({
decimals: 0
})
decimals: 0,
}),
}).on("update", updateSlider);

return () => {
Expand Down Expand Up @@ -52,6 +52,6 @@ const YearSlider = ({ start, end, onChange }) => {
</Container>
</>
);
}
};

export default YearSlider;
Loading